Documentation
¶
Index ¶
- Constants
- func FetchProxyDB(ctx context.Context, minUptime float64, maxResponse float64) ([]string, error)
- func IsProxyDBURL(url string) bool
- type Config
- type Fetcher
- type Pool
- func (p *Pool) AddRawProxies(ctx context.Context, proxies []*domain.Proxy) error
- func (p *Pool) AddRawProxy(ctx context.Context, proxy *domain.Proxy) error
- func (p *Pool) AddValidated(proxyAddr string)
- func (p *Pool) AddValidatedProxy(proxy *domain.Proxy)
- func (p *Pool) CleanupDead(ctx context.Context) (int, error)
- func (p *Pool) GetNext() (string, error)
- func (p *Pool) GetNextWithID() (*domain.Proxy, error)
- func (p *Pool) GetStats(ctx context.Context) (*domain.ProxyStats, error)
- func (p *Pool) HasRepo() bool
- func (p *Pool) LoadFromDatabase(ctx context.Context) error
- func (p *Pool) MarkFailed(proxyAddr string)
- func (p *Pool) MarkSuccess(proxyAddr string)
- func (p *Pool) Remove(proxyAddr string)
- func (p *Pool) RemoveByID(id int64)
- func (p *Pool) SetRepo(repo domain.ProxyListRepository)
- func (p *Pool) Size() int
- type ProxyDBEntry
- type ProxyGate
- func (pg *ProxyGate) AddProxyToPool(proxy *domain.Proxy)
- func (pg *ProxyGate) AddSource(url string)
- func (pg *ProxyGate) GetSources() []string
- func (pg *ProxyGate) GetStats() (int, int, time.Time)
- func (pg *ProxyGate) LoadFromDatabase(ctx context.Context) error
- func (pg *ProxyGate) PoolSize() int
- func (pg *ProxyGate) Refresh(ctx context.Context) error
- func (pg *ProxyGate) ReloadFromDatabase(ctx context.Context) error
- func (pg *ProxyGate) RemoveSource(url string)
- func (pg *ProxyGate) Run(ctx context.Context) error
- func (pg *ProxyGate) SetPoolRepo(repo domain.ProxyListRepository)
- type Server
- type Validator
Constants ¶
const DefaultPoolRefreshInterval = 2 * time.Minute
DefaultPoolRefreshInterval is the default interval for refreshing pool from database
Variables ¶
This section is empty.
Functions ¶
func FetchProxyDB ¶
FetchProxyDB fetches and parses proxies from proxydb.net Returns only high-quality proxies (uptime > minUptime%, response < maxResponse seconds)
Types ¶
type Config ¶
type Config struct {
Enabled bool
ListenAddr string // e.g., "localhost:8081"
SourceURLs []string // Default GitHub raw URLs
RefreshInterval time.Duration
ValidatorConcurrency int
}
func DefaultConfig ¶
func DefaultConfig() *Config
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
func NewFetcher ¶
func (*Fetcher) GetSources ¶
func (*Fetcher) LastUpdated ¶
func (*Fetcher) RemoveSource ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages a pool of proxies with optional database persistence
func NewPoolWithRepo ¶
func NewPoolWithRepo(repo domain.ProxyListRepository) *Pool
NewPoolWithRepo creates a new proxy pool with database persistence
func (*Pool) AddRawProxies ¶
AddRawProxies adds multiple raw proxies to the database
func (*Pool) AddRawProxy ¶
AddRawProxy adds a raw (unvalidated) proxy to the database with pending status
func (*Pool) AddValidated ¶
AddValidated adds a validated proxy to the pool
func (*Pool) AddValidatedProxy ¶
AddValidatedProxy adds a validated proxy object to the pool
func (*Pool) CleanupDead ¶
CleanupDead removes dead proxies from database
func (*Pool) GetNextWithID ¶
GetNextWithID returns the next proxy with its database ID
func (*Pool) LoadFromDatabase ¶
LoadFromDatabase loads healthy proxies from database into memory
func (*Pool) MarkFailed ¶
MarkFailed marks a proxy as failed
func (*Pool) MarkSuccess ¶
MarkSuccess marks a proxy as successful
func (*Pool) RemoveByID ¶
RemoveByID removes a proxy by database ID
func (*Pool) SetRepo ¶
func (p *Pool) SetRepo(repo domain.ProxyListRepository)
SetRepo sets the database repository for persistence (can be called after construction)
type ProxyDBEntry ¶
type ProxyDBEntry struct {
IP string
Port int
Country string
Uptime float64 // percentage
Response float64 // seconds
}
ProxyDBEntry represents a parsed proxy from proxydb.net
type ProxyGate ¶
type ProxyGate struct {
// contains filtered or unexported fields
}
func (*ProxyGate) AddProxyToPool ¶
AddProxyToPool adds a proxy directly to the in-memory pool Use this when adding proxies via API to immediately make them available
func (*ProxyGate) GetSources ¶
func (*ProxyGate) LoadFromDatabase ¶
LoadFromDatabase loads healthy proxies from database into the in-memory pool This should be called after SetPoolRepo to initialize the pool with existing proxies
func (*ProxyGate) ReloadFromDatabase ¶
ReloadFromDatabase reloads all healthy proxies from database This can be called periodically or after bulk updates
func (*ProxyGate) RemoveSource ¶
func (*ProxyGate) SetPoolRepo ¶
func (pg *ProxyGate) SetPoolRepo(repo domain.ProxyListRepository)
SetPoolRepo sets the database repository for proxy persistence This can be called after construction when database becomes available