Documentation
¶
Index ¶
Constants ¶
View Source
const ClientVersion = "0.0.1"
View Source
const DefaultBlockSize = 1024 * 16 // bytes
View Source
const DefaultPieceSize = 1024 * 1024 * 4 //bytes
View Source
const MaxPieceCount = 10000
View Source
const ServerVersion = "0.0.1"
Variables ¶
View Source
var ProtoBTun = zap.String("proto", "btun")
View Source
var ProtoBittorrent = zap.String("proto", "bittorrent")
View Source
var ProtoTcp = zap.String("proto", "tcp")
Functions ¶
Types ¶
type ClientIDValidator ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func Accept ¶
func Accept(logger *zap.Logger, conn net.Conn, keyStore KeyStore, validator ClientIDValidator) (*Connection, error)
Accept TCP connection and try to perform a handshake. TCP connection is not closed on failure. ClientIDValidator is a function that can be used to refuse connection if validator(clientID) == false.
func Connect ¶
func Connect(logger *zap.Logger, address string, keyID []byte, clientID string, keyStore KeyStore) (*Connection, error)
Connect to server at address with keyID and keyStore and clientID.
func (*Connection) Close ¶
func (conn *Connection) Close() error
Close closes the underlying TCP connection, rendering this struct useless Note: it is not safe to call Close when either ReadMessage or WriteMessage may be called by other goroutines.
func (*Connection) ReadMessage ¶
func (conn *Connection) ReadMessage() ([]byte, error)
ReadMessage reads next message from connection
func (*Connection) WriteMessage ¶
func (conn *Connection) WriteMessage(payload []byte) error
type SharedPeerId ¶
type SharedPeerId struct {
// contains filtered or unexported fields
}
func (*SharedPeerId) GetId ¶
func (pid *SharedPeerId) GetId() string
Click to show internal directories.
Click to hide internal directories.