aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/service/errors.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-20 14:18:01 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-20 14:18:01 +0200
commitcdb8c53cdea8d8ac6e6f2112e4a5e844bffd01a4 (patch)
treedb88ec568dfc508da863e67164de909448c66742 /service/errors.go
parentservice: move route monitor and account for changing index (diff)
downloadwireguard-windows-cdb8c53cdea8d8ac6e6f2112e4a5e844bffd01a4.tar.xz
wireguard-windows-cdb8c53cdea8d8ac6e6f2112e4a5e844bffd01a4.zip
service: split into tunnel and manager
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'service/errors.go')
-rw-r--r--service/errors.go96
1 files changed, 0 insertions, 96 deletions
diff --git a/service/errors.go b/service/errors.go
deleted file mode 100644
index a2cb7bc5..00000000
--- a/service/errors.go
+++ /dev/null
@@ -1,96 +0,0 @@
-/* SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.
- */
-
-package service
-
-import (
- "fmt"
- "syscall"
-
- "golang.org/x/sys/windows"
-)
-
-type Error uint32
-
-const (
- ErrorSuccess Error = iota
- ErrorRingloggerOpen
- ErrorLoadConfiguration
- ErrorCreateWintun
- ErrorDetermineWintunName
- ErrorUAPIListen
- ErrorDNSLookup
- ErrorFirewall
- ErrorDeviceSetConfig
- ErrorBindSocketsToDefaultRoutes
- ErrorSetNetConfig
- ErrorDetermineExecutablePath
- ErrorOpenNULFile
- ErrorTrackTunnels
- ErrorEnumerateSessions
- ErrorDropPrivileges
- ErrorWin32
-)
-
-func (e Error) Error() string {
- switch e {
- case ErrorSuccess:
- return "No error"
- case ErrorRingloggerOpen:
- return "Unable to open log file"
- case ErrorDetermineExecutablePath:
- return "Unable to determine path of running executable"
- case ErrorLoadConfiguration:
- return "Unable to load configuration from path"
- case ErrorCreateWintun:
- return "Unable to create Wintun device"
- case ErrorDetermineWintunName:
- return "Unable to determine Wintun name"
- case ErrorUAPIListen:
- return "Unable to listen on named pipe"
- case ErrorDNSLookup:
- return "Unable to resolve one or more DNS hostname endpoints"
- case ErrorFirewall:
- return "Unable to enable firewall rules"
- case ErrorDeviceSetConfig:
- return "Unable to set device configuration"
- case ErrorBindSocketsToDefaultRoutes:
- return "Unable to bind sockets to default route"
- case ErrorSetNetConfig:
- return "Unable to set interface addresses, routes, dns, and/or adapter settings"
- case ErrorOpenNULFile:
- return "Unable to open NUL file"
- case ErrorTrackTunnels:
- return "Unable to track existing tunnels"
- case ErrorEnumerateSessions:
- return "Unable to enumerate current sessions"
- case ErrorDropPrivileges:
- return "Unable to drop privileges"
- case ErrorWin32:
- return "An internal Windows error has occurred"
- default:
- return "An unknown error has occurred"
- }
-}
-
-func determineErrorCode(err error, serviceError Error) (bool, uint32) {
- if syserr, ok := err.(syscall.Errno); ok {
- return false, uint32(syserr)
- } else if serviceError != ErrorSuccess {
- return true, uint32(serviceError)
- } else {
- return false, windows.NO_ERROR
- }
-}
-
-func combineErrors(err error, serviceError Error) error {
- if serviceError != ErrorSuccess {
- if err != nil {
- return fmt.Errorf("%v: %v", serviceError, err)
- }
- return serviceError
- }
- return err
-}