From 300f471bab2eb756a5e8111fb2485fb1f933c2ad Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 16 Dec 2018 18:32:50 -0600 Subject: [PATCH 1/6] don't SetKeepAlive[Period] on tcp connections, since the behavior is platform specific --- src/yggdrasil/tcp.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index 873dd63c..6d923440 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -59,8 +59,6 @@ func (iface *tcpInterface) setExtraOptions(c net.Conn) { switch sock := c.(type) { case *net.TCPConn: sock.SetNoDelay(true) - sock.SetKeepAlive(true) - sock.SetKeepAlivePeriod(iface.tcp_timeout) // TODO something for socks5 default: } From 83d734e10953e08a1c0d3e8d772c785fefd12aec Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 17 Dec 2018 10:17:16 +0000 Subject: [PATCH 2/6] Make yggdrasilctl less crashy --- cmd/yggdrasilctl/main.go | 41 ++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/cmd/yggdrasilctl/main.go b/cmd/yggdrasilctl/main.go index 8135815f..4dcbbef7 100644 --- a/cmd/yggdrasilctl/main.go +++ b/cmd/yggdrasilctl/main.go @@ -30,6 +30,7 @@ func main() { if r := recover(); r != nil { logger.Println("Fatal error:", r) fmt.Print(logbuffer) + panic(r) os.Exit(1) } }() @@ -37,13 +38,15 @@ func main() { endpoint := defaults.GetDefaults().DefaultAdminListen flag.Usage = func() { - fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [options] command [key=value] [key=value] ...\n", os.Args[0]) + fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [options] command [key=value] [key=value] ...\n\n", os.Args[0]) fmt.Println("Options:") flag.PrintDefaults() - fmt.Println("Commands:\n - Use \"list\" for a list of available commands") + fmt.Println("\nPlease note that options must always specified BEFORE the command\non the command line or they will be ignored.\n") + fmt.Println("Commands:\n - Use \"list\" for a list of available commands\n") fmt.Println("Examples:") fmt.Println(" - ", os.Args[0], "list") fmt.Println(" - ", os.Args[0], "getPeers") + fmt.Println(" - ", os.Args[0], "-v getSelf") fmt.Println(" - ", os.Args[0], "setTunTap name=auto mtu=1500 tap_mode=false") fmt.Println(" - ", os.Args[0], "-endpoint=tcp://localhost:9001 getDHT") fmt.Println(" - ", os.Args[0], "-endpoint=unix:///var/run/ygg.sock getDHT") @@ -122,24 +125,34 @@ func main() { for c, a := range args { if c == 0 { + if strings.HasPrefix(a, "-") { + logger.Printf("Ignoring flag %s as it should be specified before other parameters\n", a) + continue + } logger.Printf("Sending request: %v\n", a) send["request"] = a continue } tokens := strings.Split(a, "=") - if i, err := strconv.Atoi(tokens[1]); err == nil { - logger.Printf("Sending parameter %s: %d\n", tokens[0], i) - send[tokens[0]] = i - } else { - switch strings.ToLower(tokens[1]) { - case "true": - send[tokens[0]] = true - case "false": - send[tokens[0]] = false - default: - send[tokens[0]] = tokens[1] + if len(tokens) == 1 { + send[tokens[0]] = true + } else if len(tokens) > 2 { + send[tokens[0]] = strings.Join(tokens[1:], "=") + } else if len(tokens) == 2 { + if i, err := strconv.Atoi(tokens[1]); err == nil { + logger.Printf("Sending parameter %s: %d\n", tokens[0], i) + send[tokens[0]] = i + } else { + switch strings.ToLower(tokens[1]) { + case "true": + send[tokens[0]] = true + case "false": + send[tokens[0]] = false + default: + send[tokens[0]] = tokens[1] + } + logger.Printf("Sending parameter %s: %v\n", tokens[0], send[tokens[0]]) } - logger.Printf("Sending parameter %s: %v\n", tokens[0], send[tokens[0]]) } } From 422424af64c539a99a7a7f0d574f1af3eaeb7fe8 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 17 Dec 2018 10:19:20 +0000 Subject: [PATCH 3/6] Don't panic --- cmd/yggdrasilctl/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/yggdrasilctl/main.go b/cmd/yggdrasilctl/main.go index 4dcbbef7..189a53a7 100644 --- a/cmd/yggdrasilctl/main.go +++ b/cmd/yggdrasilctl/main.go @@ -30,7 +30,6 @@ func main() { if r := recover(); r != nil { logger.Println("Fatal error:", r) fmt.Print(logbuffer) - panic(r) os.Exit(1) } }() @@ -201,7 +200,7 @@ func main() { if !keysOrdered { for k := range slv.(map[string]interface{}) { if !*verbose { - if k == "box_pub_key" || k == "box_sig_key" { + if k == "box_pub_key" || k == "box_sig_key" || k == "nodeinfo" { continue } } From 0ee74a4efd364c57af0756812d31c4f792924293 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 17 Dec 2018 10:34:26 +0000 Subject: [PATCH 4/6] Update semver --- contrib/semver/version.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/semver/version.sh b/contrib/semver/version.sh index 331046f3..eab5ab86 100644 --- a/contrib/semver/version.sh +++ b/contrib/semver/version.sh @@ -3,7 +3,7 @@ # Merge commits from this branch are counted DEVELOPBRANCH="yggdrasil-network/develop" -# Get the last tag +# Get the last tag that denotes moving to a major version number TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.0" 2>/dev/null) # Get last merge to master @@ -33,9 +33,6 @@ if [ $? != 0 ]; then exit 1 fi -# Get the number of merges on the current branch since the last tag -BUILD=$(git rev-list $TAG..HEAD --count --merges) - # Split out into major, minor and patch numbers MAJOR=$(echo $TAG | cut -c 2- | cut -d "." -f 1) MINOR=$(echo $TAG | cut -c 2- | cut -d "." -f 2) @@ -56,6 +53,10 @@ fi # Add the build tag on non-master branches if [ $BRANCH != "master" ]; then + # Get the number of merges on the current branch since the last tag + BUILDTAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" 2>/dev/null) + BUILD=$(git rev-list $BUILDTAG..HEAD --count --merges) + if [ $BUILD != 0 ]; then printf -- "-%04d" "$BUILD" fi From b20c3538b74d5fc566a37852ec783212bf91f71f Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 17 Dec 2018 10:50:57 +0000 Subject: [PATCH 5/6] Point hjson to master repo following comments merge --- cmd/yggdrasil/main.go | 2 +- cmd/yggdrasilctl/main.go | 2 +- contrib/config/yggdrasilconf.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/yggdrasil/main.go b/cmd/yggdrasil/main.go index d93f5d2a..5a9db26c 100644 --- a/cmd/yggdrasil/main.go +++ b/cmd/yggdrasil/main.go @@ -18,9 +18,9 @@ import ( "golang.org/x/text/encoding/unicode" + "github.com/hjson/hjson-go" "github.com/kardianos/minwinsvc" "github.com/mitchellh/mapstructure" - "github.com/neilalexander/hjson-go" "github.com/yggdrasil-network/yggdrasil-go/src/config" "github.com/yggdrasil-network/yggdrasil-go/src/defaults" diff --git a/cmd/yggdrasilctl/main.go b/cmd/yggdrasilctl/main.go index 189a53a7..bbe3cd2e 100644 --- a/cmd/yggdrasilctl/main.go +++ b/cmd/yggdrasilctl/main.go @@ -17,7 +17,7 @@ import ( "golang.org/x/text/encoding/unicode" - "github.com/neilalexander/hjson-go" + "github.com/hjson/hjson-go" "github.com/yggdrasil-network/yggdrasil-go/src/defaults" ) diff --git a/contrib/config/yggdrasilconf.go b/contrib/config/yggdrasilconf.go index 78c0e6d7..ad55e163 100644 --- a/contrib/config/yggdrasilconf.go +++ b/contrib/config/yggdrasilconf.go @@ -14,7 +14,7 @@ import ( "io/ioutil" "strconv" - "github.com/neilalexander/hjson-go" + "github.com/hjson/hjson-go" "golang.org/x/text/encoding/unicode" "github.com/yggdrasil-network/yggdrasil-go/src/config" diff --git a/go.mod b/go.mod index db6d359a..53a5a2b9 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,9 @@ module github.com/yggdrasil-network/yggdrasil-go require ( github.com/docker/libcontainer v2.2.1+incompatible + github.com/hjson/hjson-go v0.0.0-20181010104306-a25ecf6bd222 github.com/kardianos/minwinsvc v0.0.0-20151122163309-cad6b2b879b0 github.com/mitchellh/mapstructure v1.1.2 - github.com/neilalexander/hjson-go v0.0.0-20180509131856-23267a251165 github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091 github.com/yggdrasil-network/water v0.0.0-20180615095340-f732c88f34ae golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 diff --git a/go.sum b/go.sum index 7d064112..1695daff 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ github.com/docker/libcontainer v2.2.1+incompatible h1:++SbbkCw+X8vAd4j2gOCzZ2Nn7s2xFALTf7LZKmM1/0= github.com/docker/libcontainer v2.2.1+incompatible/go.mod h1:osvj61pYsqhNCMLGX31xr7klUBhHb/ZBuXS0o1Fvwbw= +github.com/hjson/hjson-go v0.0.0-20181010104306-a25ecf6bd222 h1:xmvkbxXDeN1ffWq8kvrhyqVYAO2aXuRBsbpxVTR+JyU= +github.com/hjson/hjson-go v0.0.0-20181010104306-a25ecf6bd222/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio= github.com/kardianos/minwinsvc v0.0.0-20151122163309-cad6b2b879b0 h1:YnZmFjg0Nvk8851WTVWlqMC1ecJH07Ctz+Ezxx4u54g= github.com/kardianos/minwinsvc v0.0.0-20151122163309-cad6b2b879b0/go.mod h1:rUi0/YffDo1oXBOGn1KRq7Fr07LX48XEBecQnmwjsAo= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/neilalexander/hjson-go v0.0.0-20180509131856-23267a251165 h1:Oo7Yfu5lEQLGvvh2p9Z8FRHJIsl7fdOCK9xXFNBkqmQ= -github.com/neilalexander/hjson-go v0.0.0-20180509131856-23267a251165/go.mod h1:l+Zao6IpQ+6d/y7LnYnOfbfOeU/9xRiTi4HLVpnkcTg= github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091 h1:1zN6ImoqhSJhN8hGXFaJlSC8msLmIbX8bFqOfWLKw0w= github.com/songgao/packets v0.0.0-20160404182456-549a10cd4091/go.mod h1:N20Z5Y8oye9a7HmytmZ+tr8Q2vlP0tAHP13kTHzwvQY= github.com/yggdrasil-network/water v0.0.0-20180615095340-f732c88f34ae h1:MYCANF1kehCG6x6G+/9txLfq6n3lS5Vp0Mxn1hdiBAc= From ebfc236153db88a244b3ca34892283e075f623cc Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 17 Dec 2018 11:13:11 +0000 Subject: [PATCH 6/6] Update changelog for v0.3.1 --- CHANGELOG.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2db4dde1..7c8994fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,27 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - in case of vulnerabilities. --> +## [0.3.1] - 2018-12-17 +### Added +- Build name and version is now imprinted onto the binaries if available/specified during build +- Ability to disable admin socket with `AdminListen: none` +- `AF_UNIX` domain sockets for the admin socket +- Cache size restriction for crypto-key routes +- `NodeInfo` support for specifying node information, e.g. node name or contact, which can be used in network crawls or surveys +- `getNodeInfo` request added to admin socket +- Adds flags `-c`, `-l` and `-t` to `build` script for specifying `GCFLAGS`, `LDFLAGS` or whether to keep symbol/DWARF tables + +### Changed +- Default `AdminListen` in newly generated config is now `unix:///var/run/yggdrasil.sock` +- Formatting of `getRoutes` in the admin socket has been improved +- Debian package now adds `yggdrasil` group to assist with `AF_UNIX` admin socket permissions +- Crypto, address and other utility code refactored into separate Go packages + +### Fixed +- Switch peer convergence is now much faster again (previously it was taking up to a minute once the peering was established) +- `yggdrasilctl` is now less prone to crashing when parameters are specified incorrectly +- Panic fixed when `Peers` or `InterfacePeers` was commented out + ## [0.3.0] - 2018-12-12 ### Added - Crypto-key routing support for tunnelling both IPv4 and IPv6 over Yggdrasil