add command line flag for control socket path

This commit is contained in:
vyzo 2018-09-15 10:38:21 +03:00
parent 2de67165b8
commit 55f594a893
1 changed files with 6 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"context"
"flag"
"fmt"
"log"
@ -9,13 +10,15 @@ import (
)
func main() {
sock := "/tmp/p2pd.sock"
d, err := p2pd.NewDaemon(context.Background(), sock)
sock := flag.String("sock", "/tmp/p2pd.sock", "daemon control socket path")
flag.Parse()
d, err := p2pd.NewDaemon(context.Background(), *sock)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Control socket: %s\n", sock)
fmt.Printf("Control socket: %s\n", *sock)
fmt.Printf("Peer ID: %s\n", d.ID().Pretty())
fmt.Printf("Peer Addrs:\n")
for _, addr := range d.Addrs() {