agentproxy

package
v0.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeDirectDNS                  = "direct_dns"
	CodeDirectConnect              = "direct_connect"
	CodeDirectTLS                  = "direct_tls"
	CodeDirectRoundTrip            = "direct_round_trip"
	CodeDirectCircuitOpen          = "direct_circuit_open"
	CodeDirectCircuitHalfOpen      = "direct_circuit_half_open"
	CodeDirectCircuitCapacity      = "direct_circuit_capacity"
	CodeDirectInvalidInput         = "direct_invalid_input"
	CodeDirectBody                 = "direct_body"
	CodeDirectResponseCopy         = "direct_response_copy"
	CodeDirectClosed               = "direct_closed"
	CodeDirectDisabled             = "direct_disabled"
	CodeDirectIngressUnsupported   = "direct_ingress_unsupported"
	CodeDirectAuthUnavailable      = "direct_auth_unavailable"
	CodeDirectIdentityMismatch     = "direct_identity_mismatch"
	CodeDirectProbeInvalidResponse = "direct_probe_invalid_response"
	CodeDirectCommitUncertain      = "direct_commit_uncertain"
	CodeDirectResponseInterrupted  = "direct_response_interrupted"
	CodeRelayNotReady              = "relay_not_ready"
	CodeRelayCommitUncertain       = "relay_commit_uncertain"
	CodeRelayResponseInterrupted   = "relay_response_interrupted"
	CodeRequestCancelled           = "request_cancelled"
	CodeRequestDeadline            = "request_deadline"
)
View Source
const (
	IngressKindDirectTunnel = "direct_tunnel"
	IngressKindRelayTunnel  = "relay_tunnel"
)
View Source
const (
	ProbeRespectBusinessPolicy = app.ProbeRespectBusinessPolicy
	ProbeBypassBusinessPolicy  = app.ProbeBypassBusinessPolicy
)
View Source
const (
	RouteHashVersionV1  = "route_hash_v1"
	CodeSelectorInvalid = "selector_invalid"
	CodeTargetNotFound  = "target_not_found"
	CodeTargetDisabled  = "target_disabled"
	CodeTagNoCandidate  = "tag_no_candidate"
)

Variables

This section is empty.

Functions

func CanonicalAddressFingerprint added in v0.0.13

func CanonicalAddressFingerprint(addresses []Address) string

func CanonicalRequestID added in v0.0.13

func CanonicalRequestID(raw string) string

func ResolveAddress

func ResolveAddress(addresses []Address, addressTag, preferredTag, cacheKey string) (string, error)

ResolveAddress selects the best address for the target agent. Priority: addressTag -> preferredTag -> auto-probe (first reachable, cached 60s).

func ResolveProxyURL

func ResolveProxyURL(agentProxyURL, globalProxyURL string) string

ResolveProxyURL returns the proxy URL to use for forwarding. Priority: per-agent > global default.

func SelectTarget added in v0.0.13

func SelectTarget(selector app.AgentSelector, requestID string, routeID uint, lookup AgentLookup) (models.Agent, error)

func StableAgentRing added in v0.0.13

func StableAgentRing(requestID string, routeID uint, tag string, candidates []string) []string

StableAgentRing returns every candidate in the same deterministic order used by SelectTarget. It only compacts, sorts, and rotates agent IDs.

func VerifyForwardTicket added in v0.0.13

func VerifyForwardTicket(snapshot ForwardAuthSnapshot, raw agentauth.ForwardTicket) (*agentauth.ForwardClaims, error)

func WithIngressMeta added in v0.0.13

func WithIngressMeta(ctx context.Context, meta IngressMeta) context.Context

Types

type APIOpen added in v0.0.16

type APIOpen = app.APIOpen

type Address

type Address = app.AgentAddress

func ParseAddresses

func ParseAddresses(raw string) []Address

ParseAddresses parses the JSON http_addresses field.

type AgentLookup added in v0.0.13

type AgentLookup interface {
	GetAgent(agentID string) *models.Agent
	GetAgentsByTag(tag string) []*models.Agent
}

type AttemptStream added in v0.0.14

type AttemptStream = app.AttemptStream

type AttemptStreamOpener added in v0.0.14

type AttemptStreamOpener = app.AttemptStreamOpener

type AttemptStreamRequest added in v0.0.14

type AttemptStreamRequest = app.AttemptStreamRequest

type AttemptTransportOutcome added in v0.0.14

type AttemptTransportOutcome struct {
	ResponseStarted bool
	Commit          tunnel.CommitState
	Stage           string
	Code            string
	AttemptResult   *attemptwire.AttemptProxyResult
	Err             error
	// contains filtered or unexported fields
}

func ExecuteDirectTransport added in v0.0.13

func ExecuteRelayTransport added in v0.0.13

type DirectAttemptStreamOpener added in v0.0.14

type DirectAttemptStreamOpener interface {
	OpenAttemptStream(
		context.Context,
		DirectSessionTarget,
		app.AttemptStreamRequest,
	) (app.AttemptStream, error)
}

