GoBackend: make socket IPC optional
This fixes the multi-user case, which cannot be determined at compile time and probably isn't reasonable to consider anyway in a global manner. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
ffa3cefa67
commit
09cf73cd3c
@ -91,19 +91,17 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var uapi net.Listener;
|
||||||
|
|
||||||
uapiFile, err := UAPIOpen(name)
|
uapiFile, err := UAPIOpen(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
unix.Close(int(tun_fd))
|
|
||||||
logger.Error.Println(err)
|
logger.Error.Println(err)
|
||||||
return -1
|
} else {
|
||||||
}
|
uapi, err = UAPIListen(name, uapiFile)
|
||||||
uapi, err := UAPIListen(name, uapiFile)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
uapiFile.Close()
|
uapiFile.Close()
|
||||||
unix.Close(int(tun_fd))
|
|
||||||
logger.Error.Println(err)
|
logger.Error.Println(err)
|
||||||
return -1
|
} else {
|
||||||
}
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
conn, err := uapi.Accept()
|
conn, err := uapi.Accept()
|
||||||
@ -113,6 +111,8 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 {
|
|||||||
go ipcHandle(device, conn)
|
go ipcHandle(device, conn)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
device.Up()
|
device.Up()
|
||||||
logger.Info.Println("Device started")
|
logger.Info.Println("Device started")
|
||||||
@ -138,7 +138,9 @@ func wgTurnOff(tunnelHandle int32) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
delete(tunnelHandles, tunnelHandle)
|
delete(tunnelHandles, tunnelHandle)
|
||||||
|
if handle.uapi != nil {
|
||||||
handle.uapi.Close()
|
handle.uapi.Close()
|
||||||
|
}
|
||||||
handle.device.Close()
|
handle.device.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user