diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-08-24 10:14:16 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-08-24 10:59:52 +0200 |
commit | 4a296b50f7f8925fa08def99a6399a887312aee4 (patch) | |
tree | cfee428900f6fb08015620c12c3f18b3583458ac /tunnel | |
parent | version: bump (diff) | |
download | wireguard-windows-4a296b50f7f8925fa08def99a6399a887312aee4.tar.xz wireguard-windows-4a296b50f7f8925fa08def99a6399a887312aee4.zip |
tunnel: move Run into own module to reduce file size
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | tunnel/service.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tunnel/service.go b/tunnel/service.go index 2dbfff9c..dbaa3133 100644 --- a/tunnel/service.go +++ b/tunnel/service.go @@ -30,11 +30,11 @@ import ( "golang.zx2c4.com/wireguard/windows/version" ) -type Service struct { +type tunnelService struct { Path string } -func (service *Service) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (svcSpecificEC bool, exitCode uint32) { +func (service *tunnelService) 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 @@ -241,3 +241,15 @@ func (service *Service) Execute(args []string, r <-chan svc.ChangeRequest, chang } } } + +func Run(confPath string) error { + name, err := conf.NameFromPath(confPath) + if err != nil { + return err + } + serviceName, err := services.ServiceNameOfTunnel(name) + if err != nil { + return err + } + return svc.Run(serviceName, &tunnelService{confPath}) +} |