Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnnounceRequest ¶
type AnnounceRequest struct {
InfoHash dht.Key // BEP 3: 20-byte SHA-1 info hash (urlencoded)
PeerID dht.Key // BEP 3: 20-byte peer ID (urlencoded)
Port uint16 // BEP 3: port this client is listening on
Uploaded int64 // BEP 3: total bytes uploaded since "started" event
Downloaded int64 // BEP 3: total bytes downloaded since "started" event
Left int64 // BEP 3: bytes remaining to download
Compact bool // BEP 23: request compact peer list (6 bytes per peer)
NoPeerID bool // BEP 3: omit peer_id in responses (compact implies this)
Event Event // BEP 3: started/stopped/completed or empty
NumWant int // BEP 3: number of peers requested (tracker may ignore)
}
AnnounceRequest contains parameters for tracker announce. BEP 3 §Tracker Request: all fields map to tracker query parameters.
type AnnounceResponse ¶
type AnnounceResponse struct {
Interval int64 // BEP 3: seconds client should wait before next announce
MinInterval int64 // BEP 3: optional minimum re-announce interval
TrackerID string // BEP 3: optional tracker identifier for future announces
Complete int64 // BEP 3: number of seeders
Incomplete int64 // BEP 3: number of leechers
Peers []Peer // BEP 3/23: peer list (compact or dict format)
ExternalIP net.IP // BEP 24: client's public IP as seen by the tracker (may be nil)
}
AnnounceResponse represents the tracker's response. BEP 3 §Tracker Response: bencoded dictionary with peer list and timing.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles communication with BitTorrent trackers
func (*Client) Announce ¶
func (c *Client) Announce(trackerURL string, req *AnnounceRequest) (*AnnounceResponse, error)
Announce sends an announce request to a tracker
func (*Client) Scrape ¶
func (c *Client) Scrape(trackerURL string, req *ScrapeRequest) (*ScrapeResponse, error)
Scrape sends a scrape request to a tracker
type Event ¶
type Event string
Event represents the event type for tracker announces. BEP 3 §Tracker Request: event is optional; if not present, it's a regular re-announce.
const ( EventNone Event = "" // BEP 3: regular re-announce (no event key sent) EventStarted Event = "started" // BEP 3: first announce for this download EventStopped Event = "stopped" // BEP 3: client is shutting down gracefully EventCompleted Event = "completed" // BEP 3: download completed (leecher → seeder) )
type ScrapeRequest ¶
type ScrapeRequest struct {
InfoHashes []dht.Key // Can scrape multiple torrents (up to ~74 for UDP)
}
ScrapeRequest contains parameters for tracker scrape
type ScrapeResponse ¶
type ScrapeResponse struct {
Files map[string]ScrapeStats // Key is hex-encoded info hash
}
ScrapeResponse represents the tracker's scrape response
type ScrapeStats ¶
type ScrapeStats struct {
Complete int64 // Number of seeders
Downloaded int64 // Number of complete downloads (peers that completed)
Incomplete int64 // Number of leechers
}
ScrapeStats contains statistics for a single torrent