netproxy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package netproxy runs a loopback HTTP proxy that all downloads are pointed at. Its only job is to be a place where the speed limit can be enforced: the embedded download engine offers no rate-limit hook, but it does let us set a proxy, so the bytes come past here on their way in.

It listens on 127.0.0.1 only and is never exposed.

It is the meter, and being the meter is the whole of it: this proxy chains into nothing. It dials the target itself, which is why a download that comes through here is both metered and unproxied - and why "the direct gateway" and "the loopback proxy" are the same path, not two.

The hazard that follows from that is worth stating where somebody reading this package will find it. Per-download routing works by naming a proxy on the download request itself, and gopeed resolves the request's proxy INSTEAD of the global one, not in addition to it. So a routed download does not come past here at all and is not metered. That is a deliberate trade in this build (see Engine.DownloadVia); the reason it is not fixed here is that carrying an upstream proxy per download would need this one listener to learn which download each connection belongs to, and a request carries nothing that says so. The arrangement that answers it is a listener per task, which is what the bandwidth budget is being built around - not a chain bolted onto this file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is the loopback proxy.

func Start

func Start(lim *throttle.Limiter) (*Server, error)

Start brings the proxy up on a free loopback port.

func (*Server) Addr

func (s *Server) Addr() string

Addr is the host:port to configure as the HTTP proxy.

func (*Server) Close

func (s *Server) Close() error

Jump to

Keyboard shortcuts

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