webseed

package
v1.61.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MPL-2.0 Imports: 18 Imported by: 2

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 added in v1.42.0

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 added in v1.37.0

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

func (*Client) StartNewRequest added in v1.57.0

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

func (*Client) UrlForFileIndex added in v1.59.0

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

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

type ErrBadResponse added in v1.25.1

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

func (ErrBadResponse) Error added in v1.25.1

func (me ErrBadResponse) Error() string

type ErrStatusOkForRangeRequest added in v1.61.0

type ErrStatusOkForRangeRequest struct{}

func (ErrStatusOkForRangeRequest) Error added in v1.61.0

type PathEscaper added in v1.43.0

type PathEscaper func(pathComps []string) string

type ReadRequestPartError added in v1.59.0

type ReadRequestPartError struct {
	FileIndex int
	Err       error
}

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

func (ReadRequestPartError) Error added in v1.59.0

func (r ReadRequestPartError) Error() string

func (ReadRequestPartError) Unwrap added in v1.59.0

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 added in v1.59.0

func (r *Request) Close()

func (*Request) Context added in v1.59.0

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

type RequestSpec

type RequestSpec = segments.Extent

type ResponseBodyWrapper added in v1.40.0

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