mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-12-23 04:05:39 +00:00
commit
262c93504f
@ -7,8 +7,6 @@ jobs:
|
||||
docker:
|
||||
- image: circleci/golang:1.11
|
||||
|
||||
working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
|
@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- Admin socket clean-up (making some names consistent)
|
||||
- Latency-based parent selection for the switch instead of uptime-based
|
||||
- Real peering endpoints now shown in the admin socket `getPeers` call
|
||||
- Reuse the multicast port on supported platforms so that multiple Yggdrasil processes can run
|
||||
|
||||
### Fixed
|
||||
- Memory leaks in the DHT fixed
|
||||
|
@ -15,7 +15,7 @@ You're encouraged to play with it, but it is strongly advised not to use it for
|
||||
|
||||
## Building
|
||||
|
||||
1. Install Go (tested on 1.9+, [godeb](https://github.com/niemeyer/godeb) is recommended for debian-based linux distributions).
|
||||
1. Install Go (requires 1.11 or later, [godeb](https://github.com/niemeyer/godeb) is recommended for Debian-based Linux distributions).
|
||||
2. Clone this repository.
|
||||
2. `./build`
|
||||
|
||||
|
16
build
16
build
@ -7,20 +7,16 @@ do
|
||||
d) DEBUG=true;;
|
||||
esac
|
||||
done
|
||||
export GOPATH=$PWD
|
||||
echo "Downloading..."
|
||||
go get -d -v
|
||||
go get -d -v yggdrasil
|
||||
for file in *.go ; do
|
||||
echo "Building: $file"
|
||||
#go build $@ $file
|
||||
IMPRINT="-X yggdrasil.buildName=$(sh contrib/semver/name.sh) -X yggdrasil.buildVersion=$(sh contrib/semver/version.sh)"
|
||||
for CMD in `ls cmd/` ; do
|
||||
echo "Building: $CMD"
|
||||
IMPRINT="-X github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil.buildName=$(sh contrib/semver/name.sh) -X github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil.buildVersion=$(sh contrib/semver/version.sh)"
|
||||
if [ $DEBUG ]; then
|
||||
go build -ldflags="$IMPRINT" -tags debug -v $file
|
||||
go build -ldflags="$IMPRINT" -tags debug -v ./cmd/$CMD
|
||||
else
|
||||
go build -ldflags="$IMPRINT -s -w" -v $file
|
||||
go build -ldflags="$IMPRINT -s -w" -v ./cmd/$CMD
|
||||
fi
|
||||
if [ $UPX ]; then
|
||||
upx --brute ${file%.go}
|
||||
upx --brute $CMD
|
||||
fi
|
||||
done
|
||||
|
@ -21,9 +21,9 @@ import (
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/neilalexander/hjson-go"
|
||||
|
||||
"yggdrasil"
|
||||
"yggdrasil/config"
|
||||
"yggdrasil/defaults"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/config"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/defaults"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil"
|
||||
)
|
||||
|
||||
type nodeConfig = config.NodeConfig
|
@ -1,17 +1,19 @@
|
||||
package main
|
||||
|
||||
import "errors"
|
||||
import "flag"
|
||||
import "fmt"
|
||||
import "strings"
|
||||
import "net"
|
||||
import "net/url"
|
||||
import "sort"
|
||||
import "encoding/json"
|
||||
import "strconv"
|
||||
import "os"
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
import "yggdrasil/defaults"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/defaults"
|
||||
)
|
||||
|
||||
type admin_info map[string]interface{}
|
||||
|
BIN
contrib/.DS_Store
vendored
BIN
contrib/.DS_Store
vendored
Binary file not shown.
@ -17,7 +17,7 @@ import (
|
||||
"github.com/neilalexander/hjson-go"
|
||||
"golang.org/x/text/encoding/unicode"
|
||||
|
||||
"yggdrasil/config"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/config"
|
||||
)
|
||||
|
||||
type nodeConfig = config.NodeConfig
|
||||
|
@ -7,7 +7,7 @@
|
||||
if [ `pwd` != `git rev-parse --show-toplevel` ]
|
||||
then
|
||||
echo "You should run this script from the top-level directory of the git repo"
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PKGBRANCH=$(basename `git name-rev --name-only HEAD`)
|
||||
@ -29,7 +29,7 @@ elif [ $PKGARCH = "armhf" ]; then GOARCH=arm GOOS=linux GOARM=7 ./build
|
||||
elif [ $PKGARCH = "arm64" ]; then GOARCH=arm64 GOOS=linux ./build
|
||||
else
|
||||
echo "Specify PKGARCH=amd64,i386,mips,mipsel,armhf,arm64"
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Building $PKGFILE"
|
||||
|
@ -6,7 +6,7 @@ BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null)
|
||||
# Complain if the git history is not available
|
||||
if [ $? != 0 ]; then
|
||||
printf "unknown"
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove "/" characters from the branch name if present
|
||||
|
@ -19,11 +19,11 @@ if [ $? != 0 ]; then
|
||||
# Complain if the git history is not available
|
||||
if [ $? != 0 ]; then
|
||||
printf 'unknown'
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf 'v0.0.%d' "$PATCH"
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the number of merges on the current branch since the last tag
|
||||
|
14
go.mod
Normal file
14
go.mod
Normal file
@ -0,0 +1,14 @@
|
||||
module github.com/yggdrasil-network/yggdrasil-go
|
||||
|
||||
require (
|
||||
github.com/docker/libcontainer v2.2.1+incompatible
|
||||
github.com/kardianos/minwinsvc v0.0.0-20151122163309-cad6b2b879b0
|
||||
github.com/mitchellh/mapstructure v1.1.2
|
||||
github.com/neilalexander/hjson-go v3.0.0+incompatible
|
||||
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
|
||||
golang.org/x/net v0.0.0-20181207154023-610586996380
|
||||
golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e
|
||||
golang.org/x/text v0.3.0
|
||||
)
|
20
go.sum
Normal file
20
go.sum
Normal file
@ -0,0 +1,20 @@
|
||||
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/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 v3.0.0+incompatible h1:MRqki7QoLwAe9kD12DF4yy6r04KKxvjBcMGvVGNNQ8g=
|
||||
github.com/neilalexander/hjson-go v3.0.0+incompatible/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=
|
||||
github.com/yggdrasil-network/water v0.0.0-20180615095340-f732c88f34ae/go.mod h1:R0SBCsugm+Sf1katgTb2t7GXMm+nRIv43tM4VDZbaOs=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 h1:mKdxBk7AujPs8kU4m80U72y/zjbZ3UcXC7dClwKbUI0=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/net v0.0.0-20181207154023-610586996380 h1:zPQexyRtNYBc7bcHmehl1dH6TB3qn8zytv8cBGLDNY0=
|
||||
golang.org/x/net v0.0.0-20181207154023-610586996380/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e h1:njOxP/wVblhCLIUhjHXf6X+dzTt5OQ3vMQo9mkOIKIo=
|
||||
golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
@ -16,7 +16,7 @@ import "encoding/hex"
|
||||
import "flag"
|
||||
import "fmt"
|
||||
import "runtime"
|
||||
import . "yggdrasil"
|
||||
import . "github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil"
|
||||
|
||||
var doSig = flag.Bool("sig", false, "generate new signing keys instead")
|
||||
|
||||
|
@ -1,4 +1,2 @@
|
||||
#!/bin/bash
|
||||
export GOPATH=$PWD
|
||||
go get -d yggdrasil
|
||||
go run -tags debug misc/sim/treesim.go "$@"
|
||||
|
@ -12,7 +12,7 @@ import "runtime"
|
||||
import "runtime/pprof"
|
||||
import "flag"
|
||||
|
||||
import . "yggdrasil"
|
||||
import . "github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"yggdrasil/defaults"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/defaults"
|
||||
)
|
||||
|
||||
// TODO: Add authentication
|
||||
@ -739,6 +739,10 @@ func (a *admin) admin_dhtPing(keyString, coordString, targetString string) (dhtR
|
||||
}
|
||||
var coords []byte
|
||||
for _, cstr := range strings.Split(strings.Trim(coordString, "[]"), " ") {
|
||||
if cstr == "" {
|
||||
// Special case, happens if trimmed is the empty string, e.g. this is the root
|
||||
continue
|
||||
}
|
||||
if u64, err := strconv.ParseUint(cstr, 10, 8); err != nil {
|
||||
return dhtRes{}, err
|
||||
} else {
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
"net"
|
||||
"regexp"
|
||||
|
||||
"yggdrasil/config"
|
||||
"yggdrasil/defaults"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/config"
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/defaults"
|
||||
)
|
||||
|
||||
var buildName string
|
||||
|
@ -22,7 +22,7 @@ import "net/http"
|
||||
import "runtime"
|
||||
import "os"
|
||||
|
||||
import "yggdrasil/defaults"
|
||||
import "github.com/yggdrasil-network/yggdrasil-go/src/defaults"
|
||||
|
||||
// Start the profiler in debug builds, if the required environment variable is set.
|
||||
func init() {
|
||||
|
@ -268,7 +268,7 @@ func (t *switchTable) forgetPeer(port switchPort) {
|
||||
// Clean all unresponsive peers from the table, needed in case a peer stops updating.
|
||||
// Needed in case a non-parent peer keeps the connection open but stops sending updates.
|
||||
// Also reclaims space from deleted peers by copying the map.
|
||||
func (t switchTable) cleanPeers() {
|
||||
func (t *switchTable) cleanPeers() {
|
||||
now := time.Now()
|
||||
for port, peer := range t.data.peers {
|
||||
if now.Sub(peer.time) > switch_timeout+switch_throttle {
|
||||
|
@ -6,10 +6,11 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"time"
|
||||
"yggdrasil/defaults"
|
||||
|
||||
"github.com/songgao/packets/ethernet"
|
||||
"github.com/yggdrasil-network/water"
|
||||
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/defaults"
|
||||
)
|
||||
|
||||
const tun_IPv6_HEADER_LENGTH = 40
|
||||
|
Loading…
Reference in New Issue
Block a user