Documentation
¶
Index ¶
- Variables
- func CreateTransport(o *Options) *http.Transport
- func GetFreePort() (int, error)
- func IsDomain(s string) bool
- func IsHost(s string) bool
- func IsIP(s string) bool
- func New(proxyURL string, options ...Option) (*http.Client, error)
- func Ping(host string, port string, timeout time.Duration) bool
- func PingWithScheme(host string, port string, scheme string, timeout time.Duration) bool
- func ProxyHTTP(u *url.URL, o *Options) (http.RoundTripper, error)
- func ProxySocks4(u *url.URL, o *Options) (http.RoundTripper, error)
- func ProxySocks5(u *url.URL, o *Options) (http.RoundTripper, error)
- func RegisterParser(proto string, f FuncParser)
- func RegisterProxy(proto string, f ProxyFunc)
- func SchemeOfURL(rawURL string) string
- func SetDeadline(conn net.Conn, timeout time.Duration, disableKeepAlives bool) (net.Conn, error)
- func WithRecover(dial func() (net.Conn, error)) (conn net.Conn, err error)
- type Bool
- type Dialer
- type FuncParser
- type Int
- type Option
- type Options
- type ProxyFunc
- type String
- type URL
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownProtocol = errors.New("proxyclient: unknown proxy protocol") ErrInvalidHost = errors.New("proxyclient: invalid proxy host") )
Functions ¶
func CreateTransport ¶ added in v0.0.2
func GetFreePort ¶ added in v0.0.2
func Ping ¶ added in v0.0.2
Ping performs a TCP fast-fail dial to host:port and reports whether the remote accepted the SYN within the (capped) timeout. It is intentionally limited to TCP: hysteria2 / hy2 use UDP, and a successful TCP dial against a UDP-only endpoint is meaningless. Use PingWithScheme for protocol-aware dispatch.
The returned bool is best-effort: even if the kernel returns a SYN-ACK, the remote service may still be dead. The caller is expected to run a full status probe afterwards; Ping is only a cheap pre-filter.
func PingWithScheme ¶ added in v0.1.1
PingWithScheme dispatches to TCP or UDP fast-fail based on the proxy scheme. Unknown schemes fall back to TCP. scheme matching is case-insensitive and supports the short alias "hy2" alongside "hysteria2".
UDP fast-fail: dial the UDP socket, send a 0-byte datagram, then attempt a short read. A successful dial + write implies the port is open; ICMP "port unreachable" or a read error from a half-open socket is treated as still-alive for hysteresis reasons (UDP is unreliable and a single probe is not authoritative).
func ProxySocks4 ¶
func ProxySocks5 ¶
func RegisterParser ¶ added in v0.0.3
func RegisterParser(proto string, f FuncParser)
func RegisterProxy ¶
func SchemeOfURL ¶ added in v0.1.1
SchemeOfURL extracts the scheme from a raw proxy URL string. It tolerates whitespace and an empty input. An unparsable URL returns "".
This is a lightweight parser used by callers that already have a raw URL string (e.g. the SQLite-backed proxy table) and don't want to pay the cost of a full url.Parse round-trip into the proxyclient URL registry.
func SetDeadline ¶ added in v0.0.8
Types ¶
type Bool ¶ added in v0.0.5
type Bool struct {
// contains filtered or unexported fields
}
func (*Bool) MarshalJSON ¶ added in v0.0.5
func (*Bool) UnmarshalJSON ¶ added in v0.0.5
type Int ¶ added in v0.0.3
type Int struct {
// contains filtered or unexported fields
}
func (*Int) MarshalJSON ¶ added in v0.0.3
func (*Int) UnmarshalJSON ¶ added in v0.0.3
type String ¶ added in v0.0.5
type String struct {
// contains filtered or unexported fields
}