Clean up error handling of listen port

This commit is contained in:
Jason A. Donenfeld 2017-09-26 15:15:27 +02:00
parent 012e7b9d33
commit 6fa65bded4
4 changed files with 6 additions and 6 deletions

View File

@ -151,7 +151,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
err = updateUDPConn(device) err = updateUDPConn(device)
if err != nil { if err != nil {
logError.Println("Failed to set listen_port:", err) logError.Println("Failed to set listen_port:", err)
return &IPCError{Code: ipcErrorIO} return &IPCError{Code: ipcErrorPortInUse}
} }
// TODO: Clear source address of all peers // TODO: Clear source address of all peers

View File

@ -11,9 +11,9 @@ import (
const ( const (
ipcErrorIO = -int64(unix.EIO) ipcErrorIO = -int64(unix.EIO)
ipcErrorNotDefined = -int64(unix.ENODEV)
ipcErrorProtocol = -int64(unix.EPROTO) ipcErrorProtocol = -int64(unix.EPROTO)
ipcErrorInvalid = -int64(unix.EINVAL) ipcErrorInvalid = -int64(unix.EINVAL)
ipcErrorPortInUse = -int64(unix.EADDRINUSE)
socketDirectory = "/var/run/wireguard" socketDirectory = "/var/run/wireguard"
socketName = "%s.sock" socketName = "%s.sock"
) )

View File

@ -11,9 +11,9 @@ import (
const ( const (
ipcErrorIO = -int64(unix.EIO) ipcErrorIO = -int64(unix.EIO)
ipcErrorNotDefined = -int64(unix.ENODEV)
ipcErrorProtocol = -int64(unix.EPROTO) ipcErrorProtocol = -int64(unix.EPROTO)
ipcErrorInvalid = -int64(unix.EINVAL) ipcErrorInvalid = -int64(unix.EINVAL)
ipcErrorPortInUse = -int64(unix.EADDRINUSE)
socketDirectory = "/var/run/wireguard" socketDirectory = "/var/run/wireguard"
socketName = "%s.sock" socketName = "%s.sock"
) )

View File

@ -12,9 +12,9 @@ import (
const ( const (
ipcErrorIO = -int64(windows.ERROR_BROKEN_PIPE) ipcErrorIO = -int64(windows.ERROR_BROKEN_PIPE)
ipcErrorNotDefined = -int64(windows.ERROR_SERVICE_SPECIFIC_ERROR) ipcErrorProtocol = -int64(windows.ERROR_INVALID_NAME)
ipcErrorProtocol = -int64(windows.ERROR_SERVICE_SPECIFIC_ERROR) ipcErrorInvalid = -int64(windows.ERROR_INVALID_PARAMETER)
ipcErrorInvalid = -int64(windows.ERROR_SERVICE_SPECIFIC_ERROR) ipcErrorPortInUse = -int64(windows.ERROR_ALREADY_EXISTS)
) )
const PipeNameFmt = "\\\\.\\pipe\\wireguard-ipc-%s" const PipeNameFmt = "\\\\.\\pipe\\wireguard-ipc-%s"