]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Block IPv6 for now
authorMatt Joiner <anacrolix@gmail.com>
Mon, 1 Dec 2014 09:27:11 +0000 (03:27 -0600)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 1 Dec 2014 09:27:11 +0000 (03:27 -0600)
client.go

index 4a6837d33f9cb958060c3415aace6d35c292171e..5d82833d16f96c3a99d9d8a4fc1910bb8214dd59 100644 (file)
--- a/client.go
+++ b/client.go
@@ -431,10 +431,18 @@ func (me *Client) Stop() {
        me.mu.Unlock()
 }
 
+var ipv6BlockRange = iplist.Range{Description: "non-IPv4 address"}
+
 func (cl *Client) ipBlockRange(ip net.IP) (r *iplist.Range) {
        if cl.ipBlockList == nil {
                return
        }
+       ip = ip.To4()
+       if ip == nil {
+               log.Printf("saw non-IPv4 address")
+               r = &ipv6BlockRange
+               return
+       }
        r = cl.ipBlockList.Lookup(ip)
        return
 }