aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-02 23:04:47 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-02 23:04:47 -0600
commit063becdc735f74965ffa2d51964b87e604b9c1e7 (patch)
treec9097106b2b7320e6be68f1f3cd0e1c4ef8000a5
parent15da869b31106d47823cb0a6cdd5c0ad3a0c243b (diff)
downloadwireguard-go-063becdc735f74965ffa2d51964b87e604b9c1e7.tar.gz
wireguard-go-063becdc735f74965ffa2d51964b87e604b9c1e7.zip
uapi: insert peer version placeholder
While we don't want people to ever use old protocols, people will complain if the API "changes", so explicitly make the unset protocol mean the latest, and add a dummy mechanism of specifying the protocol on a per-peer basis, which we hope nobody actually ever uses.
Diffstat (limited to '')
-rw-r--r--uapi.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/uapi.go b/uapi.go
index 1edafe0..1801c4c 100644
--- a/uapi.go
+++ b/uapi.go
@@ -75,6 +75,7 @@ func ipcGetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
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())
}
@@ -362,6 +363,13 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
ones, _ := network.Mask.Size()
device.allowedips.Insert(network.IP, uint(ones), peer)
+ case "protocol_version":
+
+ if value != "1" {
+ logError.Println("Invalid protocol version:", value)
+ return &IPCError{Code: ipcErrorInvalid}
+ }
+
default:
logError.Println("Invalid UAPI peer key:", key)
return &IPCError{Code: ipcErrorInvalid}