MCPcopy Create free account
hub / github.com/encodeous/nylon / Insert

Method Insert

polyamide/device/allowedips.go:291–304  ·  view source on GitHub ↗
(prefix netip.Prefix, peer *Peer)

Source from the content-addressed store, hash-verified

289}
290
291func (table *AllowedIPs) Insert(prefix netip.Prefix, peer *Peer) {
292 table.mutex.Lock()
293 defer table.mutex.Unlock()
294
295 if prefix.Addr().Is6() {
296 ip := prefix.Addr().As16()
297 parentIndirection{&table.IPv6, 2}.insert(ip[:], uint8(prefix.Bits()), peer)
298 } else if prefix.Addr().Is4() {
299 ip := prefix.Addr().As4()
300 parentIndirection{&table.IPv4, 2}.insert(ip[:], uint8(prefix.Bits()), peer)
301 } else {
302 panic(errors.New("inserting unknown address type"))
303 }
304}
305
306func (table *AllowedIPs) Lookup(ip []byte) *Peer {
307 table.mutex.RLock()

Callers 5

TestTrieRandomFunction · 0.95
TestTrieIPv4Function · 0.95
TestTrieIPv6Function · 0.95
handlePeerLineMethod · 0.45
TableInsertRouteMethod · 0.45

Calls 2

AddrMethod · 0.45
insertMethod · 0.45

Tested by 3

TestTrieRandomFunction · 0.76
TestTrieIPv4Function · 0.76
TestTrieIPv6Function · 0.76