"github.com/anacrolix/missinggo/v2/pubsub"
"github.com/anacrolix/multiless"
"github.com/anacrolix/sync"
- "github.com/davecgh/go-spew/spew"
"github.com/pion/datachannel"
"golang.org/x/exp/maps"
fmt.Fprintf(w, "DHT Announces: %d\n", t.numDHTAnnounces)
- spew.NewDefaultConfig()
- spew.Fdump(w, t.statsLocked())
+ dumpStats(w, t.statsLocked())
fmt.Fprintf(w, "webseeds:\n")
t.writePeerStatuses(w, maps.Values(t.webSeeds))
return ml.Less()
})
- fmt.Fprintf(w, "peer conns:\n")
+ fmt.Fprintf(w, "%v peer conns:\n", len(peerConns))
t.writePeerStatuses(w, g.SliceMap(peerConns, func(pc *PeerConn) *Peer {
return &pc.Peer
}))
return
}
p := t.peers.PopMax()
- t.initiateConn(p, false, false, false)
+ t.initiateConn(p, false, false, false, false)
initiated++
}
return
requireRendezvous bool,
skipHolepunchRendezvous bool,
ignoreLimits bool,
+ receivedHolepunchConnect bool,
) {
if peer.Id == t.cl.peerID {
return
t.addHalfOpen(addrStr, attemptKey)
go t.cl.outgoingConnection(
outgoingConnOpts{
- t: t,
- addr: peer.Addr,
- requireRendezvous: requireRendezvous,
- skipHolepunchRendezvous: skipHolepunchRendezvous,
+ t: t,
+ addr: peer.Addr,
+ requireRendezvous: requireRendezvous,
+ skipHolepunchRendezvous: skipHolepunchRendezvous,
+ receivedHolepunchConnect: receivedHolepunchConnect,
},
peer.Source,
peer.Trusted,
// connection.
func (t *Torrent) allStats(f func(*ConnStats)) {
f(&t.stats)
- f(&t.cl.stats)
+ f(&t.cl.connStats)
}
func (t *Torrent) hashingPiece(i pieceIndex) bool {
t.initiateConn(PeerInfo{
Addr: msg.AddrPort,
Source: PeerSourceUtHolepunch,
- }, false, true, true)
+ }, false, true, true, true)
}
return nil
case utHolepunch.Error:
}
return
}
+
+func (t *Torrent) numHalfOpenAttempts() (num int) {
+ for _, attempts := range t.halfOpen {
+ num += len(attempts)
+ }
+ return
+}