frontend

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package frontend defines interface which should satisfy every network frontend

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParseOptions

type ParseOptions struct {
	AllowIPSpoofing     bool   `cfg:"allow_ip_spoofing"`
	MaxNumWant          uint32 `cfg:"max_numwant"`
	DefaultNumWant      uint32 `cfg:"default_numwant"`
	MaxScrapeInfoHashes uint32 `cfg:"max_scrape_infohashes"`
}

ParseOptions is the configuration used to parse an Announce Request.

If AllowIPSpoofing is true, IPs provided via params will be used.

func (ParseOptions) Validate

func (op ParseOptions) Validate() ParseOptions

Validate sanity checks values set in a config and returns a new config with default values replacing anything that is invalid.

type TrackerLogic

type TrackerLogic interface {
	// HandleAnnounce generates a response for an Announce.
	//
	// Returns the updated context, the generated AnnounceResponse and no error
	// on success; nil and error on failure.
	HandleAnnounce(context.Context, *bittorrent.AnnounceRequest) (context.Context, *bittorrent.AnnounceResponse, error)

	// AfterAnnounce does something with the results of an Announce after it
	// has been completed.
	AfterAnnounce(context.Context, *bittorrent.AnnounceRequest, *bittorrent.AnnounceResponse)

	// HandleScrape generates a response for a Scrape.
	//
	// Returns the updated context, the generated AnnounceResponse and no error
	// on success; nil and error on failure.
	HandleScrape(context.Context, *bittorrent.ScrapeRequest) (context.Context, *bittorrent.ScrapeResponse, error)

	// AfterScrape does something with the results of a Scrape after it has been completed.
	AfterScrape(context.Context, *bittorrent.ScrapeRequest, *bittorrent.ScrapeResponse)
}

TrackerLogic is the interface used by a frontend in order to: (1) generate a response from a parsed request, and (2) asynchronously observe anything after the response has been delivered to the client.

Directories

Path Synopsis
Package http implements a BitTorrent frontend via the HTTP protocol as described in BEP 3 and BEP 23.
Package http implements a BitTorrent frontend via the HTTP protocol as described in BEP 3 and BEP 23.
udp
Package udp implements a BitTorrent tracker via the UDP protocol as described in BEP 15.
Package udp implements a BitTorrent tracker via the UDP protocol as described in BEP 15.
bytepool
Package bytepool defines pool for storing and reusing raw bytes
Package bytepool defines pool for storing and reusing raw bytes

Jump to

Keyboard shortcuts

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