Track the connection flags for completed handshakes
This commit is contained in:
parent
34d3d7aca0
commit
06dede5690
|
@ -66,7 +66,8 @@ var (
|
|||
acceptTCP = expvar.NewInt("acceptTCP")
|
||||
acceptReject = expvar.NewInt("acceptReject")
|
||||
|
||||
peerExtensions = expvar.NewMap("peerExtensions")
|
||||
peerExtensions = expvar.NewMap("peerExtensions")
|
||||
completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
|
||||
// Count of connections to peer with same client ID.
|
||||
connsToSelf = expvar.NewInt("connsToSelf")
|
||||
// Number of completed connections to a client we're already connected with.
|
||||
|
@ -1134,6 +1135,7 @@ func (cl *Client) runHandshookConn(c *connection, t *torrent) (err error) {
|
|||
deadlineReader{c.conn, c.rw},
|
||||
c.rw,
|
||||
}
|
||||
completedHandshakeConnectionFlags.Add(c.connectionFlags(), 1)
|
||||
if !cl.addConnection(t, c) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -204,6 +204,22 @@ func eventAgeString(t time.Time) string {
|
|||
return fmt.Sprintf("%.2fs ago", time.Now().Sub(t).Seconds())
|
||||
}
|
||||
|
||||
func (cn *connection) connectionFlags() (ret string) {
|
||||
c := func(b byte) {
|
||||
ret += string([]byte{b})
|
||||
}
|
||||
if cn.encrypted {
|
||||
c('E')
|
||||
}
|
||||
if cn.Discovery != 0 {
|
||||
c(byte(cn.Discovery))
|
||||
}
|
||||
if cn.uTP {
|
||||
c('T')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Inspired by https://trac.transmissionbt.com/wiki/PeerStatusText
|
||||
func (cn *connection) statusFlags() (ret string) {
|
||||
c := func(b byte) {
|
||||
|
@ -216,15 +232,7 @@ func (cn *connection) statusFlags() (ret string) {
|
|||
c('c')
|
||||
}
|
||||
c('-')
|
||||
if cn.encrypted {
|
||||
c('E')
|
||||
}
|
||||
if cn.Discovery != 0 {
|
||||
c(byte(cn.Discovery))
|
||||
}
|
||||
if cn.uTP {
|
||||
c('T')
|
||||
}
|
||||
ret += cn.connectionFlags()
|
||||
c('-')
|
||||
if cn.PeerInterested {
|
||||
c('i')
|
||||
|
|
Loading…
Reference in New Issue