Simplified xplatform spec

This commit is contained in:
Jason A. Donenfeld 2017-09-26 14:26:12 +02:00
parent eefa47b0f9
commit 012e7b9d33

View File

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