summaryrefslogtreecommitdiffhomepage
path: root/src/config.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-08-22 17:22:45 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-08-22 17:22:45 +0200
commit4986cfe78b49173b8a9d86b9ec7e3024d0a3c218 (patch)
tree73444bb682a9ada96f5ea666551141a933cad174 /src/config.go
parentc6d03ef17f34f7380d95e91a6091a06bce332979 (diff)
Add support for fwmark on linux
Diffstat (limited to 'src/config.go')
-rw-r--r--src/config.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/config.go b/src/config.go
index 474134b..871232c 100644
--- a/src/config.go
+++ b/src/config.go
@@ -145,10 +145,10 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
return &IPCError{Code: ipcErrorInvalid}
}
- netc := &device.net
- netc.mutex.Lock()
- netc.addr = addr
- netc.mutex.Unlock()
+ device.net.mutex.Lock()
+ device.net.addr = addr
+ device.net.mutex.Unlock()
+
err = updateUDPConn(device)
if err != nil {
logError.Println("Failed to set listen_port:", err)
@@ -158,7 +158,24 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
// TODO: Clear source address of all peers
case "fwmark":
- logError.Println("FWMark not handled yet")
+ fwmark, err := strconv.ParseInt(value, 10, 32)
+ if err != nil {
+ logError.Println("Invalid fwmark", err)
+ return &IPCError{Code: ipcErrorInvalid}
+ }
+
+ device.net.mutex.Lock()
+ device.net.fwmark = int(fwmark)
+ err = setMark(
+ device.net.conn,
+ device.net.fwmark,
+ )
+ device.net.mutex.Unlock()
+ if err != nil {
+ logError.Println("Failed to set fwmark:", err)
+ return &IPCError{Code: ipcErrorIO}
+ }
+
// TODO: Clear source address of all peers
case "public_key":