Make IPBlockList accessible from Client
This commit is contained in:
parent
bc940ae2c6
commit
61adeee308
@ -124,8 +124,12 @@ type Client struct {
|
||||
handshaking int
|
||||
|
||||
torrents map[InfoHash]*torrent
|
||||
}
|
||||
|
||||
dataWaits map[*torrent][]dataWait
|
||||
func (me *Client) IPBlockList() *iplist.IPList {
|
||||
me.mu.Lock()
|
||||
defer me.mu.Unlock()
|
||||
return me.ipBlockList
|
||||
}
|
||||
|
||||
func (me *Client) SetIPBlockList(list *iplist.IPList) {
|
||||
|
@ -28,8 +28,18 @@ func New(initSorted []Range) *IPList {
|
||||
}
|
||||
}
|
||||
|
||||
func (me *IPList) NumRanges() int {
|
||||
if me == nil {
|
||||
return 0
|
||||
}
|
||||
return len(me.ranges)
|
||||
}
|
||||
|
||||
// Return the range the given IP is in. Returns nil if no range is found.
|
||||
func (me *IPList) Lookup(ip net.IP) (r *Range) {
|
||||
if me == nil {
|
||||
return nil
|
||||
}
|
||||
// Find the index of the first range for which the following range exceeds
|
||||
// it.
|
||||
i := sort.Search(len(me.ranges), func(i int) bool {
|
||||
|
Loading…
x
Reference in New Issue
Block a user