Documentation
¶
Index ¶
- Constants
- Variables
- func ValidTransport(transport Transport) bool
- type Broker
- type Classifier
- type CompileRequest
- type ConnectionGrant
- type ConnectorPolicy
- type Destination
- type Executor
- func (e *Executor) DoHTTP(ctx context.Context, req HTTPRequest) (HTTPResponse, error)
- func (e *Executor) StreamHTTP(ctx context.Context, req HTTPRequest, onChunk func(HTTPResponseChunk) error) (HTTPStreamResponse, error)
- func (e *Executor) TCPRoundTrip(ctx context.Context, req TCPRoundTripRequest) (TCPRoundTripResponse, error)
- func (e *Executor) UDPRoundTrip(ctx context.Context, req UDPRoundTripRequest) (UDPRoundTripResponse, error)
- func (e *Executor) WebSocketRoundTrip(ctx context.Context, req WebSocketRoundTripRequest) (WebSocketRoundTripResponse, error)
- type ExecutorOptions
- type GrantRequest
- type HTTPRequest
- type HTTPResponse
- type HTTPResponseChunk
- type HTTPStreamResponse
- type MemoryBroker
- type MemoryUDPRateLimiter
- type NetworkExecutor
- type PolicySet
- type Scope
- type TCPRoundTripRequest
- type TCPRoundTripResponse
- type Transport
- type UDPRateLimit
- type UDPRateLimitKey
- type UDPRateLimiter
- type UDPRateLimiterFunc
- type UDPRoundTripRequest
- type UDPRoundTripResponse
- type WebSocketMessageType
- type WebSocketRoundTripRequest
- type WebSocketRoundTripResponse
Constants ¶
View Source
const ( DefaultGrantTTL = time.Minute MaxGrantTTL = 5 * time.Minute )
View Source
const ( DefaultMaxNetworkRequestBytes = 1 << 20 DefaultMaxNetworkResponseBytes = 1 << 20 DefaultHTTPStreamChunkBytes = 32 << 10 DefaultNetworkTimeout = 10 * time.Second DefaultUDPRateLimitRoundTrips = 120 DefaultUDPRateLimitWindow = time.Second )
Variables ¶
View Source
var ( ErrInvalidConnector = errors.New("network connector is invalid") ErrTargetDenied = errors.New("network target denied") ErrConnectorDenied = errors.New("network connector denied") ErrGrantExpired = errors.New("network grant expired") ErrRequestTooLarge = errors.New("network request too large") ErrResponseTooLarge = errors.New("network response too large") ErrRateLimited = errors.New("network rate limited") ErrConnectionClosed = errors.New("network connection closed") ErrWebSocketFailed = errors.New("websocket handshake failed") )
Functions ¶
func ValidTransport ¶
Types ¶
type Classifier ¶
type Classifier struct {
// contains filtered or unexported fields
}
func DefaultClassifier ¶
func DefaultClassifier() Classifier
func (Classifier) Evaluate ¶
func (c Classifier) Evaluate(destination Destination) error
func (Classifier) EvaluateResolvedAddress ¶
func (c Classifier) EvaluateResolvedAddress(destination Destination, addr netip.Addr) error
type CompileRequest ¶
type ConnectionGrant ¶
type ConnectionGrant struct {
GrantID string `json:"grant_id"`
PluginInstanceID string `json:"plugin_instance_id"`
ActiveFingerprint string `json:"active_fingerprint"`
PolicyRevision uint64 `json:"policy_revision"`
ManagementRevision uint64 `json:"management_revision"`
RevokeEpoch uint64 `json:"revoke_epoch"`
ConnectorID string `json:"connector_id"`
Transport Transport `json:"transport"`
Destination Destination `json:"destination"`
RuntimeGenerationID string `json:"runtime_generation_id,omitempty"`
TargetClassifierVersion string `json:"target_classifier_version"`
ExpiresAt time.Time `json:"expires_at"`
}
func MintConnectionGrant ¶
func MintConnectionGrant(_ context.Context, policy PolicySet, req GrantRequest) (ConnectionGrant, error)
type ConnectorPolicy ¶
type ConnectorPolicy struct {
ConnectorID string `json:"connector_id"`
Transport Transport `json:"transport"`
Scope Scope `json:"scope"`
Destinations []Destination `json:"destinations"`
SecretRef string `json:"secret_ref,omitempty"`
}
type Destination ¶
type Destination struct {
Transport Transport `json:"transport"`
Scheme string `json:"scheme,omitempty"`
Host string `json:"host"`
Port int `json:"port"`
}
func ParseDestination ¶
func ParseDestination(transport Transport, raw string) (Destination, error)
func (Destination) Canonical ¶
func (d Destination) Canonical() string
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
func NewExecutor ¶
func NewExecutor(options ExecutorOptions) *Executor
func (*Executor) DoHTTP ¶
func (e *Executor) DoHTTP(ctx context.Context, req HTTPRequest) (HTTPResponse, error)
func (*Executor) StreamHTTP ¶
func (e *Executor) StreamHTTP(ctx context.Context, req HTTPRequest, onChunk func(HTTPResponseChunk) error) (HTTPStreamResponse, error)
func (*Executor) TCPRoundTrip ¶
func (e *Executor) TCPRoundTrip(ctx context.Context, req TCPRoundTripRequest) (TCPRoundTripResponse, error)
func (*Executor) UDPRoundTrip ¶
func (e *Executor) UDPRoundTrip(ctx context.Context, req UDPRoundTripRequest) (UDPRoundTripResponse, error)
func (*Executor) WebSocketRoundTrip ¶
func (e *Executor) WebSocketRoundTrip(ctx context.Context, req WebSocketRoundTripRequest) (WebSocketRoundTripResponse, error)
type ExecutorOptions ¶
type ExecutorOptions struct {
HTTPClient *http.Client
Dialer *net.Dialer
DialContext func(ctx context.Context, network string, address string) (net.Conn, error)
LookupIPAddr func(ctx context.Context, host string) ([]net.IPAddr, error)
UDPRateLimiter UDPRateLimiter
MaxRequestBytes int64
MaxResponseBytes int64
DefaultTimeout time.Duration
Now func() time.Time
}
type GrantRequest ¶
type HTTPRequest ¶
type HTTPRequest struct {
Grant ConnectionGrant `json:"grant"`
Method string `json:"method"`
Path string `json:"path,omitempty"`
Query url.Values `json:"query,omitempty"`
Headers http.Header `json:"headers,omitempty"`
Body []byte `json:"-"`
MaxRequestBytes int64 `json:"max_request_bytes,omitempty"`
MaxResponseBytes int64 `json:"max_response_bytes,omitempty"`
MaxChunkBytes int64 `json:"max_chunk_bytes,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
Now time.Time `json:"now,omitempty"`
}
type HTTPResponse ¶
type HTTPResponseChunk ¶
type HTTPStreamResponse ¶
type MemoryBroker ¶
type MemoryBroker struct {
// contains filtered or unexported fields
}
func NewMemoryBroker ¶
func NewMemoryBroker() *MemoryBroker
func (*MemoryBroker) InstallPolicy ¶
func (b *MemoryBroker) InstallPolicy(_ context.Context, policy PolicySet) error
func (*MemoryBroker) MintConnectionGrant ¶
func (b *MemoryBroker) MintConnectionGrant(ctx context.Context, req GrantRequest) (ConnectionGrant, error)
func (*MemoryBroker) RemovePolicy ¶
func (b *MemoryBroker) RemovePolicy(_ context.Context, pluginInstanceID string) error
type MemoryUDPRateLimiter ¶
type MemoryUDPRateLimiter struct {
// contains filtered or unexported fields
}
func NewMemoryUDPRateLimiter ¶
func NewMemoryUDPRateLimiter(limit UDPRateLimit) *MemoryUDPRateLimiter
func (*MemoryUDPRateLimiter) AllowUDPRoundTrip ¶
func (l *MemoryUDPRateLimiter) AllowUDPRoundTrip(now time.Time, key UDPRateLimitKey) bool
type NetworkExecutor ¶
type NetworkExecutor interface {
DoHTTP(ctx context.Context, req HTTPRequest) (HTTPResponse, error)
StreamHTTP(ctx context.Context, req HTTPRequest, onChunk func(HTTPResponseChunk) error) (HTTPStreamResponse, error)
WebSocketRoundTrip(ctx context.Context, req WebSocketRoundTripRequest) (WebSocketRoundTripResponse, error)
TCPRoundTrip(ctx context.Context, req TCPRoundTripRequest) (TCPRoundTripResponse, error)
UDPRoundTrip(ctx context.Context, req UDPRoundTripRequest) (UDPRoundTripResponse, error)
}
type PolicySet ¶
type PolicySet struct {
PluginInstanceID string `json:"plugin_instance_id"`
PluginID string `json:"plugin_id"`
ActiveFingerprint string `json:"active_fingerprint"`
PolicyRevision uint64 `json:"policy_revision"`
ManagementRevision uint64 `json:"management_revision"`
RevokeEpoch uint64 `json:"revoke_epoch"`
TargetClassifierVersion string `json:"target_classifier_version"`
Connectors []ConnectorPolicy `json:"connectors"`
}
func CompilePolicy ¶
func CompilePolicy(req CompileRequest) (PolicySet, error)
type TCPRoundTripRequest ¶
type TCPRoundTripResponse ¶
type TCPRoundTripResponse struct {
Payload []byte `json:"-"`
}
type UDPRateLimit ¶
type UDPRateLimitKey ¶
type UDPRateLimitKey struct {
PluginInstanceID string `json:"plugin_instance_id"`
ActiveFingerprint string `json:"active_fingerprint"`
ConnectorID string `json:"connector_id"`
GrantID string `json:"grant_id"`
Destination Destination `json:"destination"`
}
type UDPRateLimiter ¶
type UDPRateLimiter interface {
AllowUDPRoundTrip(now time.Time, key UDPRateLimitKey) bool
}
type UDPRateLimiterFunc ¶
type UDPRateLimiterFunc func(now time.Time, key UDPRateLimitKey) bool
func (UDPRateLimiterFunc) AllowUDPRoundTrip ¶
func (f UDPRateLimiterFunc) AllowUDPRoundTrip(now time.Time, key UDPRateLimitKey) bool
type UDPRoundTripRequest ¶
type UDPRoundTripResponse ¶
type UDPRoundTripResponse struct {
Payload []byte `json:"-"`
}
type WebSocketMessageType ¶
type WebSocketMessageType string
const ( WebSocketMessageText WebSocketMessageType = "text" WebSocketMessageBinary WebSocketMessageType = "binary" )
type WebSocketRoundTripRequest ¶
type WebSocketRoundTripRequest struct {
Grant ConnectionGrant `json:"grant"`
Path string `json:"path,omitempty"`
Headers http.Header `json:"headers,omitempty"`
MessageType WebSocketMessageType `json:"message_type,omitempty"`
Payload []byte `json:"-"`
MaxRequestBytes int64 `json:"max_request_bytes,omitempty"`
MaxResponseBytes int64 `json:"max_response_bytes,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
Now time.Time `json:"now,omitempty"`
}
type WebSocketRoundTripResponse ¶
type WebSocketRoundTripResponse struct {
MessageType WebSocketMessageType `json:"message_type"`
Payload []byte `json:"-"`
}
Click to show internal directories.
Click to hide internal directories.