From bd32f5890b944d7df5519b57aeb6b2f3ce562825 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 21 May 2018 07:28:03 +0100 Subject: [PATCH 1/2] Run gofmt -s -w --- src/yggdrasil/admin.go | 4 ++-- yggdrasilctl.go | 42 +++++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index a76ffc49..0509a303 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -249,7 +249,7 @@ func (a *admin) handleRequest(conn net.Conn) { // Decode the input if err := decoder.Decode(&recv); err != nil { - // fmt.Println("Admin socket JSON decode error:", err) + // fmt.Println("Admin socket JSON decode error:", err) return } @@ -301,7 +301,7 @@ func (a *admin) handleRequest(conn net.Conn) { // Send the response back if err := encoder.Encode(&send); err != nil { - // fmt.Println("Admin socket JSON encode error:", err) + // fmt.Println("Admin socket JSON encode error:", err) return } diff --git a/yggdrasilctl.go b/yggdrasilctl.go index 9d3f3281..ad05963e 100644 --- a/yggdrasilctl.go +++ b/yggdrasilctl.go @@ -15,13 +15,13 @@ func main() { flag.Parse() args := flag.Args() - if len(args) == 0 { - fmt.Println("usage:", os.Args[0], "[-endpoint=localhost:9001] command [key=value] [...]") - fmt.Println("example:", os.Args[0], "getPeers") - fmt.Println("example:", os.Args[0], "setTunTap name=auto mtu=1500 tap_mode=false") - fmt.Println("example:", os.Args[0], "-endpoint=localhost:9001 getDHT") - return - } + if len(args) == 0 { + fmt.Println("usage:", os.Args[0], "[-endpoint=localhost:9001] command [key=value] [...]") + fmt.Println("example:", os.Args[0], "getPeers") + fmt.Println("example:", os.Args[0], "setTunTap name=auto mtu=1500 tap_mode=false") + fmt.Println("example:", os.Args[0], "-endpoint=localhost:9001 getDHT") + return + } conn, err := net.Dial("tcp", *server) if err != nil { @@ -58,16 +58,16 @@ func main() { panic(err) } if err := decoder.Decode(&recv); err == nil { - if _, ok := recv["request"]; !ok { - fmt.Println("Missing request") - return - } - if _, ok := recv["response"]; !ok { - fmt.Println("Missing response") - return - } - req := recv["request"].(map[string]interface{}) - res := recv["response"].(map[string]interface{}) + if _, ok := recv["request"]; !ok { + fmt.Println("Missing request") + return + } + if _, ok := recv["response"]; !ok { + fmt.Println("Missing response") + return + } + req := recv["request"].(map[string]interface{}) + res := recv["response"].(map[string]interface{}) switch req["request"] { case "dot": fmt.Println(res["dot"]) @@ -78,8 +78,8 @@ func main() { } } - if v, ok := recv["status"]; ok && v == "error" { - os.Exit(1) - } - os.Exit(0) + if v, ok := recv["status"]; ok && v == "error" { + os.Exit(1) + } + os.Exit(0) } From 04b3e840238ad6e63f2483000c77a69977ac52f3 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 21 May 2018 16:15:31 +0100 Subject: [PATCH 2/2] Show your IPv6 address and subnet when starting --- src/yggdrasil/core.go | 8 ++++++++ yggdrasil.go | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/yggdrasil/core.go b/src/yggdrasil/core.go index 838feef0..10c46f36 100644 --- a/src/yggdrasil/core.go +++ b/src/yggdrasil/core.go @@ -62,3 +62,11 @@ func (c *Core) GetNodeID() *NodeID { func (c *Core) GetTreeID() *TreeID { return getTreeID(&c.sigPub) } + +func (c *Core) GetAddress() *address { + return address_addrForNodeID(c.GetNodeID()) +} + +func (c *Core) GetSubnet() *subnet { + return address_subnetForNodeID(c.GetNodeID()) +} diff --git a/yggdrasil.go b/yggdrasil.go index c5d08446..7115bded 100644 --- a/yggdrasil.go +++ b/yggdrasil.go @@ -272,6 +272,11 @@ func main() { n.core.DEBUG_stopTun() }() logger.Println("Started...") + address := (*n.core.GetAddress())[:] + subnet := (*n.core.GetSubnet())[:] + subnet = append(subnet, 0, 0, 0, 0, 0, 0, 0, 0) + logger.Printf("Your IPv6 address is %s", net.IP(address).String()) + logger.Printf("Your IPv6 subnet is %s/64", net.IP(subnet).String()) if cfg.Multicast { addr, err := net.ResolveUDPAddr("udp", multicastAddr) if err != nil {