summaryrefslogtreecommitdiffhomepage
path: root/device/allowedips.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-06-03 16:12:29 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-06-03 16:29:43 +0200
commit841756e328c743fec624e9259921ea6d815911d5 (patch)
tree6b31dc3cd2e7b6e86c38ed6a1b7a36c326ef064d /device/allowedips.go
parentc382222eab9e3814f4df75fd25f8e9e31484b5e0 (diff)
device: simplify allowedips lookup signature
The inliner should handle this for us. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/allowedips.go')
-rw-r--r--device/allowedips.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/device/allowedips.go b/device/allowedips.go
index 7af9fc7..95615ab 100644
--- a/device/allowedips.go
+++ b/device/allowedips.go
@@ -285,14 +285,15 @@ func (table *AllowedIPs) Insert(ip net.IP, cidr uint8, peer *Peer) {
}
}
-func (table *AllowedIPs) LookupIPv4(address []byte) *Peer {
+func (table *AllowedIPs) Lookup(address []byte) *Peer {
table.mutex.RLock()
defer table.mutex.RUnlock()
- return table.IPv4.lookup(address)
-}
-
-func (table *AllowedIPs) LookupIPv6(address []byte) *Peer {
- table.mutex.RLock()
- defer table.mutex.RUnlock()
- return table.IPv6.lookup(address)
+ switch len(address) {
+ case net.IPv6len:
+ return table.IPv6.lookup(address)
+ case net.IPv4len:
+ return table.IPv4.lookup(address)
+ default:
+ panic(errors.New("looking up unknown address type"))
+ }
}