proxy

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: GPL-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientAPIKeyContextKey contextKey = "client_api_key"
	InstanceIDContextKey   contextKey = "instance_id"
)

Variables

This section is empty.

Functions

func ClientAPIKeyMiddleware

func ClientAPIKeyMiddleware(store *models.ClientAPIKeyStore) func(http.Handler) http.Handler

ClientAPIKeyMiddleware validates client API keys and extracts instance information

func GetClientAPIKeyFromContext

func GetClientAPIKeyFromContext(ctx context.Context) *models.ClientAPIKey

GetClientAPIKeyFromContext retrieves the client API key from the request context

func GetInstanceIDFromContext

func GetInstanceIDFromContext(ctx context.Context) int

GetInstanceIDFromContext retrieves the instance ID from the request context

Types

type BufferPool

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

BufferPool provides a thread-safe pool of byte slices for the reverse proxy

func NewBufferPool

func NewBufferPool() *BufferPool

NewBufferPool creates a new buffer pool with 32KB buffers

func (*BufferPool) Get

func (p *BufferPool) Get() []byte

Get returns a buffer from the pool

func (*BufferPool) Put

func (p *BufferPool) Put(buf []byte)

Put returns a buffer to the pool

type Handler

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

Handler manages reverse proxy requests to qBittorrent instances

func NewHandler

func NewHandler(clientPool *qbittorrent.ClientPool, clientAPIKeyStore *models.ClientAPIKeyStore, instanceStore *models.InstanceStore, syncManager *qbittorrent.SyncManager, cache *reannounce.SettingsCache, svc *reannounce.Service, baseURL string) *Handler

NewHandler creates a new proxy handler

func (*Handler) Routes

func (h *Handler) Routes(r chi.Router)

Routes sets up the proxy routes

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles the reverse proxy request (fallback for non-intercepted routes)

type RetryTransport added in v1.6.0

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

RetryTransport wraps an http.RoundTripper with retry logic for transient network errors

func NewRetryTransport added in v1.6.0

func NewRetryTransport(base http.RoundTripper) *RetryTransport

NewRetryTransport creates a new RetryTransport that wraps the given RoundTripper

func NewRetryTransportWithSelector added in v1.12.0

func NewRetryTransportWithSelector(base http.RoundTripper, selector func(*http.Request) http.RoundTripper) *RetryTransport

NewRetryTransportWithSelector creates a new RetryTransport using a per-request selector. The selector may return nil to fall back to the default base transport.

func (*RetryTransport) RoundTrip added in v1.6.0

func (t *RetryTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper with retry logic for transient errors

Jump to

Keyboard shortcuts

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