From e46bda50935cfad5bfc51130e4ea802f518917e7 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 21 Nov 2016 18:25:16 +0100 Subject: swarm/network: prevent relay of invalid IPs --- swarm/network/hive.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'swarm/network/hive.go') 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) -- cgit v1.2.3