diff options
author | Felix Lange <fjl@twurst.com> | 2016-11-25 20:59:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-25 20:59:18 +0800 |
commit | d1a95c643eadd506f6ae85784d22c7823e411ee9 (patch) | |
tree | 7872593b296835e07a96d5bb40ddcd1f04849ea3 /swarm | |
parent | 9c3ea0d32d26957fd73ddf07e37d93091de596fd (diff) | |
parent | e5edd3b983189790391dca5b2ae4a0e460cb7f42 (diff) | |
download | dexon-d1a95c643eadd506f6ae85784d22c7823e411ee9.tar dexon-d1a95c643eadd506f6ae85784d22c7823e411ee9.tar.gz dexon-d1a95c643eadd506f6ae85784d22c7823e411ee9.tar.bz2 dexon-d1a95c643eadd506f6ae85784d22c7823e411ee9.tar.lz dexon-d1a95c643eadd506f6ae85784d22c7823e411ee9.tar.xz dexon-d1a95c643eadd506f6ae85784d22c7823e411ee9.tar.zst dexon-d1a95c643eadd506f6ae85784d22c7823e411ee9.zip |
Merge pull request #3325 from fjl/p2p-netrestrict
Prevent relay of invalid IPs, add --netrestrict
Diffstat (limited to 'swarm')
-rw-r--r-- | swarm/network/hive.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/swarm/network/hive.go b/swarm/network/hive.go index f5ebdd008..f81761b97 100644 --- a/swarm/network/hive.go +++ b/swarm/network/hive.go @@ -26,6 +26,7 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/p2p/netutil" "github.com/ethereum/go-ethereum/swarm/network/kademlia" "github.com/ethereum/go-ethereum/swarm/storage" ) @@ -288,6 +289,10 @@ func newNodeRecord(addr *peerAddr) *kademlia.NodeRecord { func (self *Hive) HandlePeersMsg(req *peersMsgData, from *peer) { var nrs []*kademlia.NodeRecord for _, p := range req.Peers { + if err := netutil.CheckRelayIP(from.remoteAddr.IP, p.IP); err != nil { + glog.V(logger.Detail).Infof("invalid peer IP %v from %v: %v", from.remoteAddr.IP, p.IP, err) + continue + } nrs = append(nrs, newNodeRecord(p)) } self.kad.Add(nrs) |