tracker/bittorrent/client_id.go

23 lines
433 B
Go
Raw Normal View History

package bittorrent
2016-08-04 06:33:55 +02:00
// ClientID represents the part of a PeerID that identifies a Peer's client
// software.
2016-08-04 06:33:55 +02:00
type ClientID string
// NewClientID parses a ClientID from a PeerID.
func NewClientID(peerID string) ClientID {
var clientID string
length := len(peerID)
if length >= 6 {
if peerID[0] == '-' {
if length >= 7 {
clientID = peerID[1:7]
}
} else {
clientID = peerID[:6]
}
}
2016-08-04 06:33:55 +02:00
return ClientID(clientID)
}