]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add some debugging routes and envpprof to cmd/magnet-metainfo
authorMatt Joiner <anacrolix@gmail.com>
Fri, 18 Aug 2017 01:14:57 +0000 (11:14 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 18 Aug 2017 01:14:57 +0000 (11:14 +1000)
https://github.com/anacrolix/torrent/issues/178

cmd/magnet-metainfo/main.go

index e231f1714a09cd2b6c8aa8df208765c813fe10a5..c310aa9c8db08e4d93e79b0501a16df3df41e1f8 100644 (file)
@@ -4,9 +4,11 @@ package main
 import (
        "flag"
        "log"
+       "net/http"
        "os"
        "sync"
 
+       _ "github.com/anacrolix/envpprof"
        "github.com/anacrolix/torrent"
        "github.com/anacrolix/torrent/bencode"
 )
@@ -17,6 +19,12 @@ func main() {
        if err != nil {
                log.Fatalf("error creating client: %s", err)
        }
+       http.HandleFunc("/torrent", func(w http.ResponseWriter, r *http.Request) {
+               cl.WriteStatus(w)
+       })
+       http.HandleFunc("/dht", func(w http.ResponseWriter, r *http.Request) {
+               cl.DHT().WriteStatus(w)
+       })
        wg := sync.WaitGroup{}
        for _, arg := range flag.Args() {
                t, err := cl.AddMagnet(arg)