add outfile support (#3421)

This commit is contained in:
Preston Van Loon
2019-09-08 11:08:46 -07:00
committed by Nishant Das
parent adc27a0bc2
commit d94522510f

View File

@@ -5,6 +5,7 @@ package main
import (
"crypto/ecdsa"
"flag"
"io/ioutil"
"net"
"github.com/btcsuite/btcd/btcec"
@@ -19,6 +20,7 @@ var (
privateKey = flag.String("private", "", "Base-64 encoded Private key to use for calculation of ENR")
port = flag.Int("port", 0, "Port to use for calculation of ENR")
ipAddr = flag.String("ipAddress", "", "IP to use in calculation of ENR")
outfile = flag.String("out", "", "Filepath to write ENR")
)
func main() {
@@ -61,4 +63,12 @@ func main() {
localNode.Set(ipEntry)
localNode.Set(udpEntry)
log.Info(localNode.Node().String())
if *outfile != "" {
err := ioutil.WriteFile(*outfile, []byte(localNode.Node().String()), 0644)
if err != nil {
panic(err)
}
log.Infof("Wrote to %s", *outfile)
}
}