set_peer


Description:

public void set_peer (WireGuardPeer peer, uint idx)

If idx is one past the last peer, the behavior is the same as append_peer.

Otherwise, the peer will be at idx and replace the peer instance at that index. Note that if a peer with the same public-key exists on another index, then that peer will also be replaced. In that case, the number of peers will shrink by one (because the one at idx got replace and then one with the same public-key got removed). This also means, that the resulting index afterwards may be one less than idx (if another peer with a lower index was dropped).

Parameters:

this

the SettingWireGuard instance

peer

the WireGuardPeer instance to set. This seals peer and keeps a reference on the instance.

idx

the index, in the range of 0 to the number of peers (including). That means, if idx is one past the end of the number of peers, this is the same as append_peer. Otherwise, the peer at this index is replaced.