From 89f39b0b097f1dcebcd384acb387caf60159eb64 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Fri, 18 Aug 2017 11:14:57 +1000 Subject: [PATCH] Add some debugging routes and envpprof to cmd/magnet-metainfo https://github.com/anacrolix/torrent/issues/178 --- cmd/magnet-metainfo/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/magnet-metainfo/main.go b/cmd/magnet-metainfo/main.go index e231f171..c310aa9c 100644 --- a/cmd/magnet-metainfo/main.go +++ b/cmd/magnet-metainfo/main.go @@ -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)