package peer import ( "crypto/rand" "fmt" "math/big" ) type Message int const ( Choke Message = iota // choke: Unchoke // unchoke: Interested // interested: NotInterested // not interested: Have // have: BitField // bitfield: Request // request: Piece // piece: Cancel // cancel: Port // port: _ // keep-alive: ) const ( Proto = `BitTorrent protocol` ClientID = `+++ATH0-xxxxxxxxxxxx` // or may be `D13--xxxxxxxxxxxxxxx` ) func NewID() (string, error) { limit := new(big.Int).Lsh(big.NewInt(1), 48) id, err := rand.Int(rand.Reader, limit) if err != nil { return "", err } return fmt.Sprintf("+++ATH0-%0.12x", id), nil }