From 324fb946844b1f6edecfc2a6f13290ee626f60f7 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 24 Jul 2014 13:45:49 +1000 Subject: [PATCH] cmd/torrentfs: Missing listener on client --- cmd/torrentfs/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/torrentfs/main.go b/cmd/torrentfs/main.go index e8e7211d..16fa3bf2 100644 --- a/cmd/torrentfs/main.go +++ b/cmd/torrentfs/main.go @@ -30,6 +30,7 @@ var ( 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() { @@ -44,6 +45,14 @@ func init() { 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() { if *testPeer == "" { return @@ -107,7 +116,8 @@ func main() { 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) -- 2.48.1