diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2018-05-05 02:20:52 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2018-05-05 02:20:52 +0200 |
commit | 6db41d5a269c79bd04b18dbfa171cc241a6cdcc9 (patch) | |
tree | 7cfd9a8461b5c66dd971971e3706ada4c8b0484a /uapi.go | |
parent | 168ef61a638e4875b260edbc51551bae0dc34ac3 (diff) |
Initial version of migration to new event model
- Begin move away from global timer state.
- Made logging format more consistent
Diffstat (limited to 'uapi.go')
-rw-r--r-- | uapi.go | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -248,12 +248,10 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { logError.Println("Failed to create new peer:", err) return &IPCError{Code: ipcErrorInvalid} } - logDebug.Println("UAPI: Created new peer:", peer.String()) + logDebug.Println("UAPI: Created new peer:", peer) } - peer.mutex.Lock() - peer.timer.handshakeDeadline.Reset(RekeyAttemptTime) - peer.mutex.Unlock() + peer.event.handshakePushDeadline.Fire() case "remove": @@ -264,7 +262,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { return &IPCError{Code: ipcErrorInvalid} } if !dummy { - logDebug.Println("UAPI: Removing peer:", peer.String()) + logDebug.Println("UAPI: Removing peer:", peer) device.RemovePeer(peer.handshake.remoteStatic) } peer = &Peer{} @@ -274,7 +272,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { // update PSK - logDebug.Println("UAPI: Updating pre-shared key for peer:", peer.String()) + logDebug.Println("UAPI: Updating pre-shared key for peer:", peer) peer.handshake.mutex.Lock() err := peer.handshake.presharedKey.FromHex(value) @@ -289,7 +287,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { // set endpoint destination - logDebug.Println("UAPI: Updating endpoint for peer:", peer.String()) + logDebug.Println("UAPI: Updating endpoint for peer:", peer) err := func() error { peer.mutex.Lock() @@ -299,7 +297,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { return err } peer.endpoint = endpoint - peer.timer.handshakeDeadline.Reset(RekeyAttemptTime) + peer.event.handshakePushDeadline.Fire() return nil }() @@ -312,7 +310,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { // update keep-alive interval - logDebug.Println("UAPI: Updating persistent_keepalive_interval for peer:", peer.String()) + logDebug.Println("UAPI: Updating persistent_keepalive_interval for peer:", peer) secs, err := strconv.ParseUint(value, 10, 16) if err != nil { @@ -337,7 +335,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { case "replace_allowed_ips": - logDebug.Println("UAPI: Removing all allowed IPs for peer:", peer.String()) + logDebug.Println("UAPI: Removing all allowed IPs for peer:", peer) if value != "true" { logError.Println("Failed to set replace_allowed_ips, invalid value:", value) @@ -354,7 +352,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { case "allowed_ip": - logDebug.Println("UAPI: Adding allowed_ip to peer:", peer.String()) + logDebug.Println("UAPI: Adding allowed_ip to peer:", peer) _, network, err := net.ParseCIDR(value) if err != nil { |