agent

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const EnrollmentV = "1"
View Source
const RegistryV = "2"

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessPrivateRequest

type AccessPrivateRequest struct {
	ShareToken      string   `json:"share_token"`
	BindAddress     string   `json:"bind_address"`
	AutoMode        bool     `json:"auto_mode"`
	AutoAddress     string   `json:"auto_address"`
	AutoStartPort   uint16   `json:"auto_start_port"`
	AutoEndPort     uint16   `json:"auto_end_port"`
	ResponseHeaders []string `json:"response_headers"`
}

type AccessRegistryEntry

type AccessRegistryEntry struct {
	Request *AccessPrivateRequest `json:"request"`
	Failure *FailureEntry         `json:"failure,omitempty"`
}

type Agent

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

func NewAgent

func NewAgent(cfg *AgentConfig, root env_core.Root) (*Agent, error)

func (*Agent) AccessPrivate

func (a *Agent) AccessPrivate(req *AccessPrivateRequest) (frontendToken string, err error)

func (*Agent) Config

func (a *Agent) Config() *AgentConfig

func (*Agent) ReleaseAccess

func (a *Agent) ReleaseAccess(frontendToken string) error

func (*Agent) ReleaseShare

func (a *Agent) ReleaseShare(shareToken string) error

func (*Agent) ReloadRegistry

func (a *Agent) ReloadRegistry() error

func (*Agent) Run

func (a *Agent) Run() error

func (*Agent) SaveRegistry

func (a *Agent) SaveRegistry() error

func (*Agent) ShareHttpHealthcheck

func (a *Agent) ShareHttpHealthcheck(shareToken, endpoint, httpVerb string, expectedHttpResponse, timeoutMs int) error

func (*Agent) SharePrivate

func (a *Agent) SharePrivate(req *SharePrivateRequest) (shareToken string, err error)

func (*Agent) SharePublic

func (a *Agent) SharePublic(req *SharePublicRequest) (shareToken string, frontendEndpoint []string, err error)

func (*Agent) Shutdown

func (a *Agent) Shutdown()

type AgentConfig

type AgentConfig struct {
	ConsoleAddress     string        `json:"console_address"`
	ConsoleStartPort   uint16        `json:"console_start_port"`
	ConsoleEndPort     uint16        `json:"console_end_port"`
	ConsoleEnabled     bool          `json:"console_enabled"`
	RequireRemoting    bool          `json:"require_remoting"`
	MaxRetries         int           `json:"max_retries,omitempty"`
	RetryInitialDelay  time.Duration `json:"retry_initial_delay,omitempty"`
	RetryMaxDelay      time.Duration `json:"retry_max_delay,omitempty"`
	RetryCheckInterval time.Duration `json:"retry_check_interval,omitempty"`
}

func DefaultConfig

func DefaultConfig() *AgentConfig

type BootHandlerConfig

type BootHandlerConfig struct {
	// StringFields maps message keys to functions that set string values
	StringFields map[string]func(string)
	// ArrayFields maps message keys to functions that set string array values
	ArrayFields map[string]func([]string)
	// OperationType for logging and debugging purposes
	OperationType string
}

BootHandlerConfig defines the field mappings for extracting values from boot messages

type CommandBuilder

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

CommandBuilder provides a fluent interface for building zrok commands eliminating repetitive command construction patterns across the agent

func NewAccessPrivateCommand

func NewAccessPrivateCommand() *CommandBuilder

NewAccessPrivateCommand creates a command builder for private access commands

func NewSharePrivateCommand

func NewSharePrivateCommand() *CommandBuilder

NewSharePrivateCommand creates a command builder for private share commands

func NewSharePublicCommand

func NewSharePublicCommand() *CommandBuilder

NewSharePublicCommand creates a command builder for public share commands

func (*CommandBuilder) AccessGrants

func (cb *CommandBuilder) AccessGrants(grants []string) *CommandBuilder

AccessGrants adds multiple --access-grant options

func (*CommandBuilder) AddConditionalFlag

func (cb *CommandBuilder) AddConditionalFlag(condition bool, flag string) *CommandBuilder

AddConditionalFlag adds a flag only if the condition is true

func (*CommandBuilder) AddFlag

func (cb *CommandBuilder) AddFlag(flag string) *CommandBuilder

AddFlag adds a simple flag (e.g., --insecure, --open)

func (*CommandBuilder) AddMultipleOptions

func (cb *CommandBuilder) AddMultipleOptions(option string, values []string) *CommandBuilder

AddMultipleOptions adds multiple instances of the same option

func (*CommandBuilder) AddOption

func (cb *CommandBuilder) AddOption(option, value string) *CommandBuilder

AddOption adds an option with a value (e.g., --option value)

func (*CommandBuilder) AutoMode

func (cb *CommandBuilder) AutoMode(auto bool, address string, startPort, endPort int) *CommandBuilder

AutoMode adds auto mode options for access commands

func (*CommandBuilder) BackendMode

func (cb *CommandBuilder) BackendMode(mode string) *CommandBuilder

BackendMode adds the backend mode option (-b)

func (*CommandBuilder) BasicAuth

func (cb *CommandBuilder) BasicAuth(auths []string) *CommandBuilder

BasicAuth adds multiple --basic-auth options

func (*CommandBuilder) BindAddress

func (cb *CommandBuilder) BindAddress(address string) *CommandBuilder

BindAddress adds the bind address as a positional argument for access commands

