()
| 224 | } |
| 225 | |
| 226 | func (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 | |
| 259 | func (table *AllowedIPs) Remove(prefix netip.Prefix, peer *Peer) { |
| 260 | table.mutex.Lock() |
no test coverage detected