This commit is contained in:
yourok
2020-03-07 21:32:21 +03:00
parent c411024ede
commit 59a39ad363
2 changed files with 10 additions and 6 deletions

View File

@@ -1,14 +1,14 @@
package torr
import (
"github.com/anacrolix/dht"
"github.com/anacrolix/torrent"
)
type BTState struct {
LocalPort int
PeerID string
BannedIPs int
DHTs []*dht.Server
DHTs []torrent.DhtServer
Torrents []*Torrent
}

View File

@@ -7,6 +7,8 @@ import (
"server/utils"
dht2 "github.com/anacrolix/dht"
"github.com/anacrolix/torrent/metainfo"
"github.com/labstack/echo"
"github.com/labstack/gommon/bytes"
@@ -39,10 +41,12 @@ func statePage(c echo.Context) error {
for _, dht := range state.DHTs {
msg += fmt.Sprintf("%s DHT server at %s:<br>\n", dht.Addr().Network(), dht.Addr().String())
dhtStats := dht.Stats()
msg += fmt.Sprintf("\t&emsp;# Nodes: %d (%d good, %d banned)<br>\n", dhtStats.Nodes, dhtStats.GoodNodes, dhtStats.BadNodes)
if ds, ok := dhtStats.(dht2.ServerStats); ok {
msg += fmt.Sprintf("\t&emsp;# Nodes: %d (%d good, %d banned)<br>\n", ds.Nodes, ds.GoodNodes, ds.BadNodes)
msg += fmt.Sprintf("\t&emsp;Server ID: %x<br>\n", dht.ID())
msg += fmt.Sprintf("\t&emsp;Announces: %d<br>\n", dhtStats.SuccessfulOutboundAnnouncePeerQueries)
msg += fmt.Sprintf("\t&emsp;Outstanding transactions: %d<br>\n", dhtStats.OutstandingTransactions)
msg += fmt.Sprintf("\t&emsp;Announces: %d<br>\n", ds.SuccessfulOutboundAnnouncePeerQueries)
msg += fmt.Sprintf("\t&emsp;Outstanding transactions: %d<br>\n", ds.OutstandingTransactions)
}
}
sort.Slice(state.Torrents, func(i, j int) bool {