diff options
Diffstat (limited to 'device/uapi.go')
-rw-r--r-- | device/uapi.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/device/uapi.go b/device/uapi.go index b266f4c..1671faa 100644 --- a/device/uapi.go +++ b/device/uapi.go @@ -18,7 +18,6 @@ import ( "golang.zx2c4.com/wireguard/conn" "golang.zx2c4.com/wireguard/ipc" - "golang.zx2c4.com/wireguard/wgcfg" ) type IPCError struct { @@ -55,7 +54,7 @@ func (device *Device) IpcGetOperation(socket *bufio.Writer) error { // serialize device related values if !device.staticIdentity.privateKey.IsZero() { - send("private_key=" + device.staticIdentity.privateKey.HexString()) + send("private_key=" + device.staticIdentity.privateKey.ToHex()) } if device.net.port != 0 { @@ -72,8 +71,8 @@ func (device *Device) IpcGetOperation(socket *bufio.Writer) error { peer.RLock() defer peer.RUnlock() - send("public_key=" + peer.handshake.remoteStatic.HexString()) - send("preshared_key=" + peer.handshake.presharedKey.HexString()) + send("public_key=" + peer.handshake.remoteStatic.ToHex()) + send("preshared_key=" + peer.handshake.presharedKey.ToHex()) send("protocol_version=1") if peer.endpoint != nil { send("endpoint=" + peer.endpoint.DstToString()) @@ -140,7 +139,8 @@ func (device *Device) IpcSetOperation(socket *bufio.Reader) error { switch key { case "private_key": - sk, err := wgcfg.ParsePrivateHexKey(value) + var sk NoisePrivateKey + err := sk.FromMaybeZeroHex(value) if err != nil { logError.Println("Failed to set private_key:", err) return &IPCError{ipc.IpcErrorInvalid} @@ -221,7 +221,8 @@ func (device *Device) IpcSetOperation(socket *bufio.Reader) error { switch key { case "public_key": - publicKey, err := wgcfg.ParseHexKey(value) + var publicKey NoisePublicKey + err := publicKey.FromHex(value) if err != nil { logError.Println("Failed to get peer by public key:", err) return &IPCError{ipc.IpcErrorInvalid} @@ -230,7 +231,7 @@ func (device *Device) IpcSetOperation(socket *bufio.Reader) error { // ignore peer with public key of device device.staticIdentity.RLock() - dummy = device.staticIdentity.publicKey.Equal(publicKey) + dummy = device.staticIdentity.publicKey.Equals(publicKey) device.staticIdentity.RUnlock() if dummy { @@ -290,8 +291,7 @@ func (device *Device) IpcSetOperation(socket *bufio.Reader) error { logDebug.Println(peer, "- UAPI: Updating preshared key") peer.handshake.mutex.Lock() - key, err := wgcfg.ParseSymmetricHexKey(value) - peer.handshake.presharedKey = key + err := peer.handshake.presharedKey.FromHex(value) peer.handshake.mutex.Unlock() if err != nil { |