diff options
Diffstat (limited to 'device/uapi.go')
-rw-r--r-- | device/uapi.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/device/uapi.go b/device/uapi.go index 76b6fb8..148a7a2 100644 --- a/device/uapi.go +++ b/device/uapi.go @@ -130,7 +130,7 @@ func (device *Device) IpcSetOperation(r io.Reader) (err error) { defer func() { if err != nil { - device.errorf("%v", err) + device.log.Errorf("%v", err) } }() @@ -188,7 +188,7 @@ func (device *Device) handleDeviceLine(key, value string) error { if err != nil { return ipcErrorf(ipc.IpcErrorInvalid, "failed to set private_key: %w", err) } - device.debugf("UAPI: Updating private key") + device.log.Verbosef("UAPI: Updating private key") device.SetPrivateKey(sk) case "listen_port": @@ -198,7 +198,7 @@ func (device *Device) handleDeviceLine(key, value string) error { } // update port and rebind - device.debugf("UAPI: Updating listen port") + device.log.Verbosef("UAPI: Updating listen port") device.net.Lock() device.net.port = uint16(port) @@ -214,7 +214,7 @@ func (device *Device) handleDeviceLine(key, value string) error { return ipcErrorf(ipc.IpcErrorInvalid, "invalid fwmark: %w", err) } - device.debugf("UAPI: Updating fwmark") + device.log.Verbosef("UAPI: Updating fwmark") if err := device.BindSetMark(uint32(mark)); err != nil { return ipcErrorf(ipc.IpcErrorPortInUse, "failed to update fwmark: %w", err) } @@ -223,7 +223,7 @@ func (device *Device) handleDeviceLine(key, value string) error { if value != "true" { return ipcErrorf(ipc.IpcErrorInvalid, "failed to set replace_peers, invalid value: %v", value) } - device.debugf("UAPI: Removing all peers") + device.log.Verbosef("UAPI: Removing all peers") device.RemoveAllPeers() default: @@ -265,7 +265,7 @@ func (device *Device) handlePublicKeyLine(peer *ipcSetPeer, value string) error if err != nil { return ipcErrorf(ipc.IpcErrorInvalid, "failed to create new peer: %w", err) } - device.debugf("%v - UAPI: Created", peer.Peer) + device.log.Verbosef("%v - UAPI: Created", peer.Peer) } return nil } @@ -289,14 +289,14 @@ func (device *Device) handlePeerLine(peer *ipcSetPeer, key, value string) error return ipcErrorf(ipc.IpcErrorInvalid, "failed to set remove, invalid value: %v", value) } if !peer.dummy { - device.debugf("%v - UAPI: Removing", peer.Peer) + device.log.Verbosef("%v - UAPI: Removing", peer.Peer) device.RemovePeer(peer.handshake.remoteStatic) } peer.Peer = &Peer{} peer.dummy = true case "preshared_key": - device.debugf("%v - UAPI: Updating preshared key", peer.Peer) + device.log.Verbosef("%v - UAPI: Updating preshared key", peer.Peer) peer.handshake.mutex.Lock() err := peer.handshake.presharedKey.FromHex(value) @@ -307,7 +307,7 @@ func (device *Device) handlePeerLine(peer *ipcSetPeer, key, value string) error } case "endpoint": - device.debugf("%v - UAPI: Updating endpoint", peer.Peer) + device.log.Verbosef("%v - UAPI: Updating endpoint", peer.Peer) endpoint, err := conn.CreateEndpoint(value) if err != nil { return ipcErrorf(ipc.IpcErrorInvalid, "failed to set endpoint %v: %w", value, err) @@ -317,7 +317,7 @@ func (device *Device) handlePeerLine(peer *ipcSetPeer, key, value string) error peer.endpoint = endpoint case "persistent_keepalive_interval": - device.debugf("%v - UAPI: Updating persistent keepalive interval", peer.Peer) + device.log.Verbosef("%v - UAPI: Updating persistent keepalive interval", peer.Peer) secs, err := strconv.ParseUint(value, 10, 16) if err != nil { @@ -337,7 +337,7 @@ func (device *Device) handlePeerLine(peer *ipcSetPeer, key, value string) error } case "replace_allowed_ips": - device.debugf("%v - UAPI: Removing all allowedips", peer.Peer) + device.log.Verbosef("%v - UAPI: Removing all allowedips", peer.Peer) if value != "true" { return ipcErrorf(ipc.IpcErrorInvalid, "failed to replace allowedips, invalid value: %v", value) } @@ -347,7 +347,7 @@ func (device *Device) handlePeerLine(peer *ipcSetPeer, key, value string) error device.allowedips.RemoveByPeer(peer.Peer) case "allowed_ip": - device.debugf("%v - UAPI: Adding allowedip", peer.Peer) + device.log.Verbosef("%v - UAPI: Adding allowedip", peer.Peer) _, network, err := net.ParseCIDR(value) if err != nil { @@ -409,12 +409,12 @@ func (device *Device) IpcHandle(socket net.Conn) { return } if nextByte != '\n' { - err = ipcErrorf(ipc.IpcErrorInvalid, "trailing character in UAPI get: %c", nextByte) + err = ipcErrorf(ipc.IpcErrorInvalid, "trailing character in UAPI get: %q", nextByte) break } err = device.IpcGetOperation(buffered.Writer) default: - device.errorf("invalid UAPI operation: %v", op) + device.log.Errorf("invalid UAPI operation: %v", op) return } @@ -425,7 +425,7 @@ func (device *Device) IpcHandle(socket net.Conn) { status = ipcErrorf(ipc.IpcErrorUnknown, "other UAPI error: %w", err) } if status != nil { - device.errorf("%v", status) + device.log.Errorf("%v", status) fmt.Fprintf(buffered, "errno=%d\n\n", status.ErrorCode()) } else { fmt.Fprintf(buffered, "errno=0\n\n") |