From 841756e328c743fec624e9259921ea6d815911d5 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 3 Jun 2021 16:12:29 +0200 Subject: device: simplify allowedips lookup signature The inliner should handle this for us. Signed-off-by: Jason A. Donenfeld --- device/allowedips.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'device/allowedips.go') 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")) + } } -- cgit v1.2.3-59-g8ed1b