device: simplify handling of IPC set endpoint
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
d8f2cc87ee
commit
a9ce4b762c
|
@ -301,21 +301,13 @@ func (device *Device) handlePeerLine(peer *ipcSetPeer, key, value string) error
|
||||||
|
|
||||||
case "endpoint":
|
case "endpoint":
|
||||||
device.log.Debug.Println(peer, "- UAPI: Updating endpoint")
|
device.log.Debug.Println(peer, "- UAPI: Updating endpoint")
|
||||||
|
|
||||||
err := func() error {
|
|
||||||
peer.Lock()
|
|
||||||
defer peer.Unlock()
|
|
||||||
endpoint, err := conn.CreateEndpoint(value)
|
endpoint, err := conn.CreateEndpoint(value)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
peer.endpoint = endpoint
|
|
||||||
return nil
|
|
||||||
}()
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ipcErrorf(ipc.IpcErrorInvalid, "failed to set endpoint %v: %w", value, err)
|
return ipcErrorf(ipc.IpcErrorInvalid, "failed to set endpoint %v: %w", value, err)
|
||||||
}
|
}
|
||||||
|
peer.Lock()
|
||||||
|
defer peer.Unlock()
|
||||||
|
peer.endpoint = endpoint
|
||||||
|
|
||||||
case "persistent_keepalive_interval":
|
case "persistent_keepalive_interval":
|
||||||
device.log.Debug.Println(peer, "- UAPI: Updating persistent keepalive interval")
|
device.log.Debug.Println(peer, "- UAPI: Updating persistent keepalive interval")
|
||||||
|
|
Loading…
Reference in a new issue