Documentation ¶
Overview ¶
Package http implements a BitTorrent frontend via the HTTP protocol as described in BEP 3 and BEP 23.
Index ¶
- func ParseAnnounce(r *http.Request, opts ParseOptions) (*bittorrent.AnnounceRequest, error)
- func ParseScrape(r *http.Request, opts ParseOptions) (*bittorrent.ScrapeRequest, error)
- func WriteAnnounceResponse(w http.ResponseWriter, resp *bittorrent.AnnounceResponse) error
- func WriteError(w http.ResponseWriter, err error) error
- func WriteScrapeResponse(w http.ResponseWriter, resp *bittorrent.ScrapeResponse) error
- type Config
- type Frontend
- type ParseOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAnnounce ¶
func ParseAnnounce(r *http.Request, opts ParseOptions) (*bittorrent.AnnounceRequest, error)
ParseAnnounce parses an bittorrent.AnnounceRequest from an http.Request.
func ParseScrape ¶
func ParseScrape(r *http.Request, opts ParseOptions) (*bittorrent.ScrapeRequest, error)
ParseScrape parses an bittorrent.ScrapeRequest from an http.Request.
func WriteAnnounceResponse ¶
func WriteAnnounceResponse(w http.ResponseWriter, resp *bittorrent.AnnounceResponse) error
WriteAnnounceResponse communicates the results of an Announce to a BitTorrent client over HTTP.
func WriteError ¶
func WriteError(w http.ResponseWriter, err error) error
WriteError communicates an error to a BitTorrent client over HTTP.
func WriteScrapeResponse ¶
func WriteScrapeResponse(w http.ResponseWriter, resp *bittorrent.ScrapeResponse) error
WriteScrapeResponse communicates the results of a Scrape to a BitTorrent client over HTTP.
Types ¶
type Config ¶
type Config struct { Addr string `yaml:"addr"` HTTPSAddr string `yaml:"https_addr"` ReadTimeout time.Duration `yaml:"read_timeout"` WriteTimeout time.Duration `yaml:"write_timeout"` IdleTimeout time.Duration `yaml:"idle_timeout"` EnableKeepAlive bool `yaml:"enable_keepalive"` TLSCertPath string `yaml:"tls_cert_path"` TLSKeyPath string `yaml:"tls_key_path"` AnnounceRoutes []string `yaml:"announce_routes"` ScrapeRoutes []string `yaml:"scrape_routes"` EnableRequestTiming bool `yaml:"enable_request_timing"` ParseOptions `yaml:",inline"` }
Config represents all of the configurable options for an HTTP BitTorrent Frontend.
type Frontend ¶
type Frontend struct { Config // contains filtered or unexported fields }
Frontend represents the state of an HTTP BitTorrent Frontend.
func NewFrontend ¶
func NewFrontend(logic frontend.TrackerLogic, provided Config) (*Frontend, error)
NewFrontend creates a new instance of an HTTP Frontend that asynchronously serves requests.
type ParseOptions ¶
type ParseOptions struct { AllowIPSpoofing bool `yaml:"allow_ip_spoofing"` RealIPHeader string `yaml:"real_ip_header"` MaxNumWant uint32 `yaml:"max_numwant"` DefaultNumWant uint32 `yaml:"default_numwant"` MaxScrapeInfoHashes uint32 `yaml:"max_scrape_infohashes"` }
ParseOptions is the configuration used to parse an Announce Request.
If AllowIPSpoofing is true, IPs provided via BitTorrent params will be used. If RealIPHeader is not empty string, the value of the first HTTP Header with that name will be used.