aboutsummaryrefslogtreecommitdiffstatshomepage
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
commite493f911269a2dabab7b05ec28726cdaeffb660e (patch)
treedb88ec568dfc508da863e67164de909448c66742
parentservice: move route monitor and account for changing index (diff)
downloadwireguard-windows-e493f911269a2dabab7b05ec28726cdaeffb660e.tar.xz
wireguard-windows-e493f911269a2dabab7b05ec28726cdaeffb660e.zip
service: split into tunnel and manager
-rw-r--r--main.go21
-rw-r--r--manager/install.go (renamed from service/install.go)5
-rw-r--r--manager/ipc_client.go (renamed from service/ipc_client.go)2
-rw-r--r--manager/ipc_pipe.go (renamed from service/ipc_pipe.go)2
-rw-r--r--manager/ipc_server.go (renamed from service/ipc_server.go)2
-rw-r--r--manager/names.go (renamed from service/names.go)2
-rw-r--r--manager/service.go (renamed from service/service_manager.go)22
-rw-r--r--manager/tunneltracker.go (renamed from service/tunneltracker.go)12
-rw-r--r--manager/updatestate.go (renamed from service/updatestate.go)2
-rw-r--r--services/errors.go (renamed from service/errors.go)6
-rw-r--r--services/tokens.go (renamed from service/tokens.go)2
-rw-r--r--tunnel/defaultroutemonitor.go (renamed from service/defaultroutemonitor.go)2
-rw-r--r--tunnel/firewall/blocker.go (renamed from service/firewall/blocker.go)0
-rw-r--r--tunnel/firewall/helpers.go (renamed from service/firewall/helpers.go)0
-rw-r--r--tunnel/firewall/mksyscall.go (renamed from service/firewall/mksyscall.go)0
-rw-r--r--tunnel/firewall/rules.go (renamed from service/firewall/rules.go)0
-rw-r--r--tunnel/firewall/syscall_windows.go (renamed from service/firewall/syscall_windows.go)0
-rw-r--r--tunnel/firewall/types_windows.go (renamed from service/firewall/types_windows.go)0
-rw-r--r--tunnel/firewall/types_windows_386.go (renamed from service/firewall/types_windows_386.go)0
-rw-r--r--tunnel/firewall/types_windows_amd64.go (renamed from service/firewall/types_windows_amd64.go)0
-rw-r--r--tunnel/firewall/types_windows_test.go (renamed from service/firewall/types_windows_test.go)0
-rw-r--r--tunnel/firewall/zsyscall_windows.go (renamed from service/firewall/zsyscall_windows.go)0
-rw-r--r--tunnel/ifaceconfig.go (renamed from service/ifaceconfig.go)4
-rw-r--r--tunnel/service.go (renamed from service/service_tunnel.go)42
-rw-r--r--ui/confview.go55
-rw-r--r--ui/editdialog.go7
-rw-r--r--ui/iconprovider.go29
-rw-r--r--ui/listview.go26
-rw-r--r--ui/managewindow.go20
-rw-r--r--ui/tray.go40
-rw-r--r--ui/tunnelspage.go25
-rw-r--r--ui/ui.go19
-rw-r--r--ui/updatepage.go7
33 files changed, 184 insertions, 170 deletions
diff --git a/main.go b/main.go
index fa6d4e5..1cb1fd8 100644
--- a/main.go
+++ b/main.go
@@ -14,8 +14,9 @@ import (
"golang.org/x/sys/windows"
+ "golang.zx2c4.com/wireguard/windows/manager"
"golang.zx2c4.com/wireguard/windows/ringlogger"
- "golang.zx2c4.com/wireguard/windows/service"
+ "golang.zx2c4.com/wireguard/windows/services"
"golang.zx2c4.com/wireguard/windows/ui"
)
@@ -68,7 +69,7 @@ func checkForAdminGroup() {
fatal("Unable to open current process token: ", err)
}
defer processToken.Close()
- if !service.TokenIsMemberOfBuiltInAdministrator(processToken) {
+ if !services.TokenIsMemberOfBuiltInAdministrator(processToken) {
fatal("WireGuard may only be used by users who are a member of the Builtin Administrators group.")
}
}
@@ -115,7 +116,7 @@ func main() {
usage()
}
go ui.WaitForRaiseUIThenQuit()
- err := service.InstallManager()
+ err := manager.InstallManager()
if err != nil {
fatal(err)
}
@@ -126,7 +127,7 @@ func main() {
if len(os.Args) != 2 {
usage()
}
- err := service.UninstallManager()
+ err := manager.UninstallManager()
if err != nil {
fatal(err)
}
@@ -135,7 +136,7 @@ func main() {
if len(os.Args) != 2 {
usage()
}
- err := service.RunManager()
+ err := manager.RunManager()
if err != nil {
fatal(err)
}
@@ -144,7 +145,7 @@ func main() {
if len(os.Args) != 3 {
usage()
}
- err := service.InstallTunnel(os.Args[2])
+ err := manager.InstallTunnel(os.Args[2])
if err != nil {
fatal(err)
}
@@ -153,7 +154,7 @@ func main() {
if len(os.Args) != 3 {
usage()
}
- err := service.UninstallTunnel(os.Args[2])
+ err := manager.UninstallTunnel(os.Args[2])
if err != nil {
fatal(err)
}
@@ -162,7 +163,7 @@ func main() {
if len(os.Args) != 3 {
usage()
}
- err := service.RunTunnel(os.Args[2])
+ err := manager.RunTunnel(os.Args[2])
if err != nil {
fatal(err)
}
@@ -171,7 +172,7 @@ func main() {
if len(os.Args) != 6 {
usage()
}
- err := service.DropAllPrivileges()
+ err := services.DropAllPrivileges()
if err != nil {
fatal(err)
}
@@ -191,7 +192,7 @@ func main() {
if err != nil {
fatal(err)
}
- service.InitializeIPCClient(readPipe, writePipe, eventPipe)
+ manager.InitializeIPCClient(readPipe, writePipe, eventPipe)
ui.RunUI()
return
case "/dumplog":
diff --git a/service/install.go b/manager/install.go
index 1d97726..4a57029 100644
--- a/service/install.go
+++ b/manager/install.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package manager
import (
"errors"
@@ -15,6 +15,7 @@ import (
"golang.org/x/sys/windows/svc/mgr"
"golang.zx2c4.com/wireguard/windows/conf"
+ "golang.zx2c4.com/wireguard/windows/tunnel"
)
var cachedServiceManager *mgr.Mgr
@@ -200,5 +201,5 @@ func RunTunnel(confPath string) error {
if err != nil {
return err
}
- return svc.Run(serviceName, &tunnelService{confPath})
+ return svc.Run(serviceName, &tunnel.Service{confPath})
}
diff --git a/service/ipc_client.go b/manager/ipc_client.go
index 268f18e..a23493f 100644
--- a/service/ipc_client.go
+++ b/manager/ipc_client.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package manager
import (
"encoding/gob"
diff --git a/service/ipc_pipe.go b/manager/ipc_pipe.go
index ecf2471..657a627 100644
--- a/service/ipc_pipe.go
+++ b/manager/ipc_pipe.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package manager
import (
"os"
diff --git a/service/ipc_server.go b/manager/ipc_server.go
index 766f417..0accb4d 100644
--- a/service/ipc_server.go
+++ b/manager/ipc_server.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package manager
import (
"bytes"
diff --git a/service/names.go b/manager/names.go
index e93ed66..bebf0ca 100644
--- a/service/names.go
+++ b/manager/names.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package manager
import (
"errors"
diff --git a/service/service_manager.go b/manager/service.go
index 5bd94e0..ba7208d 100644
--- a/service/service_manager.go
+++ b/manager/service.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package manager
import (
"errors"
@@ -20,8 +20,10 @@ import (
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc"
+
"golang.zx2c4.com/wireguard/windows/conf"
"golang.zx2c4.com/wireguard/windows/ringlogger"
+ "golang.zx2c4.com/wireguard/windows/services"
"golang.zx2c4.com/wireguard/windows/version"
)
@@ -31,11 +33,11 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest
changes <- svc.Status{State: svc.StartPending}
var err error
- serviceError := ErrorSuccess
+ serviceError := services.ErrorSuccess
defer func() {
- svcSpecificEC, exitCode = determineErrorCode(err, serviceError)
- logErr := combineErrors(err, serviceError)
+ svcSpecificEC, exitCode = services.DetermineErrorCode(err, serviceError)
+ logErr := services.CombineErrors(err, serviceError)
if logErr != nil {
log.Print(logErr)
}
@@ -44,7 +46,7 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest
err = ringlogger.InitGlobalLogger("MGR")
if err != nil {
- serviceError = ErrorRingloggerOpen
+ serviceError = services.ErrorRingloggerOpen
return
}
defer func() {
@@ -62,19 +64,19 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest
path, err := os.Executable()
if err != nil {
- serviceError = ErrorDetermineExecutablePath
+ serviceError = services.ErrorDetermineExecutablePath
return
}
devNull, err := os.OpenFile(os.DevNull, os.O_RDWR, 0)
if err != nil {
- serviceError = ErrorOpenNULFile
+ serviceError = services.ErrorOpenNULFile
return
}
err = trackExistingTunnels()
if err != nil {
- serviceError = ErrorTrackTunnels
+ serviceError = services.ErrorTrackTunnels
return
}
@@ -100,7 +102,7 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest
if err != nil {
return
}
- if !TokenIsMemberOfBuiltInAdministrator(userToken) {
+ if !services.TokenIsMemberOfBuiltInAdministrator(userToken) {
userToken.Close()
return
}
@@ -240,7 +242,7 @@ func (service *managerService) Execute(args []string, r <-chan svc.ChangeRequest
var count uint32
err = windows.WTSEnumerateSessions(0, 0, 1, &sessionsPointer, &count)
if err != nil {
- serviceError = ErrorEnumerateSessions
+ serviceError = services.ErrorEnumerateSessions
return
}
sessions := *(*[]windows.WTS_SESSION_INFO)(unsafe.Pointer(&struct {
diff --git a/service/tunneltracker.go b/manager/tunneltracker.go
index 4c61925..1cde98e 100644
--- a/service/tunneltracker.go
+++ b/manager/tunneltracker.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package manager
import (
"fmt"
@@ -16,7 +16,9 @@ import (
"golang.org/x/sys/windows"
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/mgr"
+
"golang.zx2c4.com/wireguard/windows/conf"
+ "golang.zx2c4.com/wireguard/windows/services"
)
func trackExistingTunnels() error {
@@ -83,7 +85,7 @@ func trackedTunnelsGlobalState() (state TunnelState) {
func trackTunnelService(tunnelName string, service *mgr.Service) {
defer func() {
service.Close()
- log.Printf("[%s] Tunnel service tracker finished", tunnelName)
+ log.Printf("[%s] Tunnel managerService tracker finished", tunnelName)
}()
trackedTunnelsLock.Lock()
@@ -148,7 +150,7 @@ func trackTunnelService(tunnelName string, service *mgr.Service) {
trackedTunnelsLock.Lock()
trackedTunnels[tunnelName] = TunnelStopped
trackedTunnelsLock.Unlock()
- IPCServerNotifyTunnelChange(tunnelName, TunnelStopped, fmt.Errorf("Unable to continue monitoring service, so stopping: %v", err))
+ IPCServerNotifyTunnelChange(tunnelName, TunnelStopped, fmt.Errorf("Unable to continue monitoring managerService, so stopping: %v", err))
service.Control(svc.Stop)
return
}
@@ -157,8 +159,8 @@ func trackTunnelService(tunnelName string, service *mgr.Service) {
var tunnelError error
if state == TunnelStopped {
if notifier.ServiceStatus.Win32ExitCode == uint32(windows.ERROR_SERVICE_SPECIFIC_ERROR) {
- maybeErr := Error(notifier.ServiceStatus.ServiceSpecificExitCode)
- if maybeErr != ErrorSuccess {
+ maybeErr := services.Error(notifier.ServiceStatus.ServiceSpecificExitCode)
+ if maybeErr != services.ErrorSuccess {
tunnelError = maybeErr
}
} else {
diff --git a/service/updatestate.go b/manager/updatestate.go
index 4d9330f..2e82baf 100644
--- a/service/updatestate.go
+++ b/manager/updatestate.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package manager
import (
"log"
diff --git a/service/errors.go b/services/errors.go
index a2cb7bc..c9b2c04 100644
--- a/service/errors.go
+++ b/services/errors.go
@@ -3,7 +3,7 @@
* Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package services
import (
"fmt"
@@ -75,7 +75,7 @@ func (e Error) Error() string {
}
}
-func determineErrorCode(err error, serviceError Error) (bool, uint32) {
+func DetermineErrorCode(err error, serviceError Error) (bool, uint32) {
if syserr, ok := err.(syscall.Errno); ok {
return false, uint32(syserr)
} else if serviceError != ErrorSuccess {
@@ -85,7 +85,7 @@ func determineErrorCode(err error, serviceError Error) (bool, uint32) {
}
}
-func combineErrors(err error, serviceError Error) error {
+func CombineErrors(err error, serviceError Error) error {
if serviceError != ErrorSuccess {
if err != nil {
return fmt.Errorf("%v: %v", serviceError, err)
diff --git a/service/tokens.go b/services/tokens.go
index aade873..aa6f2c4 100644
--- a/service/tokens.go
+++ b/services/tokens.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package services
import (
"errors"
diff --git a/service/defaultroutemonitor.go b/tunnel/defaultroutemonitor.go
index d410544..1ffce5f 100644
--- a/service/defaultroutemonitor.go
+++ b/tunnel/defaultroutemonitor.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package tunnel
import (
"log"
diff --git a/service/firewall/blocker.go b/tunnel/firewall/blocker.go
index 8034935..8034935 100644
--- a/service/firewall/blocker.go
+++ b/tunnel/firewall/blocker.go
diff --git a/service/firewall/helpers.go b/tunnel/firewall/helpers.go
index e340b80..e340b80 100644
--- a/service/firewall/helpers.go
+++ b/tunnel/firewall/helpers.go
diff --git a/service/firewall/mksyscall.go b/tunnel/firewall/mksyscall.go
index 5e4bcaa..5e4bcaa 100644
--- a/service/firewall/mksyscall.go
+++ b/tunnel/firewall/mksyscall.go
diff --git a/service/firewall/rules.go b/tunnel/firewall/rules.go
index 76e2a85..76e2a85 100644
--- a/service/firewall/rules.go
+++ b/tunnel/firewall/rules.go
diff --git a/service/firewall/syscall_windows.go b/tunnel/firewall/syscall_windows.go
index 5ec41b0..5ec41b0 100644
--- a/service/firewall/syscall_windows.go
+++ b/tunnel/firewall/syscall_windows.go
diff --git a/service/firewall/types_windows.go b/tunnel/firewall/types_windows.go
index e06f7d2..e06f7d2 100644
--- a/service/firewall/types_windows.go
+++ b/tunnel/firewall/types_windows.go
diff --git a/service/firewall/types_windows_386.go b/tunnel/firewall/types_windows_386.go
index 00d7ba8..00d7ba8 100644
--- a/service/firewall/types_windows_386.go
+++ b/tunnel/firewall/types_windows_386.go
diff --git a/service/firewall/types_windows_amd64.go b/tunnel/firewall/types_windows_amd64.go
index f0aa557..f0aa557 100644
--- a/service/firewall/types_windows_amd64.go
+++ b/tunnel/firewall/types_windows_amd64.go
diff --git a/service/firewall/types_windows_test.go b/tunnel/firewall/types_windows_test.go
index 97cb032..97cb032 100644
--- a/service/firewall/types_windows_test.go
+++ b/tunnel/firewall/types_windows_test.go
diff --git a/service/firewall/zsyscall_windows.go b/tunnel/firewall/zsyscall_windows.go
index 15e7270..15e7270 100644
--- a/service/firewall/zsyscall_windows.go
+++ b/tunnel/firewall/zsyscall_windows.go
diff --git a/service/ifaceconfig.go b/tunnel/ifaceconfig.go
index 7d8b2f7..453d4ca 100644
--- a/service/ifaceconfig.go
+++ b/tunnel/ifaceconfig.go
@@ -3,7 +3,7 @@
* Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package tunnel
import (
"bytes"
@@ -16,7 +16,7 @@ import (
"golang.zx2c4.com/wireguard/tun"
"golang.zx2c4.com/wireguard/windows/conf"
- "golang.zx2c4.com/wireguard/windows/service/firewall"
+ "golang.zx2c4.com/wireguard/windows/tunnel/firewall"
)
func cleanupAddressesOnDisconnectedInterfaces(addresses []*net.IPNet) {
diff --git a/service/service_tunnel.go b/tunnel/service.go
index 2a82a2f..e93a2c4 100644
--- a/service/service_tunnel.go
+++ b/tunnel/service.go
@@ -3,7 +3,7 @@
* Copyright (C) 2017-2019 WireGuard LLC. All Rights Reserved.
*/
-package service
+package tunnel
import (
"bufio"
@@ -22,27 +22,29 @@ import (
"golang.zx2c4.com/wireguard/device"
"golang.zx2c4.com/wireguard/ipc"
"golang.zx2c4.com/wireguard/tun"
+
"golang.zx2c4.com/wireguard/windows/conf"
"golang.zx2c4.com/wireguard/windows/ringlogger"
+ "golang.zx2c4.com/wireguard/windows/services"
"golang.zx2c4.com/wireguard/windows/version"
)
-type tunnelService struct {
- path string
+type Service struct {
+ Path string
}
-func (service *tunnelService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (svcSpecificEC bool, exitCode uint32) {
+func (service *Service) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (svcSpecificEC bool, exitCode uint32) {
changes <- svc.Status{State: svc.StartPending}
var dev *device.Device
var uapi net.Listener
var routeChangeCallback *winipcfg.RouteChangeCallback
var err error
- serviceError := ErrorSuccess
+ serviceError := services.ErrorSuccess
defer func() {
- svcSpecificEC, exitCode = determineErrorCode(err, serviceError)
- logErr := combineErrors(err, serviceError)
+ svcSpecificEC, exitCode = services.DetermineErrorCode(err, serviceError)
+ logErr := services.CombineErrors(err, serviceError)
if logErr != nil {
log.Println(logErr)
}
@@ -95,7 +97,7 @@ func (service *tunnelService) Execute(args []string, r <-chan svc.ChangeRequest,
err = ringlogger.InitGlobalLogger("TUN")
if err != nil {
- serviceError = ErrorRingloggerOpen
+ serviceError = services.ErrorRingloggerOpen
return
}
defer func() {
@@ -109,9 +111,9 @@ func (service *tunnelService) Execute(args []string, r <-chan svc.ChangeRequest,
}
}()
- conf, err := conf.LoadFromPath(service.path)
+ conf, err := conf.LoadFromPath(service.Path)
if err != nil {
- serviceError = ErrorLoadConfiguration
+ serviceError = services.ErrorLoadConfiguration
return
}
@@ -123,20 +125,20 @@ func (service *tunnelService) Execute(args []string, r <-chan svc.ChangeRequest,
log.Println("Resolving DNS names")
uapiConf, err := conf.ToUAPI()
if err != nil {
- serviceError = ErrorDNSLookup
+ serviceError = services.ErrorDNSLookup
return
}
log.Println("Creating Wintun device")
wintun, err := tun.CreateTUN(conf.Name)
if err != nil {
- serviceError = ErrorCreateWintun
+ serviceError = services.ErrorCreateWintun
return
}
log.Println("Determining Wintun device name")
realInterfaceName, err := wintun.Name()
if err != nil {
- serviceError = ErrorDetermineWintunName
+ serviceError = services.ErrorDetermineWintunName
return
}
conf.Name = realInterfaceName
@@ -145,14 +147,14 @@ func (service *tunnelService) Execute(args []string, r <-chan svc.ChangeRequest,
log.Println("Enabling firewall rules")
err = enableFirewall(conf, nativeTun)
if err != nil {
- serviceError = ErrorFirewall
+ serviceError = services.ErrorFirewall
return
}
log.Println("Dropping all privileges")
- err = DropAllPrivileges()
+ err = services.DropAllPrivileges()
if err != nil {
- serviceError = ErrorDropPrivileges
+ serviceError = services.ErrorDropPrivileges
return
}
@@ -164,13 +166,13 @@ func (service *tunnelService) Execute(args []string, r <-chan svc.ChangeRequest,
log.Println("Setting interface configuration")
uapi, err = ipc.UAPIListen(conf.Name)
if err != nil {
- serviceError = ErrorUAPIListen
+ serviceError = services.ErrorUAPIListen
return
}
ipcErr := dev.IpcSetOperation(bufio.NewReader(strings.NewReader(uapiConf)))
if ipcErr != nil {
err = ipcErr
- serviceError = ErrorDeviceSetConfig
+ serviceError = services.ErrorDeviceSetConfig
return
}
@@ -180,14 +182,14 @@ func (service *tunnelService) Execute(args []string, r <-chan svc.ChangeRequest,
log.Println("Monitoring default routes")
routeChangeCallback, err = monitorDefaultRoutes(dev, conf.Interface.MTU == 0, nativeTun)
if err != nil {
- serviceError = ErrorBindSocketsToDefaultRoutes
+ serviceError = services.ErrorBindSocketsToDefaultRoutes
return
}
log.Println("Setting device address")
err = configureInterface(conf, nativeTun)
if err != nil {
- serviceError = ErrorSetNetConfig
+ serviceError = services.ErrorSetNetConfig
return
}
diff --git a/ui/confview.go b/ui/confview.go
index 8e28e83..665841d 100644
--- a/ui/confview.go
+++ b/ui/confview.go
@@ -13,8 +13,9 @@ import (
"github.com/lxn/walk"
"github.com/lxn/win"
+
"golang.zx2c4.com/wireguard/windows/conf"
- "golang.zx2c4.com/wireguard/windows/service"
+ "golang.zx2c4.com/wireguard/windows/manager"
)
type widgetsLine interface {
@@ -28,7 +29,7 @@ type widgetsLinesView interface {
type rectAndSizeAndState struct {
rect walk.Rectangle
size walk.Size
- state service.TunnelState
+ state manager.TunnelState
}
type labelStatusLine struct {
@@ -75,8 +76,8 @@ type ConfView struct {
name *walk.GroupBox
interfaze *interfaceView
peers map[conf.Key]*peerView
- tunnelChangedCB *service.TunnelChangeCallback
- tunnel *service.Tunnel
+ tunnelChangedCB *manager.TunnelChangeCallback
+ tunnel *manager.Tunnel
updateTicker *time.Ticker
}
@@ -84,7 +85,7 @@ func (lsl *labelStatusLine) widgets() (walk.Widget, walk.Widget) {
return lsl.label, lsl.statusComposite
}
-func (lsl *labelStatusLine) update(state service.TunnelState) {
+func (lsl *labelStatusLine) update(state manager.TunnelState) {
icon, err := iconForState(state, 14)
if err == nil {
lsl.statusImage.SetImage(icon)
@@ -122,7 +123,7 @@ func newLabelStatusLine(parent walk.Container) *labelStatusLine {
lsl.statusLabel.FocusedChanged().Attach(func() {
lsl.statusLabel.SetTextSelection(0, 0)
})
- lsl.update(service.TunnelUnknown)
+ lsl.update(manager.TunnelUnknown)
return lsl
}
@@ -167,26 +168,26 @@ func (tal *toggleActiveLine) widgets() (walk.Widget, walk.Widget) {
return nil, tal.composite
}
-func (tal *toggleActiveLine) updateGlobal(globalState service.TunnelState) {
- tal.button.SetEnabled(globalState == service.TunnelStarted || globalState == service.TunnelStopped)
+func (tal *toggleActiveLine) updateGlobal(globalState manager.TunnelState) {
+ tal.button.SetEnabled(globalState == manager.TunnelStarted || globalState == manager.TunnelStopped)
}
-func (tal *toggleActiveLine) update(state service.TunnelState) {
+func (tal *toggleActiveLine) update(state manager.TunnelState) {
var text string
switch state {
- case service.TunnelStarted:
+ case manager.TunnelStarted:
text = "Deactivate"
- case service.TunnelStopped:
+ case manager.TunnelStopped:
text = "Activate"
- case service.TunnelStarting, service.TunnelStopping:
+ case manager.TunnelStarting, manager.TunnelStopping:
text = textForState(state, true)
default:
text = ""
}
tal.button.SetText(text)
- tal.button.SetVisible(state != service.TunnelUnknown)
+ tal.button.SetVisible(state != manager.TunnelUnknown)
}
func newToggleActiveLine(parent walk.Container) *toggleActiveLine {
@@ -199,7 +200,7 @@ func newToggleActiveLine(parent walk.Container) *toggleActiveLine {
tal.button, _ = walk.NewPushButton(tal.composite)
walk.NewHSpacer(tal.composite)
- tal.update(service.TunnelStopped)
+ tal.update(manager.TunnelStopped)
return tal
}
@@ -388,9 +389,9 @@ func NewConfView(parent walk.Container) (*ConfView, error) {
cv.interfaze = newInterfaceView(cv.name)
cv.interfaze.toggleActive.button.Clicked().Attach(cv.onToggleActiveClicked)
cv.peers = make(map[conf.Key]*peerView)
- cv.tunnelChangedCB = service.IPCClientRegisterTunnelChange(cv.onTunnelChanged)
+ cv.tunnelChangedCB = manager.IPCClientRegisterTunnelChange(cv.onTunnelChanged)
cv.SetTunnel(nil)
- globalState, _ := service.IPCClientGlobalState()
+ globalState, _ := manager.IPCClientGlobalState()
cv.interfaze.toggleActive.updateGlobal(globalState)
if err := walk.InitWrapperWindow(cv); err != nil {
@@ -405,9 +406,9 @@ func NewConfView(parent walk.Container) (*ConfView, error) {
}
if cv.tunnel != nil {
tunnel := cv.tunnel
- var state service.TunnelState
+ var state manager.TunnelState
var config conf.Config
- if state, _ = tunnel.State(); state == service.TunnelStarted {
+ if state, _ = tunnel.State(); state == manager.TunnelStarted {
config, _ = tunnel.RuntimeConfig()
}
if config.Name == "" {
@@ -440,11 +441,11 @@ func (cv *ConfView) onToggleActiveClicked() {
oldState, err := cv.tunnel.Toggle()
if err != nil {
cv.Synchronize(func() {
- if oldState == service.TunnelUnknown {
+ if oldState == manager.TunnelUnknown {
walk.MsgBox(cv.Form(), "Failed to determine tunnel state", err.Error(), walk.MsgBoxIconError)
- } else if oldState == service.TunnelStopped {
+ } else if oldState == manager.TunnelStopped {
walk.MsgBox(cv.Form(), "Failed to activate tunnel", err.Error(), walk.MsgBoxIconError)
- } else if oldState == service.TunnelStarted {
+ } else if oldState == manager.TunnelStarted {
walk.MsgBox(cv.Form(), "Failed to deactivate tunnel", err.Error(), walk.MsgBoxIconError)
}
})
@@ -452,7 +453,7 @@ func (cv *ConfView) onToggleActiveClicked() {
}()
}
-func (cv *ConfView) onTunnelChanged(tunnel *service.Tunnel, state service.TunnelState, globalState service.TunnelState, err error) {
+func (cv *ConfView) onTunnelChanged(tunnel *manager.Tunnel, state manager.TunnelState, globalState manager.TunnelState, err error) {
cv.Synchronize(func() {
cv.interfaze.toggleActive.updateGlobal(globalState)
if cv.tunnel != nil && cv.tunnel.Name == tunnel.Name {
@@ -462,7 +463,7 @@ func (cv *ConfView) onTunnelChanged(tunnel *service.Tunnel, state service.Tunnel
})
if cv.tunnel != nil && cv.tunnel.Name == tunnel.Name {
var config conf.Config
- if state == service.TunnelStarted {
+ if state == manager.TunnelStarted {
config, _ = tunnel.RuntimeConfig()
}
if config.Name == "" {
@@ -474,14 +475,14 @@ func (cv *ConfView) onTunnelChanged(tunnel *service.Tunnel, state service.Tunnel
}
}
-func (cv *ConfView) SetTunnel(tunnel *service.Tunnel) {
+func (cv *ConfView) SetTunnel(tunnel *manager.Tunnel) {
cv.tunnel = tunnel //XXX: This races with the read in the updateTicker, but it's pointer-sized!
var config conf.Config
- var state service.TunnelState
+ var state manager.TunnelState
if tunnel != nil {
go func() {
- if state, _ = tunnel.State(); state == service.TunnelStarted {
+ if state, _ = tunnel.State(); state == manager.TunnelStarted {
config, _ = tunnel.RuntimeConfig()
}
if config.Name == "" {
@@ -496,7 +497,7 @@ func (cv *ConfView) SetTunnel(tunnel *service.Tunnel) {
}
}
-func (cv *ConfView) setTunnel(tunnel *service.Tunnel, config *conf.Config, state service.TunnelState) {
+func (cv *ConfView) setTunnel(tunnel *manager.Tunnel, config *conf.Config, state manager.TunnelState) {
if !(cv.tunnel == nil || tunnel == nil || tunnel.Name == cv.tunnel.Name) {
return
}
diff --git a/ui/editdialog.go b/ui/editdialog.go
index f46e91e..27c22eb 100644
--- a/ui/editdialog.go
+++ b/ui/editdialog.go
@@ -10,8 +10,9 @@ import (
"strings"
"github.com/lxn/walk"
+
"golang.zx2c4.com/wireguard/windows/conf"
- "golang.zx2c4.com/wireguard/windows/service"
+ "golang.zx2c4.com/wireguard/windows/manager"
"golang.zx2c4.com/wireguard/windows/ui/syntax"
)
@@ -27,7 +28,7 @@ type EditDialog struct {
blockUntunneledTraficCheckGuard bool
}
-func runTunnelEditDialog(owner walk.Form, tunnel *service.Tunnel, clone bool) *conf.Config {
+func runTunnelEditDialog(owner walk.Form, tunnel *manager.Tunnel, clone bool) *conf.Config {
dlg := &EditDialog{}
var title string
@@ -268,7 +269,7 @@ func (dlg *EditDialog) onSaveButtonClicked() {
newNameLower := strings.ToLower(newName)
if newNameLower != strings.ToLower(dlg.config.Name) {
- existingTunnelList, err := service.IPCClientTunnels()
+ existingTunnelList, err := manager.IPCClientTunnels()
if err != nil {
walk.MsgBox(dlg, "Unable to list existing tunnels", err.Error(), walk.MsgBoxIconError)
return
diff --git a/ui/iconprovider.go b/ui/iconprovider.go
index d7d6fbc..9a9d7ae 100644
--- a/ui/iconprovider.go
+++ b/ui/iconprovider.go
@@ -7,12 +7,13 @@ package ui
import (
"github.com/lxn/walk"
- "golang.zx2c4.com/wireguard/windows/service"
+
+ "golang.zx2c4.com/wireguard/windows/manager"
)
type widthAndState struct {
width int
- state service.TunnelState
+ state manager.TunnelState
}
type widthAndDllIdx struct {
@@ -23,7 +24,7 @@ type widthAndDllIdx struct {
var cachedOverlayIconsForWidthAndState = make(map[widthAndState]walk.Image)
-func iconWithOverlayForState(state service.TunnelState, size int) (icon walk.Image, err error) {
+func iconWithOverlayForState(state manager.TunnelState, size int) (icon walk.Image, err error) {
icon = cachedOverlayIconsForWidthAndState[widthAndState{size, state}]
if icon != nil {
return
@@ -34,7 +35,7 @@ func iconWithOverlayForState(state service.TunnelState, size int) (icon walk.Ima
return
}
- if state == service.TunnelStopped {
+ if state == manager.TunnelStopped {
return wireguardIcon, err //TODO: if we find something prettier than the gray dot, then remove this clause
}
@@ -64,15 +65,15 @@ func iconWithOverlayForState(state service.TunnelState, size int) (icon walk.Ima
var cachedIconsForWidthAndState = make(map[widthAndState]*walk.Icon)
-func iconForState(state service.TunnelState, size int) (icon *walk.Icon, err error) {
+func iconForState(state manager.TunnelState, size int) (icon *walk.Icon, err error) {
icon = cachedIconsForWidthAndState[widthAndState{size, state}]
if icon != nil {
return
}
switch state {
- case service.TunnelStarted:
+ case manager.TunnelStarted:
icon, err = loadSystemIcon("imageres", 101, size)
- case service.TunnelStopped:
+ case manager.TunnelStopped:
icon, err = walk.NewIconFromResourceWithSize("dot-gray.ico", walk.Size{size, size}) //TODO: replace with real icon
default:
icon, err = loadSystemIcon("shell32", 238, size) //TODO: this doesn't look that great overlayed on the app icon
@@ -83,22 +84,22 @@ func iconForState(state service.TunnelState, size int) (icon *walk.Icon, err err
return
}
-func textForState(state service.TunnelState, withEllipsis bool) (text string) {
+func textForState(state manager.TunnelState, withEllipsis bool) (text string) {
switch state {
- case service.TunnelStarted:
+ case manager.TunnelStarted:
text = "Active"
- case service.TunnelStarting:
+ case manager.TunnelStarting:
text = "Activating"
- case service.TunnelStopped:
+ case manager.TunnelStopped:
text = "Inactive"
- case service.TunnelStopping:
+ case manager.TunnelStopping:
text = "Deactivating"
- case service.TunnelUnknown:
+ case manager.TunnelUnknown:
text = "Unknown state"
}
if withEllipsis {
switch state {
- case service.TunnelStarting, service.TunnelStopping:
+ case manager.TunnelStarting, manager.TunnelStopping:
text += "..."
}
}
diff --git a/ui/listview.go b/ui/listview.go
index a8c5de8..b99f2d9 100644
--- a/ui/listview.go
+++ b/ui/listview.go
@@ -10,9 +10,9 @@ import (
"sync/atomic"
"golang.zx2c4.com/wireguard/windows/conf"
+ "golang.zx2c4.com/wireguard/windows/manager"
"github.com/lxn/walk"
- "golang.zx2c4.com/wireguard/windows/service"
)
// ListModel is a struct to store the currently known tunnels to the GUI, suitable as a model for a walk.TableView.
@@ -20,7 +20,7 @@ type ListModel struct {
walk.TableModelBase
walk.SorterBase
- tunnels []service.Tunnel
+ tunnels []manager.Tunnel
}
func (t *ListModel) RowCount() int {
@@ -55,8 +55,8 @@ type ListView struct {
model *ListModel
- tunnelChangedCB *service.TunnelChangeCallback
- tunnelsChangedCB *service.TunnelsChangeCallback
+ tunnelChangedCB *manager.TunnelChangeCallback
+ tunnelsChangedCB *manager.TunnelsChangeCallback
tunnelsUpdateSuspended int32
}
@@ -88,8 +88,8 @@ func NewListView(parent walk.Container) (*ListView, error) {
disposables.Spare()
- tunnelsView.tunnelChangedCB = service.IPCClientRegisterTunnelChange(tunnelsView.onTunnelChange)
- tunnelsView.tunnelsChangedCB = service.IPCClientRegisterTunnelsChange(tunnelsView.onTunnelsChange)
+ tunnelsView.tunnelChangedCB = manager.IPCClientRegisterTunnelChange(tunnelsView.onTunnelChange)
+ tunnelsView.tunnelsChangedCB = manager.IPCClientRegisterTunnelsChange(tunnelsView.onTunnelsChange)
return tunnelsView, nil
}
@@ -141,7 +141,7 @@ func (tv *ListView) StyleCell(style *walk.CellStyle) {
canvas.DrawImageStretched(icon, b)
}
-func (tv *ListView) CurrentTunnel() *service.Tunnel {
+func (tv *ListView) CurrentTunnel() *manager.Tunnel {
idx := tv.CurrentIndex()
if idx == -1 {
return nil
@@ -150,7 +150,7 @@ func (tv *ListView) CurrentTunnel() *service.Tunnel {
return &tv.model.tunnels[idx]
}
-func (tv *ListView) onTunnelChange(tunnel *service.Tunnel, state service.TunnelState, globalState service.TunnelState, err error) {
+func (tv *ListView) onTunnelChange(tunnel *manager.Tunnel, state manager.TunnelState, globalState manager.TunnelState, err error) {
tv.Synchronize(func() {
idx := -1
for i := range tv.model.tunnels {
@@ -183,13 +183,13 @@ func (tv *ListView) SetSuspendTunnelsUpdate(suspend bool) {
}
func (tv *ListView) Load(asyncUI bool) {
- tunnels, err := service.IPCClientTunnels()
+ tunnels, err := manager.IPCClientTunnels()
if err != nil {
return
}
doUI := func() {
- newTunnels := make(map[service.Tunnel]bool, len(tunnels))
- oldTunnels := make(map[service.Tunnel]bool, len(tv.model.tunnels))
+ newTunnels := make(map[manager.Tunnel]bool, len(tunnels))
+ oldTunnels := make(map[manager.Tunnel]bool, len(tv.model.tunnels))
for _, tunnel := range tunnels {
newTunnels[tunnel] = true
}
@@ -245,7 +245,7 @@ func (tv *ListView) selectTunnel(tunnelName string) {
}
func (tv *ListView) SelectFirstActiveTunnel() {
- tunnels := make([]service.Tunnel, len(tv.model.tunnels))
+ tunnels := make([]manager.Tunnel, len(tv.model.tunnels))
copy(tunnels, tv.model.tunnels)
go func() {
for _, tunnel := range tunnels {
@@ -253,7 +253,7 @@ func (tv *ListView) SelectFirstActiveTunnel() {
if err != nil {
continue
}
- if state == service.TunnelStarting || state == service.TunnelStarted {
+ if state == manager.TunnelStarting || state == manager.TunnelStarted {
tv.Synchronize(func() {
tv.selectTunnel(tunnel.Name)
})
diff --git a/ui/managewindow.go b/ui/managewindow.go
index b1a22ac..7c643ab 100644
--- a/ui/managewindow.go
+++ b/ui/managewindow.go
@@ -12,7 +12,7 @@ import (
"github.com/lxn/win"
"golang.org/x/sys/windows"
- "golang.zx2c4.com/wireguard/windows/service"
+ "golang.zx2c4.com/wireguard/windows/manager"
)
type ManageTunnelsWindow struct {
@@ -23,7 +23,7 @@ type ManageTunnelsWindow struct {
logPage *LogPage
updatePage *UpdatePage
- tunnelChangedCB *service.TunnelChangeCallback
+ tunnelChangedCB *manager.TunnelChangeCallback
}
const (
@@ -98,9 +98,9 @@ func NewManageTunnelsWindow() (*ManageTunnelsWindow, error) {
}
mtw.tabs.Pages().Add(mtw.logPage.TabPage)
- mtw.tunnelChangedCB = service.IPCClientRegisterTunnelChange(mtw.onTunnelChange)
- globalState, _ := service.IPCClientGlobalState()
- mtw.onTunnelChange(nil, service.TunnelUnknown, globalState, nil)
+ mtw.tunnelChangedCB = manager.IPCClientRegisterTunnelChange(mtw.onTunnelChange)
+ globalState, _ := manager.IPCClientGlobalState()
+ mtw.onTunnelChange(nil, manager.TunnelUnknown, globalState, nil)
systemMenu := win.GetSystemMenu(mtw.Handle(), false)
if systemMenu != 0 {
@@ -129,26 +129,26 @@ func (mtw *ManageTunnelsWindow) Dispose() {
mtw.FormBase.Dispose()
}
-func (mtw *ManageTunnelsWindow) updateProgressIndicator(globalState service.TunnelState) {
+func (mtw *ManageTunnelsWindow) updateProgressIndicator(globalState manager.TunnelState) {
pi := mtw.ProgressIndicator()
if pi == nil {
return
}
switch globalState {
- case service.TunnelStopping, service.TunnelStarting:
+ case manager.TunnelStopping, manager.TunnelStarting:
pi.SetState(walk.PIIndeterminate)
default:
pi.SetState(walk.PINoProgress)
}
if icon, err := iconForState(globalState, 16); err == nil {
- if globalState == service.TunnelStopped {
+ if globalState == manager.TunnelStopped {
icon = nil
}
pi.SetOverlayIcon(icon, textForState(globalState, false))
}
}
-func (mtw *ManageTunnelsWindow) onTunnelChange(tunnel *service.Tunnel, state service.TunnelState, globalState service.TunnelState, err error) {
+func (mtw *ManageTunnelsWindow) onTunnelChange(tunnel *manager.Tunnel, state manager.TunnelState, globalState manager.TunnelState, err error) {
mtw.Synchronize(func() {
mtw.updateProgressIndicator(globalState)
@@ -204,7 +204,7 @@ func (mtw *ManageTunnelsWindow) WndProc(hwnd win.HWND, msg uint32, wParam, lPara
case taskbarButtonCreatedMsg:
ret := mtw.FormBase.WndProc(hwnd, msg, wParam, lParam)
go func() {
- globalState, err := service.IPCClientGlobalState()
+ globalState, err := manager.IPCClientGlobalState()
if err == nil {
mtw.Synchronize(func() {
mtw.updateProgressIndicator(globalState)
diff --git a/ui/tray.go b/ui/tray.go
index d376e74..673439c 100644
--- a/ui/tray.go
+++ b/ui/tray.go
@@ -12,9 +12,9 @@ import (
"time"
"golang.zx2c4.com/wireguard/windows/conf"
+ "golang.zx2c4.com/wireguard/windows/manager"
"github.com/lxn/walk"
- "golang.zx2c4.com/wireguard/windows/service"
)
// Status + active CIDRs + separator
@@ -28,8 +28,8 @@ type Tray struct {
mtw *ManageTunnelsWindow
- tunnelChangedCB *service.TunnelChangeCallback
- tunnelsChangedCB *service.TunnelsChangeCallback
+ tunnelChangedCB *manager.TunnelChangeCallback
+ tunnelsChangedCB *manager.TunnelsChangeCallback
clicked func()
}
@@ -102,10 +102,10 @@ func (tray *Tray) setup() error {
tray.ContextMenu().Actions().Add(action)
}
- tray.tunnelChangedCB = service.IPCClientRegisterTunnelChange(tray.onTunnelChange)
- tray.tunnelsChangedCB = service.IPCClientRegisterTunnelsChange(tray.onTunnelsChange)
+ tray.tunnelChangedCB = manager.IPCClientRegisterTunnelChange(tray.onTunnelChange)
+ tray.tunnelsChangedCB = manager.IPCClientRegisterTunnelsChange(tray.onTunnelsChange)
tray.onTunnelsChange()
- globalState, _ := service.IPCClientGlobalState()
+ globalState, _ := manager.IPCClientGlobalState()
tray.updateGlobalState(globalState)
return nil
@@ -124,7 +124,7 @@ func (tray *Tray) Dispose() error {
}
func (tray *Tray) onTunnelsChange() {
- tunnels, err := service.IPCClientTunnels()
+ tunnels, err := manager.IPCClientTunnels()
if err != nil {
return
}
@@ -144,7 +144,7 @@ func (tray *Tray) onTunnelsChange() {
})
}
-func (tray *Tray) addTunnelAction(tunnel *service.Tunnel) {
+func (tray *Tray) addTunnelAction(tunnel *manager.Tunnel) {
tunnelAction := walk.NewAction()
tunnelAction.SetText(tunnel.Name)
tunnelAction.SetEnabled(true)
@@ -159,11 +159,11 @@ func (tray *Tray) addTunnelAction(tunnel *service.Tunnel) {
raise(tray.mtw.Handle())
tray.mtw.tunnelsPage.listView.selectTunnel(tclosure.Name)
tray.mtw.tabs.SetCurrentIndex(0)
- if oldState == service.TunnelUnknown {
+ if oldState == manager.TunnelUnknown {
walk.MsgBox(tray.mtw, "Failed to determine tunnel state", err.Error(), walk.MsgBoxIconError)
- } else if oldState == service.TunnelStopped {
+ } else if oldState == manager.TunnelStopped {
walk.MsgBox(tray.mtw, "Failed to activate tunnel", err.Error(), walk.MsgBoxIconError)
- } else if oldState == service.TunnelStarted {
+ } else if oldState == manager.TunnelStarted {
walk.MsgBox(tray.mtw, "Failed to deactivate tunnel", err.Error(), walk.MsgBoxIconError)
}
})
@@ -208,7 +208,7 @@ func (tray *Tray) removeTunnelAction(tunnelName string) {
delete(tray.tunnels, tunnelName)
}
-func (tray *Tray) onTunnelChange(tunnel *service.Tunnel, state service.TunnelState, globalState service.TunnelState, err error) {
+func (tray *Tray) onTunnelChange(tunnel *manager.Tunnel, state manager.TunnelState, globalState manager.TunnelState, err error) {
tray.mtw.Synchronize(func() {
tray.updateGlobalState(globalState)
tray.SetTunnelState(tunnel, state, err == nil)
@@ -218,7 +218,7 @@ func (tray *Tray) onTunnelChange(tunnel *service.Tunnel, state service.TunnelSta
})
}
-func (tray *Tray) updateGlobalState(globalState service.TunnelState) {
+func (tray *Tray) updateGlobalState(globalState manager.TunnelState) {
if icon, err := iconWithOverlayForState(globalState, 16); err == nil {
tray.SetIcon(icon)
}
@@ -238,23 +238,23 @@ func (tray *Tray) updateGlobalState(globalState service.TunnelState) {
statusAction.SetText(fmt.Sprintf("Status: %s", textForState(globalState, false)))
switch globalState {
- case service.TunnelStarting:
+ case manager.TunnelStarting:
setTunnelActionsEnabled(false)
- case service.TunnelStarted:
+ case manager.TunnelStarted:
activeCIDRsAction.SetVisible(true)
setTunnelActionsEnabled(true)
- case service.TunnelStopping:
+ case manager.TunnelStopping:
setTunnelActionsEnabled(false)
- case service.TunnelStopped:
+ case manager.TunnelStopped:
activeCIDRsAction.SetVisible(false)
setTunnelActionsEnabled(true)
}
}
-func (tray *Tray) SetTunnelState(tunnel *service.Tunnel, state service.TunnelState, showNotifications bool) {
+func (tray *Tray) SetTunnelState(tunnel *manager.Tunnel, state manager.TunnelState, showNotifications bool) {
tunnelAction := tray.tunnels[tunnel.Name]
if tunnelAction == nil {
return
@@ -266,7 +266,7 @@ func (tray *Tray) SetTunnelState(tunnel *service.Tunnel, state service.TunnelSta
wasChecked := tunnelAction.Checked()
switch state {
- case service.TunnelStarted:
+ case manager.TunnelStarted:
activeCIDRsAction.SetText("")
go func() {
config, err := tunnel.RuntimeConfig()
@@ -291,7 +291,7 @@ func (tray *Tray) SetTunnelState(tunnel *service.Tunnel, state service.TunnelSta
tray.ShowCustom("WireGuard Activated", fmt.Sprintf("The %s tunnel has been activated.", tunnel.Name), icon)
}
- case service.TunnelStopped:
+ case manager.TunnelStopped:
tunnelAction.SetChecked(false)
if wasChecked && showNotifications {
icon, _ := loadSystemIcon("imageres", 26, 128) //TODO: this icon isn't very good...
diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go
index d6defff..847036f 100644
--- a/ui/tunnelspage.go
+++ b/ui/tunnelspage.go
@@ -16,8 +16,9 @@ import (
"github.com/lxn/walk"
"github.com/lxn/win"
+
"golang.zx2c4.com/wireguard/windows/conf"
- "golang.zx2c4.com/wireguard/windows/service"
+ "golang.zx2c4.com/wireguard/windows/manager"
)
type TunnelsPage struct {
@@ -314,7 +315,7 @@ func (tp *TunnelsPage) importFiles(paths []string) {
return conf.TunnelNameIsLess(unparsedConfigs[j].Name, unparsedConfigs[i].Name)
})
- existingTunnelList, err := service.IPCClientTunnels()
+ existingTunnelList, err := manager.IPCClientTunnels()
if err != nil {
syncedMsgBox("Error", fmt.Sprintf("Could not enumerate existing tunnels: %v", lastErr), walk.MsgBoxIconWarning)
return
@@ -336,7 +337,7 @@ func (tp *TunnelsPage) importFiles(paths []string) {
lastErr = err
continue
}
- _, err = service.IPCClientNewTunnel(config)
+ _, err = manager.IPCClientNewTunnel(config)
if err != nil {
lastErr = err
continue
@@ -384,7 +385,7 @@ func (tp *TunnelsPage) exportTunnels(filePath string) {
}
func (tp *TunnelsPage) addTunnel(config *conf.Config) {
- _, err := service.IPCClientNewTunnel(config)
+ _, err := manager.IPCClientNewTunnel(config)
if err != nil {
walk.MsgBox(tp.Form(), "Unable to create tunnel", err.Error(), walk.MsgBoxIconError)
}
@@ -395,18 +396,18 @@ func (tp *TunnelsPage) addTunnel(config *conf.Config) {
func (tp *TunnelsPage) onTunnelsViewItemActivated() {
go func() {
- globalState, err := service.IPCClientGlobalState()
- if err != nil || (globalState != service.TunnelStarted && globalState != service.TunnelStopped) {
+ globalState, err := manager.IPCClientGlobalState()
+ if err != nil || (globalState != manager.TunnelStarted && globalState != manager.TunnelStopped) {
return
}
oldState, err := tp.listView.CurrentTunnel().Toggle()
if err != nil {
tp.Synchronize(func() {
- if oldState == service.TunnelUnknown {
+ if oldState == manager.TunnelUnknown {
walk.MsgBox(tp.Form(), "Failed to determine tunnel state", err.Error(), walk.MsgBoxIconError)
- } else if oldState == service.TunnelStopped {
+ } else if oldState == manager.TunnelStopped {
walk.MsgBox(tp.Form(), "Failed to activate tunnel", err.Error(), walk.MsgBoxIconError)
- } else if oldState == service.TunnelStarted {
+ } else if oldState == manager.TunnelStarted {
walk.MsgBox(tp.Form(), "Failed to deactivate tunnel", err.Error(), walk.MsgBoxIconError)
}
})
@@ -426,8 +427,8 @@ func (tp *TunnelsPage) onEditTunnel() {
priorState, err := tunnel.State()
tunnel.Delete()
tunnel.WaitForStop()
- tunnel, err2 := service.IPCClientNewTunnel(config)
- if err == nil && err2 == nil && (priorState == service.TunnelStarting || priorState == service.TunnelStarted) {
+ tunnel, err2 := manager.IPCClientNewTunnel(config)
+ if err == nil && err2 == nil && (priorState == manager.TunnelStarting || priorState == manager.TunnelStarted) {
tunnel.Start()
}
}()
@@ -490,7 +491,7 @@ func (tp *TunnelsPage) onDelete() {
tp.listView.selectTunnel(selectTunnelAfter)
}
- tunnelsToDelete := make([]service.Tunnel, len(indices))
+ tunnelsToDelete := make([]manager.Tunnel, len(indices))
for i, j := range indices {
tunnelsToDelete[i] = tp.listView.model.tunnels[j]
diff --git a/ui/ui.go b/ui/ui.go
index 6805754..0f91b61 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -13,7 +13,8 @@ import (
"github.com/lxn/walk"
"github.com/lxn/win"
- "golang.zx2c4.com/wireguard/windows/service"
+
+ "golang.zx2c4.com/wireguard/windows/manager"
"golang.zx2c4.com/wireguard/windows/version"
)
@@ -55,29 +56,29 @@ func RunUI() {
}
}
- service.IPCClientRegisterManagerStopping(func() {
+ manager.IPCClientRegisterManagerStopping(func() {
mtw.Synchronize(func() {
walk.App().Exit(0)
})
})
- onUpdateNotification := func(updateState service.UpdateState) {
- if updateState == service.UpdateStateUnknown {
+ onUpdateNotification := func(updateState manager.UpdateState) {
+ if updateState == manager.UpdateStateUnknown {
return
}
mtw.Synchronize(func() {
switch updateState {
- case service.UpdateStateFoundUpdate:
+ case manager.UpdateStateFoundUpdate:
mtw.UpdateFound()
tray.UpdateFound()
- case service.UpdateStateUpdatesDisabledUnofficialBuild:
+ case manager.UpdateStateUpdatesDisabledUnofficialBuild:
mtw.SetTitle(mtw.Title() + " (unsigned build, no updates)")
}
})
}
- service.IPCClientRegisterUpdateFound(onUpdateNotification)
+ manager.IPCClientRegisterUpdateFound(onUpdateNotification)
go func() {
- updateState, err := service.IPCClientUpdateState()
+ updateState, err := manager.IPCClientUpdateState()
if err == nil {
onUpdateNotification(updateState)
}
@@ -92,7 +93,7 @@ func RunUI() {
mtw.Dispose()
if shouldQuitManagerWhenExiting {
- _, err := service.IPCClientQuit(true)
+ _, err := manager.IPCClientQuit(true)
if err != nil {
walk.MsgBox(nil, "Error Exiting WireGuard", fmt.Sprintf("Unable to exit service due to: %s. You may want to stop WireGuard from the service manager.", err), walk.MsgBoxIconError)
}
diff --git a/ui/updatepage.go b/ui/updatepage.go
index 1cab0d2..9565779 100644
--- a/ui/updatepage.go
+++ b/ui/updatepage.go
@@ -9,7 +9,8 @@ import (
"fmt"
"github.com/lxn/walk"
- "golang.zx2c4.com/wireguard/windows/service"
+
+ "golang.zx2c4.com/wireguard/windows/manager"
"golang.zx2c4.com/wireguard/windows/updater"
)
@@ -77,14 +78,14 @@ func NewUpdatePage() (*UpdatePage, error) {
button.Clicked().Attach(func() {
switchToUpdatingState()
- err := service.IPCClientUpdate()
+ err := manager.IPCClientUpdate()
if err != nil {
switchToReadyState()
status.SetText(fmt.Sprintf("Error: %v. Please try again.", err))
}
})
- service.IPCClientRegisterUpdateProgress(func(dp updater.DownloadProgress) {
+ manager.IPCClientRegisterUpdateProgress(func(dp updater.DownloadProgress) {
up.Synchronize(func() {
switchToUpdatingState()
if dp.Error != nil {