fix preservation of order on remove
This commit is contained in:
parent
fb9cc3d4e3
commit
2d7447c32c
@ -125,10 +125,9 @@ func (conf *DsnetConfig) MustRemovePeer(hostname string) {
|
|||||||
ExitFail("Could not find peer with hostname %s", hostname)
|
ExitFail("Could not find peer with hostname %s", hostname)
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove peer from slice (by moving the last element to peerIndex, and
|
// remove peer from slice, retaining order
|
||||||
// truncating)
|
copy(conf.Peers[peerIndex:], conf.Peers[peerIndex+1:]) // shift left
|
||||||
conf.Peers[peerIndex] = conf.Peers[len(conf.Peers)-1]
|
conf.Peers = conf.Peers[:len(conf.Peers)-1] // truncate
|
||||||
conf.Peers = conf.Peers[:len(conf.Peers)-1]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conf DsnetConfig) IPAllocated(IP net.IP) bool {
|
func (conf DsnetConfig) IPAllocated(IP net.IP) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user