aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/network/hive.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-11-22 01:25:16 +0800
committerFelix Lange <fjl@twurst.com>2016-11-23 05:21:18 +0800
commite46bda50935cfad5bfc51130e4ea802f518917e7 (patch)
treeb755802d261fb017f401cd79c7e5122e6fe01cd3 /swarm/network/hive.go
parenta98d1d67d6192df0bd57f608921a82cc508eee18 (diff)
downloaddexon-e46bda50935cfad5bfc51130e4ea802f518917e7.tar
dexon-e46bda50935cfad5bfc51130e4ea802f518917e7.tar.gz
dexon-e46bda50935cfad5bfc51130e4ea802f518917e7.tar.bz2
dexon-e46bda50935cfad5bfc51130e4ea802f518917e7.tar.lz
dexon-e46bda50935cfad5bfc51130e4ea802f518917e7.tar.xz
dexon-e46bda50935cfad5bfc51130e4ea802f518917e7.tar.zst
dexon-e46bda50935cfad5bfc51130e4ea802f518917e7.zip
swarm/network: prevent relay of invalid IPs
Diffstat (limited to 'swarm/network/hive.go')
-rw-r--r--swarm/network/hive.go5
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)