webseed

package
v1.82.5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDiscardBytes = 48 << 10

How many consecutive bytes to allow discarding from responses. This number is based on https://archive.org/download/BloodyPitOfHorror/BloodyPitOfHorror.asr.srt. It seems that archive.org might be using a webserver implementation that refuses to do partial responses to small files. TODO: Make this configurable.

Variables

View Source
var ErrTooFast = errors.New("making requests too fast")
View Source
var PrintDebug = false

Output debug information to stdout.

Functions

func EscapePath

func EscapePath(pathComps []string) string

Escapes path name components suitable for appending to a webseed URL. This works for converting S3 object keys to URLs too.

Contrary to the name, this actually does a QueryEscape, rather than a PathEscape. This works better with most S3 providers.

Types

type Client

type Client struct {
	Logger     *slog.Logger
	HttpClient *http.Client
	Url        string
	// Max concurrent requests to a WebSeed for a given torrent. TODO: Unused.
	MaxRequests int

	// The pieces we can request with the Url. We're more likely to ban/block at the file-level
	// given that's how requests are mapped to webseeds, but the torrent.Client works at the piece
	// level. We can map our file-level adjustments to the pieces here. This probably need to be
	// private in the future, if Client ever starts removing pieces. TODO: This belongs in
	// webseedPeer. TODO: Unused.
	Pieces roaring.Bitmap
	// This wraps http.Response bodies, for example to limit the download rate.
	ResponseBodyWrapper     ResponseBodyWrapper
	ResponseBodyRateLimiter *rate.Limiter
	PathEscaper             PathEscaper
	// contains filtered or unexported fields
}

func (*Client) SetInfo

func (me *Client) SetInfo(info *metainfo.Info, fileIndex *segments.Index)

func (*Client) StartNewRequest

func (ws *Client) StartNewRequest(ctx context.Context, r RequestSpec, debugLogger *slog.Logger) Request

func (*Client) UrlForFileIndex

func (ws *Client) UrlForFileIndex(fileIndex int) string

Returns the URL for the given file index. This is assumed to be globally unique.

type ErrBadResponse

type ErrBadResponse struct {
	Msg      string
	Response *http.Response
}

func (ErrBadResponse) Error

func (me ErrBadResponse) Error() string

type ErrStatusOkForRangeRequest

type ErrStatusOkForRangeRequest struct{}

func (ErrStatusOkForRangeRequest) Error

type PathEscaper

type PathEscaper func(pathComps []string) string

type ReadRequestPartError

type ReadRequestPartError struct {
	FileIndex int
	Err       error
}

Contains info for callers to act (like ignoring particular files or rate limiting).

func (ReadRequestPartError) Error

func (r ReadRequestPartError) Error() string

func (ReadRequestPartError) Unwrap

func (me ReadRequestPartError) Unwrap() error

type Request

type Request struct {
	Body io.Reader
	// contains filtered or unexported fields
}

func (*Request) Cancel

func (r *Request) Cancel(cause error)

func (*Request) Close

func (r *Request) Close()

func (*Request) Context

func (r *Request) Context() context.Context

type RequestSpec

type RequestSpec = segments.Extent

type ResponseBodyWrapper

type ResponseBodyWrapper func(r io.Reader, interrupt func()) io.Reader

Jump to

Keyboard shortcuts

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