client

package
v0.0.0-...-ef7f9f6 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Conn            packets.UDPConn
	Choked          bool
	Bitfield        bitfield.Bitfield
	Peer            peers.Peer
	InfoHash        [20]byte
	PeerID          [20]byte
	DiscoveryConfig *config.PeerDiscoveryConfig
	DhtNode         *dht_node.DhtNode
}

A Client is a TCP connection with a peer

func (*Client) Handshake

func (c *Client) Handshake() error

func (*Client) Read

func (c *Client) Read() (*message.Message, error)

Read reads and consumes a message from the connection

func (*Client) SendHave

func (c *Client) SendHave(index int) error

SendHave sends a Have message to the peer

func (*Client) SendInterested

func (c *Client) SendInterested() error

SendInterested sends an Interested message to the peer

func (*Client) SendNotInterested

func (c *Client) SendNotInterested() error

SendNotInterested sends a NotInterested message to the peer

func (*Client) SendRequest

func (c *Client) SendRequest(index, begin, length int) error

SendRequest sends a Request message to the peer

func (*Client) SendUnchoke

func (c *Client) SendUnchoke() error

SendUnchoke sends an Unchoke message to the peer

type ClientInitiatedSelection

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

LastSelection users could add more fields

func (*ClientInitiatedSelection) CustomPathSelectAlg

func (lastSel *ClientInitiatedSelection) CustomPathSelectAlg(pathSet *pathselection.PathSet) (*pathselection.PathSet, error)

CustomPathSelectAlg this is where the user actually wants to implement its logic in

type ClientSelection

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

LastSelection users could add more fields

func (*ClientSelection) CustomPathSelectAlg

func (lastSel *ClientSelection) CustomPathSelectAlg(pathSet *pathselection.PathSet) (*pathselection.PathSet, error)

CustomPathSelectAlg this is where the user actually wants to implement its logic in

type MPClient

type MPClient struct {
	Client
	// contains filtered or unexported fields
}

func NewMPClient

func NewMPClient() *MPClient

func (*MPClient) DialAndWaitForConnectBack

func (mp *MPClient) DialAndWaitForConnectBack(
	local string,
	peer peers.Peer,
	peerID,
	infoHash [20]byte,
	discoveryConfig *config.PeerDiscoveryConfig,
	node *dht_node.DhtNode) ([]*Client, error)

func (*MPClient) GetSocket

func (mp *MPClient) GetSocket() *smp.MPPeerSock

func (*MPClient) WaitForNewClient

func (mp *MPClient) WaitForNewClient() (*Client, error)

Jump to

Keyboard shortcuts

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