7 type clientHolepunchAddrSets struct {
8 undialableWithoutHolepunch map[netip.AddrPort]struct{}
9 undialableWithoutHolepunchDialedAfterHolepunchConnect map[netip.AddrPort]struct{}
10 dialableOnlyAfterHolepunch map[netip.AddrPort]struct{}
11 dialedSuccessfullyAfterHolepunchConnect map[netip.AddrPort]struct{}
12 probablyOnlyConnectedDueToHolepunch map[netip.AddrPort]struct{}
15 type ClientStats struct {
18 // Ongoing outgoing dial attempts. There may be more than one dial going on per peer address due
19 // to hole-punch connect requests. The total may not match the sum of attempts for all Torrents
20 // if a Torrent is dropped while there are outstanding dials.
21 ActiveHalfOpenAttempts int
23 NumPeersUndialableWithoutHolepunch int
24 // Number of unique peer addresses that were dialed after receiving a holepunch connect message,
25 // that have previously been undialable without any hole-punching attempts.
26 NumPeersUndialableWithoutHolepunchDialedAfterHolepunchConnect int
27 // Number of unique peer addresses that were successfully dialed and connected after a holepunch
28 // connect message and previously failing to connect without holepunching.
29 NumPeersDialableOnlyAfterHolepunch int
30 NumPeersDialedSuccessfullyAfterHolepunchConnect int
31 NumPeersProbablyOnlyConnectedDueToHolepunch int
34 func (cl *Client) statsLocked() (stats ClientStats) {
35 stats.ConnStats = cl.connStats.Copy()
36 stats.ActiveHalfOpenAttempts = cl.numHalfOpen
38 stats.NumPeersUndialableWithoutHolepunch = len(cl.undialableWithoutHolepunch)
39 stats.NumPeersUndialableWithoutHolepunchDialedAfterHolepunchConnect = len(cl.undialableWithoutHolepunchDialedAfterHolepunchConnect)
40 stats.NumPeersDialableOnlyAfterHolepunch = len(cl.dialableOnlyAfterHolepunch)
41 stats.NumPeersDialedSuccessfullyAfterHolepunchConnect = len(cl.dialedSuccessfullyAfterHolepunchConnect)
42 stats.NumPeersProbablyOnlyConnectedDueToHolepunch = len(cl.probablyOnlyConnectedDueToHolepunch)