DirectAttemptStreamOpener opens an attempt stream to a frozen direct target.

type DirectAttemptStreamReservation added in v0.0.14

type DirectAttemptStreamReservation interface {
	TransportIdentity() DirectTransportIdentity
	AddressFingerprint() string
	OpenAttemptStream(context.Context, app.AttemptStreamRequest) (app.AttemptStream, error)
	Release()
}

DirectAttemptStreamReservation owns one acquired session admission. Its actual transport may differ from the built transport when a replacement falls back to a still-healthy prior session. Release is idempotent.

type DirectAttemptTransport added in v0.0.14

type DirectAttemptTransport interface {
	TransportIdentity() DirectTransportIdentity
	AcquireAttemptStream(context.Context) (DirectAttemptStreamReservation, error)
}

DirectAttemptTransport freezes the pool inputs used by one Direct attempt. Building it performs local validation only. AcquireAttemptStream owns session admission and dialing; the returned reservation opens the attempt stream.

type DirectAttemptTransportBuilder added in v0.0.14

type DirectAttemptTransportBuilder interface {
	BuildDirectAttemptTransport(context.Context, DirectSessionTarget) (DirectAttemptTransport, error)
}

DirectAttemptTransportBuilder builds a frozen transport for a Direct target.

type DirectCircuitTransition added in v0.0.13

type DirectCircuitTransition struct {
	TargetAgentID string
	State         string
}

type DirectForwarder added in v0.0.13

type DirectForwarder struct {
	// contains filtered or unexported fields
}

func NewDirectForwarder added in v0.0.13

func NewDirectForwarder(opts DirectForwarderOptions) *DirectForwarder

func (*DirectForwarder) Cancel added in v0.0.13

func (f *DirectForwarder) Cancel()

func (*DirectForwarder) Close added in v0.0.13

func (f *DirectForwarder) Close(ctx context.Context) error

func (*DirectForwarder) Done added in v0.0.13

func (f *DirectForwarder) Done() <-chan struct{}

func (*DirectForwarder) Forward added in v0.0.13

func (*DirectForwarder) ResetCircuit added in v0.0.13

func (f *DirectForwarder) ResetCircuit(targetAgentID, addressFingerprint string)

func (*DirectForwarder) ResourceCount added in v0.0.13

func (f *DirectForwarder) ResourceCount() int

type DirectForwarderOptions added in v0.0.13

type DirectForwarderOptions struct {
	Transports              DirectAttemptTransportBuilder
	CircuitStateLimit       int
	CircuitFailureThreshold int
	CircuitOpenDuration     time.Duration
	Now                     func() time.Time
	OnCircuitTransition     func(DirectCircuitTransition)
}

type DirectHTTPAPIStreamOpener added in v0.0.16

type DirectHTTPAPIStreamOpener interface {
	OpenHTTPAPIStream(
		context.Context,
		DirectSessionTarget,
		app.APIOpen,
	) (app.HTTPAPIStream, error)
}

DirectHTTPAPIStreamOpener opens a Generic API stream to a frozen direct target.

type DirectHTTPAPIStreamReservation added in v0.0.16

type DirectHTTPAPIStreamReservation interface {
	TransportIdentity() DirectTransportIdentity
	AddressFingerprint() string
	OpenHTTPAPIStream(context.Context, app.APIOpen) (app.HTTPAPIStream, error)
	Release()
}

DirectHTTPAPIStreamReservation owns one acquired session admission for a Generic API stream. Release is idempotent.

type DirectHTTPAPITransport added in v0.0.16

type DirectHTTPAPITransport interface {
	TransportIdentity() DirectTransportIdentity
	AcquireHTTPAPIStream(context.Context) (DirectHTTPAPIStreamReservation, error)
}

DirectHTTPAPITransport freezes the pool inputs used by one Generic API stream.

type DirectHTTPAPITransportBuilder added in v0.0.16

type DirectHTTPAPITransportBuilder interface {
	BuildDirectHTTPAPITransport(context.Context, DirectSessionTarget) (DirectHTTPAPITransport, error)
}

type DirectPathDisabledEvent added in v0.0.14

type DirectPathDisabledEvent struct {
	SourceAgentID string
	TargetAgentID string
	Reason        DirectPathDisabledReason
}

type DirectPathDisabledReason added in v0.0.14

type DirectPathDisabledReason string
const (
	DirectPathDisabledSourceOutbound DirectPathDisabledReason = "source_direct_outbound_disabled"
	DirectPathDisabledTargetInbound  DirectPathDisabledReason = "target_direct_inbound_disabled"
)

type DirectPathDisabledRecorder added in v0.0.14

type DirectPathDisabledRecorder interface {
	RecordDirectPathDisabled(DirectPathDisabledEvent)
}

type DirectProbeStreamOpener added in v0.0.14

