]> Sergey Matveev's repositories - btrtrc.git/commitdiff
cmd/torrentfs: Missing listener on client
authorMatt Joiner <anacrolix@gmail.com>
Thu, 24 Jul 2014 03:45:49 +0000 (13:45 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 24 Jul 2014 03:45:49 +0000 (13:45 +1000)
cmd/torrentfs/main.go

index e8e7211d6c4bd1b92c77efc5eb7602630b37b1f7..16fa3bf2d5e81e835bb700d980a0c5be6e3f371d 100644 (file)
@@ -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)