Documentation ¶
Overview ¶
Package udp implements a BitTorrent tracker over the UDP protocol as per BEP 15.
Index ¶
- type ConnectionIDGenerator
- type Server
- type Writer
- func (w *Writer) WriteAnnounce(resp *models.AnnounceResponse) (err error)
- func (w *Writer) WriteAnnounceIPv4(resp *models.AnnounceResponse) error
- func (w *Writer) WriteAnnounceIPv6(resp *models.AnnounceResponse) error
- func (w *Writer) WriteError(err error) error
- func (w *Writer) WriteScrape(resp *models.ScrapeResponse) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionIDGenerator ¶
type ConnectionIDGenerator struct {
// contains filtered or unexported fields
}
ConnectionIDGenerator represents the logic to generate 64-bit UDP connection IDs from peer IP addresses.
func NewConnectionIDGenerator ¶
func NewConnectionIDGenerator() (gen *ConnectionIDGenerator, err error)
NewConnectionIDGenerator creates a ConnectionIDGenerator and generates its AES key and first initialization vector.
func (*ConnectionIDGenerator) Generate ¶
func (g *ConnectionIDGenerator) Generate(ip net.IP) []byte
Generate returns the 64-bit connection ID for an IP
func (*ConnectionIDGenerator) Matches ¶
func (g *ConnectionIDGenerator) Matches(id []byte, ip net.IP) bool
Matches checks if the given connection ID matches an IP with the current or previous initialization vectors.
func (*ConnectionIDGenerator) NewIV ¶
func (g *ConnectionIDGenerator) NewIV() error
NewIV generates a new initialization vector and rotates the current one.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a UDP torrent tracker.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer implements the tracker.Writer interface for the UDP protocol.
func (*Writer) WriteAnnounce ¶
func (w *Writer) WriteAnnounce(resp *models.AnnounceResponse) (err error)
WriteAnnounce encodes an announce response by selecting the proper announce format based on the BitTorrent spec.
func (*Writer) WriteAnnounceIPv4 ¶
func (w *Writer) WriteAnnounceIPv4(resp *models.AnnounceResponse) error
WriteAnnounceIPv4 encodes an announce response according to BEP15.
func (*Writer) WriteAnnounceIPv6 ¶
func (w *Writer) WriteAnnounceIPv6(resp *models.AnnounceResponse) error
WriteAnnounceIPv6 encodes an announce response according to BEP45.
func (*Writer) WriteError ¶
WriteError writes the failure reason as a null-terminated string.
func (*Writer) WriteScrape ¶
func (w *Writer) WriteScrape(resp *models.ScrapeResponse) error
WriteScrape encodes a scrape response according to BEP15.