http

package
v2.0.0-rc.2.0...-2c67ad4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2017 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package http implements a BitTorrent frontend via the HTTP protocol as described in BEP 3 and BEP 23.

Index

Constants

This section is empty.

Variables

View Source
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.

func (Config) LogFields

func (cfg Config) LogFields() log.Fields

LogFields renders the current config as a set of Logrus fields.

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.

func (*Frontend) Stop

func (f *Frontend) Stop() <-chan error

Stop provides a thread-safe way to shutdown a currently running Frontend.

Directories

Path Synopsis
Package bencode implements bencoding of data as defined in BEP 3 using type assertion over reflection for performance.
Package bencode implements bencoding of data as defined in BEP 3 using type assertion over reflection for performance.

Jump to

Keyboard shortcuts

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