mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 06:20:26 +00:00
Merge pull request #86 from neilalexander/youraddresses
Show IPv6 address and subnet on startup
This commit is contained in:
commit
14b2dd0c61
@ -249,7 +249,7 @@ func (a *admin) handleRequest(conn net.Conn) {
|
|||||||
|
|
||||||
// Decode the input
|
// Decode the input
|
||||||
if err := decoder.Decode(&recv); err != nil {
|
if err := decoder.Decode(&recv); err != nil {
|
||||||
// fmt.Println("Admin socket JSON decode error:", err)
|
// fmt.Println("Admin socket JSON decode error:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ func (a *admin) handleRequest(conn net.Conn) {
|
|||||||
|
|
||||||
// Send the response back
|
// Send the response back
|
||||||
if err := encoder.Encode(&send); err != nil {
|
if err := encoder.Encode(&send); err != nil {
|
||||||
// fmt.Println("Admin socket JSON encode error:", err)
|
// fmt.Println("Admin socket JSON encode error:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,3 +62,11 @@ func (c *Core) GetNodeID() *NodeID {
|
|||||||
func (c *Core) GetTreeID() *TreeID {
|
func (c *Core) GetTreeID() *TreeID {
|
||||||
return getTreeID(&c.sigPub)
|
return getTreeID(&c.sigPub)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Core) GetAddress() *address {
|
||||||
|
return address_addrForNodeID(c.GetNodeID())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Core) GetSubnet() *subnet {
|
||||||
|
return address_subnetForNodeID(c.GetNodeID())
|
||||||
|
}
|
||||||
|
@ -272,6 +272,11 @@ func main() {
|
|||||||
n.core.DEBUG_stopTun()
|
n.core.DEBUG_stopTun()
|
||||||
}()
|
}()
|
||||||
logger.Println("Started...")
|
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 {
|
if cfg.Multicast {
|
||||||
addr, err := net.ResolveUDPAddr("udp", multicastAddr)
|
addr, err := net.ResolveUDPAddr("udp", multicastAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -15,13 +15,13 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
args := flag.Args()
|
args := flag.Args()
|
||||||
|
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
fmt.Println("usage:", os.Args[0], "[-endpoint=localhost:9001] command [key=value] [...]")
|
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], "getPeers")
|
||||||
fmt.Println("example:", os.Args[0], "setTunTap name=auto mtu=1500 tap_mode=false")
|
fmt.Println("example:", os.Args[0], "setTunTap name=auto mtu=1500 tap_mode=false")
|
||||||
fmt.Println("example:", os.Args[0], "-endpoint=localhost:9001 getDHT")
|
fmt.Println("example:", os.Args[0], "-endpoint=localhost:9001 getDHT")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := net.Dial("tcp", *server)
|
conn, err := net.Dial("tcp", *server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -58,16 +58,16 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if err := decoder.Decode(&recv); err == nil {
|
if err := decoder.Decode(&recv); err == nil {
|
||||||
if _, ok := recv["request"]; !ok {
|
if _, ok := recv["request"]; !ok {
|
||||||
fmt.Println("Missing request")
|
fmt.Println("Missing request")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, ok := recv["response"]; !ok {
|
if _, ok := recv["response"]; !ok {
|
||||||
fmt.Println("Missing response")
|
fmt.Println("Missing response")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req := recv["request"].(map[string]interface{})
|
req := recv["request"].(map[string]interface{})
|
||||||
res := recv["response"].(map[string]interface{})
|
res := recv["response"].(map[string]interface{})
|
||||||
switch req["request"] {
|
switch req["request"] {
|
||||||
case "dot":
|
case "dot":
|
||||||
fmt.Println(res["dot"])
|
fmt.Println(res["dot"])
|
||||||
@ -78,8 +78,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := recv["status"]; ok && v == "error" {
|
if v, ok := recv["status"]; ok && v == "error" {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user