diff --git a/README-zh.md b/README-zh.md index 1e821c2..bc713b3 100644 --- a/README-zh.md +++ b/README-zh.md @@ -22,7 +22,7 @@ Usage: torsniff [flags] Flags: - -a, --addr string listen on given address (default "0.0.0.0") + -a, --addr string listen on given address (default all, ipv4 and ipv6) -d, --dir string the directory to store the torrents (default "$HOME/torrents") -h, --help help for torsniff -f, --friends int max fiends to make with per second (default 500) diff --git a/README.md b/README.md index bdde520..41f23fe 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Usage: torsniff [flags] Flags: - -a, --addr string listen on given address (default "0.0.0.0") + -a, --addr string listen on given address (default all, ipv4 and ipv6) -d, --dir string the directory to store the torrents (default "$HOME/torrents") -h, --help help for torsniff -f, --friends int max fiends to make with per second (default 500) diff --git a/build.sh b/build.sh index 89502d3..9fc24cd 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ GOARCH=amd64 GOOS=linux go build -o releases/torsniff-${VERSION}-linux-amd64 GOARCH=386 GOOS=linux go build -o releases/torsniff-${VERSION}-linux-386 -GOARCH=amd64 GOOS=windows go build -o releases/torsniff-${VERSION}-windows-amd64 -GOARCH=386 GOOS=windows go build -o releases/torsniff-${VERSION}-windows-386 +GOARCH=amd64 GOOS=windows go build -o releases/torsniff-${VERSION}-windows-amd64.exe +GOARCH=386 GOOS=windows go build -o releases/torsniff-${VERSION}-windows-386.exe GOARCH=amd64 GOOS=darwin go build -o releases/torsniff-${VERSION}-darwin-amd64 diff --git a/dht.go b/dht.go index ab0be77..fdc8fd5 100644 --- a/dht.go +++ b/dht.go @@ -155,7 +155,7 @@ type dht struct { } func newDHT(laddr string, maxFriendsPerSec int) (*dht, error) { - conn, err := net.ListenPacket("udp4", laddr) + conn, err := net.ListenPacket("udp", laddr) if err != nil { return nil, err } @@ -277,7 +277,7 @@ func (d *dht) findNode(to string, target nodeID) { "target": string(randBytes(20)), }) - addr, err := net.ResolveUDPAddr("udp4", to) + addr, err := net.ResolveUDPAddr("udp", to) if err != nil { return } diff --git a/torsniff.go b/torsniff.go index 69c45b3..6100953 100644 --- a/torsniff.go +++ b/torsniff.go @@ -5,9 +5,11 @@ import ( "fmt" "io/ioutil" "log" + "net" "os" "path" "path/filepath" + "strconv" "strings" "time" @@ -143,7 +145,6 @@ func (t *torsniff) run() error { } } - return nil } func (t *torsniff) work(ac *announcement, tokens chan struct{}) { @@ -258,7 +259,7 @@ func main() { } p := &torsniff{ - laddr: fmt.Sprintf("%s:%d", addr, port), + laddr: net.JoinHostPort(addr, strconv.Itoa(int(port))), timeout: timeout, maxFriends: friends, maxPeers: peers, @@ -269,7 +270,7 @@ func main() { return p.run() } - root.Flags().StringVarP(&addr, "addr", "a", "0.0.0.0", "listen on given address") + root.Flags().StringVarP(&addr, "addr", "a", "", "listen on given address (default all, ipv4 and ipv6)") root.Flags().Uint16VarP(&port, "port", "p", 6881, "listen on given port") root.Flags().IntVarP(&friends, "friends", "f", 500, "max fiends to make with per second") root.Flags().IntVarP(&peers, "peers", "e", 400, "max peers to connect to download torrents") @@ -278,6 +279,6 @@ func main() { root.Flags().BoolVarP(&verbose, "verbose", "v", true, "run in verbose mode") if err := root.Execute(); err != nil { - fmt.Errorf("could not start: %s\n", err) + fmt.Println(fmt.Errorf("could not start: %s", err)) } }