Documentation
¶
Index ¶
- Constants
- Variables
- func Close()
- func CurrentDialer() *fastdialer.Dialer
- func DialTLSFor(d *fastdialer.Dialer, mode string) func(ctx context.Context, network, addr string) (net.Conn, error)
- func Init(options *types.Options) error
- func IsLowOnMemory() bool
- func NewDialer(options *types.Options) (*fastdialer.Dialer, error)
- func SetLowMemoryForTest(low bool) (reset func())
- func StartActiveMemGuardian(ctx context.Context)
- func StopActiveMemGuardian()
- func TLSSessionCache() tls.ClientSessionCache
Constants ¶
const ( TLSImpersonateOff = "off" TLSImpersonateChrome = "chrome" TLSImpersonateRandom = "random" )
TLS ClientHello impersonation modes for target traffic (--tls-impersonate).
Off is Go's crypto/tls ClientHello, which bot-management products (Cloudflare, Akamai, DataDome, ...) know as a non-browser JA3/JA4. Chrome sends a current Chrome ClientHello through utls; Random sends a randomized one per connection, which matches no published fingerprint blocklist but no browser either.
Only the TLS layer changes. The transport still speaks HTTP/1.1, so ALPN is pinned to http/1.1 where Chrome would offer h2 first: JA3 matches Chrome, JA4's ALPN field reads h1 where Chrome's reads h2.
Variables ¶
var Dialer *fastdialer.Dialer
Dialer is a shared fastdialer instance for host DNS resolution. Prefer CurrentDialer() for reads; the variable is exported for backward compatibility but is mutated under mu.
var ErrDialerPolicyConflict = errors.New(
"network dialer already initialized with a different network policy; " +
"concurrent scans cannot use conflicting exclude/resolver settings")
ErrDialerPolicyConflict is returned by Init when the shared dialer already exists and was built from a DIFFERENT network policy.
The dialer is process-global and built once, from whichever options reached Init first. Every later Init silently adopted it. For a deny list that is the wrong direction to fail: a second scan configured to refuse a host would reuse a dialer that allows it, and nothing would say so. The tripwire fails closed instead — the caller learns its policy cannot be honoured rather than running under someone else's.
No current behaviour changes: ExcludeTargets, RestrictLocalNetworkAccess, SystemResolvers, DialerTimeout and DialerKeepAlive are not assigned anywhere in the tree, so every Init today computes the same key. This exists so the first code to wire one of them cannot land the silent-inheritance bug with it; the real fix (a scan-local dialer) is a larger change.
var TLSImpersonateModes = []string{TLSImpersonateOff, TLSImpersonateChrome, TLSImpersonateRandom}
TLSImpersonateModes lists the accepted --tls-impersonate values.
Functions ¶
func Close ¶
func Close()
Close releases one reference to the global shared fastdialer. The dialer is closed and reset to nil only when the final reference is released, allowing a later Init() to re-create it. Extra Close() calls (more than Init()) are ignored rather than tearing down a dialer still in use.
func CurrentDialer ¶
func CurrentDialer() *fastdialer.Dialer
CurrentDialer returns the shared dialer (nil if not initialized), read under the lock so it doesn't race with Init/Close.
func DialTLSFor ¶ added in v0.6.0
func DialTLSFor(d *fastdialer.Dialer, mode string) func(ctx context.Context, network, addr string) (net.Conn, error)
DialTLSFor returns the TLS dial function the scan transport uses for mode: dialTLSResumable for Off, an impersonating dial otherwise.
An impersonated handshake that the server refuses (a TLS alert, a version or cipher it does not speak, a reset mid-handshake) is retried once with the stock dial, which keeps fastdialer's TLS 1.0 / legacy-cipher reach; that host then stays on the stock dial for the rest of the process so it does not pay a failed handshake per connection. Dial errors, timeouts and cancellation are returned as they are.
func Init ¶
Init creates the global Dialer instance based on user configuration, or reuses the existing one, and registers one reference. Every successful Init must be paired with exactly one Close.
Reuse requires the SAME network policy: an Init whose policy differs from the live dialer's returns ErrDialerPolicyConflict and takes no reference, so the caller must not Close. See ErrDialerPolicyConflict.
func IsLowOnMemory ¶
func IsLowOnMemory() bool
IsLowOnMemory reports whether the running memory monitor is in its warning state (used RAM over MEMGUARDIAN_MAX_RAM_RATIO, default 75%, or over MEMGUARDIAN_MAX_RAM). Admission control reads it to back off: the executor's active-task scheduler halves its global concurrency while it is true.
func NewDialer ¶
func NewDialer(options *types.Options) (*fastdialer.Dialer, error)
NewDialer creates a new fastdialer instance based on user configuration.
func SetLowMemoryForTest ¶ added in v0.5.7
func SetLowMemoryForTest(low bool) (reset func())
SetLowMemoryForTest forces IsLowOnMemory's answer; reset restores it. For tests of components that back off under memory pressure.
func StartActiveMemGuardian ¶
func StopActiveMemGuardian ¶
func StopActiveMemGuardian()
func TLSSessionCache ¶ added in v0.5.5
func TLSSessionCache() tls.ClientSessionCache
TLSSessionCache returns the shared client session cache.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package networktest holds test helpers for transports built on pkg/core/network.
|
Package networktest holds test helpers for transports built on pkg/core/network. |