http

package
Version: 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 http implements a BitTorrent tracker over the HTTP protocol as per BEP 3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseHandler

type ResponseHandler func(http.ResponseWriter, *http.Request, httprouter.Params) (int, error)

ResponseHandler is an HTTP handler that returns a status code.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents an HTTP serving torrent tracker.

func NewServer

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

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

func (*Server) Serve

func (s *Server) Serve()

Serve runs an HTTP 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 {
	http.ResponseWriter
}

Writer implements the tracker.Writer interface for the HTTP protocol.

func (*Writer) WriteAnnounce

func (w *Writer) WriteAnnounce(res *models.AnnounceResponse) error

WriteAnnounce writes a bencode dict representation of an AnnounceResponse.

func (*Writer) WriteError

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

WriteError writes a bencode dict with a failure reason.

func (*Writer) WriteScrape

func (w *Writer) WriteScrape(res *models.ScrapeResponse) error

WriteScrape writes a bencode dict representation of a ScrapeResponse.

Directories

Path Synopsis
Package query implements a faster single-purpose URL Query parser.
Package query implements a faster single-purpose URL Query parser.

Jump to

Keyboard shortcuts

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