Documentation
¶
Overview ¶
Package http implements a BitTorrent frontend via the HTTP protocol as described in BEP 3 and BEP 23.
Index ¶
- Variables
- func ParseAnnounce(r *http.Request, realIPHeader string, allowIPSpoofing bool) (*bittorrent.AnnounceRequest, error)
- func ParseScrape(r *http.Request) (*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
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidIP = bittorrent.ClientError("invalid IP")
ErrInvalidIP indicates an invalid IP.
Functions ¶
func ParseAnnounce ¶
func ParseAnnounce(r *http.Request, realIPHeader string, allowIPSpoofing bool) (*bittorrent.AnnounceRequest, error)
ParseAnnounce parses an bittorrent.AnnounceRequest from an http.Request.
If allowIPSpoofing is true, IPs provided via params will be used. If realIPHeader is not empty string, the first value of the HTTP Header with that name will be used.
func ParseScrape ¶
func ParseScrape(r *http.Request) (*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"` ReadTimeout time.Duration `yaml:"read_timeout"` WriteTimeout time.Duration `yaml:"write_timeout"` AllowIPSpoofing bool `yaml:"allow_ip_spoofing"` RealIPHeader string `yaml:"real_ip_header"` TLSCertPath string `yaml:"tls_cert_path"` TLSKeyPath string `yaml:"tls_key_path"` EnableRequestTiming bool `yaml:"enable_request_timing"` }
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, cfg Config) (*Frontend, error)
NewFrontend creates a new instance of an HTTP Frontend that asynchronously serves requests.