5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-26 00:11:36 +00:00

Merge pull request #17 from neilalexander/windowssvc

Add support for running Yggdrasil as a Windows service
This commit is contained in:
Arceliar 2018-02-16 11:56:05 -06:00 committed by GitHub
commit 032ad3a162
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 4 deletions

View File

@ -9,6 +9,7 @@ os:
install: install:
- export GOPATH="$TRAVIS_BUILD_DIR:$GOPATH" - export GOPATH="$TRAVIS_BUILD_DIR:$GOPATH"
- go get -d -v
- go get -d -v yggdrasil - go get -d -v yggdrasil
- for file in *.go ; do go build -v $file; done - for file in *.go ; do go build -v $file; done

View File

@ -52,6 +52,16 @@ In the interest of testing the TCP machinery, it's set to create TCP connections
#### Linux #### Linux
- Should work out of the box on most Linux distributions with `iproute2` installed. - Should work out of the box on most Linux distributions with `iproute2` installed.
- systemd service scripts are included in the `contrib/systemd/` folder so that it runs automatically in the background (using `/etc/yggdrasil.conf` for configuration), copy the service files into `/etc/systemd/system`, copy `yggdrasil` into your `$PATH`, i.e. `/usr/bin`, and then enable the service:
```
systemctl enable yggdrasil
systemctl start yggdrasil
```
- Once installed as a systemd service, you can read the `yggdrasil` output:
```
systemctl status yggdrasil
journalctl -u yggdrasil
```
#### macOS #### macOS
@ -63,6 +73,17 @@ In the interest of testing the TCP machinery, it's set to create TCP connections
- Tested and working on Windows 7 and Windows 10, and should work on any recent versions of Windows, but it depends on the [OpenVPN TAP driver](https://openvpn.net/index.php/open-source/downloads.html) being installed first. - Tested and working on Windows 7 and Windows 10, and should work on any recent versions of Windows, but it depends on the [OpenVPN TAP driver](https://openvpn.net/index.php/open-source/downloads.html) being installed first.
- Has been proven to work with both the [NDIS 5](https://swupdate.openvpn.org/community/releases/tap-windows-9.9.2_3.exe) (`tap-windows-9.9.2_3`) driver and the [NDIS 6](https://swupdate.openvpn.org/community/releases/tap-windows-9.21.2.exe) (`tap-windows-9.21.2`) driver, however there are substantial performance issues with the NDIS 6 driver therefore it is recommended to use the NDIS 5 driver instead. - Has been proven to work with both the [NDIS 5](https://swupdate.openvpn.org/community/releases/tap-windows-9.9.2_3.exe) (`tap-windows-9.9.2_3`) driver and the [NDIS 6](https://swupdate.openvpn.org/community/releases/tap-windows-9.21.2.exe) (`tap-windows-9.21.2`) driver, however there are substantial performance issues with the NDIS 6 driver therefore it is recommended to use the NDIS 5 driver instead.
- Be aware that connectivity issues can occur on Windows if multiple IPv6 addresses from the `fd00::/8` prefix are assigned to the TAP interface. If this happens, then you may need to manually remove the old/unused addresses from the interface (though the code has a workaround in place to do this automatically in some cases). - Be aware that connectivity issues can occur on Windows if multiple IPv6 addresses from the `fd00::/8` prefix are assigned to the TAP interface. If this happens, then you may need to manually remove the old/unused addresses from the interface (though the code has a workaround in place to do this automatically in some cases).
- Yggdrasil can be installed as a Windows service so that it runs automatically in the background. From an Administrator Command Prompt:
```
sc create yggdrasil binpath= "\"C:\path\to\yggdrasil.exe\" -useconffile \"C:\path\to\yggdrasil.conf\""
sc config yggdrasil displayname= "Yggdrasil Service"
sc config yggdrasil start= "auto"
sc start yggdrasil
```
- Alternatively, if you want the service to autoconfigure instead of using an `yggdrasil.conf`, replace the `sc create` line from above with:
```
sc create yggdrasil binpath= "\"C:\path\to\yggdrasil.exe\" -autoconf"
```
#### EdgeRouter #### EdgeRouter
@ -114,4 +135,3 @@ Both of these optimizations are not present in the current implementation, as th
This code is released under the terms of the LGPLv3, but with an added exception that was shamelessly taken from [godeb](https://github.com/niemeyer/godeb). This code is released under the terms of the LGPLv3, but with an added exception that was shamelessly taken from [godeb](https://github.com/niemeyer/godeb).
Under certain circumstances, this exception permits distribution of binaries that are (statically or dynamically) linked with this code, without requiring the distribution of Minimal Corresponding Source or Minimal Application Code. Under certain circumstances, this exception permits distribution of binaries that are (statically or dynamically) linked with this code, without requiring the distribution of Minimal Corresponding Source or Minimal Application Code.
For more details, see: [LICENSE](LICENSE). For more details, see: [LICENSE](LICENSE).

1
build
View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
export GOPATH=$PWD export GOPATH=$PWD
echo "Downloading..." echo "Downloading..."
go get -d -v
go get -d -v yggdrasil go get -d -v yggdrasil
for file in *.go ; do for file in *.go ; do
echo "Building: $file" echo "Building: $file"

View File

@ -21,6 +21,8 @@ import "golang.org/x/net/ipv6"
import . "yggdrasil" import . "yggdrasil"
import _ "github.com/kardianos/minwinsvc"
/** /**
* This is a very crude wrapper around src/yggdrasil * This is a very crude wrapper around src/yggdrasil
* It can generate a new config (--genconf) * It can generate a new config (--genconf)
@ -228,6 +230,7 @@ func (n *node) announce() {
var pprof = flag.Bool("pprof", false, "Run pprof, see http://localhost:6060/debug/pprof/") var pprof = flag.Bool("pprof", false, "Run pprof, see http://localhost:6060/debug/pprof/")
var genconf = flag.Bool("genconf", false, "print a new config to stdout") var genconf = flag.Bool("genconf", false, "print a new config to stdout")
var useconf = flag.Bool("useconf", false, "read config from stdin") var useconf = flag.Bool("useconf", false, "read config from stdin")
var useconffile = flag.String("useconffile", "", "read config from specified file path")
var autoconf = flag.Bool("autoconf", false, "automatic mode (dynamic IP, peer with IPv6 neighbors)") var autoconf = flag.Bool("autoconf", false, "automatic mode (dynamic IP, peer with IPv6 neighbors)")
func main() { func main() {
@ -236,8 +239,14 @@ func main() {
switch { switch {
case *autoconf: case *autoconf:
cfg = generateConfig() cfg = generateConfig()
case *useconf: case *useconffile != "" || *useconf:
config, err := ioutil.ReadAll(os.Stdin) var config []byte
var err error
if *useconffile != "" {
config, err = ioutil.ReadFile(*useconffile)
} else {
config, err = ioutil.ReadAll(os.Stdin)
}
if err != nil { if err != nil {
panic(err) panic(err)
} }