Documentation ¶
Index ¶
- Constants
- Variables
- func AddHost(host string, ip string)
- func DialContext(ctx context.Context, target string, proxies ...string) (net.Conn, error)
- func DialContextWithoutProxy(ctx context.Context, network, addr string) (net.Conn, error)
- func DialSocksProxy(socksType int, proxy string, username string, password string) func(string, string) (net.Conn, error)
- func DialTCPTimeout(timeout time.Duration, target string, proxies ...string) (net.Conn, error)
- func DialTCPTimeoutForceProxy(timeout time.Duration, target string, proxy string) (net.Conn, error)
- func DialTLSTimeout(timeout time.Duration, target string, tlsConfig any, proxy ...string) (net.Conn, error)
- func DialTimeout(connectTimeout time.Duration, target string, proxy ...string) (net.Conn, error)
- func DialTimeoutWithoutProxy(timeout time.Duration, network, addr string) (net.Conn, error)
- func DialX(target string, opt ...DialXOption) (net.Conn, error)
- func FixProxy(i string) string
- func GetDefaultHostsFilePath() string
- func GetHost(host string) (ip string, ok bool)
- func IsExistedHost(host string) bool
- func IsTLSService(addr string, proxies ...string) bool
- func LoadCertificatesConfig(i any) error
- func LoadHostsFromFile(p string) error
- func LoadP12Bytes(p12bytes []byte, password string) error
- func LookupAll(host string, opt ...DNSOption) []string
- func LookupCallback(host string, h func(dnsType, domain, ip, fromServer string, method string), ...) error
- func LookupFirst(host string, opt ...DNSOption) string
- func NewDefaultHTTPClient(proxy ...string) *http.Client
- func NewDialContextFunc(timeout time.Duration, opts ...DNSOption) func(ctx context.Context, network string, addr string) (net.Conn, error)
- func NewDialGMTLSContextFunc(enableGM bool, preferGMTLS bool, onlyGMTLS bool, timeout time.Duration, ...) func(ctx context.Context, network string, addr string) (net.Conn, error)
- func ProxyCheck(proxy string, connectTimeout time.Duration) (net.Conn, error)
- func SetDefaultDNSOptions(opt ...DNSOption)
- func SetDefaultDialXConfig(opt ...DialXOption)
- func UnsetProxyFromEnv()
- func UpgradeToTLSConnection(conn net.Conn, sni string, i any) (net.Conn, error)
- func UpgradeToTLSConnectionWithTimeout(conn net.Conn, sni string, i any, timeout time.Duration, ...) (net.Conn, error)
- type DNSOption
- func GetDefaultOptions() []DNSOption
- func WithDNSCallback(cb func(dnsType, domain, ip, fromServer, method string)) DNSOption
- func WithDNSContext(ctx context.Context) DNSOption
- func WithDNSDisableSystemResolver(b bool) DNSOption
- func WithDNSDisabledDomain(domain ...string) DNSOption
- func WithDNSFallbackDoH(b bool) DNSOption
- func WithDNSFallbackSpecificDNS(b bool) DNSOption
- func WithDNSFallbackTCP(b bool) DNSOption
- func WithDNSNoCache(b bool) DNSOption
- func WithDNSOnFinished(cb func()) DNSOption
- func WithDNSPreferDoH(b bool) DNSOption
- func WithDNSPreferTCP(b bool) DNSOption
- func WithDNSRetryTimes(i int) DNSOption
- func WithDNSServers(s ...string) DNSOption
- func WithDNSSpecificDoH(s ...string) DNSOption
- func WithTemporaryHosts(i map[string]string) DNSOption
- func WithTimeout(timeout time.Duration) DNSOption
- type DialXOption
- func DialX_Debug(b bool) DialXOption
- func DialX_WithDNSOptions(opt ...DNSOption) DialXOption
- func DialX_WithDisableProxy(b bool) DialXOption
- func DialX_WithDisallowAddress(a ...string) DialXOption
- func DialX_WithEnableSystemProxyFromEnv(b bool) DialXOption
- func DialX_WithForceProxy(b bool) DialXOption
- func DialX_WithGMTLSConfig(config *gmtls.Config) DialXOption
- func DialX_WithGMTLSOnly(b bool) DialXOption
- func DialX_WithGMTLSPrefer(b bool) DialXOption
- func DialX_WithGMTLSSupport(b bool) DialXOption
- func DialX_WithKeepAlive(aliveTime time.Duration) DialXOption
- func DialX_WithProxy(proxy ...string) DialXOption
- func DialX_WithSNI(sni string) DialXOption
- func DialX_WithTLS(b bool) DialXOption
- func DialX_WithTLSConfig(tlsConfig any) DialXOption
- func DialX_WithTLSNextProto(nextProtos ...string) DialXOption
- func DialX_WithTLSTimeout(t time.Duration) DialXOption
- func DialX_WithTimeout(timeout time.Duration) DialXOption
- func DialX_WithTimeoutRetry(max int) DialXOption
- func DialX_WithTimeoutRetryWait(timeout time.Duration) DialXOption
- func DialX_WithTimeoutRetryWaitRange(min, max time.Duration) DialXOption
- type DoHDNSResponse
- type ReliableDNSConfig
- type TLSInspectResult
- type TLSStrategy
Constants ¶
const ( SOCKS4 = iota SOCKS4A SOCKS5 )
Constants to choose which version of SOCKS protocol to use.
const DefaultUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
Variables ¶
var DefaultCustomDNSServers = []string{
"223.5.5.5", "223.6.6.6",
"120.53.53.53", "1.1.1.1",
"8.8.8.8",
}
var DefaultCustomDoHServers = []string{
"https://223.5.5.5/resolve",
"https://223.6.6.6/resolve",
"https://1.12.12.12/dns-query",
"https://120.53.53.53/dns-query",
"https://1.1.1.1/dns-query",
"https://8.8.8.8/resolve",
"https://8.8.4.4/resolve",
}
var ErrorProxyAuthFailed = utils.Error("invalid proxy username or password")
Functions ¶
func DialContext ¶ added in v1.2.5
func DialContextWithoutProxy ¶
DialContextWithoutProxy dials a connection with a context.
func DialSocksProxy ¶
func DialSocksProxy(socksType int, proxy string, username string, password string) func(string, string) (net.Conn, error)
DialSocksProxy returns the dial function to be used in http.Transport object. Argument socksType should be one of SOCKS4, SOCKS4A and SOCKS5. Argument proxy should be in this format "127.0.0.1:1080".
func DialTCPTimeout ¶
DialTCPTimeout is alias for DialTimeout
func DialTLSTimeout ¶
func DialTLSTimeout(timeout time.Duration, target string, tlsConfig any, proxy ...string) (net.Conn, error)
DialTLSTimeout is a shortcut for DialX with timeout
func DialTimeout ¶
DialTimeout is a shortcut for DialX with timeout
func DialTimeoutWithoutProxy ¶
DialTimeoutWithoutProxy dials a connection with a timeout.
func DialX ¶ added in v1.2.6
func DialX(target string, opt ...DialXOption) (net.Conn, error)
DialX is netx dial with more options
Proxy is a list of proxy servers, if empty, no proxy will be used, otherwise retry with each proxy until success (no redirect)
func GetDefaultHostsFilePath ¶
func GetDefaultHostsFilePath() string
func IsExistedHost ¶
func IsTLSService ¶
func LoadCertificatesConfig ¶ added in v1.2.7
func LoadP12Bytes ¶ added in v1.2.7
func LookupCallback ¶
func LookupFirst ¶
func NewDefaultHTTPClient ¶ added in v1.2.6
func NewDialContextFunc ¶
func NewDialContextFunc(timeout time.Duration, opts ...DNSOption) func(ctx context.Context, network string, addr string) (net.Conn, error)
NewDialContextFunc is a function that can be used to dial a connection.
func NewDialGMTLSContextFunc ¶
func ProxyCheck ¶ added in v1.2.9
func SetDefaultDNSOptions ¶ added in v1.2.8
func SetDefaultDNSOptions(opt ...DNSOption)
func SetDefaultDialXConfig ¶ added in v1.2.8
func SetDefaultDialXConfig(opt ...DialXOption)
func UnsetProxyFromEnv ¶ added in v1.2.8
func UnsetProxyFromEnv()
func UpgradeToTLSConnection ¶
Types ¶
type DNSOption ¶
type DNSOption func(*ReliableDNSConfig)
func GetDefaultOptions ¶
func GetDefaultOptions() []DNSOption
func WithDNSCallback ¶
func WithDNSContext ¶
func WithDNSDisabledDomain ¶ added in v1.2.8
func WithDNSFallbackDoH ¶
func WithDNSFallbackTCP ¶
func WithDNSNoCache ¶
func WithDNSOnFinished ¶ added in v1.2.6
func WithDNSOnFinished(cb func()) DNSOption
func WithDNSPreferDoH ¶
func WithDNSPreferTCP ¶
func WithDNSRetryTimes ¶
func WithDNSServers ¶
func WithDNSSpecificDoH ¶
func WithTemporaryHosts ¶
func WithTimeout ¶
type DialXOption ¶ added in v1.2.6
type DialXOption func(c *dialXConfig)
func DialX_Debug ¶ added in v1.2.7
func DialX_Debug(b bool) DialXOption
func DialX_WithDNSOptions ¶ added in v1.2.6
func DialX_WithDNSOptions(opt ...DNSOption) DialXOption
func DialX_WithDisableProxy ¶ added in v1.2.8
func DialX_WithDisableProxy(b bool) DialXOption
func DialX_WithDisallowAddress ¶ added in v1.2.8
func DialX_WithDisallowAddress(a ...string) DialXOption
func DialX_WithEnableSystemProxyFromEnv ¶ added in v1.2.8
func DialX_WithEnableSystemProxyFromEnv(b bool) DialXOption
func DialX_WithForceProxy ¶ added in v1.2.8
func DialX_WithForceProxy(b bool) DialXOption
func DialX_WithGMTLSConfig ¶ added in v1.2.6
func DialX_WithGMTLSConfig(config *gmtls.Config) DialXOption
func DialX_WithGMTLSOnly ¶ added in v1.2.6
func DialX_WithGMTLSOnly(b bool) DialXOption
func DialX_WithGMTLSPrefer ¶ added in v1.2.6
func DialX_WithGMTLSPrefer(b bool) DialXOption
func DialX_WithGMTLSSupport ¶ added in v1.2.6
func DialX_WithGMTLSSupport(b bool) DialXOption
func DialX_WithKeepAlive ¶ added in v1.2.7
func DialX_WithKeepAlive(aliveTime time.Duration) DialXOption
func DialX_WithProxy ¶ added in v1.2.6
func DialX_WithProxy(proxy ...string) DialXOption
func DialX_WithSNI ¶ added in v1.2.6
func DialX_WithSNI(sni string) DialXOption
func DialX_WithTLS ¶ added in v1.2.6
func DialX_WithTLS(b bool) DialXOption
func DialX_WithTLSConfig ¶ added in v1.2.6
func DialX_WithTLSConfig(tlsConfig any) DialXOption
func DialX_WithTLSNextProto ¶ added in v1.2.8
func DialX_WithTLSNextProto(nextProtos ...string) DialXOption
func DialX_WithTLSTimeout ¶ added in v1.2.6
func DialX_WithTLSTimeout(t time.Duration) DialXOption
func DialX_WithTimeout ¶ added in v1.2.6
func DialX_WithTimeout(timeout time.Duration) DialXOption
func DialX_WithTimeoutRetry ¶ added in v1.2.6
func DialX_WithTimeoutRetry(max int) DialXOption
func DialX_WithTimeoutRetryWait ¶ added in v1.2.6
func DialX_WithTimeoutRetryWait(timeout time.Duration) DialXOption
func DialX_WithTimeoutRetryWaitRange ¶ added in v1.2.6
func DialX_WithTimeoutRetryWaitRange(min, max time.Duration) DialXOption
type DoHDNSResponse ¶
type DoHDNSResponse struct { Status int `json:"Status"` TC bool `json:"TC"` RD bool `json:"RD"` RA bool `json:"RA"` AD bool `json:"AD"` CD bool `json:"CD"` Question json.RawMessage Answer []struct { Name string `json:"name"` Type int `json:"type"` TTL int `json:"TTL"` Data string `json:"data"` } `json:"Answer"` }
type ReliableDNSConfig ¶
type ReliableDNSConfig struct { Timeout time.Duration Hosts map[string]string PreferTCP bool FallbackTCP bool RetryTimes int // default 3 // DoH config PreferDoH bool FallbackDoH bool // as backup SpecificDoH []string // NoCache NoCache bool // Disable System Resolver DisableSystemResolver bool // SpecificDNSServers 作为备选项 FallbackSpecificDNS bool SpecificDNSServers []string // ctx BaseContext context.Context Callback func(dnsType string, domain string, ip, fromServer, method string) OnFinished func() // blacklist DisabledDomain *utils.HostsFilter // contains filtered or unexported fields }
func NewBackupInitilizedReliableDNSConfig ¶
func NewBackupInitilizedReliableDNSConfig() *ReliableDNSConfig
func NewDefaultReliableDNSConfig ¶
func NewDefaultReliableDNSConfig() *ReliableDNSConfig
func (*ReliableDNSConfig) GetBaseContext ¶
func (r *ReliableDNSConfig) GetBaseContext() context.Context
type TLSInspectResult ¶ added in v1.2.7
type TLSInspectResult struct { Description string Raw []byte RelativeDomains []string RelativeEmail []string RelativeAccount []string RelativeURIs []string }
func TLSInspect ¶ added in v1.2.7
func TLSInspect(addr string) ([]*TLSInspectResult, error)
Inspect 检查目标地址的TLS证书,并返回其证书信息与错误 Example: ``` cert, err := tls.Inspect("yaklang.io:443") ```
func (TLSInspectResult) Show ¶ added in v1.2.7
func (t TLSInspectResult) Show()
func (TLSInspectResult) String ¶ added in v1.2.7
func (t TLSInspectResult) String() string
type TLSStrategy ¶ added in v1.2.6
type TLSStrategy string
const ( TLS_Strategy_GMDail TLSStrategy = "gmtls" TLS_Strategy_GMDial_Without_GMSupport TLSStrategy = "gmtls-ns" TLS_Strategy_Ordinary TLSStrategy = "tls" )