Documentation
¶
Overview ¶
Package proxypool adapts the proxypool library to router policy and storage.
Index ¶
- Variables
- func TransportFor(proxyURL string, timeout time.Duration) (*http.Transport, error)
- type Candidate
- type DemandStat
- type LaneStat
- type NetStatus
- type Proxy
- type Service
- func (s *Service) DeleteCustomPool(id string) error
- func (s *Service) Get(id string) (*Proxy, error)
- func (s *Service) KnownIDs() ([]string, error)
- func (s *Service) List() ([]*Proxy, error)
- func (s *Service) ListCustomPools() ([]*models.CustomProxyPool, error)
- func (s *Service) MarkDead(url, reason string) bool
- func (s *Service) Query(pool, country string, limit int) ([]models.ProxyView, error)
- func (s *Service) RecheckBanned(reason, source string) (int, error)
- func (s *Service) RequestIngest() bool
- func (s *Service) Require(ctx context.Context, req models.ProxyRequire) (models.ProxyRequireResult, error)
- func (s *Service) SaveCustomPool(pool *models.CustomProxyPool) (*models.CustomProxyPool, error)
- func (s *Service) SetLogger(logger *slog.Logger)
- func (s *Service) SetSourceHandlers(keys func() ([]string, error), ...)
- func (s *Service) SourceInfos() []SourceInfo
- func (s *Service) Start(ctx context.Context)
- func (s *Service) Status() (Status, error)
- type SourceInfo
- type SourceStat
- type Status
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoProxies = errors.New("proxy pool has no usable proxy") ErrInvalidBanReason = errors.New("invalid proxy ban reason") )
Functions ¶
func TransportFor ¶
TransportFor builds an HTTP transport for a library-supported proxy URL (http/https/socks4/socks5, with optional userinfo credentials). Dialing lives in the proxypool library; this wrapper keeps the router-internal call boundary stable.
Types ¶
type Candidate ¶ added in v0.3.8
Candidate is one proxy endpoint produced by a Lua proxy-source feed.
type DemandStat ¶ added in v0.3.8
type DemandStat struct {
Countries []string `json:"countries"`
State string `json:"state"`
Waiters int `json:"waiters"`
Alive int `json:"alive"`
Target int `json:"target"`
Served int64 `json:"served"`
CreatedAt time.Time `json:"created_at,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
ReplenishUntil time.Time `json:"replenish_until,omitempty"`
LastSatisfiedAt time.Time `json:"last_satisfied_at,omitempty"`
}
DemandStat reports one registered country demand.
type Proxy ¶ added in v0.3.7
type Proxy struct {
ID string `json:"id"`
URL string `json:"url"`
Location string `json:"location"`
Latency time.Duration `json:"latency"`
Score float64 `json:"score"`
LastChecked time.Time `json:"last_checked"`
}
Proxy is the stable router-facing view of a validated library entry.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns the adapter boundary, persistence and pool lifecycle. Proxy health and lifecycle remain in the proxypool library. Provider request routing never consults this service: plugins select proxies through Query and assign proxy_url per request.
func (*Service) DeleteCustomPool ¶ added in v0.3.8
DeleteCustomPool removes a custom pool by ID.
func (*Service) KnownIDs ¶ added in v0.3.7
KnownIDs returns IDs for all cached proxies, including dead entries.
func (*Service) ListCustomPools ¶ added in v0.3.8
func (s *Service) ListCustomPools() ([]*models.CustomProxyPool, error)
ListCustomPools returns every manually managed proxy pool by name order.
func (*Service) MarkDead ¶ added in v0.3.8
MarkDead applies the router failure mapping before updating proxy health.
func (*Service) Query ¶ added in v0.3.8
Query returns proxy endpoints for plugin selection. Pool "auto" reads the library free pool in rank order; empty pool means direct and returns no endpoints; any other name reads a custom pool by ID or name. Country filters case-insensitively; limit caps the result (<=0 means all).
func (*Service) RecheckBanned ¶ added in v0.3.8
RecheckBanned queues manual rechecks for banned proxies matching the filters.
func (*Service) RequestIngest ¶ added in v0.3.8
RequestIngest requests an immediate source ingest when the service is running.
func (*Service) Require ¶ added in v0.3.8
func (s *Service) Require(ctx context.Context, req models.ProxyRequire) (models.ProxyRequireResult, error)
Require serves proxies.require. The free pool waits for a matching live proxy up to req.Timeout; an empty pool means direct; a custom pool answers from its own entries without waiting.
func (*Service) SaveCustomPool ¶ added in v0.3.8
func (s *Service) SaveCustomPool(pool *models.CustomProxyPool) (*models.CustomProxyPool, error)
SaveCustomPool creates or replaces a custom pool. IDs are slugified from the name when empty; entries with empty URLs are dropped.
func (*Service) SetSourceHandlers ¶ added in v0.3.7
func (s *Service) SetSourceHandlers(keys func() ([]string, error), fetch func(context.Context, string) ([]Candidate, error))
SetSourceHandlers connects registered Lua proxy-source feeds.
func (*Service) SourceInfos ¶ added in v0.0.5
func (s *Service) SourceInfos() []SourceInfo
SourceInfos returns last-fetch diagnostics for currently registered feeds.
type SourceInfo ¶ added in v0.0.5
type SourceInfo struct {
Key string `json:"key"`
Name string `json:"name"`
LastFetchAt time.Time `json:"last_fetch_at,omitempty"`
Total int `json:"total"`
Unsupported int `json:"unsupported"`
LastError string `json:"last_error,omitempty"`
}
SourceInfo reports feed diagnostics for registered Lua proxy sources.
type SourceStat ¶ added in v0.3.8
type Status ¶ added in v0.3.7
type Status struct {
Mode string `json:"mode"`
Net NetStatus `json:"net"`
Limit int `json:"limit"`
Inflight int `json:"inflight"`
Total int `json:"total"`
Alive int `json:"alive"`
Suspect int `json:"suspect"`
Banned int `json:"banned"`
Queued int `json:"queued"`
Lanes []LaneStat `json:"lanes"`
Sources []SourceStat `json:"sources"`
BanReasons map[string]int `json:"ban_reasons"`
Demands []DemandStat `json:"demands"`
LastIngestAt time.Time `json:"last_ingest_at,omitempty"`
LastError string `json:"last_error,omitempty"`
}