diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-09-21 21:47:06 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-09-23 15:29:18 +0200 |
commit | d37a6b53214e0d55070ea7b5f4aad9df1d53e2ab (patch) | |
tree | 19532ff36d00dfa8d7af0518507aa2923c85ede3 /embeddable-dll-service/main.go | |
parent | manager: switch to vanilla gob from rpc to remove reflection bloat (diff) | |
download | wireguard-windows-d37a6b53214e0d55070ea7b5f4aad9df1d53e2ab.tar.xz wireguard-windows-d37a6b53214e0d55070ea7b5f4aad9df1d53e2ab.zip |
embeddable-dll-service: add basic outline for embedding wireguard
This allows people to embed WireGuard inside other apps as a service.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | embeddable-dll-service/main.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/embeddable-dll-service/main.go b/embeddable-dll-service/main.go new file mode 100644 index 00000000..a8ce7c10 --- /dev/null +++ b/embeddable-dll-service/main.go @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: MIT + * + * Copyright (C) 2019 WireGuard LLC. All Rights Reserved. + */ + +package main + +import ( + "C" + "golang.zx2c4.com/wireguard/windows/conf" + "golang.zx2c4.com/wireguard/windows/tunnel" + "log" + "path/filepath" +) + +//export WireGuardTunnelService +func WireGuardTunnelService(confFile string) bool { + conf.PresetRootDirectory(filepath.Dir(confFile)) + tunnel.UseFixedGUIDInsteadOfDeterministic = true + err := tunnel.Run(confFile) + if err != nil { + log.Printf("Service run error: %v", err) + } + return err == nil +} + +func main() {} |