proxy

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package proxy provides proxy IP pool management and online filtering.

Index

Constants

View Source
const (
	CONN_TIMEOUT = 4 //4s
	DAIL_TIMEOUT = 4 //4s
	TRY_TIMES    = 3
	// Max concurrency for IP speed testing
	MAX_THREAD_NUM = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Proxy manages a pool of proxy IPs with online filtering and per-host sorting.

func New

func New() *Proxy

New creates and starts a Proxy that loads and filters proxy IPs from config.

func (*Proxy) Count

func (p *Proxy) Count() int32

Count returns the number of online proxy IPs.

func (*Proxy) GetOne

func (p *Proxy) GetOne(u string) option.Option[string]

GetOne returns an unused proxy IP for this cycle and its response time.

func (*Proxy) SetSurfForTest added in v1.4.0

func (p *Proxy) SetSurfForTest(s surfer.Surfer)

SetSurfForTest injects a Surfer for testing.

func (*Proxy) Update

func (p *Proxy) Update() result.VoidResult

Update refreshes the proxy IP list.

func (*Proxy) UpdateTicker

func (p *Proxy) UpdateTicker(tickMinute int64)

UpdateTicker updates the ticker.

type ProxyForHost

type ProxyForHost struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ProxyForHost manages proxy IPs for a host, sorted by response time.

func (*ProxyForHost) Len

func (ph *ProxyForHost) Len() int

Len implements sort.Interface.

func (*ProxyForHost) Less

func (ph *ProxyForHost) Less(i, j int) bool

func (*ProxyForHost) Swap

func (ph *ProxyForHost) Swap(i, j int)

Jump to

Keyboard shortcuts

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