return
}
if utp {
- acceptUTP.Add(1)
+ torrent.Add("accepted utp connections", 1)
} else {
- acceptTCP.Add(1)
+ torrent.Add("accepted tcp connections", 1)
+ }
+ torrent.Add(fmt.Sprintf("accepted conn with network %q", conn.RemoteAddr().Network()), 1)
+ remoteIP := missinggo.AddrIP(conn.RemoteAddr())
+ if remoteIP.To4() != nil {
+ torrent.Add("accepted conn from ipv4 address", 1)
+ } else if remoteIP.To16() != nil {
+ torrent.Add("accepted conn from ipv6 address", 1)
+ } else {
+ torrent.Add("accepted conn from unknown ip address type", 1)
}
if cl.config.Debug {
log.Printf("accepted connection from %s", conn.RemoteAddr())
if cl.config.Debug {
log.Printf("rejecting connection from %s", conn.RemoteAddr())
}
- acceptReject.Add(1)
+ torrent.Add("rejected accepted connection", 1)
conn.Close()
continue
}
c.conn.SetWriteDeadline(time.Time{})
c.r = deadlineReader{c.conn, c.r}
completedHandshakeConnectionFlags.Add(c.connectionFlags(), 1)
+ if connIsIpv6(c.conn) {
+ torrent.Add("completed handshake over ipv6", 1)
+ }
if !t.addConnection(c, outgoing) {
return
}
unsuccessfulDials = expvar.NewInt("dialSuccessful")
successfulDials = expvar.NewInt("dialUnsuccessful")
- acceptUTP = expvar.NewInt("acceptUTP")
- acceptTCP = expvar.NewInt("acceptTCP")
- acceptReject = expvar.NewInt("acceptReject")
-
peerExtensions = expvar.NewMap("peerExtensions")
completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
// Count of connections to peer with same client ID.
import (
"errors"
+ "log"
"net"
+ "github.com/anacrolix/missinggo"
"github.com/anacrolix/torrent/metainfo"
pp "github.com/anacrolix/torrent/peer_protocol"
)
}
return string(ip.To16()), nil
}
+
+func connIsIpv6(nc net.Conn) bool {
+ ra := nc.RemoteAddr()
+ log.Printf("network: %q, string: %q", ra.Network(), ra.String())
+ rip := missinggo.AddrIP(ra)
+ return rip.To4() == nil && rip.To16() != nil
+}