Documentation
¶
Index ¶
- Constants
- func Open(r io.Reader) (*bencodeObject, error)
- func Unmarshal(r io.Reader, ben *bencodeObject) error
- func Verify(tf *TorrentFile) error
- type BencodeType
- type Bitfield
- type Downloader
- func (d *Downloader) AddPeer(p *PeerCon)
- func (d *Downloader) Done() <-chan struct{}
- func (d *Downloader) GetActivePeers() []PeerInfo
- func (d *Downloader) GetBitfield() Bitfield
- func (d *Downloader) PickPiece(peerBitfield Bitfield) (int, bool)
- func (d *Downloader) PrintLogs()
- func (d *Downloader) Wait()
- type FileInfo
- type HTTPConnector
- type HTTPTracker
- type Message
- type MessageID
- type Peer
- type PeerCon
- func (p *PeerCon) DownloadLoop(d *Downloader, results chan Piece)
- func (p *PeerCon) ReadMessage() (*Message, error)
- func (p *PeerCon) SendBitfield() error
- func (p *PeerCon) SendExtendedHandshake() error
- func (p *PeerCon) SendInterested() error
- func (p *PeerCon) SendMessage(msg *Message) error
- func (p *PeerCon) SendPiece(index, begin uint32, data []byte) error
- func (p *PeerCon) SendRequest(index, begin, length int) error
- func (p *PeerCon) SendUnchoke() error
- func (p *PeerCon) ShakeHands() error
- type PeerInfo
- type Piece
- type Stats
- type TCPConnector
- func (c *TCPConnector) Close() error
- func (c *TCPConnector) Recv(size int32, timeout float32) ([]byte, *net.TCPAddr, error)
- func (c *TCPConnector) RecvAll(size int32, timeout float32) ([]byte, *net.TCPAddr, error)
- func (c *TCPConnector) Send(buf []byte) error
- func (c *TCPConnector) SetDestination(addr *net.TCPAddr)
- func (c *TCPConnector) SetDestinationTo(remoteAddr string) error
- type TorrentFile
- type TorrentWriter
- type UDPConnector
- type UDPTracker
Constants ¶
View Source
const ( PIECE_QUEUE = 256 PEX_CHANNEL = 512 DISCOVERY_LIMIT = 64 CONFIRMED_PEER_QUEUE = 812 HANDSHAKE_WAIT_TIMEOUT = 10 READ_MSG_TIMEOUT = 130 REQUEST_BLOCK_SIZE = 16384 MAX_CHOKED_TIME = 60 * time.Second MAX_BACKLOG = 32 MAX_MSG_LEN = 262144 PEX_INTERVAL = 60 * time.Second )
View Source
const ( ExtendedHandshakeID = 0 UtPexID = 1 )
View Source
const MAGIC_CONSTANT = 0x41727101980
Variables ¶
This section is empty.
Functions ¶
func Verify ¶
func Verify(tf *TorrentFile) error
Types ¶
type Downloader ¶
type Downloader struct {
Stats Stats
// contains filtered or unexported fields
}
func NewDownloader ¶
func NewDownloader(tf *TorrentFile) (*Downloader, error)
func (*Downloader) AddPeer ¶
func (d *Downloader) AddPeer(p *PeerCon)
func (*Downloader) Done ¶ added in v0.2.2
func (d *Downloader) Done() <-chan struct{}
func (*Downloader) GetActivePeers ¶ added in v0.2.2
func (d *Downloader) GetActivePeers() []PeerInfo
func (*Downloader) GetBitfield ¶ added in v0.2.2
func (d *Downloader) GetBitfield() Bitfield
func (*Downloader) PickPiece ¶ added in v0.1.1
func (d *Downloader) PickPiece(peerBitfield Bitfield) (int, bool)
func (*Downloader) PrintLogs ¶ added in v0.2.0
func (d *Downloader) PrintLogs()
func (*Downloader) Wait ¶
func (d *Downloader) Wait()
type HTTPConnector ¶
type HTTPConnector struct {
// contains filtered or unexported fields
}
func NewHTTPConnector ¶
func NewHTTPConnector(baseURL string) *HTTPConnector
type HTTPTracker ¶ added in v0.2.0
type HTTPTracker struct {
// contains filtered or unexported fields
}
func NewHTTPTracker ¶ added in v0.2.0
func NewHTTPTracker(rawURL string) *HTTPTracker
func (*HTTPTracker) SendRequest ¶ added in v0.2.0
type Peer ¶
func UnmarshalPeers ¶
type PeerCon ¶
type PeerCon struct {
RemotePeerID string
// contains filtered or unexported fields
}
func NewPeerCon ¶
func NewPeerCon(tf *TorrentFile, p *Peer, bits Bitfield, pexCh chan string) *PeerCon
func (*PeerCon) DownloadLoop ¶
func (p *PeerCon) DownloadLoop(d *Downloader, results chan Piece)
func (*PeerCon) ReadMessage ¶
func (*PeerCon) SendBitfield ¶ added in v0.2.0
func (*PeerCon) SendExtendedHandshake ¶ added in v0.1.1
func (*PeerCon) SendInterested ¶
func (*PeerCon) SendMessage ¶
func (*PeerCon) SendRequest ¶
func (*PeerCon) SendUnchoke ¶
func (*PeerCon) ShakeHands ¶
type Stats ¶ added in v0.2.0
type Stats struct {
TotalSize int64
PexProcessed atomic.Int32
PexAdded atomic.Int32
PexSent atomic.Int32
PeersProcessed atomic.Int32
PeersConfirmed atomic.Int32
PeersDenied atomic.Int32
StartTime time.Time
GlobalBitfield Bitfield
TotalWritten int64
CurrentlyDownloading atomic.Int32
Failed atomic.Int32
NumPeers atomic.Int32
Searching atomic.Int32
NotFound atomic.Int32
UnchokedPeers atomic.Int32
Seeders atomic.Int32
BitfieldRecv atomic.Int32
BitfieldMiss atomic.Int32
ValidTrackers atomic.Int32
PeersProvided atomic.Int32
}
type TCPConnector ¶
type TCPConnector struct {
// contains filtered or unexported fields
}
func NewTCPConnector ¶
func NewTCPConnector(p *Peer) *TCPConnector
func (*TCPConnector) Close ¶
func (c *TCPConnector) Close() error
func (*TCPConnector) Send ¶
func (c *TCPConnector) Send(buf []byte) error
func (*TCPConnector) SetDestination ¶
func (c *TCPConnector) SetDestination(addr *net.TCPAddr)
func (*TCPConnector) SetDestinationTo ¶
func (c *TCPConnector) SetDestinationTo(remoteAddr string) error
type TorrentFile ¶
type TorrentFile struct {
Announce string
AnnounceList [][]string
InfoHash [20]byte
PieceHashes [][20]byte
PieceLength int
Length int
Files []FileInfo
Name string
}
func NewTorrentFile ¶
func NewTorrentFile(path string) (*TorrentFile, error)
func (*TorrentFile) DownloadLength ¶ added in v0.2.1
func (bto *TorrentFile) DownloadLength() int64
type TorrentWriter ¶
type TorrentWriter struct {
// contains filtered or unexported fields
}
func NewTorrentWriter ¶
func NewTorrentWriter(tf *TorrentFile, d *Downloader) (*TorrentWriter, error)
type UDPConnector ¶
type UDPConnector struct {
// contains filtered or unexported fields
}
func NewUDPConnector ¶
func NewUDPConnector(localAddr string) (*UDPConnector, error)
func (*UDPConnector) Close ¶
func (c *UDPConnector) Close() error
func (*UDPConnector) Send ¶
func (c *UDPConnector) Send(buf []byte) error
func (*UDPConnector) SetDestination ¶
func (c *UDPConnector) SetDestination(addr *net.UDPAddr)
func (*UDPConnector) SetDestinationTo ¶
func (c *UDPConnector) SetDestinationTo(localAddr string) error
type UDPTracker ¶
type UDPTracker struct {
// contains filtered or unexported fields
}
func NewUDPTracker ¶
func NewUDPTracker(rawURL string) (*UDPTracker, error)
Click to show internal directories.
Click to hide internal directories.