(ip []byte)
| 189 | } |
| 190 | |
| 191 | func (node *trieEntry) lookup(ip []byte) *Peer { |
| 192 | var found *Peer |
| 193 | size := uint8(len(ip)) |
| 194 | for node != nil && commonBits(node.bits, ip) >= node.cidr { |
| 195 | if node.peer != nil { |
| 196 | found = node.peer |
| 197 | } |
| 198 | if node.bitAtByte == size { |
| 199 | break |
| 200 | } |
| 201 | bit := node.choose(ip) |
| 202 | node = node.child[bit] |
| 203 | } |
| 204 | return found |
| 205 | } |
| 206 | |
| 207 | type AllowedIPs struct { |
| 208 | IPv4 *trieEntry |