udp

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2016 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package udp implements a BitTorrent tracker over the UDP protocol as per BEP 15.

Index

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.

func NewServer

func NewServer(cfg *config.Config, tkr *tracker.Tracker) *Server

NewServer returns a new UDP server for a given configuration and tracker.

func (*Server) Serve

func (s *Server) Serve()

Serve runs a UDP server, blocking until the server has shut down.

func (*Server) Stop

func (s *Server) Stop()

Stop cleanly shuts down the server.

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

func (w *Writer) WriteError(err error) error

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.

Jump to

Keyboard shortcuts

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