From: Matt Joiner Date: Wed, 20 May 2015 12:26:33 +0000 (+1000) Subject: dht: Improve behaviour when adding new root nodes X-Git-Tag: v1.0.0~1177 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=83685f2a4bb5db96e0144cb15e44656b6a2c6688;p=btrtrc.git dht: Improve behaviour when adding new root nodes --- diff --git a/dht/dht.go b/dht/dht.go index 78875578..de96fe9e 100644 --- a/dht/dht.go +++ b/dht/dht.go @@ -1052,12 +1052,24 @@ func bootstrapAddrs(nodeAddrs []string) (addrs []*net.UDPAddr, err error) { return } +// Adds bootstrap nodes directly to table, if there's room. Node ID security +// is bypassed, but the IP blocklist is not. func (s *Server) addRootNodes() error { addrs, err := bootstrapAddrs(s.bootstrapNodes) if err != nil { return err } for _, addr := range addrs { + if len(s.nodes) >= maxNodes { + break + } + if s.nodes[addr.String()] != nil { + continue + } + if s.ipBlocked(addr.IP) { + log.Printf("dht root node is in the blocklist: %s", addr.IP) + continue + } s.nodes[addr.String()] = &node{ addr: newDHTAddr(addr), }