func (*CommandBuilder) Build

func (cb *CommandBuilder) Build() []string

Build returns the final command as a string slice

func (*CommandBuilder) Insecure

func (cb *CommandBuilder) Insecure(insecure bool) *CommandBuilder

Insecure adds the --insecure flag if true

func (*CommandBuilder) NameSelections

func (cb *CommandBuilder) NameSelections(selections []NameSelection) *CommandBuilder

NameSelections adds multiple --name-selection options with namespace:name format

func (*CommandBuilder) OauthEmailDomains

func (cb *CommandBuilder) OauthEmailDomains(domains []string) *CommandBuilder

OauthEmailDomains adds multiple --oauth-email-domain options

func (*CommandBuilder) OauthProvider

func (cb *CommandBuilder) OauthProvider(provider string) *CommandBuilder

OauthProvider adds the --oauth-provider option

func (*CommandBuilder) OauthRefreshInterval

func (cb *CommandBuilder) OauthRefreshInterval(interval string) *CommandBuilder

OauthRefreshInterval adds the --oauth-refresh-interval option

func (*CommandBuilder) Open

func (cb *CommandBuilder) Open(open bool) *CommandBuilder

Open adds the --open flag if true (note: inverted logic from Closed)

func (*CommandBuilder) ShareToken

func (cb *CommandBuilder) ShareToken(token string) *CommandBuilder

ShareToken adds the --share-token option for private shares

func (*CommandBuilder) String

func (cb *CommandBuilder) String() string

String returns a string representation of the command for debugging

func (*CommandBuilder) Target

func (cb *CommandBuilder) Target(target string) *CommandBuilder

Target adds the target as the final argument

type Enrollment

type Enrollment struct {
	V     string `json:"v"`
	Token string `json:"token"`
}

func LoadEnrollment

func LoadEnrollment(path string) (*Enrollment, error)

func NewEnrollment

func NewEnrollment(token string) *Enrollment

func (*Enrollment) Save

func (e *Enrollment) Save(path string) error

type FailureEntry

type FailureEntry struct {
	Count     int       `json:"count,omitempty"`
	LastError string    `json:"last_error,omitempty"`
	NextRetry time.Time `json:"next_retry,omitempty"`
}

type NameSelection

type NameSelection struct {
	NamespaceToken string `json:"namespace_token"`
	Name           string `json:"name"`
}

type PrivateShareRegistryEntry

type PrivateShareRegistryEntry struct {
	Request *SharePrivateRequest `json:"request"`
	Failure *FailureEntry        `json:"failure,omitempty"`
}

type PublicShareRegistryEntry

type PublicShareRegistryEntry struct {
	Request *SharePublicRequest `json:"request"`
	Failure *FailureEntry       `json:"failure,omitempty"`
}

type Registry

type Registry struct {
	V               string                       `json:"v"`
	PrivateAccesses []*AccessRegistryEntry       `json:"private_accesses,omitempty"`
	PublicShares    []*PublicShareRegistryEntry  `json:"public_shares,omitempty"`
	PrivateShares   []*PrivateShareRegistryEntry `json:"private_shares,omitempty"`
}

func LoadRegistry

func LoadRegistry(path string) (*Registry, error)

func (*Registry) Save

func (r *Registry) Save(path string) error

type SharePrivateRequest

type SharePrivateRequest struct {
	Target            string   `json:"target"`
	PrivateShareToken string   `json:"private_share_token"`
	BackendMode       string   `json:"backend_mode"`
	Insecure          bool     `json:"insecure"`
	Closed            bool     `json:"closed"`
	AccessGrants      []string `json:"access_grants"`
}

type SharePublicRequest

type SharePublicRequest struct {
	Target               string          `json:"target"`
	BasicAuth            []string        `json:"basic_auth"`
	NameSelections       []NameSelection `json:"name_selections"`
	BackendMode          string          `json:"backend_mode"`
	Insecure             bool            `json:"insecure"`
	OauthProvider        string          `json:"oauth_provider"`
	OauthEmailDomains    []string        `json:"oauth_email_domains"`
	OauthRefreshInterval string          `json:"oauth_refresh_interval"`
	Closed               bool            `json:"closed"`
	AccessGrants         []string        `json:"access_grants"`
}

type UnifiedBootHandler

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

UnifiedBootHandler provides centralized boot message processing eliminating duplication across share and access operations

func NewAccessBootHandler

func NewAccessBootHandler(acc *access, bootErr *error) *UnifiedBootHandler

NewAccessBootHandler creates a boot handler configured for access operations

func NewBootHandler

func NewBootHandler(config *BootHandlerConfig, bootErr *error) *UnifiedBootHandler

NewBootHandler creates a new unified boot handler with the specified configuration

func NewShareBootHandler

func NewShareBootHandler(shr *share, bootErr *error) *UnifiedBootHandler

NewShareBootHandler creates a boot handler configured for share operations

func (*UnifiedBootHandler) HandleBoot

func (ubh *UnifiedBootHandler) HandleBoot(msgType string, msg subordinate.Message)

HandleBoot processes boot and error messages from subordinate processes

func (*UnifiedBootHandler) HandleMalformed

func (ubh *UnifiedBootHandler) HandleMalformed(msg subordinate.Message)

HandleMalformed processes malformed messages from subordinate processes

Directories

Path Synopsis
Package agentGrpc is a reverse proxy.
Package agentGrpc is a reverse proxy.

Jump to

Keyboard shortcuts

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