aboutsummaryrefslogtreecommitdiffstats
path: root/src/uapi.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2018-01-13 09:00:37 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2018-01-13 09:00:37 +0100
commit1dd590b91b893a413666b6daaed848d89bab7f05 (patch)
tree702ff9185afe072565a17fb089cf6014f4cbccfc /src/uapi.go
parentPeer timer teardown (diff)
downloadwireguard-go-1dd590b91b893a413666b6daaed848d89bab7f05.tar.xz
wireguard-go-1dd590b91b893a413666b6daaed848d89bab7f05.zip
Work on timer teardown + bug fixes
Added waitgroups to peer struct for routine start / stop synchronisation
Diffstat (limited to 'src/uapi.go')
-rw-r--r--src/uapi.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/uapi.go b/src/uapi.go
index a67bff1..f66528c 100644
--- a/src/uapi.go
+++ b/src/uapi.go
@@ -133,13 +133,27 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
device.SetPrivateKey(sk)
case "listen_port":
+
+ // parse port number
+
port, err := strconv.ParseUint(value, 10, 16)
if err != nil {
logError.Println("Failed to parse listen_port:", err)
return &IPCError{Code: ipcErrorInvalid}
}
+
+ // update port and rebind
+
+ device.mutex.Lock()
+ device.net.mutex.Lock()
+
device.net.port = uint16(port)
- if err := updateBind(device); err != nil {
+ err = unsafeUpdateBind(device)
+
+ device.net.mutex.Unlock()
+ device.mutex.Unlock()
+
+ if err != nil {
logError.Println("Failed to set listen_port:", err)
return &IPCError{Code: ipcErrorPortInUse}
}