]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
Simplified xplatform spec
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 26 Sep 2017 12:26:12 +0000 (14:26 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 26 Sep 2017 12:26:50 +0000 (14:26 +0200)
src/uapi.go

index 3a2f3f984d764d777b19b97f292a40a0abac8b57..034033ac06ff1de5d26ff469fa528016b7f93061 100644 (file)
@@ -124,16 +124,12 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
                        switch key {
                        case "private_key":
                                var sk NoisePrivateKey
-                               if value == "" {
-                                       device.SetPrivateKey(sk)
-                               } else {
-                                       err := sk.FromHex(value)
-                                       if err != nil {
-                                               logError.Println("Failed to set private_key:", err)
-                                               return &IPCError{Code: ipcErrorInvalid}
-                                       }
-                                       device.SetPrivateKey(sk)
+                               err := sk.FromHex(value)
+                               if err != nil {
+                                       logError.Println("Failed to set private_key:", err)
+                                       return &IPCError{Code: ipcErrorInvalid}
                                }
+                               device.SetPrivateKey(sk)
 
                        case "listen_port":
                                port, err := strconv.ParseUint(value, 10, 16)
@@ -161,14 +157,10 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
                                // TODO: Clear source address of all peers
 
                        case "fwmark":
-                               var fwmark uint64 = 0
-                               if value != "" {
-                                       var err error
-                                       fwmark, err = strconv.ParseUint(value, 10, 32)
-                                       if err != nil {
-                                               logError.Println("Invalid fwmark", err)
-                                               return &IPCError{Code: ipcErrorInvalid}
-                                       }
+                               fwmark, err := strconv.ParseUint(value, 10, 32)
+                               if err != nil {
+                                       logError.Println("Invalid fwmark", err)
+                                       return &IPCError{Code: ipcErrorInvalid}
                                }
 
                                device.net.mutex.Lock()