Documentation
¶
Overview ¶
Package proxylib parses proxy lists in any practical format and turns entries into usable dialers/URLs.
Supported protocols: http, https, socks4, socks4a, socks5, socks5h.
Accepted input formats (mixed freely, separated by newlines, commas or semicolons; a JSON array of strings is accepted too):
http://user:pass@host:8080 https://host:443 socks5://host:1080 socks5h://user:pass@host socks4://host:1080 socks4a://host:1080 user:pass@host:8080 host:8080 host:8080:user:pass host (http, port 80) [::1]:8080 [::1]:8080:user:pass
Rules:
- scheme defaults to http when omitted (port defaults: http 80, https 443, socks* 1080);
- path/query/fragment on scheme URLs are stripped (new-api compat);
- IPv6 literals must be bracketed;
- lines starting with '#' are comments and skipped;
- duplicate entries are removed (first occurrence wins);
- credentials are never exposed: String() masks the password and the package never logs raw proxy strings.
Index ¶
Constants ¶
const ( SchemeHTTP = "http" SchemeHTTPS = "https" SchemeSOCKS4 = "socks4" SchemeSOCKS4a = "socks4a" SchemeSOCKS5 = "socks5" SchemeSOCKS5h = "socks5h" )
Schemes the parser accepts.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
Entry is a single normalized proxy.
func Parse ¶
Parse parses a raw multi-entry list strictly: any invalid entry fails the whole list (with the offending lines in the error message).
func ParseEntry ¶
ParseEntry parses a single proxy token in any supported format.
func (Entry) DialContext ¶
DialContext returns a dial function that connects to address through the proxy. For socks variants the connection is a raw tunnel; for http/https proxies use URL() with http.Transport.Proxy instead.
socks5 resolves the destination locally; socks5h, socks4a and socks4 send the hostname to the proxy (remote DNS; socks4 sends an IP — for socks4 the hostname is resolved locally, like socks5).
func (Entry) IsHTTP ¶
IsHTTP reports whether the entry is an http/https proxy (used through http.Transport.Proxy).
func (Entry) Key ¶
Key returns the identity used for de-duplication. The password is part of the identity: rotating-session providers (bpproxy, oxylabs, …) encode the session id in the password, so two entries with the same user/host/port but different passwords are different proxies.