From cda7a2abccae4a4c833c0a81fe494e952f70cafe Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 20 May 2018 23:46:02 +0100 Subject: [PATCH] Builds for yggdrasilctl plus usage info and fixes --- .circleci/config.yml | 30 +++++++++++++++--------------- contrib/deb/generate.sh | 1 + yggdrasilctl.go | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5773c6b1..93aa264c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,42 +21,42 @@ jobs: - run: name: Build for Linux (including Debian packages) command: | - PKGARCH=amd64 sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-amd64; - PKGARCH=i386 sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-i386; - PKGARCH=mipsel sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-mipsel; - PKGARCH=mips sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-mips; - PKGARCH=armhf sh contrib/deb/generate.sh && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-linux-armhf; + PKGARCH=amd64 sh contrib/deb/generate.sh && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-linux-amd64; + PKGARCH=i386 sh contrib/deb/generate.sh && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-linux-i386; + PKGARCH=mipsel sh contrib/deb/generate.sh && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-linux-mipsel; + PKGARCH=mips sh contrib/deb/generate.sh && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-linux-mips; + PKGARCH=armhf sh contrib/deb/generate.sh && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-linux-armhf; mv *.deb /tmp/upload/ - run: name: Build for macOS command: | - GOOS=darwin GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-darwin-amd64; - GOOS=darwin GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-darwin-i386; + GOOS=darwin GOARCH=amd64 ./build && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-darwin-amd64; + GOOS=darwin GOARCH=386 ./build && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-darwin-i386; - run: name: Build for OpenBSD command: | - GOOS=openbsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-openbsd-amd64; - GOOS=openbsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-openbsd-i386; + GOOS=openbsd GOARCH=amd64 ./build && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-openbsd-amd64; + GOOS=openbsd GOARCH=386 ./build && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-openbsd-i386; - run: name: Build for FreeBSD command: | - GOOS=freebsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-amd64; - GOOS=freebsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-i386; + GOOS=freebsd GOARCH=amd64 ./build && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-freebsd-amd64; + GOOS=freebsd GOARCH=386 ./build && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-freebsd-i386; - run: name: Build for NetBSD command: | - GOOS=netbsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-netbsd-amd64; - GOOS=netbsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-netbsd-i386; + GOOS=netbsd GOARCH=amd64 ./build && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-netbsd-amd64; + GOOS=netbsd GOARCH=386 ./build && mv yggdrasil yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-netbsd-i386; - run: name: Build for Windows command: | - GOOS=windows GOARCH=amd64 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-amd64.exe; - GOOS=windows GOARCH=386 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-i386.exe; + GOOS=windows GOARCH=amd64 ./build && mv yggdrasil.exe yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-windows-amd64.exe; + GOOS=windows GOARCH=386 ./build && mv yggdrasil.exe yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-windows-i386.exe; - run: name: Build for EdgeRouter diff --git a/contrib/deb/generate.sh b/contrib/deb/generate.sh index c46aa247..860d4f1e 100644 --- a/contrib/deb/generate.sh +++ b/contrib/deb/generate.sh @@ -69,6 +69,7 @@ systemctl stop yggdrasil EOF cp yggdrasil /tmp/$PKGNAME/usr/bin/ +cp yggdrasilctl /tmp/$PKGNAME/usr/bin/ cp contrib/systemd/yggdrasil.service /tmp/$PKGNAME/etc/systemd/system/ cp contrib/systemd/yggdrasil-resume.service /tmp/$PKGNAME/etc/systemd/system/ diff --git a/yggdrasilctl.go b/yggdrasilctl.go index 9914cd8b..9d3f3281 100644 --- a/yggdrasilctl.go +++ b/yggdrasilctl.go @@ -15,6 +15,14 @@ func main() { flag.Parse() args := flag.Args() + if len(args) == 0 { + fmt.Println("usage:", os.Args[0], "[-endpoint=localhost:9001] command [key=value] [...]") + fmt.Println("example:", os.Args[0], "getPeers") + fmt.Println("example:", os.Args[0], "setTunTap name=auto mtu=1500 tap_mode=false") + fmt.Println("example:", os.Args[0], "-endpoint=localhost:9001 getDHT") + return + } + conn, err := net.Dial("tcp", *server) if err != nil { panic(err) @@ -50,6 +58,14 @@ func main() { panic(err) } if err := decoder.Decode(&recv); err == nil { + if _, ok := recv["request"]; !ok { + fmt.Println("Missing request") + return + } + if _, ok := recv["response"]; !ok { + fmt.Println("Missing response") + return + } req := recv["request"].(map[string]interface{}) res := recv["response"].(map[string]interface{}) switch req["request"] {