btconn

package
v1.6.1-0...-b16536f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package btconn provides support for dialing and accepting BitTorrent connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accept

func Accept(
	conn net.Conn,
	handshakeTimeout time.Duration,
	getSKey func(sKeyHash [20]byte) (sKey []byte),
	forceEncryption bool,
	hasInfoHash func([20]byte) bool,
	ourExtensions [8]byte, ourID [20]byte) (
	encConn net.Conn, cipher mse.CryptoMethod, peerExtensions [8]byte, peerID [20]byte, infoHash [20]byte, err error)

Accept BitTorrent handshake from the connection. Handles encryption. Returns a new connection that is ready for sending/receiving BitTorrent protocol messages.

func Dial

func Dial(
	addr net.Addr,
	dialTimeout, handshakeTimeout time.Duration,
	enableEncryption,
	forceEncryption bool,
	ourExtensions [8]byte,
	ih [20]byte,
	ourID [20]byte,
	stopC chan struct{}) (
	conn net.Conn, cipher mse.CryptoMethod, peerExtensions [8]byte, peerID [20]byte, err error)

Dial new connection to the address. Does the BitTorrent protocol handshake. Handles encryption. May try to connect again if encryption does not match with given setting. Returns a net.Conn that is ready for sending/receiving BitTorrent peer protocol messages.

Types

type HandshakeError

type HandshakeError struct {
	// contains filtered or unexported fields
}

HandshakeError is an error while doing the protocol handshake.

func (*HandshakeError) Error

func (e *HandshakeError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL