Skip to content

Commit

Permalink
rpc/net_info: change RemoteIP type from net.IP to String
Browse files Browse the repository at this point in the history
Before:
"AAAAAAAAAAAAAP//rB8ktw=="
which is amino-encoded net.IP byte slice

After:
"192.0.2.1"

Fixes #3251
  • Loading branch information
melekes committed Feb 14, 2019
1 parent d32f7d2 commit e841163
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ Special thanks to external contributors on this release:
### BUG FIXES:
- [consensus] \#3297 Flush WAL on stop to prevent data corruption during
graceful shutdown
- [rpc] \#3251 Fix /net_info#peers#remote_ip format. New format spec:
* dotted decimal ("192.0.2.1"), if ip is an IPv4 or IP4-mapped IPv6 address
* IPv6 ("2001:db8::1"), if ip is a valid IPv6 address
5 changes: 3 additions & 2 deletions rpc/core/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ import (
// }
// ```
func NetInfo() (*ctypes.ResultNetInfo, error) {
peers := []ctypes.Peer{}
out, in, _ := p2pPeers.NumPeers()
peers := make([]ctypes.Peer, 0, out+in)
for _, peer := range p2pPeers.Peers().List() {
nodeInfo, ok := peer.NodeInfo().(p2p.DefaultNodeInfo)
if !ok {
Expand All @@ -53,7 +54,7 @@ func NetInfo() (*ctypes.ResultNetInfo, error) {
NodeInfo: nodeInfo,
IsOutbound: peer.IsOutbound(),
ConnectionStatus: peer.Status(),
RemoteIP: peer.RemoteIP(),
RemoteIP: peer.RemoteIP().String(),
})
}
// TODO: Should we include PersistentPeers and Seeds in here?
Expand Down
3 changes: 1 addition & 2 deletions rpc/core/types/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package core_types

import (
"encoding/json"
"net"
"time"

abci "github.com/tendermint/tendermint/abci/types"
Expand Down Expand Up @@ -111,7 +110,7 @@ type Peer struct {
NodeInfo p2p.DefaultNodeInfo `json:"node_info"`
IsOutbound bool `json:"is_outbound"`
ConnectionStatus p2p.ConnectionStatus `json:"connection_status"`
RemoteIP net.IP `json:"remote_ip"`
RemoteIP string `json:"remote_ip"`
}

// Validators for a height
Expand Down

0 comments on commit e841163

Please sign in to comment.