type DirectProbeStreamOpener interface {
	OpenProbeStream(
		context.Context,
		DirectSessionTarget,
		app.ProbeStreamRequest,
	) (app.ProbeStream, error)
}

DirectProbeStreamOpener opens a connectivity probe stream to a frozen direct target.

type DirectRequest added in v0.0.13

type DirectRequest struct {
	Target    DirectSessionTarget
	RouteID   uint
	RequestID string
	Hop       uint8
	Request   *http.Request
	Body      app.ReplayBody
	Attempt   attemptwire.AttemptProxyMeta
}

DirectRequest carries only what the tunnel attempt stream needs. The frozen target owns the address; credentials belong to the session pool.

type DirectRequestForwarder added in v0.0.13

type DirectRequestForwarder interface {
	Forward(context.Context, DirectRequest, http.ResponseWriter) AttemptTransportOutcome
}

type DirectSessionTarget added in v0.0.14

type DirectSessionTarget struct {
	TargetAgentID      string
	AddressFingerprint string
	WebSocketURL       *url.URL
	ProxyURL           *url.URL
}

DirectSessionTarget is the frozen address of a direct peer. Callers resolve and freeze the address once; the pool never re-selects an address internally. WebSocketURL and ProxyURL are already validated by the resolver. The pool treats them as opaque, only ever emitting the sanitized endpoint in errors.

func PrepareDirectTarget added in v0.0.13

func PrepareDirectTarget(snapshot DirectTargetSnapshot) (DirectSessionTarget, error)

PrepareDirectTarget resolves and freezes the direct peer address once. The returned target holds the canonical http/https base URL; the session pool and dialer adapt it to ws/wss at the dial boundary.

type DirectTargetSnapshot added in v0.0.13

type DirectTargetSnapshot struct {
	AgentID        string
	HTTPAddresses  string
	AgentProxyURL  string
	GlobalProxyURL string
	AddressTag     string
	PreferredTag   string
}

type DirectTransportIdentity added in v0.0.14

type DirectTransportIdentity [32]byte

DirectTransportIdentity is an opaque fingerprint of the peer address, effective proxy, and credential generation. It is safe to use as a circuit key because it never contains their raw values.

type DirectTransportRequest added in v0.0.13

type DirectTransportRequest struct {
	TargetAgentID  string
	RouteID        uint
	RequestID      string
	Hop            uint8
	PreparedTarget DirectSessionTarget
	Request        *http.Request
	Body           app.ReplayBody
	Attempt        attemptwire.AttemptProxyMeta
}

type DirectWebSocketAPIStreamOpener added in v0.0.16

type DirectWebSocketAPIStreamOpener interface {
	OpenWebSocketAPIStream(
		context.Context,
		DirectSessionTarget,
		app.WebSocketOpen,
	) (app.WebSocketAPIStream, error)
}

DirectWebSocketAPIStreamOpener opens one Generic API WebSocket stream to a frozen direct target. Implementations must not retry or choose another path.

type ForwardAuthSnapshot added in v0.0.13

type ForwardAuthSnapshot struct {
	Capabilities []string
	SigningKeys  []agentauth.PublicKey
}

func (ForwardAuthSnapshot) SupportsForwardTickets added in v0.0.13

func (s ForwardAuthSnapshot) SupportsForwardTickets() bool

type HTTPAPIStream added in v0.0.16

type HTTPAPIStream = app.HTTPAPIStream

type HTTPAPIStreamOpener added in v0.0.16

type HTTPAPIStreamOpener = app.HTTPAPIStreamOpener

type IngressMeta added in v0.0.13

type IngressMeta struct {
	Kind          string
	SourceAgentID string
	RouteID       uint
	StreamID      tunnel.StreamID
	Hop           uint8
	Attempt       *attemptproxy.AttemptProxyMeta
}

func IngressMetaFromContext added in v0.0.13

func IngressMetaFromContext(ctx context.Context) (IngressMeta, bool)

type ProbePolicy added in v0.0.14

type ProbePolicy = app.ProbePolicy

type ProbeStream added in v0.0.14

type ProbeStream = app.ProbeStream

type ProbeStreamOpener added in v0.0.14

type ProbeStreamOpener = app.ProbeStreamOpener

type ProbeStreamRequest added in v0.0.14

type ProbeStreamRequest = app.ProbeStreamRequest
type RelayLink = app.RelayLink

type RelayTransportRequest added in v0.0.13

type RelayTransportRequest struct {
	TargetAgentID string
	RouteID       uint
	RequestID     string
	Request       *http.Request
	Body          app.ReplayBody
	Attempt       *attemptwire.AttemptProxyMeta
}

type TargetSelectionError added in v0.0.13

type TargetSelectionError struct {
	// contains filtered or unexported fields
}

func (*TargetSelectionError) Error added in v0.0.13

func (e *TargetSelectionError) Error() string

func (*TargetSelectionError) SelectionCode added in v0.0.13

func (e *TargetSelectionError) SelectionCode() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL