agentproxy

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 28 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"
	CodeRelayFallbackDisabled      = tunnel.ErrorCodeRelayFallbackDisabled
	CodeRelayNotReady              = "relay_not_ready"
	CodeRelayCommitUncertain       = "relay_commit_uncertain"
	CodeRelayResponseInterrupted   = "relay_response_interrupted"
	CodeRequestCancelled           = "request_cancelled"
	CodeRequestDeadline            = "request_deadline"
)
View Source
const (
	IngressKindDirect = "direct"
	IngressKindTunnel = "tunnel"
)
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 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 BeforeWriteError added in v0.0.13

type BeforeWriteError struct {
	Stage string
	Code  string
	Err   error
}

BeforeWriteError is emitted only by dial and TLS stages that complete before http.Transport receives a connection capable of writing the request.

func (*BeforeWriteError) Error added in v0.0.13

func (e *BeforeWriteError) Error() string

func (*BeforeWriteError) Unwrap added in v0.0.13

func (e *BeforeWriteError) Unwrap() error

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 {
	TransportLimit          int
	CircuitStateLimit       int
	CircuitFailureThreshold int
	CircuitOpenDuration     time.Duration
	ResponseHeaderTimeout   time.Duration
	TLSHandshakeTimeout     time.Duration
	DialContext             func(context.Context, string, string) (net.Conn, error)
	TLSClientConfig         *tls.Config
	Now                     func() time.Time
	OnCircuitTransition     func(DirectCircuitTransition)
}

type DirectOutcome added in v0.0.13

type DirectOutcome struct {
	ResponseStarted bool
	Commit          tunnel.CommitState
	Stage           string
	Code            string
	Err             error
}

func ExecuteDirectTransport added in v0.0.13

func ExecuteDirectTransport(
	ctx context.Context,
	direct DirectRequestForwarder,
	req DirectTransportRequest,
	dst http.ResponseWriter,
) DirectOutcome

func ExecuteRelayTransport added in v0.0.13

func ExecuteRelayTransport(
	ctx context.Context,
	link RelayLink,
	req RelayTransportRequest,
	dst http.ResponseWriter,
) DirectOutcome

type DirectRequest added in v0.0.13

type DirectRequest struct {
	TargetAgentID      string
	RouteID            uint
	Hop                uint8
	AddressFingerprint string
	TargetURL          *url.URL
	ProxyURL           *url.URL
	Request            *http.Request
	Body               ReplayBody
	ForwardTicket      agentauth.ForwardTicket
	Attempt            *attemptwire.AttemptProxyMeta
}

type DirectRequestForwarder added in v0.0.13

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

type DirectTargetSnapshot added in v0.0.13

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

type DirectTransportRequest added in v0.0.13

type DirectTransportRequest struct {
	TargetAgentID  string
	RouteID        uint
	Hop            uint8
	PreparedTarget PreparedDirectTarget
	Request        *http.Request
	Body           ReplayBody
	ForwardTicket  agentauth.ForwardTicket
	Attempt        *attemptwire.AttemptProxyMeta
}

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 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 PreparedDirectTarget added in v0.0.13

type PreparedDirectTarget struct {
	AddressFingerprint string
	TargetURL          *url.URL
	ProxyURL           *url.URL
}

func PrepareDirectTarget added in v0.0.13

func PrepareDirectTarget(snapshot DirectTargetSnapshot) (PreparedDirectTarget, error)
type RelayLink = app.RelayLink

type RelayRequest added in v0.0.13

type RelayRequest = app.RelayRequest

type RelayStream added in v0.0.13

type RelayStream = app.RelayStream

type RelayTransportRequest added in v0.0.13

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

type ReplayBody added in v0.0.13

type ReplayBody interface {
	Size() int64
	Open() (io.ReadCloser, error)
	Bytes(limit int64) ([]byte, error)
	Close() error
}

ReplayBody is the request-owned body contract consumed by DirectForwarder.

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