-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.go
40 lines (32 loc) · 851 Bytes
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/guillaumemichel/passtor"
)
func main() {
name := flag.String("name", "", "name of the Passtor instance")
addr := flag.String("addr", "127.0.0.1:5000", "address used to communicate "+
"other passtors instances")
peers := flag.String("peers", "", "bootstrap peer addresses")
verbose := flag.Int("v", 1, "verbose mode")
flag.Parse()
// help message
flag.Usage = func() {
fmt.Printf("Usage of %s:\n", os.Args[0])
flag.PrintDefaults()
}
p := passtor.NewPasstor(*name, *addr, *verbose)
go p.ListenToPasstors()
go p.ListenToClients()
p.JoinDHT(passtor.ParsePeers(*peers))
// keep the program active until ctrl+c is pressed
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c
p.Printer.Print("", passtor.V0)
os.Exit(0)
}