diff --git a/.circleci/config.yml b/.circleci/config.yml index 549de14..4b18534 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,6 +16,11 @@ jobs: go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0 golangci-lint run + - run: + name: Run Go tests + command: | + go test ./... + build-linux: docker: - image: circleci/golang:1.16 @@ -157,43 +162,6 @@ jobs: paths: - upload - build-windows: - docker: - - image: circleci/golang:1.16 - - steps: - - checkout - - - run: - name: Create artifact upload directory and set variables - command: | - mkdir /tmp/upload - echo 'export CINAME=$(sh contrib/semver/name.sh)' >> $BASH_ENV - echo 'export CIVERSION=$(sh contrib/semver/version.sh --bare)' >> $BASH_ENV - git config --global user.email "$(git log --format='%ae' HEAD -1)"; - git config --global user.name "$(git log --format='%an' HEAD -1)"; - - - run: - name: Install tools - command: | - sudo apt-get update - sudo apt-get -y install msitools wixl - - - run: - name: Build for Windows - command: | - rm -f {yggdrasil,yggdrasilctl} - GOOS=windows GOARCH=amd64 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-amd64.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-amd64.exe; - GOOS=windows GOARCH=386 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-i386.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-i386.exe; - bash contrib/msi/build-msi.sh x64 - bash contrib/msi/build-msi.sh x86 - mv *.msi /tmp/upload - - - persist_to_workspace: - root: /tmp - paths: - - upload - build-other: docker: - image: circleci/golang:1.16 @@ -224,6 +192,13 @@ jobs: GOOS=freebsd GOARCH=amd64 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-amd64 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-freebsd-amd64; GOOS=freebsd GOARCH=386 ./build && mv yggdrasil /tmp/upload/$CINAME-$CIVERSION-freebsd-i386 && mv yggdrasilctl /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-freebsd-i386; + - run: + name: Build for Windows + command: | + rm -f {yggdrasil,yggdrasilctl} + GOOS=windows GOARCH=amd64 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-amd64.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-amd64.exe; + GOOS=windows GOARCH=386 ./build && mv yggdrasil.exe /tmp/upload/$CINAME-$CIVERSION-windows-i386.exe && mv yggdrasilctl.exe /tmp/upload/$CINAME-$CIVERSION-yggdrasilctl-windows-i386.exe; + - persist_to_workspace: root: /tmp paths: @@ -244,11 +219,10 @@ workflows: version: 2.1 build: jobs: + - lint - build-linux - - build-windows - build-other - upload: requires: - build-linux - - build-windows - build-other diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..903014e --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,20 @@ +version: '{build}' +pull_requests: + do_not_increment_build_number: true +os: Visual Studio 2019 +shallow_clone: false + +environment: + MSYS2_PATH_TYPE: inherit + CHERE_INVOKING: enabled_from_arguments + +build_script: +- cmd: >- + cd %APPVEYOR_BUILD_FOLDER% +- c:\msys64\usr\bin\bash -lc "./contrib/msi/build-msi.sh x64" +- c:\msys64\usr\bin\bash -lc "./contrib/msi/build-msi.sh x86" + +test: off + +artifacts: +- path: '*.msi' diff --git a/assets/peers.txt b/assets/peers.txt index 28ae77d..b271725 100644 --- a/assets/peers.txt +++ b/assets/peers.txt @@ -1,121 +1,64 @@ -tcp://104.248.15.125:31337 -tcp://108.175.10.127:61216 -tcp://139.162.119.37:44478 -tcp://140.238.168.104:17117 -tcp://176.101.222.31:27363 -tcp://176.215.237.83:2755 -tcp://176.223.130.120:22632 -tcp://188.226.125.64:54321 -tcp://194.177.21.156:5066 +tcp://159.203.12.215:1010 +tls://159.203.12.215:1020 tcp://195.123.245.146:7743 -tcp://198.58.100.240:44478 -tcp://[2001:19f0:5401:272a:5400:2ff:fe21:7a26]:8082 -tcp://[2001:19f0:7402:431:5400:2ff:fe21:7912]:8082 -tcp://[2001:1af8:4700:a119:7::1]:35239 -tcp://[2001:41d0:2:c44a:51:255:223:60]:26409 -tcp://[2001:41d0:401:3000::4227]:62506 -tcp://[2001:41d0:601:1100::cf2]:37145 -tcp://[2001:8d8:1800:8224::1]:61216 -tcp://[2001:bc8:1820:192f::1]:62486 -tcp://212.129.52.193:39565 tcp://217.195.164.4:10000 -tcp://[2400:8902::f03c:91ff:fe1f:c32a]:44478 -tcp://[2600:3c00::f03c:91ff:feae:3efa]:44478 -tcp://[2604:a880:400:d0::16e5:7001]:19103 -tcp://[2604:a880:800:c1::2c2:a001]:31337 -tcp://[2607:f1c0:1801:d4::1]:61216 -tcp://[2804:49fc::ffff:ffff:5b5:e8be]:58301 -tcp://[2a00:b700:2::6:69]:1333 -tcp://[2a02:17d0:1b4:bddd::7]:54321 +tcp://37.205.14.171:46370 tcp://[2a03:3b40:fe:ab::1]:46370 -tcp://[2a03:6f00:5:1::59df:79d3]:5353 -tcp://[2a05:3580:d900:1b13:e2d5:5eff:fed8:8b86]:8777 tcp://[2a05:9403::8b]:7743 -tcp://37.205.14.171:46370 -tcp://45.11.19.26:5001 -tcp://45.231.133.188:58301 -tcp://45.76.137.140:8082 -tcp://45.77.107.150:34660 -tcp://46.105.92.61:62506 -tcp://46.151.26.194:60575 -tcp://50.236.201.218:56088 -tcp://51.15.118.10:62486 +tls://217.195.164.4:10531 +tcp://212.129.52.193:39565 tcp://51.15.204.214:12345 -tcp://51.255.223.60:26409 -tcp://51.75.44.73:50001 -tcp://54.37.137.221:37145 -tcp://64.112.176.176:1617 -tcp://64.112.177.94:1617 -tcp://64.112.180.77:1617 -tcp://64.112.182.119:1617 -tcp://64.112.182.182:1617 -tcp://67.205.187.55:19103 -tcp://78.27.153.163:33165 -tcp://82.165.69.111:61216 -tcp://85.17.15.221:35239 -tcp://88.201.129.205:8777 -tcp://89.223.121.211:5353 -tcp://91.206.93.65:1333 -tcp://95.165.99.143:61933 -tcp://ams1.y.sota.sh:8080 -tcp://curiosity.tdjs.tech:30003 -tcp://edge.v4.hel1.devices.y.samip.fi:65444 -tcp://edge.v4.tku1.devices.y.samip.fi:65444 -tcp://edge.v6.hel1.devices.y.samip.fi:65444 -tcp://edge.v6.tku1.devices.y.samip.fi:65444 -tcp://glimmy.092918.xyz:50001 -tcp://hindsight.krvtz.net:8082 -tcp://lancis.iscute.moe:49273 -tcp://lan.tdem.in:50001 -tcp://n2o.ddns.net:22632 -tcp://nessie.krvtz.net:8082 -tcp://vps.tomasgl.ru:61933 -tcp://yggdrasil.frank2.net:1337 -tcp://ygg.loskiq.com:17313 -tcp://yggnode.ddns.net:18226 -tcp://yggnode.ddns.net:18228 -tcp://y.zbin.eu:7743 -tls://104.248.15.125:32337 -tls://140.238.168.104:17121 -tls://176.101.222.31:27364 -tls://176.215.237.83:2756 -tls://194.177.21.156:5068 -tls://[2001:41d0:2:c44a:51:255:223:60]:10259 -tls://[2001:41d0:401:3000::4227]:46394 -tls://[2001:41d0:601:1100::cf2]:14987 +tcp://[2001:470:1f13:e56::64]:39565 tls://212.129.52.193:39575 -tls://217.195.164.4:10531 -tls://[2604:a880:400:d0::16e5:7001]:19102 -tls://[2604:a880:800:c1::2c2:a001]:32337 -tls://[2a00:b700:2::6:69]:1444 -tls://[2a01:d0:ffff:4353::2]:6010 -tls://[2a02:1802:5e:0:18d2:e2ff:fe44:17d2]:9944 -tls://[2a02:1802:5e:0:4b7:c2ff:fe29:ba37]:9944 -tls://[2a02:1802:5e:0:7cc7:cdff:fe28:128a]:9944 -tls://[2a02:1802:5e:0:8854:12ff:fe35:65b3]:9944 -tls://[2a02:1802:5e:0:900c:33ff:fea5:7aec]:9944 -tls://[2a02:1802:5e:0:b841:d3ff:feb2:9a81]:9944 -tls://[2a02:1802:5e:0:b84d:bdff:fe90:1a82]:9944 -tls://[2a02:1802:5e:0:bc20:44ff:fe93:6353]:9944 -tls://[2a05:3580:d900:1b13:e2d5:5eff:fed8:8b86]:8778 -tls://45.11.19.26:5002 +tls://51.15.204.214:54321 +tls://[2001:470:1f13:e56::64]:39575 +tcp://94.130.203.208:5999 +tcp://bunkertreff.ddns.net:5454 +tcp://ygg.cofob.ru:80 +tcp://yugudorashiru.de:80 +tls://ygg.cofob.ru:443 +tls://yugudorashiru.de:443 +tcp://213.188.197.95:10010 +tcp://[2a09:8280:1::3:313]:10010 +tls://213.188.197.95:10020 +tls://[2a09:8280:1::3:313]:10020 tls://45.147.198.155:6010 -tls://46.105.92.61:46394 +tls://94.103.82.150:8080 +tcp://yggdrasil.frank2.net:1337 +tcp://185.165.169.234:8880 +tls://185.165.169.234:8443 +tcp://46.151.26.194:60575 +tcp://lan.tdem.in:50001 +tcp://ygg-ru.cofob.ru:18000 +tcp://ygg-ru2.cofob.ru:80 +tcp://ygg.loskiq.dev:17313 +tcp://ygg.tomasgl.ru:61933 +tcp://ygg.tomasgl.ru:61933?key=c5e0c28a600c2118e986196a0bbcbda4934d8e9278ceabea48838dc5d8fae576 +tcp://yggnode.cf:18226 +tls://185.22.60.71:8443 tls://46.151.26.194:8443 -tls://51.255.223.60:10259 -tls://54.37.137.221:14987 -tls://67.205.187.55:19102 +tls://[2a01:d0:ffff:4353::2]:6010 +tls://lan.tdem.in:50002 +tls://ygg-ru.cofob.ru:18001 +tls://ygg-ru2.cofob.ru:443 +tls://ygg.loskiq.dev:17314 +tls://ygg.tomasgl.ru:61944 +tls://ygg.tomasgl.ru:61944?key=c5e0c28a600c2118e986196a0bbcbda4934d8e9278ceabea48838dc5d8fae576 +tls://yggnode.cf:18227 +tcp://y.zbin.eu:7743 +tcp://[2a04:5b81:2010::90]:2000 +tls://185.130.44.194:7040 +tls://[2a07:e01:105:444:c634:6bff:feb5:6e28]:7040 +tcp://140.238.168.104:17117 +tls://140.238.168.104:17121 +tcp://78.27.153.163:33165 tls://78.27.153.163:33166 -tls://88.201.129.205:8778 -tls://91.206.93.65:1444 -tls://edge.v4.hel1.devices.y.samip.fi:65445 -tls://edge.v4.tku1.devices.y.samip.fi:65445 -tls://edge.v6.hel1.devices.y.samip.fi:65445 -tls://edge.v6.tku1.devices.y.samip.fi:65445 -tls://glimmy.092918.xyz:58008 +tcp://curiosity.tdjs.tech:30003 +tcp://213.188.199.150:10010 +tcp://213.188.210.9:10010 +tcp://[2a09:8280:1::3:312]:10010 +tcp://[2a09:8280:1::a:2e2]:10010 +tcp://lancis.iscute.moe:49273 +tcp://longseason.1200bps.xyz:13121 tls://lancis.iscute.moe:49274 -tls://lan.tdem.in:50002 -tls://vps.tomasgl.ru:61944 -tls://ygg.loskiq.com:17314 -tls://yggnode.ddns.net:18227 -tls://yggnode.ddns.net:18229 +tls://longseason.1200bps.xyz:13122 diff --git a/build b/build index 37c5024..8510a03 100755 --- a/build +++ b/build @@ -35,18 +35,16 @@ fi if [ $IOS ]; then echo "Building framework for iOS" - gomobile bind -target ios -tags mobile -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \ - github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil \ - github.com/yggdrasil-network/yggdrasil-go/src/config \ + go get golang.org/x/mobile/bind + gomobile bind -target ios -tags mobile -o Yggdrasil.framework -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \ github.com/yggdrasil-network/yggdrasil-extras/src/mobile \ - github.com/yggdrasil-network/yggdrasil-extras/src/dummy + github.com/yggdrasil-network/yggdrasil-go/src/config elif [ $ANDROID ]; then echo "Building aar for Android" - gomobile bind -target android -tags mobile -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \ - github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil \ - github.com/yggdrasil-network/yggdrasil-go/src/config \ + go get golang.org/x/mobile/bind + gomobile bind -target android -tags mobile -o yggdrasil.aar -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \ github.com/yggdrasil-network/yggdrasil-extras/src/mobile \ - github.com/yggdrasil-network/yggdrasil-extras/src/dummy + github.com/yggdrasil-network/yggdrasil-go/src/config else for CMD in yggdrasil yggdrasilctl ; do echo "Building: $CMD" diff --git a/cmd/genkeys/main.go b/cmd/genkeys/main.go new file mode 100644 index 0000000..8194244 --- /dev/null +++ b/cmd/genkeys/main.go @@ -0,0 +1,78 @@ +/* + +This file generates crypto keys. +It prints out a new set of keys each time if finds a "better" one. +By default, "better" means a higher NodeID (-> higher IP address). +This is because the IP address format can compress leading 1s in the address, to increase the number of ID bits in the address. + +If run with the "-sig" flag, it generates signing keys instead. +A "better" signing key means one with a higher TreeID. +This only matters if it's high enough to make you the root of the tree. + +*/ +package main + +import ( + "crypto/ed25519" + "encoding/hex" + "fmt" + "net" + "runtime" + + "github.com/yggdrasil-network/yggdrasil-go/src/address" +) + +type keySet struct { + priv ed25519.PrivateKey + pub ed25519.PublicKey +} + +func main() { + threads := runtime.GOMAXPROCS(0) + var currentBest ed25519.PublicKey + newKeys := make(chan keySet, threads) + for i := 0; i < threads; i++ { + go doKeys(newKeys) + } + for { + newKey := <-newKeys + if isBetter(currentBest, newKey.pub) || len(currentBest) == 0 { + currentBest = newKey.pub + fmt.Println("-----") + fmt.Println("Priv:", hex.EncodeToString(newKey.priv)) + fmt.Println("Pub:", hex.EncodeToString(newKey.pub)) + addr := address.AddrForKey(newKey.pub) + fmt.Println("IP:", net.IP(addr[:]).String()) + } + } +} + +func isBetter(oldPub, newPub ed25519.PublicKey) bool { + for idx := range oldPub { + if newPub[idx] < oldPub[idx] { + return true + } + if newPub[idx] > oldPub[idx] { + break + } + } + return false +} + +func doKeys(out chan<- keySet) { + bestKey := make(ed25519.PublicKey, ed25519.PublicKeySize) + for idx := range bestKey { + bestKey[idx] = 0xff + } + for { + pub, priv, err := ed25519.GenerateKey(nil) + if err != nil { + panic(err) + } + if !isBetter(bestKey, pub) { + continue + } + bestKey = pub + out <- keySet{priv, pub} + } +} diff --git a/cmd/yggdrasil/main.go b/cmd/yggdrasil/main.go index 03ecb60..ace24b5 100644 --- a/cmd/yggdrasil/main.go +++ b/cmd/yggdrasil/main.go @@ -1,6 +1,8 @@ package main import ( + "context" + "crypto/ed25519" "encoding/hex" "flag" "fmt" @@ -17,30 +19,29 @@ import ( "github.com/yggdrasil-network/yggdrasil-go/src/address" "github.com/yggdrasil-network/yggdrasil-go/src/admin" "github.com/yggdrasil-network/yggdrasil-go/src/config" - "github.com/yggdrasil-network/yggdrasil-go/src/crypto" - "github.com/yggdrasil-network/yggdrasil-go/src/module" + + "github.com/yggdrasil-network/yggdrasil-go/src/core" "github.com/yggdrasil-network/yggdrasil-go/src/multicast" "github.com/yggdrasil-network/yggdrasil-go/src/tuntap" "github.com/yggdrasil-network/yggdrasil-go/src/version" - "github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil" _meshname "github.com/zhoreeq/meshname/pkg/meshname" "github.com/popura-network/Popura/src/autopeering" "github.com/popura-network/Popura/src/meshname" - "github.com/popura-network/Popura/src/radv" "github.com/popura-network/Popura/src/popura" + "github.com/popura-network/Popura/src/radv" ) type node struct { - core yggdrasil.Core - state *config.NodeState - tuntap module.Module // tuntap.TunAdapter - multicast module.Module // multicast.Multicast - admin module.Module // admin.AdminSocket - meshname popura.Module // meshname.MeshnameServer - radv popura.Module // radv.RAdv - autopeering popura.Module // autopeering.AutoPeering + core core.Core + config *config.NodeConfig + tuntap *tuntap.TunAdapter + multicast *multicast.Multicast + admin *admin.AdminSocket + meshname popura.Module // meshname.MeshnameServer + radv popura.Module // radv.RAdv + autopeering popura.Module // autopeering.AutoPeering } func setLogLevel(loglevel string, logger *log.Logger) { @@ -69,9 +70,24 @@ func setLogLevel(loglevel string, logger *log.Logger) { } } -// The main function is responsible for configuring and starting Yggdrasil. -func run_yggdrasil() { - // Configure the command line parameters. +type yggArgs struct { + genconf bool + useconf bool + useconffile string + normaliseconf bool + confjson bool + autoconf bool + ver bool + logto string + getaddr bool + getsnet bool + loglevel string + autopeer bool + meshnameconf bool + withpeers int +} + +func getArgs() yggArgs { genconf := flag.Bool("genconf", false, "print a new config to stdout") useconf := flag.Bool("useconf", false, "read HJSON/JSON config from stdin") useconffile := flag.String("useconffile", "", "read HJSON/JSON config from specified file path") @@ -83,49 +99,101 @@ func run_yggdrasil() { logto := flag.String("logto", "stdout", "file path to log to, \"syslog\" or \"stdout\"") getaddr := flag.Bool("address", false, "returns the IPv6 address as derived from the supplied configuration") getsnet := flag.Bool("subnet", false, "returns the IPv6 subnet as derived from the supplied configuration") - meshnameconf := flag.String("meshnameconf", "", "prints example Meshname.Config config value for a specified IP address") + meshnameconf := flag.Bool("meshnameconf", false, "use with -useconffile. Prints config with a default meshname DNS record") withpeers := flag.Int("withpeers", 0, "generate a config with N number of alive peers") loglevel := flag.String("loglevel", "info", "loglevel to enable") flag.Parse() + return yggArgs{ + genconf: *genconf, + useconf: *useconf, + useconffile: *useconffile, + normaliseconf: *normaliseconf, + confjson: *confjson, + autoconf: *autoconf, + autopeer: *autopeer, + ver: *ver, + logto: *logto, + getaddr: *getaddr, + getsnet: *getsnet, + meshnameconf: *meshnameconf, + withpeers: *withpeers, + loglevel: *loglevel, + } +} + +// The main function is responsible for configuring and starting Yggdrasil. +func run(args yggArgs, ctx context.Context, done chan struct{}) { + defer close(done) + // Create a new logger that logs output to stdout. + var logger *log.Logger + switch args.logto { + case "stdout": + logger = log.New(os.Stdout, "", log.Flags()) + case "syslog": + if syslogger, err := gsyslog.NewLogger(gsyslog.LOG_NOTICE, "DAEMON", version.BuildName()); err == nil { + logger = log.New(syslogger, "", log.Flags()) + } + default: + if logfd, err := os.OpenFile(args.logto, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil { + logger = log.New(logfd, "", log.Flags()) + } + } + if logger == nil { + logger = log.New(os.Stdout, "", log.Flags()) + logger.Warnln("Logging defaulting to stdout") + } + + if args.normaliseconf { + setLogLevel("error", logger) + } else { + setLogLevel(args.loglevel, logger) + } var yggConfig *config.NodeConfig var popConfig *popura.PopuraConfig var err error switch { - case *ver: + case args.ver: fmt.Println("Build name:", version.BuildName()) fmt.Println("Build version:", version.BuildVersion()) return - case *autoconf: + case args.autoconf: // Use an autoconf-generated config, this will give us random keys and // port numbers, and will use an automatically selected TUN/TAP interface. yggConfig, popConfig = popura.GenerateConfig() - case *useconffile != "" || *useconf: + case args.useconffile != "" || args.useconf: // Read the configuration from either stdin or from the filesystem - yggConfig, popConfig = popura.LoadConfig(useconf, useconffile, normaliseconf) + yggConfig, popConfig = popura.LoadConfig(&args.useconf, &args.useconffile, &args.normaliseconf) // If the -normaliseconf option was specified then remarshal the above // configuration and print it back to stdout. This lets the user update // their configuration file with newly mapped names (like above) or to // convert from plain JSON to commented HJSON. - if *normaliseconf { - fmt.Println(popura.SaveConfig(*yggConfig, *popConfig, *confjson)) + if args.normaliseconf { + fmt.Println(popura.SaveConfig(*yggConfig, *popConfig, args.confjson)) return } - case *genconf: + + if args.meshnameconf { + ip := popura.AddressFromKey(yggConfig.PrivateKey) + subDomain := _meshname.DomainFromIP(ip) + + defaultRecord := fmt.Sprintf("%s.vapordns AAAA %s", subDomain, ip.String()) + meshnameConfig := make(map[string][]string) + meshnameConfig[subDomain] = []string{defaultRecord} + + popConfig.Meshname.Enable = true + popConfig.Meshname.Config = meshnameConfig + fmt.Println(popura.SaveConfig(*yggConfig, *popConfig, args.confjson)) + return + } + case args.genconf: // Generate a new configuration and print it to stdout. yggConfig, popConfig = popura.GenerateConfig() - if *withpeers > 0 { - apeers := autopeering.RandomPick(autopeering.GetClosestPeers(autopeering.PublicPeers, 10), *withpeers) + if args.withpeers > 0 { + apeers := autopeering.RandomPick(autopeering.GetClosestPeers(autopeering.PublicPeers, 10), args.withpeers) yggConfig.Peers = append(yggConfig.Peers, apeers...) } - fmt.Println(popura.SaveConfig(*yggConfig, *popConfig, *confjson)) - return - case *meshnameconf != "": - if conf, err := _meshname.GenConf(*meshnameconf, "meshname."); err == nil { - fmt.Println(conf) - } else { - panic(err) - } + fmt.Println(popura.SaveConfig(*yggConfig, *popConfig, args.confjson)) return default: // No flags were provided, therefore print the list of flags to stdout. @@ -138,25 +206,23 @@ func run_yggdrasil() { return } // Have we been asked for the node address yet? If so, print it and then stop. - getNodeID := func() *crypto.NodeID { - if pubkey, err := hex.DecodeString(yggConfig.EncryptionPublicKey); err == nil { - var box crypto.BoxPubKey - copy(box[:], pubkey) - return crypto.GetNodeID(&box) + getNodeKey := func() ed25519.PublicKey { + if pubkey, err := hex.DecodeString(yggConfig.PrivateKey); err == nil { + return ed25519.PrivateKey(pubkey).Public().(ed25519.PublicKey) } return nil } switch { - case *getaddr: - if nodeid := getNodeID(); nodeid != nil { - addr := *address.AddrForNodeID(nodeid) + case args.getaddr: + if key := getNodeKey(); key != nil { + addr := address.AddrForKey(key) ip := net.IP(addr[:]) fmt.Println(ip.String()) } return - case *getsnet: - if nodeid := getNodeID(); nodeid != nil { - snet := *address.SubnetForNodeID(nodeid) + case args.getsnet: + if key := getNodeKey(); key != nil { + snet := address.SubnetForKey(key) ipnet := net.IPNet{ IP: append(snet[:], 0, 0, 0, 0, 0, 0, 0, 0), Mask: net.CIDRMask(len(snet)*8, 128), @@ -167,39 +233,16 @@ func run_yggdrasil() { default: } - // Create a new logger that logs output to stdout. - var logger *log.Logger - switch *logto { - case "stdout": - logger = log.New(os.Stdout, "", log.Flags()) - case "syslog": - if syslogger, err := gsyslog.NewLogger(gsyslog.LOG_NOTICE, "DAEMON", version.BuildName()); err == nil { - logger = log.New(syslogger, "", log.Flags()) - } - default: - if logfd, err := os.OpenFile(*logto, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil { - logger = log.New(logfd, "", log.Flags()) - } - } - if logger == nil { - logger = log.New(os.Stdout, "", log.Flags()) - logger.Warnln("Logging defaulting to stdout") - } - - setLogLevel(*loglevel, logger) - // Setup the Yggdrasil node itself. The node{} type includes a Core, so we // don't need to create this manually. - n := node{} + n := node{config: yggConfig} // Now start Yggdrasil - this starts the DHT, router, switch and other core // components needed for Yggdrasil to operate - n.state, err = n.core.Start(yggConfig, logger) - if err != nil { + if err = n.core.Start(yggConfig, logger); err != nil { logger.Errorln("An error occurred during startup") panic(err) } // Register the session firewall gatekeeper function - n.core.SetSessionGatekeeper(n.sessionFirewall) // Allocate our modules n.admin = &admin.AdminSocket{} n.multicast = &multicast.Multicast{} @@ -208,159 +251,86 @@ func run_yggdrasil() { n.radv = &radv.RAdv{} n.autopeering = &autopeering.AutoPeering{} // Start the admin socket - n.admin.Init(&n.core, n.state, logger, nil) - if err := n.admin.Start(); err != nil { + if err := n.admin.Init(&n.core, yggConfig, logger, nil); err != nil { + logger.Errorln("An error occurred initialising admin socket:", err) + } else if err := n.admin.Start(); err != nil { logger.Errorln("An error occurred starting admin socket:", err) } - n.admin.SetupAdminHandlers(n.admin.(*admin.AdminSocket)) + n.admin.SetupAdminHandlers(n.admin) // Start the multicast interface - n.multicast.Init(&n.core, n.state, logger, nil) - if err := n.multicast.Start(); err != nil { + if err := n.multicast.Init(&n.core, yggConfig, logger, nil); err != nil { + logger.Errorln("An error occurred initialising multicast:", err) + } else if err := n.multicast.Start(); err != nil { logger.Errorln("An error occurred starting multicast:", err) } - n.multicast.SetupAdminHandlers(n.admin.(*admin.AdminSocket)) + n.multicast.SetupAdminHandlers(n.admin) // Start the TUN/TAP interface - if listener, err := n.core.ConnListen(); err == nil { - if dialer, err := n.core.ConnDialer(); err == nil { - n.tuntap.Init(&n.core, n.state, logger, tuntap.TunOptions{Listener: listener, Dialer: dialer}) - if err := n.tuntap.Start(); err != nil { - logger.Errorln("An error occurred starting TUN/TAP:", err) - } - n.tuntap.SetupAdminHandlers(n.admin.(*admin.AdminSocket)) - } else { - logger.Errorln("Unable to get Dialer:", err) - } - } else { - logger.Errorln("Unable to get Listener:", err) + if err := n.tuntap.Init(&n.core, yggConfig, logger, nil); err != nil { + logger.Errorln("An error occurred initialising TUN/TAP:", err) + } else if err := n.tuntap.Start(); err != nil { + logger.Errorln("An error occurred starting TUN/TAP:", err) } + n.tuntap.SetupAdminHandlers(n.admin) // Start the DNS server - n.meshname.Init(&n.core, n.state, popConfig, logger, nil) + n.meshname.Init(&n.core, yggConfig, popConfig, logger, nil) n.meshname.Start() - // Start Router Advertisement module - n.radv.Init(&n.core, n.state, popConfig, logger, nil) + n.radv.Init(&n.core, yggConfig, popConfig, logger, nil) if err := n.radv.Start(); err != nil { logger.Errorln("An error occured starting RAdv: ", err) } - n.autopeering.Init(&n.core, n.state, popConfig, logger, nil) + n.autopeering.Init(&n.core, yggConfig, popConfig, logger, nil) + // Setup auto peering + if args.autopeer && len(yggConfig.Peers) == 0 { + n.autopeering.Start() + } // Make some nice output that tells us what our IPv6 address and subnet are. // This is just logged to stdout for the user. address := n.core.Address() subnet := n.core.Subnet() + public := n.core.GetSelf().Key + logger.Infof("Your public key is %s", hex.EncodeToString(public[:])) logger.Infof("Your IPv6 address is %s", address.String()) logger.Infof("Your IPv6 subnet is %s", subnet.String()) // Catch interrupts from the operating system to exit gracefully. - c := make(chan os.Signal, 1) - r := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt, syscall.SIGTERM) - signal.Notify(r, os.Interrupt, syscall.SIGHUP) + <-ctx.Done() // Capture the service being stopped on Windows. minwinsvc.SetOnExit(n.shutdown) - defer n.shutdown() - - // Setup auto peering - if *autopeer && len(yggConfig.Peers) == 0 { - n.autopeering.Start() - } - - // Wait for the terminate/interrupt signal. Once a signal is received, the - // deferred Stop function above will run which will shut down TUN/TAP. - for { - select { - case <-c: - goto exit - case <-r: - if *useconffile != "" { - yggConfig, popConfig = popura.LoadConfig(useconf, useconffile, normaliseconf) - logger.Infoln("Reloading configuration from", *useconffile) - n.core.UpdateConfig(yggConfig) - n.tuntap.UpdateConfig(yggConfig) - n.multicast.UpdateConfig(yggConfig) - n.meshname.UpdateConfig(yggConfig, popConfig) - n.radv.UpdateConfig(yggConfig, popConfig) - } else { - logger.Errorln("Reloading config at runtime is only possible with -useconffile") - } - } - } -exit: + n.shutdown() } func (n *node) shutdown() { - n.autopeering.Stop() - n.radv.Stop() - n.meshname.Stop() - n.admin.Stop() - n.multicast.Stop() - n.tuntap.Stop() + _ = n.autopeering.Stop() + _ = n.radv.Stop() + _ = n.meshname.Stop() + _ = n.admin.Stop() + _ = n.multicast.Stop() + _ = n.tuntap.Stop() n.core.Stop() } -func (n *node) sessionFirewall(pubkey *crypto.BoxPubKey, initiator bool) bool { - n.state.Mutex.RLock() - defer n.state.Mutex.RUnlock() - - // Allow by default if the session firewall is disabled - if !n.state.Current.SessionFirewall.Enable { - return true - } - - // Prepare for checking whitelist/blacklist - var box crypto.BoxPubKey - // Reject blacklisted nodes - for _, b := range n.state.Current.SessionFirewall.BlacklistEncryptionPublicKeys { - key, err := hex.DecodeString(b) - if err == nil { - copy(box[:crypto.BoxPubKeyLen], key) - if box == *pubkey { - return false - } - } - } - - // Allow whitelisted nodes - for _, b := range n.state.Current.SessionFirewall.WhitelistEncryptionPublicKeys { - key, err := hex.DecodeString(b) - if err == nil { - copy(box[:crypto.BoxPubKeyLen], key) - if box == *pubkey { - return true - } - } - } - - // Allow outbound sessions if appropriate - if n.state.Current.SessionFirewall.AlwaysAllowOutbound { - if initiator { - return true - } - } - - // Look and see if the pubkey is that of a direct peer - var isDirectPeer bool - for _, peer := range n.core.GetPeers() { - if peer.PublicKey == *pubkey { - isDirectPeer = true - break +func main() { + args := getArgs() + hup := make(chan os.Signal, 1) + //signal.Notify(hup, os.Interrupt, syscall.SIGHUP) + term := make(chan os.Signal, 1) + signal.Notify(term, os.Interrupt, syscall.SIGTERM) + for { + done := make(chan struct{}) + ctx, cancel := context.WithCancel(context.Background()) + go run(args, ctx, done) + select { + case <-hup: + cancel() + <-done + case <-term: + cancel() + <-done + return + case <-done: + return } } - - // Allow direct peers if appropriate - if n.state.Current.SessionFirewall.AllowFromDirect && isDirectPeer { - return true - } - - // Allow remote nodes if appropriate - if n.state.Current.SessionFirewall.AllowFromRemote && !isDirectPeer { - return true - } - - // Finally, default-deny if not matching any of the above rules - return false -} - -func main() { - run_yggdrasil() } diff --git a/cmd/yggdrasilctl/main.go b/cmd/yggdrasilctl/main.go index 38d935a..9192339 100644 --- a/cmd/yggdrasilctl/main.go +++ b/cmd/yggdrasilctl/main.go @@ -47,8 +47,11 @@ func run() int { 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("\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() + fmt.Println("Please note that options must always specified BEFORE the command\non the command line or they will be ignored.") + fmt.Println() + fmt.Println("Commands:\n - Use \"list\" for a list of available commands") + fmt.Println() fmt.Println("Examples:") fmt.Println(" - ", os.Args[0], "list") fmt.Println(" - ", os.Args[0], "getPeers") @@ -288,6 +291,9 @@ func run() int { if subnet, ok := v.(map[string]interface{})["subnet"].(string); ok { fmt.Println("IPv6 subnet:", subnet) } + if boxSigKey, ok := v.(map[string]interface{})["key"].(string); ok { + fmt.Println("Public key:", boxSigKey) + } if coords, ok := v.(map[string]interface{})["coords"].(string); ok { fmt.Println("Coords:", coords) } diff --git a/contrib/ansible/genkeys.go b/contrib/ansible/genkeys.go index 681431b..4a02b9b 100644 --- a/contrib/ansible/genkeys.go +++ b/contrib/ansible/genkeys.go @@ -6,6 +6,7 @@ This file generates crypto keys for [ansible-yggdrasil](https://github.com/jcgru package main import ( + "crypto/ed25519" "encoding/hex" "flag" "fmt" @@ -14,7 +15,6 @@ import ( "github.com/cheggaaa/pb/v3" "github.com/yggdrasil-network/yggdrasil-go/src/address" - "github.com/yggdrasil-network/yggdrasil-go/src/crypto" ) var numHosts = flag.Int("hosts", 1, "number of host vars to generate") @@ -23,7 +23,6 @@ var keyTries = flag.Int("tries", 1000, "number of tries before taking the best k type keySet struct { priv []byte pub []byte - id []byte ip string } @@ -37,27 +36,15 @@ func main() { return } - var encryptionKeys []keySet + var keys []keySet for i := 0; i < *numHosts+1; i++ { - encryptionKeys = append(encryptionKeys, newBoxKey()) + keys = append(keys, newKey()) bar.Increment() } - encryptionKeys = sortKeySetArray(encryptionKeys) + keys = sortKeySetArray(keys) for i := 0; i < *keyTries-*numHosts-1; i++ { - encryptionKeys[0] = newBoxKey() - encryptionKeys = bubbleUpTo(encryptionKeys, 0) - bar.Increment() - } - - var signatureKeys []keySet - for i := 0; i < *numHosts+1; i++ { - signatureKeys = append(signatureKeys, newSigKey()) - bar.Increment() - } - signatureKeys = sortKeySetArray(signatureKeys) - for i := 0; i < *keyTries-*numHosts-1; i++ { - signatureKeys[0] = newSigKey() - signatureKeys = bubbleUpTo(signatureKeys, 0) + keys[0] = newKey() + keys = bubbleUpTo(keys, 0) bar.Increment() } @@ -70,43 +57,36 @@ func main() { return } defer file.Close() - file.WriteString(fmt.Sprintf("yggdrasil_encryption_public_key: %v\n", hex.EncodeToString(encryptionKeys[i].pub))) - file.WriteString("yggdrasil_encryption_private_key: \"{{ vault_yggdrasil_encryption_private_key }}\"\n") - file.WriteString(fmt.Sprintf("yggdrasil_signing_public_key: %v\n", hex.EncodeToString(signatureKeys[i].pub))) - file.WriteString("yggdrasil_signing_private_key: \"{{ vault_yggdrasil_signing_private_key }}\"\n") - file.WriteString(fmt.Sprintf("ansible_host: %v\n", encryptionKeys[i].ip)) + file.WriteString(fmt.Sprintf("yggdrasil_public_key: %v\n", hex.EncodeToString(keys[i].pub))) + file.WriteString("yggdrasil_private_key: \"{{ vault_yggdrasil_private_key }}\"\n") + file.WriteString(fmt.Sprintf("ansible_host: %v\n", keys[i].ip)) file, err = os.Create(fmt.Sprintf("host_vars/%x/vault", i)) if err != nil { return } defer file.Close() - file.WriteString(fmt.Sprintf("vault_yggdrasil_encryption_private_key: %v\n", hex.EncodeToString(encryptionKeys[i].priv))) - file.WriteString(fmt.Sprintf("vault_yggdrasil_signing_private_key: %v\n", hex.EncodeToString(signatureKeys[i].priv))) + file.WriteString(fmt.Sprintf("vault_yggdrasil_private_key: %v\n", hex.EncodeToString(keys[i].priv))) bar.Increment() } bar.Finish() } -func newBoxKey() keySet { - pub, priv := crypto.NewBoxKeys() - id := crypto.GetNodeID(pub) - ip := net.IP(address.AddrForNodeID(id)[:]).String() - return keySet{priv[:], pub[:], id[:], ip} -} - -func newSigKey() keySet { - pub, priv := crypto.NewSigKeys() - id := crypto.GetTreeID(pub) - return keySet{priv[:], pub[:], id[:], ""} +func newKey() keySet { + pub, priv, err := ed25519.GenerateKey(nil) + if err != nil { + panic(err) + } + ip := net.IP(address.AddrForKey(pub)[:]).String() + return keySet{priv[:], pub[:], ip} } func isBetter(oldID, newID []byte) bool { for idx := range oldID { - if newID[idx] > oldID[idx] { + if newID[idx] < oldID[idx] { return true } - if newID[idx] < oldID[idx] { + if newID[idx] > oldID[idx] { return false } } @@ -122,7 +102,7 @@ func sortKeySetArray(sets []keySet) []keySet { func bubbleUpTo(sets []keySet, num int) []keySet { for i := 0; i < len(sets)-num-1; i++ { - if isBetter(sets[i+1].id, sets[i].id) { + if isBetter(sets[i+1].pub, sets[i].pub) { var tmp = sets[i] sets[i] = sets[i+1] sets[i+1] = tmp diff --git a/contrib/config/yggdrasilconf.go b/contrib/config/yggdrasilconf.go deleted file mode 100644 index ad55e16..0000000 --- a/contrib/config/yggdrasilconf.go +++ /dev/null @@ -1,97 +0,0 @@ -package main - -/* -This is a small utility that is designed to accompany the vyatta-yggdrasil -package. It takes a HJSON configuration file, makes changes to it based on -the command line arguments, and then spits out an updated file. -*/ - -import ( - "bytes" - "encoding/json" - "flag" - "fmt" - "io/ioutil" - "strconv" - - "github.com/hjson/hjson-go" - "golang.org/x/text/encoding/unicode" - - "github.com/yggdrasil-network/yggdrasil-go/src/config" -) - -type nodeConfig = config.NodeConfig - -func main() { - useconffile := flag.String("useconffile", "/etc/yggdrasil.conf", "update config at specified file path") - flag.Parse() - cfg := nodeConfig{} - var config []byte - var err error - config, err = ioutil.ReadFile(*useconffile) - if err != nil { - panic(err) - } - if bytes.Compare(config[0:2], []byte{0xFF, 0xFE}) == 0 || - bytes.Compare(config[0:2], []byte{0xFE, 0xFF}) == 0 { - utf := unicode.UTF16(unicode.BigEndian, unicode.UseBOM) - decoder := utf.NewDecoder() - config, err = decoder.Bytes(config) - if err != nil { - panic(err) - } - } - var dat map[string]interface{} - if err := hjson.Unmarshal(config, &dat); err != nil { - panic(err) - } - confJson, err := json.Marshal(dat) - if err != nil { - panic(err) - } - json.Unmarshal(confJson, &cfg) - switch flag.Arg(0) { - case "setMTU": - cfg.IfMTU, err = strconv.Atoi(flag.Arg(1)) - if err != nil { - cfg.IfMTU = 1280 - } - if mtu, _ := strconv.Atoi(flag.Arg(1)); mtu < 1280 { - cfg.IfMTU = 1280 - } - case "setIfName": - cfg.IfName = flag.Arg(1) - case "setListen": - cfg.Listen = flag.Arg(1) - case "setAdminListen": - cfg.AdminListen = flag.Arg(1) - case "setIfTapMode": - if flag.Arg(1) == "true" { - cfg.IfTAPMode = true - } else { - cfg.IfTAPMode = false - } - case "addPeer": - found := false - for _, v := range cfg.Peers { - if v == flag.Arg(1) { - found = true - } - } - if !found { - cfg.Peers = append(cfg.Peers, flag.Arg(1)) - } - case "removePeer": - for k, v := range cfg.Peers { - if v == flag.Arg(1) { - cfg.Peers = append(cfg.Peers[:k], cfg.Peers[k+1:]...) - } - } - } - bs, err := hjson.Marshal(cfg) - if err != nil { - panic(err) - } - fmt.Println(string(bs)) - return -} diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile index fd2ae98..15129b1 100644 --- a/contrib/docker/Dockerfile +++ b/contrib/docker/Dockerfile @@ -8,7 +8,6 @@ ENV CGO_ENABLED=0 RUN apk add git && ./build && go build -o /src/genkeys cmd/genkeys/main.go FROM docker.io/alpine -LABEL maintainer="Christer Waren/CWINFO " COPY --from=builder /src/yggdrasil /usr/bin/yggdrasil COPY --from=builder /src/yggdrasilctl /usr/bin/yggdrasilctl diff --git a/contrib/msi/build-msi.sh b/contrib/msi/build-msi.sh index b7dd491..2f85d80 100644 --- a/contrib/msi/build-msi.sh +++ b/contrib/msi/build-msi.sh @@ -1,7 +1,9 @@ -#!/bin/bash +#!/bin/sh # This script generates an MSI file for Yggdrasil for a given architecture. It -# needs to run on Linux or macOS with Go 1.16, wixl and msitools installed. +# needs to run on Windows within MSYS2 and Go 1.13 or later must be installed on +# the system and within the PATH. This is ran currently by Appveyor (see +# appveyor.yml in the repository root) for both x86 and x64. # # Author: Neil Alexander @@ -26,10 +28,29 @@ then git checkout ${APPVEYOR_REPO_BRANCH} fi +# Install prerequisites within MSYS2 +pacman -S --needed --noconfirm unzip git curl + +# Download the wix tools! +if [ ! -d wixbin ]; +then + curl -LO https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip + if [ `md5sum wix311-binaries.zip | cut -f 1 -d " "` != "47a506f8ab6666ee3cc502fb07d0ee2a" ]; + then + echo "wix package didn't match expected checksum" + exit 1 + fi + mkdir -p wixbin + unzip -o wix311-binaries.zip -d wixbin || ( + echo "failed to unzip WiX" + exit 1 + ) +fi + # Build Yggdrasil! -[ "${PKGARCH}" == "x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 ./build -p -l "-aslr" -[ "${PKGARCH}" == "x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=0 ./build -p -l "-aslr" -[ "${PKGARCH}" == "arm" ] && GOOS=windows GOARCH=arm CGO_ENABLED=0 ./build -p -l "-aslr" +[ "${PKGARCH}" == "x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 ./build +[ "${PKGARCH}" == "x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=0 ./build +[ "${PKGARCH}" == "arm" ] && GOOS=windows GOARCH=arm CGO_ENABLED=0 ./build #[ "${PKGARCH}" == "arm64" ] && GOOS=windows GOARCH=arm64 CGO_ENABLED=0 ./build # Create the postinstall script @@ -39,24 +60,25 @@ if not exist %ALLUSERSPROFILE%\\Yggdrasil ( ) if not exist %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf ( if exist yggdrasil.exe ( - if not exist %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf ( - yggdrasil.exe -genconf > %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf - ) + yggdrasil.exe -genconf > %ALLUSERSPROFILE%\\Yggdrasil\\yggdrasil.conf ) ) EOF # Work out metadata for the package info PKGNAME=$(sh contrib/semver/name.sh) -PKGVERSION=$(sh contrib/semver/version.sh --bare | cut -d "+" -f 1) +PKGVERSION=$(sh contrib/msi/msversion.sh --bare | cut -d "+" -f 1) PKGVERSIONMS=$(echo $PKGVERSION | tr - .) [ "${PKGARCH}" == "x64" ] && \ PKGGUID="77757838-1a23-40a5-a720-c3b43e0260cc" PKGINSTFOLDER="ProgramFiles64Folder" || \ PKGGUID="54a3294e-a441-4322-aefb-3bb40dd022bb" PKGINSTFOLDER="ProgramFilesFolder" # Download the Wintun driver -curl -o wintun.zip https://www.wintun.net/builds/wintun-0.10.2.zip -unzip wintun.zip +if [ ! -d wintun ]; +then + curl -o wintun.zip https://www.wintun.net/builds/wintun-0.11.zip + unzip wintun.zip +fi if [ $PKGARCH = "x64" ]; then PKGWINTUNDLL=wintun/bin/amd64/wintun.dll elif [ $PKGARCH = "x86" ]; then @@ -87,7 +109,6 @@ cat > wix.xml << EOF Language="1033" Codepage="1252" Version="${PKGVERSIONMS}" - Platform="${PKGARCH}" Manufacturer="github.com/yggdrasil-network"> wix.xml << EOF InstallScope="perMachine" Languages="1033" Compressed="yes" - Platform="${PKGARCH}" SummaryCodepage="1252" /> wix.xml << EOF + Before="StartServices"> + NOT Installed AND NOT REMOVE + @@ -197,4 +219,7 @@ cat > wix.xml << EOF EOF # Generate the MSI -wixl -v wix.xml -a ${PKGARCH} -o ${PKGNAME}-${PKGVERSION}-${PKGARCH}.msi +CANDLEFLAGS="-nologo" +LIGHTFLAGS="-nologo -spdb -sice:ICE71 -sice:ICE61" +wixbin/candle $CANDLEFLAGS -out ${PKGNAME}-${PKGVERSION}-${PKGARCH}.wixobj -arch ${PKGARCH} wix.xml && \ +wixbin/light $LIGHTFLAGS -ext WixUtilExtension.dll -out ${PKGNAME}-${PKGVERSION}-${PKGARCH}.msi ${PKGNAME}-${PKGVERSION}-${PKGARCH}.wixobj diff --git a/contrib/msi/msversion.sh b/contrib/msi/msversion.sh new file mode 100644 index 0000000..b37e4df --- /dev/null +++ b/contrib/msi/msversion.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Get the last tag +TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" 2>/dev/null) + +# Did getting the tag succeed? +if [ $? != 0 ] || [ -z "$TAG" ]; then + printf -- "unknown" + exit 0 +fi + +# Get the current branch +BRANCH=$(git symbolic-ref -q HEAD --short 2>/dev/null) + +# Did getting the branch succeed? +if [ $? != 0 ] || [ -z "$BRANCH" ]; then + BRANCH="master" +fi + +# 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) +PATCH=$(echo $TAG | cut -c 2- | cut -d "." -f 3 | awk -F"rc" '{print $1}') + +# Output in the desired format +printf '%s%d.%d.%s' "$PREPEND" "$((MAJOR))" "$((MINOR))" "$PATCH" + +# Add the build tag on non-master branches +if [ "$BRANCH" != "master" ]; then + BUILD=$(git rev-list --count $TAG..HEAD 2>/dev/null) + + # Did getting the count of commits since the tag succeed? + if [ $? != 0 ] || [ -z "$BUILD" ]; then + printf -- "-unknown" + exit 0 + fi + + # Is the build greater than zero? + if [ $((BUILD)) -gt 0 ]; then + printf -- "-%04d" "$((BUILD))" + fi +fi diff --git a/contrib/semver/version.sh b/contrib/semver/version.sh index 379707e..d2ec6ce 100644 --- a/contrib/semver/version.sh +++ b/contrib/semver/version.sh @@ -1,42 +1,11 @@ #!/bin/sh -# Get the last tag -TAG=$(git describe --abbrev=0 --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" 2>/dev/null) - -# Did getting the tag succeed? -if [ $? != 0 ] || [ -z "$TAG" ]; then - printf -- "unknown" - exit 0 -fi - -# Get the current branch -BRANCH=$(git symbolic-ref -q HEAD --short 2>/dev/null) - -# Did getting the branch succeed? -if [ $? != 0 ] || [ -z "$BRANCH" ]; then - BRANCH="master" -fi - -# 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) -PATCH=$(echo $TAG | cut -c 2- | cut -d "." -f 3) - -# Output in the desired format -printf '%s%d.%d.%s' "$PREPEND" "$((MAJOR))" "$((MINOR))" "$PATCH" - -# Add the build tag on non-master branches -if [ "$BRANCH" != "master" ]; then - BUILD=$(git rev-list --count $TAG..HEAD 2>/dev/null) - - # Did getting the count of commits since the tag succeed? - if [ $? != 0 ] || [ -z "$BUILD" ]; then - printf -- "-unknown" - exit 0 - fi - - # Is the build greater than zero? - if [ $((BUILD)) -gt 0 ]; then - printf -- "-%04d" "$((BUILD))" - fi -fi +case "$*" in + *--bare*) + # Remove the "v" prefix + git describe --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" | cut -c 2- + ;; + *) + git describe --tags --match="v[0-9]*\.[0-9]*\.[0-9]*" + ;; +esac diff --git a/go.mod b/go.mod index e1fa431..b8d8816 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/popura-network/Popura go 1.16 require ( - github.com/cheggaaa/pb/v3 v3.0.6 + github.com/cheggaaa/pb/v3 v3.0.8 github.com/gologme/log v1.2.0 github.com/hashicorp/go-syslog v1.0.0 github.com/hjson/hjson-go v3.1.0+incompatible @@ -12,10 +12,8 @@ require ( github.com/miekg/dns v1.1.41 // indirect github.com/mitchellh/mapstructure v1.4.1 github.com/vishvananda/netlink v1.1.0 - github.com/yggdrasil-network/yggdrasil-go v0.3.16 + github.com/yggdrasil-network/yggdrasil-go v0.4.0 github.com/zhoreeq/meshname v0.1.0 - golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670 // indirect - golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4 - golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d // indirect - golang.org/x/text v0.3.6-0.20210220033129-8f690f22cf1c + golang.org/x/net v0.0.0-20210610132358-84b48f89b13b + golang.org/x/text v0.3.7-0.20210503195748-5c7c50ebbd4f ) diff --git a/go.sum b/go.sum index 08708e1..ff15904 100644 --- a/go.sum +++ b/go.sum @@ -1,187 +1,109 @@ -github.com/Arceliar/phony v0.0.0-20191006174943-d0c68492aca0 h1:p3puK8Sl2xK+2FnnIvY/C0N1aqJo2kbEsdAzU+Tnv48= -github.com/Arceliar/phony v0.0.0-20191006174943-d0c68492aca0/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI= +github.com/Arceliar/ironwood v0.0.0-20210619124114-6ad55cae5031 h1:DZVDfYhVdu+0wAiRHoY1olyNkKxIot9UjBnbQFzuUlM= +github.com/Arceliar/ironwood v0.0.0-20210619124114-6ad55cae5031/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk= github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 h1:WndgpSW13S32VLQ3ugUxx2EnnWmgba1kCqPkd4Gk1yQ= github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI= -github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM= github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= -github.com/cheggaaa/pb/v3 v3.0.4 h1:QZEPYOj2ix6d5oEg63fbHmpolrnNiwjUsk+h74Yt4bM= -github.com/cheggaaa/pb/v3 v3.0.4/go.mod h1:7rgWxLrAUcFMkvJuv09+DYi7mMUYi8nO9iOWcvGJPfw= -github.com/cheggaaa/pb/v3 v3.0.6 h1:ULPm1wpzvj60FvmCrX7bIaB80UgbhI+zSaQJKRfCbAs= -github.com/cheggaaa/pb/v3 v3.0.6/go.mod h1:X1L61/+36nz9bjIsrDU52qHKOQukUQe2Ge+YvGuquCw= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= -github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= +github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= +github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= +github.com/cheggaaa/pb/v3 v3.0.8 h1:bC8oemdChbke2FHIIGy9mn4DPJ2caZYQnfbRqwmdCoA= +github.com/cheggaaa/pb/v3 v3.0.8/go.mod h1:UICbiLec/XO6Hw6k+BHEtHeQFzzBH4i2/qk/ow1EJTA= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/gologme/log v0.0.0-20181207131047-4e5d8ccb38e8/go.mod h1:gq31gQ8wEHkR+WekdWsqDuf8pXTUZA9BnnzTuPz1Y9U= +github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= +github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/gologme/log v1.2.0 h1:Ya5Ip/KD6FX7uH0S31QO87nCCSucKtF44TLbTtO7V4c= github.com/gologme/log v1.2.0/go.mod h1:gq31gQ8wEHkR+WekdWsqDuf8pXTUZA9BnnzTuPz1Y9U= github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hjson/hjson-go v3.0.1-0.20190209023717-9147687966d9+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio= -github.com/hjson/hjson-go v3.0.1+incompatible h1:JwOXblcMiBbiWue7iPkoFK9oXSnW8n+qXh/0Fio6TCo= -github.com/hjson/hjson-go v3.0.1+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio= -github.com/hjson/hjson-go v3.0.2-0.20200316202735-d5d0e8b0617d+incompatible h1:v6BPcb9q9U6JDVsuizxBr/piVB/2Y1Q5GWoBybvZVWI= -github.com/hjson/hjson-go v3.0.2-0.20200316202735-d5d0e8b0617d+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio= github.com/hjson/hjson-go v3.1.0+incompatible h1:DY/9yE8ey8Zv22bY+mHV1uk2yRy0h8tKhZ77hEdi0Aw= github.com/hjson/hjson-go v3.1.0+incompatible/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/kardianos/minwinsvc v1.0.0 h1:+JfAi8IBJna0jY2dJGZqi7o15z13JelFIklJCAENALA= github.com/kardianos/minwinsvc v1.0.0/go.mod h1:Bgd0oc+D0Qo3bBytmNtyRKVlp85dAloLKhfxanPFFRc= -github.com/lxn/walk v0.0.0-20191128110447-55ccb3a9f5c1/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ= github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ= -github.com/lxn/win v0.0.0-20191128105842-2da648fda5b4/go.mod h1:ouWl4wViUNh8tPSIwxTVMuS014WakR1hqvBc2I0bMoA= github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= -github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= -github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= -github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= +github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= +github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mdlayher/ndp v0.0.0-20200602162440-17ab9e3e5567 h1:x+xs91ZJ+lr0C6sedWeREvck4uGCt+AA1kKXwsHB6jI= github.com/mdlayher/ndp v0.0.0-20200602162440-17ab9e3e5567/go.mod h1:32w/5dDZWVSEOxyniAgKK4d7dHTuO6TCxWmUznQe3f8= -github.com/miekg/dns v1.1.27 h1:aEH/kqUzUxGJ/UHcEKdJY+ugH6WEzsEBBSPa8zuy1aM= github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= -github.com/miekg/dns v1.1.29 h1:xHBEhR+t5RzcFJjBLJlax2daXOrTYtr9z4WdKEfWFzg= -github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.2.2 h1:dxe5oCinTXiTIcfgmZecdCzPmAJKd46KsCWc35r0TV4= -github.com/mitchellh/mapstructure v1.2.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.3.0 h1:iDwIio/3gk2QtLLEsqU5lInaMzos0hDTz8a6lazSFVw= -github.com/mitchellh/mapstructure v1.3.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/vishvananda/netlink v1.0.0 h1:bqNY2lgheFIu1meHUFSH3d7vG93AFyqg3oGbJCOJgSM= -github.com/vishvananda/netlink v1.0.0/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= -github.com/vishvananda/netns v0.0.0-20190625233234-7109fa855b0f h1:nBX3nTcmxEtHSERBJaIo1Qa26VwRaopnZmfDQUXsF4I= -github.com/vishvananda/netns v0.0.0-20190625233234-7109fa855b0f/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= -github.com/vishvananda/netns v0.0.0-20200520041808-52d707b772fe h1:mjAZxE1nh8yvuwhGHpdDqdhtNu2dgbpk93TwoXuk5so= -github.com/vishvananda/netns v0.0.0-20200520041808-52d707b772fe/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f h1:p4VB7kIXpOQvVn1ZaTIVp+3vuYAXFe3OJEvjbUYJLaA= github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= -github.com/yggdrasil-network/yggdrasil-extras v0.0.0-20200525205615-6c8a4a2e8855/go.mod h1:xQdsh08Io6nV4WRnOVTe6gI8/2iTvfLDQ0CYa5aMt+I= -github.com/yggdrasil-network/yggdrasil-go v0.3.14 h1:vWzYzCQxOruS+J5FkLfXOS0JhCJx1yI9Erj/h2wfZ/E= -github.com/yggdrasil-network/yggdrasil-go v0.3.14/go.mod h1:rkQzLzVHlFdzsEMG+bDdTI+KeWPCZq1HpXRFzwinf6M= -github.com/yggdrasil-network/yggdrasil-go v0.3.15 h1:os+HOx1nyxEv9awTIkliMPgIFljywVOZDroFWz2C2B0= -github.com/yggdrasil-network/yggdrasil-go v0.3.15/go.mod h1:d+Nz6SPeG6kmeSPFL0cvfWfgwEql75fUnZiAONgvyBE= -github.com/yggdrasil-network/yggdrasil-go v0.3.16 h1:M+mcn5Yb2pXaZYTk9b815Ud3A46SeEXYgaR7IjW67MU= -github.com/yggdrasil-network/yggdrasil-go v0.3.16/go.mod h1:OU9MNryPJKkr9riNCEERrnxSQlOqf6xR5v7SuZrT/5E= -github.com/zhoreeq/meshname v0.0.0-20200517140506-5c5e93874284 h1:BziJ6xfXSA7u8Jm7DlIYRrpUxbbtE7o9x3OgxDY2lUQ= -github.com/zhoreeq/meshname v0.0.0-20200517140506-5c5e93874284/go.mod h1:3I8MpFZ304bAYiD+e+ovlMDDZat8aKyUlqllUok4qm0= -github.com/zhoreeq/meshname v0.0.0-20200519200412-cad772d30578 h1:xmEYsm95dzBKWEYTmDdGJer1geUd52WctSXTW84U9ns= -github.com/zhoreeq/meshname v0.0.0-20200519200412-cad772d30578/go.mod h1:3I8MpFZ304bAYiD+e+ovlMDDZat8aKyUlqllUok4qm0= +github.com/yggdrasil-network/yggdrasil-go v0.4.0 h1:H2CS2pTjCTzNQMHFU7sEW3Ge59fQWQbUeh6fVUO1Gi0= +github.com/yggdrasil-network/yggdrasil-go v0.4.0/go.mod h1:/iMJjOrXRsjlFgqhWOPhecOKi7xHmHiY4/En3A42Fog= github.com/zhoreeq/meshname v0.1.0 h1:o7HlQeki4zxv+iorEhmmr4qRQdA2c43/+DLjeOO1Z6g= github.com/zhoreeq/meshname v0.1.0/go.mod h1:3I8MpFZ304bAYiD+e+ovlMDDZat8aKyUlqllUok4qm0= gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f h1:Wku8eEdeJqIOFHtrfkYUByc4bCaTeA6fL0UJgfEiFMI= gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f/go.mod h1:Tiuhl+njh/JIg0uS/sOJVYi0x2HEa5rc1OAaVsb5tAs= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= -golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw= -golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670 h1:gzMM0EjIYiRmJI3+jBdFuoynZlpxa2JQZsolKu09BXo= -golang.org/x/crypto v0.0.0-20210317152858-513c2a44f670/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191003171128-d98b1b443823/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4 h1:b0LrWgu8+q7z4J+0Y3Umo5q1dL7NXBkKBWkaVkAq17E= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191003212358-c178f38b412c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200301040627-c5d0d7b4ec88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200602100848-8d3cce7afc34 h1:u6CI7A++8r4SItZHYe2cWeAEndN4p1p+3Oum/Ft2EzM= golang.org/x/sys v0.0.0-20200602100848-8d3cce7afc34/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225014209-683adc9d29d7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305215415-5cdee2b1b5a0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d h1:jbzgAvDZn8aEnytae+4ou0J0GwFZoHR0hOrTg4qH8GA= -golang.org/x/sys v0.0.0-20210319071255-635bc2c9138d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210309040221-94ec62e08169/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 h1:faDu4veV+8pcThn4fewv6TVlNCezafGoC1gM/mxQLbQ= +golang.org/x/sys v0.0.0-20210611083646-a4fc73990273/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3-0.20191230102452-929e72ca90de h1:aYKJLPSrddB2N7/6OKyFqJ337SXpo61bBuvO5p1+7iY= -golang.org/x/text v0.3.3-0.20191230102452-929e72ca90de/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6-0.20210220033129-8f690f22cf1c h1:SW/oilbeWd6f32u3ZvuYGqZ+wivcp//I3Dy/gByk7Wk= -golang.org/x/text v0.3.6-0.20210220033129-8f690f22cf1c/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7-0.20210503195748-5c7c50ebbd4f h1:yQJrRE0hDxDFmZLlRaw+3vusO4fwNHgHIjUOMO7bHYI= +golang.org/x/text v0.3.7-0.20210503195748-5c7c50ebbd4f/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.zx2c4.com/wireguard v0.0.0-20210225140808-70b7b7158fc9/go.mod h1:39ZQQ95hUxDxT7opsWy/rtfgvXXc8s30qfZ02df69Fo= -golang.zx2c4.com/wireguard v0.0.0-20210306175010-7e3b8371a1bf h1:AtdIMfzvVNPXN4kVY/yWS8mvpQogSwtCRJk2y/LBPpg= -golang.zx2c4.com/wireguard v0.0.0-20210306175010-7e3b8371a1bf/go.mod h1:ojGPy+9W6ZSM8anL+xC67fvh8zPQJwA6KpFOHyDWLX4= -golang.zx2c4.com/wireguard v0.0.20200122-0.20200214175355-9cbcff10dd3e/go.mod h1:P2HsVp8SKwZEufsnezXZA4GRX/T49/HlU7DGuelXsU4= -golang.zx2c4.com/wireguard v0.0.20200320 h1:1vE6zVeO7fix9cJX1Z9ZQ+ikPIIx7vIyU0o0tLDD88g= -golang.zx2c4.com/wireguard v0.0.20200320/go.mod h1:lDian4Sw4poJ04SgHh35nzMVwGSYlPumkdnHcucAQoY= -golang.zx2c4.com/wireguard/windows v0.1.0 h1:742izt2DAJBpIQT+DvrzN58P9p7fO4BUFOgMzY9qVhw= -golang.zx2c4.com/wireguard/windows v0.1.0/go.mod h1:EK7CxrFnicmYJ0ZCF6crBh2/EMMeSxMlqgLlwN0Kv9s= -golang.zx2c4.com/wireguard/windows v0.3.8 h1:FvfBEhdZZTwthLuPHdyP6zpivYL3enopxd4XpggAufM= -golang.zx2c4.com/wireguard/windows v0.3.8/go.mod h1:lm7dxHcBuzMNq706Ge1tZKZKw4+19vG9dLOhoDX05HQ= +golang.zx2c4.com/wireguard v0.0.0-20210510202332-9844c74f67ec/go.mod h1:a057zjmoc00UN7gVkaJt2sXVK523kMJcogDTEvPIasg= +golang.zx2c4.com/wireguard v0.0.0-20210604143328-f9b48a961cd2 h1:wfOOSvHgIzTZ9h5Vb6yUFZNn7uf3bT7PeYsHOO7tYDM= +golang.zx2c4.com/wireguard v0.0.0-20210604143328-f9b48a961cd2/go.mod h1:laHzsbfMhGSobUmruXWAyMKKHSqvIcrqZJMyHD+/3O8= +golang.zx2c4.com/wireguard/windows v0.3.14 h1:5yIDYyrQyGkLqV+tzY4ilMNeIvQeMXAz0glZz9u179A= +golang.zx2c4.com/wireguard/windows v0.3.14/go.mod h1:3P4IEAsb+BjlKZmpUXgy74c0iX9AVwwr3WcVJ8nPgME= diff --git a/src/autopeering/module.go b/src/autopeering/module.go index b7ca61d..336fb1c 100644 --- a/src/autopeering/module.go +++ b/src/autopeering/module.go @@ -10,7 +10,7 @@ import ( "github.com/yggdrasil-network/yggdrasil-go/src/admin" "github.com/yggdrasil-network/yggdrasil-go/src/config" - "github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil" + "github.com/yggdrasil-network/yggdrasil-go/src/core" "github.com/popura-network/Popura/src/popura" ) @@ -22,7 +22,7 @@ const ( ) type AutoPeering struct { - core *yggdrasil.Core + core *core.Core log *log.Logger checkPeerTimer *time.Timer hadPeers time.Time @@ -30,8 +30,8 @@ type AutoPeering struct { publicPeers *[]string } -func (ap *AutoPeering) Init(core *yggdrasil.Core, state *config.NodeState, popConfig *popura.PopuraConfig, log *log.Logger, options interface{}) error { - ap.core = core +func (ap *AutoPeering) Init(yggcore *core.Core, yggConfig *config.NodeConfig, popConfig *popura.PopuraConfig, log *log.Logger, options interface{}) error { + ap.core = yggcore ap.log = log proxyEnv := os.Getenv("ALL_PROXY") @@ -67,8 +67,8 @@ func (ap *AutoPeering) Stop() error { func (ap *AutoPeering) checkPeerLoop() { havePeers := false - for _, p := range ap.core.GetSwitchPeers() { - if p.Endpoint[:4] != linkLocalPrefix { + for _, p := range ap.core.GetPeers() { + if p.Remote[:4] != linkLocalPrefix { havePeers = true break } @@ -83,7 +83,7 @@ func (ap *AutoPeering) checkPeerLoop() { peerUri := ap.getPeerUri(peers[0]) ap.log.Infoln("autopeering: adding new peer", peerUri) - if err := ap.core.AddPeer(peerUri, ""); err != nil { + if err := ap.core.CallPeer(peerUri, ""); err != nil { ap.log.Infoln("autopeering: Failed to connect to peer:", err) } } @@ -95,11 +95,14 @@ func (ap *AutoPeering) checkPeerLoop() { } // Return peer URI with respect to proxy environment settings -func (ap *AutoPeering) getPeerUri(uri string) string { - if !ap.proxyURL.IsAbs() { - return uri +func (ap *AutoPeering) getPeerUri(uriString string) *url.URL { + if ap.proxyURL.IsAbs() { + uriString = fmt.Sprintf("socks://%s/%s", ap.proxyURL.Host, uriString[6:len(uriString)]) } - return fmt.Sprintf("socks://%s/%s", ap.proxyURL.Host, uri[6:len(uri)]) + + uri, _ := url.Parse(uriString) + + return uri } func (ap *AutoPeering) UpdateConfig(yggConfig *config.NodeConfig, popConfig *popura.PopuraConfig) {} diff --git a/src/autopeering/peers.go b/src/autopeering/peers.go index 86c4804..4228a12 100644 --- a/src/autopeering/peers.go +++ b/src/autopeering/peers.go @@ -1,123 +1,67 @@ package autopeering + var PublicPeers = []string{ - "tcp://104.248.15.125:31337", - "tcp://108.175.10.127:61216", - "tcp://139.162.119.37:44478", - "tcp://140.238.168.104:17117", - "tcp://176.101.222.31:27363", - "tcp://176.215.237.83:2755", - "tcp://176.223.130.120:22632", - "tcp://188.226.125.64:54321", - "tcp://194.177.21.156:5066", + "tcp://159.203.12.215:1010", + "tls://159.203.12.215:1020", "tcp://195.123.245.146:7743", - "tcp://198.58.100.240:44478", - "tcp://[2001:19f0:5401:272a:5400:2ff:fe21:7a26]:8082", - "tcp://[2001:19f0:7402:431:5400:2ff:fe21:7912]:8082", - "tcp://[2001:1af8:4700:a119:7::1]:35239", - "tcp://[2001:41d0:2:c44a:51:255:223:60]:26409", - "tcp://[2001:41d0:401:3000::4227]:62506", - "tcp://[2001:41d0:601:1100::cf2]:37145", - "tcp://[2001:8d8:1800:8224::1]:61216", - "tcp://[2001:bc8:1820:192f::1]:62486", - "tcp://212.129.52.193:39565", "tcp://217.195.164.4:10000", - "tcp://[2400:8902::f03c:91ff:fe1f:c32a]:44478", - "tcp://[2600:3c00::f03c:91ff:feae:3efa]:44478", - "tcp://[2604:a880:400:d0::16e5:7001]:19103", - "tcp://[2604:a880:800:c1::2c2:a001]:31337", - "tcp://[2607:f1c0:1801:d4::1]:61216", - "tcp://[2804:49fc::ffff:ffff:5b5:e8be]:58301", - "tcp://[2a00:b700:2::6:69]:1333", - "tcp://[2a02:17d0:1b4:bddd::7]:54321", + "tcp://37.205.14.171:46370", "tcp://[2a03:3b40:fe:ab::1]:46370", - "tcp://[2a03:6f00:5:1::59df:79d3]:5353", - "tcp://[2a05:3580:d900:1b13:e2d5:5eff:fed8:8b86]:8777", "tcp://[2a05:9403::8b]:7743", - "tcp://37.205.14.171:46370", - "tcp://45.11.19.26:5001", - "tcp://45.231.133.188:58301", - "tcp://45.76.137.140:8082", - "tcp://45.77.107.150:34660", - "tcp://46.105.92.61:62506", - "tcp://46.151.26.194:60575", - "tcp://50.236.201.218:56088", - "tcp://51.15.118.10:62486", + "tls://217.195.164.4:10531", + "tcp://212.129.52.193:39565", "tcp://51.15.204.214:12345", - "tcp://51.255.223.60:26409", - "tcp://51.75.44.73:50001", - "tcp://54.37.137.221:37145", - "tcp://64.112.176.176:1617", - "tcp://64.112.177.94:1617", - "tcp://64.112.180.77:1617", - "tcp://64.112.182.119:1617", - "tcp://64.112.182.182:1617", - "tcp://67.205.187.55:19103", - "tcp://78.27.153.163:33165", - "tcp://82.165.69.111:61216", - "tcp://85.17.15.221:35239", - "tcp://88.201.129.205:8777", - "tcp://89.223.121.211:5353", - "tcp://91.206.93.65:1333", - "tcp://95.165.99.143:61933", - "tcp://ams1.y.sota.sh:8080", - "tcp://curiosity.tdjs.tech:30003", - "tcp://edge.v4.hel1.devices.y.samip.fi:65444", - "tcp://edge.v4.tku1.devices.y.samip.fi:65444", - "tcp://edge.v6.hel1.devices.y.samip.fi:65444", - "tcp://edge.v6.tku1.devices.y.samip.fi:65444", - "tcp://glimmy.092918.xyz:50001", - "tcp://hindsight.krvtz.net:8082", - "tcp://lancis.iscute.moe:49273", - "tcp://lan.tdem.in:50001", - "tcp://n2o.ddns.net:22632", - "tcp://nessie.krvtz.net:8082", - "tcp://vps.tomasgl.ru:61933", - "tcp://yggdrasil.frank2.net:1337", - "tcp://ygg.loskiq.com:17313", - "tcp://yggnode.ddns.net:18226", - "tcp://yggnode.ddns.net:18228", - "tcp://y.zbin.eu:7743", - "tls://104.248.15.125:32337", - "tls://140.238.168.104:17121", - "tls://176.101.222.31:27364", - "tls://176.215.237.83:2756", - "tls://194.177.21.156:5068", - "tls://[2001:41d0:2:c44a:51:255:223:60]:10259", - "tls://[2001:41d0:401:3000::4227]:46394", - "tls://[2001:41d0:601:1100::cf2]:14987", + "tcp://[2001:470:1f13:e56::64]:39565", "tls://212.129.52.193:39575", - "tls://217.195.164.4:10531", - "tls://[2604:a880:400:d0::16e5:7001]:19102", - "tls://[2604:a880:800:c1::2c2:a001]:32337", - "tls://[2a00:b700:2::6:69]:1444", - "tls://[2a01:d0:ffff:4353::2]:6010", - "tls://[2a02:1802:5e:0:18d2:e2ff:fe44:17d2]:9944", - "tls://[2a02:1802:5e:0:4b7:c2ff:fe29:ba37]:9944", - "tls://[2a02:1802:5e:0:7cc7:cdff:fe28:128a]:9944", - "tls://[2a02:1802:5e:0:8854:12ff:fe35:65b3]:9944", - "tls://[2a02:1802:5e:0:900c:33ff:fea5:7aec]:9944", - "tls://[2a02:1802:5e:0:b841:d3ff:feb2:9a81]:9944", - "tls://[2a02:1802:5e:0:b84d:bdff:fe90:1a82]:9944", - "tls://[2a02:1802:5e:0:bc20:44ff:fe93:6353]:9944", - "tls://[2a05:3580:d900:1b13:e2d5:5eff:fed8:8b86]:8778", - "tls://45.11.19.26:5002", + "tls://51.15.204.214:54321", + "tls://[2001:470:1f13:e56::64]:39575", + "tcp://94.130.203.208:5999", + "tcp://bunkertreff.ddns.net:5454", + "tcp://ygg.cofob.ru:80", + "tcp://yugudorashiru.de:80", + "tls://ygg.cofob.ru:443", + "tls://yugudorashiru.de:443", + "tcp://213.188.197.95:10010", + "tcp://[2a09:8280:1::3:313]:10010", + "tls://213.188.197.95:10020", + "tls://[2a09:8280:1::3:313]:10020", "tls://45.147.198.155:6010", - "tls://46.105.92.61:46394", + "tls://94.103.82.150:8080", + "tcp://yggdrasil.frank2.net:1337", + "tcp://185.165.169.234:8880", + "tls://185.165.169.234:8443", + "tcp://46.151.26.194:60575", + "tcp://lan.tdem.in:50001", + "tcp://ygg-ru.cofob.ru:18000", + "tcp://ygg-ru2.cofob.ru:80", + "tcp://ygg.loskiq.dev:17313", + "tcp://ygg.tomasgl.ru:61933", + "tcp://ygg.tomasgl.ru:61933?key=c5e0c28a600c2118e986196a0bbcbda4934d8e9278ceabea48838dc5d8fae576", + "tcp://yggnode.cf:18226", + "tls://185.22.60.71:8443", "tls://46.151.26.194:8443", - "tls://51.255.223.60:10259", - "tls://54.37.137.221:14987", - "tls://67.205.187.55:19102", + "tls://[2a01:d0:ffff:4353::2]:6010", + "tls://lan.tdem.in:50002", + "tls://ygg-ru.cofob.ru:18001", + "tls://ygg-ru2.cofob.ru:443", + "tls://ygg.loskiq.dev:17314", + "tls://ygg.tomasgl.ru:61944", + "tls://ygg.tomasgl.ru:61944?key=c5e0c28a600c2118e986196a0bbcbda4934d8e9278ceabea48838dc5d8fae576", + "tls://yggnode.cf:18227", + "tcp://y.zbin.eu:7743", + "tcp://[2a04:5b81:2010::90]:2000", + "tls://185.130.44.194:7040", + "tls://[2a07:e01:105:444:c634:6bff:feb5:6e28]:7040", + "tcp://140.238.168.104:17117", + "tls://140.238.168.104:17121", + "tcp://78.27.153.163:33165", "tls://78.27.153.163:33166", - "tls://88.201.129.205:8778", - "tls://91.206.93.65:1444", - "tls://edge.v4.hel1.devices.y.samip.fi:65445", - "tls://edge.v4.tku1.devices.y.samip.fi:65445", - "tls://edge.v6.hel1.devices.y.samip.fi:65445", - "tls://edge.v6.tku1.devices.y.samip.fi:65445", - "tls://glimmy.092918.xyz:58008", + "tcp://curiosity.tdjs.tech:30003", + "tcp://213.188.199.150:10010", + "tcp://213.188.210.9:10010", + "tcp://[2a09:8280:1::3:312]:10010", + "tcp://[2a09:8280:1::a:2e2]:10010", + "tcp://lancis.iscute.moe:49273", + "tcp://longseason.1200bps.xyz:13121", "tls://lancis.iscute.moe:49274", - "tls://lan.tdem.in:50002", - "tls://vps.tomasgl.ru:61944", - "tls://ygg.loskiq.com:17314", - "tls://yggnode.ddns.net:18227", - "tls://yggnode.ddns.net:18229"} + "tls://longseason.1200bps.xyz:13122"} diff --git a/src/meshname/module.go b/src/meshname/module.go index 148f5fd..e4f1d9e 100644 --- a/src/meshname/module.go +++ b/src/meshname/module.go @@ -7,7 +7,7 @@ import ( "github.com/yggdrasil-network/yggdrasil-go/src/admin" "github.com/yggdrasil-network/yggdrasil-go/src/config" - "github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil" + "github.com/yggdrasil-network/yggdrasil-go/src/core" _meshname "github.com/zhoreeq/meshname/pkg/meshname" @@ -20,7 +20,7 @@ type MeshnameServer struct { enable bool } -func (s *MeshnameServer) Init(core *yggdrasil.Core, state *config.NodeState, popConfig *popura.PopuraConfig, log *log.Logger, options interface{}) error { +func (s *MeshnameServer) Init(yggcore *core.Core, yggConfig *config.NodeConfig, popConfig *popura.PopuraConfig, log *log.Logger, options interface{}) error { s.log = log s.enable = popConfig.Meshname.Enable yggIPNet := &net.IPNet{IP: net.ParseIP("200::"), Mask: net.CIDRMask(7, 128)} diff --git a/src/popura/config.go b/src/popura/config.go index 64f3ef5..2c7bdef 100644 --- a/src/popura/config.go +++ b/src/popura/config.go @@ -12,6 +12,7 @@ import ( "github.com/mitchellh/mapstructure" "github.com/yggdrasil-network/yggdrasil-go/src/config" + "github.com/yggdrasil-network/yggdrasil-go/src/defaults" ) type PopuraConfig struct { @@ -26,11 +27,11 @@ type MeshnameConfig struct { } type RAdvConfig struct { - Enable bool `comment:"Enable or disable Router Advertisement"` - Interface string `comment:"Send router advertisement for this network interface"` - SetGatewayIP bool `comment:"Set IP address on the Interface automatically"` - DefaultRouter bool `comment:"Advertise a default router (a fix for Android)"` - DNS bool `comment:"Advertise this router as a DNS server (RFC 8106)"` + Enable bool `comment:"Enable or disable Router Advertisement"` + Interface string `comment:"Send router advertisement for this network interface"` + SetGatewayIP bool `comment:"Set IP address on the Interface automatically"` + DefaultRouter bool `comment:"Advertise a default router (a fix for Android)"` + DNS bool `comment:"Advertise this router as a DNS server (RFC 8106)"` } func GenerateConfig() (*config.NodeConfig, *PopuraConfig) { @@ -46,29 +47,11 @@ func GenerateConfig() (*config.NodeConfig, *PopuraConfig) { popConfig.RAdv.DefaultRouter = false popConfig.RAdv.DNS = false - return config.GenerateConfig(), &popConfig + return defaults.GenerateConfig(), &popConfig } // initialize empty values for correct JSON serialization func correctEmptyValues(yggConfig *config.NodeConfig) { - if len(yggConfig.TunnelRouting.IPv4LocalSubnets) == 0 { - yggConfig.TunnelRouting.IPv4LocalSubnets = []string{} - } - if len(yggConfig.TunnelRouting.IPv6LocalSubnets) == 0 { - yggConfig.TunnelRouting.IPv6LocalSubnets = []string{} - } - if len(yggConfig.TunnelRouting.IPv4RemoteSubnets) == 0 { - yggConfig.TunnelRouting.IPv4RemoteSubnets = make(map[string]string) - } - if len(yggConfig.TunnelRouting.IPv6RemoteSubnets) == 0 { - yggConfig.TunnelRouting.IPv6RemoteSubnets = make(map[string]string) - } - if len(yggConfig.SessionFirewall.WhitelistEncryptionPublicKeys) == 0 { - yggConfig.SessionFirewall.WhitelistEncryptionPublicKeys = []string{} - } - if len(yggConfig.SessionFirewall.BlacklistEncryptionPublicKeys) == 0 { - yggConfig.SessionFirewall.BlacklistEncryptionPublicKeys = []string{} - } if len(yggConfig.NodeInfo) == 0 { yggConfig.NodeInfo = make(map[string]interface{}) } diff --git a/src/popura/module.go b/src/popura/module.go index 7051435..8bb223f 100644 --- a/src/popura/module.go +++ b/src/popura/module.go @@ -5,13 +5,13 @@ import ( "github.com/yggdrasil-network/yggdrasil-go/src/admin" "github.com/yggdrasil-network/yggdrasil-go/src/config" - "github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil" + "github.com/yggdrasil-network/yggdrasil-go/src/core" ) // Module is an interface that defines which functions must be supported by a // given Popura module. type Module interface { - Init(core *yggdrasil.Core, state *config.NodeState, popuraConf *PopuraConfig, log *log.Logger, options interface{}) error + Init(yggcore *core.Core, yggConfig *config.NodeConfig, popuraConf *PopuraConfig, log *log.Logger, options interface{}) error Start() error Stop() error UpdateConfig(yggConf *config.NodeConfig, popuraConf *PopuraConfig) diff --git a/src/popura/utils.go b/src/popura/utils.go new file mode 100644 index 0000000..2748c0c --- /dev/null +++ b/src/popura/utils.go @@ -0,0 +1,36 @@ +package popura + +import ( + "crypto/ed25519" + "encoding/hex" + "net" + + "github.com/yggdrasil-network/yggdrasil-go/src/address" +) + +func decodeKey(input string) ed25519.PublicKey { + keyData, _ := hex.DecodeString(input) + return ed25519.PrivateKey(keyData).Public().(ed25519.PublicKey) +} + +// Get the subnet information from PublicKey +func SubnetFromKey(inputString string) *net.IPNet { + key := decodeKey(inputString) + + snet := address.SubnetForKey(key) + ipnet := net.IPNet{ + IP: append(snet[:], 0, 0, 0, 0, 0, 0, 0, 0), + Mask: net.CIDRMask(len(snet)*8, 128), + } + + return &ipnet +} + +// Get the address information from PublicKey +func AddressFromKey(inputString string) *net.IP { + key := decodeKey(inputString) + + addr := address.AddrForKey(key) + ip := net.IP(addr[:]) + return &ip +} diff --git a/src/radv/radv.go b/src/radv/radv.go index 9ba1c09..3d60941 100644 --- a/src/radv/radv.go +++ b/src/radv/radv.go @@ -1,7 +1,6 @@ package radv import ( - "encoding/hex" "math/rand" "net" "time" @@ -9,11 +8,9 @@ import ( "github.com/gologme/log" "github.com/mdlayher/ndp" - "github.com/yggdrasil-network/yggdrasil-go/src/address" "github.com/yggdrasil-network/yggdrasil-go/src/admin" "github.com/yggdrasil-network/yggdrasil-go/src/config" - "github.com/yggdrasil-network/yggdrasil-go/src/crypto" - "github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil" + "github.com/yggdrasil-network/yggdrasil-go/src/core" "github.com/popura-network/Popura/src/popura" ) @@ -27,21 +24,6 @@ const ( maxDelay = 600 * time.Second ) -// Get the subnet information from EncryptopnPublicKey -func getSubnet(inputKey string) *net.IPNet { - pubkey, _ := hex.DecodeString(inputKey) - var box crypto.BoxPubKey - copy(box[:], pubkey[:]) - nodeid := crypto.GetNodeID(&box) - - snet := *address.SubnetForNodeID(nodeid) - ipnet := net.IPNet{ - IP: append(snet[:], 0, 0, 0, 0, 0, 0, 0, 0), - Mask: net.CIDRMask(len(snet)*8, 128), - } - return &ipnet -} - type RAdv struct { log *log.Logger conn *ndp.Conn @@ -51,11 +33,9 @@ type RAdv struct { quit chan struct{} } -func (s *RAdv) Init(core *yggdrasil.Core, state *config.NodeState, popConfig *popura.PopuraConfig, log *log.Logger, options interface{}) error { - yggConfig := state.GetCurrent() - +func (s *RAdv) Init(yggcore *core.Core, yggConfig *config.NodeConfig, popConfig *popura.PopuraConfig, log *log.Logger, options interface{}) error { s.log = log - s.subnet = getSubnet(yggConfig.EncryptionPublicKey) + s.subnet = popura.SubnetFromKey(yggConfig.PrivateKey) s.config = popConfig.RAdv s.quit = make(chan struct{}, 2) @@ -103,17 +83,17 @@ func (s *RAdv) Start() error { routerLifetime = time.Second * 1800 } else { options = append(options, &ndp.RouteInformation{ - PrefixLength: 7, - Preference: ndp.Medium, + PrefixLength: 7, + Preference: ndp.Medium, RouteLifetime: time.Second * 1800, - Prefix: yggdrasilPrefixIP, + Prefix: yggdrasilPrefixIP, }) } if s.config.DNS { options = append(options, &ndp.RecursiveDNSServer{ Lifetime: time.Second * 4294967295, - Servers: []net.IP{ ip }, + Servers: []net.IP{ip}, }) } @@ -125,7 +105,7 @@ func (s *RAdv) Start() error { RouterLifetime: routerLifetime, ReachableTime: time.Second * 0, RetransmitTimer: time.Second * 0, - Options: options, + Options: options, } advTrigger := make(chan struct{}) @@ -226,7 +206,7 @@ func (s *RAdv) Stop() error { func (s *RAdv) UpdateConfig(yggConfig *config.NodeConfig, popConfig *popura.PopuraConfig) { s.Stop() - s.subnet = getSubnet(yggConfig.EncryptionPublicKey) + s.subnet = popura.SubnetFromKey(yggConfig.PrivateKey) s.config = popConfig.RAdv s.quit = make(chan struct{}, 2) if err := s.Start(); err != nil {