proxy

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package proxy provides per-request proxy selection for CredBaron.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoHealthyProxies = errors.New("no healthy proxies available")

Functions

This section is empty.

Types

type FileSource

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

FileSource loads a proxy list from disk and tracks per-entry health. A proxy reported with err != nil is considered unhealthy until `cooldown` elapses, then it is tried again.

func NewFileSource

func NewFileSource(path string, s Strategy) (*FileSource, error)

func (*FileSource) Next

func (s *FileSource) Next(ctx context.Context) (*url.URL, error)

func (*FileSource) Report

func (s *FileSource) Report(u *url.URL, err error)

type RotatingEndpointSource

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

RotatingEndpointSource returns the same base proxy URL for every call but rewrites the username with a configurable session token pattern so the upstream residential-proxy provider gives each request a fresh IP.

func NewRotatingEndpoint

func NewRotatingEndpoint(base *url.URL, pattern string) (*RotatingEndpointSource, error)

The pattern is appended to the username separated by "-", with tokens:

  • {rand} 8-hex random per-call
  • {seq} monotonic counter starting at 1
  • {uuid} uuid v4

func (*RotatingEndpointSource) Next

func (*RotatingEndpointSource) Report

func (s *RotatingEndpointSource) Report(_ *url.URL, _ error)

type Source

type Source interface {
	Next(ctx context.Context) (*url.URL, error)

	// Report feeds the per-request outcome back to the source so it
	// can track proxy health. err == nil means success. Implementations
	// that don't track health (e.g. single rotating endpoints) make
	// this a no-op.
	Report(u *url.URL, err error)
}

Source hands out proxy URLs for individual HTTP requests. All implementations must be safe for concurrent use.

type Strategy

type Strategy int
const (
	StrategyRandom Strategy = iota
	StrategyRoundRobin
)

Jump to

Keyboard shortcuts

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