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

Method remove

polyamide/device/allowedips.go:226–257  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

224}
225
226func (node *trieEntry) remove() {
227 node.removeFromPeerEntries()
228 node.peer = nil
229 if node.child[0] != nil && node.child[1] != nil {
230 return
231 }
232 bit := 0
233 if node.child[0] == nil {
234 bit = 1
235 }
236 child := node.child[bit]
237 if child != nil {
238 child.parent = node.parent
239 }
240 *node.parent.parentBit = child
241 if node.child[0] != nil || node.child[1] != nil || node.parent.parentBitType > 1 {
242 node.zeroizePointers()
243 return
244 }
245 parent := (*trieEntry)(unsafe.Pointer(uintptr(unsafe.Pointer(node.parent.parentBit)) - unsafe.Offsetof(node.child) - unsafe.Sizeof(node.child[0])*uintptr(node.parent.parentBitType)))
246 if parent.peer != nil {
247 node.zeroizePointers()
248 return
249 }
250 child = parent.child[node.parent.parentBitType^1]
251 if child != nil {
252 child.parent = parent.parent
253 }
254 *parent.parent.parentBit = child
255 node.zeroizePointers()
256 parent.zeroizePointers()
257}
258
259func (table *AllowedIPs) Remove(prefix netip.Prefix, peer *Peer) {
260 table.mutex.Lock()

Callers 2

RemoveMethod · 0.95
RemoveByPeerMethod · 0.80

Calls 2

removeFromPeerEntriesMethod · 0.95
zeroizePointersMethod · 0.95

Tested by

no test coverage detected