cmd/torrentfs/main.go | 12 +++++++++++- diff --git a/cmd/torrentfs/main.go b/cmd/torrentfs/main.go index e8e7211d6c4bd1b92c77efc5eb7602630b37b1f7..16fa3bf2d5e81e835bb700d980a0c5be6e3f371d 100644 --- a/cmd/torrentfs/main.go +++ b/cmd/torrentfs/main.go @@ -30,6 +30,7 @@ testPeer = flag.String("testPeer", "", "the address for a test peer") httpAddr = flag.String("httpAddr", "localhost:0", "HTTP server bind address") readaheadBytes = flag.Int("readaheadBytes", 10*1024*1024, "bytes to readahead in each torrent from the last read piece") testPeerAddr *net.TCPAddr + listenAddr = flag.String("listenAddr", ":6882", "incoming connection address") ) func init() { @@ -42,6 +43,14 @@ } return filepath.Join(_user.HomeDir, ".config/transmission/torrents") }(), "torrent files in this location describe the contents of the mounted filesystem") flag.StringVar(&mountDir, "mountDir", "", "location the torrent contents are made available") +} + +func makeListener() net.Listener { + l, err := net.Listen("tcp", *listenAddr) + if err != nil { + log.Fatal(err) + } + return l } func resolveTestPeerAddr() { @@ -107,7 +116,8 @@ defer conn.Close() client := &torrent.Client{ DataDir: downloadDir, DisableTrackers: *disableTrackers, - DownloadStrategy: &torrent.ResponsiveDownloadStrategy{*readaheadBytes}, + DownloadStrategy: torrent.NewResponsiveDownloadStrategy(*readaheadBytes), + Listener: makeListener(), } http.DefaultServeMux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { client.WriteStatus(w)