Skip to content

Commit

Permalink
add bootstrapPeers command line flag
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Oct 5, 2018
1 parent e1a93a8 commit bd604c4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions p2pd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"log"
"strings"

libp2p "github.com/libp2p/go-libp2p"
p2pd "github.com/libp2p/go-libp2p-daemon"
Expand All @@ -18,6 +19,7 @@ func main() {
quiet := flag.Bool("q", false, "be quiet")
id := flag.String("id", "", "peer identity; private key file")
bootstrap := flag.Bool("b", false, "connects to bootstrap peers and bootstraps the dht if enabled")
bootstrapPeers := flag.String("bootstrapPeers", "", "comma separated list of bootstrap peers; defaults to the IPFS DHT peers")
dht := flag.Bool("dht", false, "Enables the DHT in full node mode")
dhtClient := flag.Bool("dhtClient", false, "Enables the DHT in client mode")
flag.Parse()
Expand Down Expand Up @@ -45,6 +47,10 @@ func main() {
}
}

if *bootstrapPeers != "" {
p2pd.BootstrapPeers = strings.Split(*bootstrapPeers, ",")
}

if *bootstrap {
err = d.Bootstrap()
if err != nil {
Expand All @@ -59,6 +65,12 @@ func main() {
for _, addr := range d.Addrs() {
fmt.Printf("%s\n", addr.String())
}
if *bootstrap && *bootstrapPeers != "" {
fmt.Printf("Bootstrap peers:\n")
for _, p := range p2pd.BootstrapPeers {
fmt.Printf("%s\n", p)
}
}
}

select {}
Expand Down

0 comments on commit bd604c4

Please sign in to comment.