cmd/bootnode: print node URL on startup (#18516)

Also say that cmd/bootnode is not for production use.
This commit is contained in:
Felix Lange 2019-01-25 12:39:52 +01:00 committed by GitHub
parent f28da4f602
commit 17723a5294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,12 +112,13 @@ func main() {
if !realaddr.IP.IsLoopback() { if !realaddr.IP.IsLoopback() {
go nat.Map(natm, nil, "udp", realaddr.Port, realaddr.Port, "ethereum discovery") go nat.Map(natm, nil, "udp", realaddr.Port, realaddr.Port, "ethereum discovery")
} }
// TODO: react to external IP changes over time.
if ext, err := natm.ExternalIP(); err == nil { if ext, err := natm.ExternalIP(); err == nil {
realaddr = &net.UDPAddr{IP: ext, Port: realaddr.Port} realaddr = &net.UDPAddr{IP: ext, Port: realaddr.Port}
} }
} }
printNotice(&nodeKey.PublicKey, *realaddr)
if *runv5 { if *runv5 {
if _, err := discv5.ListenUDP(nodeKey, conn, "", restrictList); err != nil { if _, err := discv5.ListenUDP(nodeKey, conn, "", restrictList); err != nil {
utils.Fatalf("%v", err) utils.Fatalf("%v", err)
@ -136,3 +137,13 @@ func main() {
select {} select {}
} }
func printNotice(nodeKey *ecdsa.PublicKey, addr net.UDPAddr) {
if addr.IP.IsUnspecified() {
addr.IP = net.IP{127, 0, 0, 1}
}
n := enode.NewV4(nodeKey, addr.IP, 0, addr.Port)
fmt.Println(n.String())
fmt.Println("Note: you're using cmd/bootnode, a developer tool.")
fmt.Println("We recommend using a regular node as bootstrap node for production deployments.")
}