Documentation
¶
Index ¶
- Constants
- func AccountFromContext(ctx context.Context) string
- func BuildSSOCookie(token, cloudflareCookies string) string
- func EgressNodeFromContext(ctx context.Context) uint64
- func QualityProbeFromContext(ctx context.Context) bool
- func RecordDirectPhysicalCall(ctx context.Context, response *http.Response, err error)
- func WithAccount(ctx context.Context, provider string, accountID uint64) context.Context
- func WithAccountIdentity(ctx context.Context, identity string) context.Context
- func WithCredential(ctx context.Context, credential accountdomain.Credential) context.Context
- func WithEgressNode(ctx context.Context, nodeID uint64) context.Context
- func WithPhysicalCallPlane(ctx context.Context, plane string) context.Context
- func WithPhysicalCallStage(ctx context.Context, stage string) context.Context
- func WithPhysicalCallTrace(ctx context.Context, provider, operation string) context.Context
- func WithQualityProbe(ctx context.Context) context.Context
- type ClearanceConfig
- type FailureProber
- type Lease
- func (l *Lease) DialWebSocket(ctx context.Context, endpoint string, headers fhttp.Header, ...) (*websocket.Conn, *fhttp.Response, error)
- func (l *Lease) DialWebSocketDeferredForbidden(ctx context.Context, endpoint string, headers fhttp.Header, ...) (*websocket.Conn, *fhttp.Response, error)
- func (l *Lease) Do(request *http.Request) (*http.Response, error)
- func (l *Lease) DoDeferredForbidden(request *http.Request) (*http.Response, error)
- func (l *Lease) DoPinnedHTTPS(request *http.Request, serverName string) (*http.Response, error)
- func (l *Lease) InvalidateClearance()
- func (l *Lease) Release()
- type Manager
- func (m *Manager) AccountIsolatedConnections() bool
- func (m *Manager) Acquire(ctx context.Context, scope domain.Scope, affinity string) (*Lease, error)
- func (m *Manager) AcquireBuildEnvironmentDirectIfIsolated(ctx context.Context, affinity string) (*Lease, bool, error)
- func (m *Manager) AcquireCredential(ctx context.Context, scope domain.Scope, credential accountdomain.Credential) (*Lease, error)
- func (m *Manager) AcquireIfConfigured(ctx context.Context, scope domain.Scope, affinity string) (*Lease, bool, error)
- func (m *Manager) BuildStreamIdleTimeout() time.Duration
- func (m *Manager) Feedback(ctx context.Context, nodeID uint64, status int, transportErr error)
- func (m *Manager) FeedbackForScope(ctx context.Context, scope domain.Scope, nodeID uint64, status int, ...)
- func (m *Manager) ForgetClearance(nodeID uint64)
- func (m *Manager) ForgetClearances(nodeIDs []uint64)
- func (m *Manager) InvalidateClearance(nodeID uint64)
- func (m *Manager) InvalidateOperationsConfig()
- func (m *Manager) ProbeEgressNode(ctx context.Context, node domain.Node) (domain.ProbeResult, error)
- func (m *Manager) RefreshClearance(ctx context.Context, nodeID uint64) error
- func (m *Manager) RefreshDueClearances(ctx context.Context, force bool) error
- func (m *Manager) SetClearanceLock(value repository.DistributedLock)
- func (m *Manager) SetFailureProber(value FailureProber)
- func (m *Manager) SetLogger(logger *slog.Logger)
- func (m *Manager) UpdateAccountIsolatedConnections(enabled bool)
- func (m *Manager) UpdateBuildResponseHeaderTimeout(value time.Duration)
- func (m *Manager) UpdateBuildStreamIdleTimeout(value time.Duration)
- func (m *Manager) UpdateClearanceConfig(value ClearanceConfig)
- type Selection
- type Trace
Constants ¶
const DefaultUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
Variables ¶
This section is empty.
Functions ¶
func AccountFromContext ¶
AccountFromContext exposes the non-sensitive sticky account identity to provider transports while keeping the context key private.
func BuildSSOCookie ¶
func EgressNodeFromContext ¶
EgressNodeFromContext exposes a non-sensitive binding identifier to the Build transport without exposing the context key itself.
func QualityProbeFromContext ¶
QualityProbeFromContext reports whether the request is an internal administrator quality probe. Gateway retry policy uses this signal to keep ambiguous egress failures from changing credential health.
func RecordDirectPhysicalCall ¶
RecordDirectPhysicalCall records a transport call that intentionally bypasses the managed egress lease because no Build node is configured.
func WithAccount ¶
WithAccount passes a stable Provider account identity to the egress layer. It is used only to render authentication usernames for sticky proxies such as Resin and is never written to upstream headers or audit.
func WithAccountIdentity ¶
WithAccountIdentity attaches the stable, non-sensitive identity used by account-bound proxy templates such as Resin. Providers that represent the same upstream login (for example Web and Console sharing one SSO token) can deliberately pass the same identity so their proxy and clearance lease is not split by the internal provider name.
func WithCredential ¶
func WithCredential(ctx context.Context, credential accountdomain.Credential) context.Context
WithCredential passes the stable egress identity of a weakly linked account to Build transport; unlinked accounts retain the existing Provider+ID identity.
func WithEgressNode ¶
WithEgressNode attaches the explicitly assigned node ID for transports that only receive a request context (notably Grok Build's RoundTripper).
func WithPhysicalCallPlane ¶
WithPhysicalCallPlane annotates a bounded upstream plane while preserving the request-wide ordinal and current stage.
func WithPhysicalCallStage ¶
WithPhysicalCallStage annotates an internal retry or preparation stage while preserving the request-wide ordinal and upstream plane.
func WithPhysicalCallTrace ¶
WithPhysicalCallTrace starts observe-only physical-call accounting for one downstream request. It does not impose a retry budget or alter transport.
Types ¶
type ClearanceConfig ¶
type FailureProber ¶
type Lease ¶
type Lease struct {
NodeID uint64
NodeName string
Scope domain.Scope
ProxyURL string
UserAgent string
CFCookies string
// contains filtered or unexported fields
}
func (*Lease) DialWebSocket ¶
func (*Lease) DialWebSocketDeferredForbidden ¶
func (l *Lease) DialWebSocketDeferredForbidden(ctx context.Context, endpoint string, headers fhttp.Header, handshakeTimeout time.Duration) (*websocket.Conn, *fhttp.Response, error)
DialWebSocketDeferredForbidden leaves a 403 handshake response for the caller to classify before invalidating the browser-session Clearance.
func (*Lease) DoDeferredForbidden ¶
DoDeferredForbidden executes an HTTP request while leaving 403 clearance invalidation to the caller after it has classified the response body.
func (*Lease) DoPinnedHTTPS ¶
DoPinnedHTTPS sends a request whose URL host is an already validated IP address while preserving serverName for TLS verification. Keeping this transport separate from the shared browser client prevents a later DNS lookup or a pooled connection from reopening an SSRF validation gap.
func (*Lease) InvalidateClearance ¶
func (l *Lease) InvalidateClearance()
InvalidateClearance invalidates the exact browser-session binding used by this lease after a 403 has been classified as egress-related.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(repository repository.EgressRepository, cipher *security.Cipher) *Manager
func (*Manager) AccountIsolatedConnections ¶
AccountIsolatedConnections reports whether upstream clients are partitioned by account.
func (*Manager) AcquireBuildEnvironmentDirectIfIsolated ¶
func (m *Manager) AcquireBuildEnvironmentDirectIfIsolated(ctx context.Context, affinity string) (*Lease, bool, error)
AcquireBuildEnvironmentDirectIfIsolated creates an account-partitioned direct Build lease while preserving the legacy direct transport's environment-proxy semantics. The bool is false when isolation was disabled before the lease was acquired, allowing the caller to retain its original fallback transport.
func (*Manager) AcquireCredential ¶
func (m *Manager) AcquireCredential(ctx context.Context, scope domain.Scope, credential accountdomain.Credential) (*Lease, error)
AcquireCredential binds the outbound proxy identity to one persisted Provider credential. Resin templates use this identity as their Account.
func (*Manager) AcquireIfConfigured ¶
func (*Manager) BuildStreamIdleTimeout ¶
BuildStreamIdleTimeout returns the configured stream idle deadline for Grok Build responses. Returns zero when idle enforcement is disabled.
func (*Manager) FeedbackForScope ¶
func (*Manager) ForgetClearance ¶
ForgetClearance evicts runtime state after an administrator changes or removes a node. Unlike a 403 rejection, it does not mark the persisted last-known-good cookie as invalid; ensureClearance will still verify its binding before using it as a solver-failure fallback.
func (*Manager) ForgetClearances ¶
ForgetClearances evicts a batch of node-scoped runtime state with one cache scan and one lock acquisition. Administrative bulk updates can contain thousands of nodes, so repeating the global snapshot invalidation per ID would add avoidable lock contention and CPU work.
func (*Manager) InvalidateClearance ¶
func (*Manager) InvalidateOperationsConfig ¶
func (m *Manager) InvalidateOperationsConfig()
func (*Manager) ProbeEgressNode ¶
func (m *Manager) ProbeEgressNode(ctx context.Context, node domain.Node) (domain.ProbeResult, error)
ProbeEgressNode verifies IPv4 and IPv6 independently through fixed provider endpoints. Both requests share one immutable node snapshot so a concurrent administrator edit cannot mix results from different proxy configurations.
func (*Manager) RefreshClearance ¶
func (*Manager) RefreshDueClearances ¶
func (*Manager) SetClearanceLock ¶
func (m *Manager) SetClearanceLock(value repository.DistributedLock)
SetClearanceLock enables cross-instance coordination for shared, fixed egress nodes. Account-bound Resin clearances remain process-local because they must never be persisted into the node-wide cookie fields.
func (*Manager) SetFailureProber ¶
func (m *Manager) SetFailureProber(value FailureProber)
SetFailureProber enables an immediate, deduplicated connectivity probe after a fixed proxy reports a transport failure. The callback persists the probe result; it must not depend on the failed request context.
func (*Manager) UpdateAccountIsolatedConnections ¶
UpdateAccountIsolatedConnections toggles per-account upstream connection pools. When enabled, different accounts do not share TCP/HTTP clients so upstream egress load balancers can spread traffic by connection; the same account still reuses its own pool. Changing the setting rebuilds cached clients without interrupting in-flight requests.
func (*Manager) UpdateBuildResponseHeaderTimeout ¶
UpdateBuildResponseHeaderTimeout rebuilds only cached Build clients. Active requests keep their current transport and are not interrupted.
func (*Manager) UpdateBuildStreamIdleTimeout ¶
UpdateBuildStreamIdleTimeout affects subsequent Build streams. Active response bodies retain the deadline captured by their existing wrapper and are not interrupted; the underlying HTTP connection pool is unchanged.
func (*Manager) UpdateClearanceConfig ¶
func (m *Manager) UpdateClearanceConfig(value ClearanceConfig)
type Selection ¶
Selection is the egress snapshot actually selected for an upstream request. It contains only metadata safe for audit and excludes proxy URLs, credentials, User-Agent, and Cookies.
type Trace ¶
type Trace struct {
// contains filtered or unexported fields
}
Trace retains the most recent actual egress selection per scope. When a request retries egress, audit records the final attempt. Web asset archival uses an independent scope and does not overwrite the primary Grok Web inference egress.
func TraceFromContext ¶
TraceFromContext returns the egress trace from context, or nil when none is configured.