config

package
v0.0.0-...-7c31a77 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(level string) (*zap.Logger, error)

NewLogger creates a zap logger based on the log level string.

Types

type AuthConfig

type AuthConfig struct {
	Enabled bool   `mapstructure:"enabled"`
	Token   string `mapstructure:"token"`
}

AuthConfig holds authentication settings.

type BrokerClientConfig

type BrokerClientConfig struct {
	URL                string `mapstructure:"url"`
	Endpoint           string `mapstructure:"endpoint"`
	InsecureSkipVerify bool   `mapstructure:"insecure_skip_verify"` // Skip TLS certificate verification (for self-signed certs)
	AuthToken          string `mapstructure:"auth_token"`           // Authentication token for broker
}

BrokerClientConfig holds broker connection settings for clients.

type BrokerConfig

type BrokerConfig struct {
	Server  ServerConfig  `mapstructure:"server"`
	Tunnel  TunnelConfig  `mapstructure:"tunnel"`
	Auth    AuthConfig    `mapstructure:"auth"`
	Logging LoggingConfig `mapstructure:"logging"`
}

BrokerConfig holds all configuration for the broker server (Machine A).

func LoadBrokerConfig

func LoadBrokerConfig(path string) (*BrokerConfig, error)

LoadBrokerConfig loads broker config from a YAML file using viper.

type ConsumerConfig

type ConsumerConfig struct {
	Broker    BrokerClientConfig `mapstructure:"broker"`
	Socks5    Socks5Config       `mapstructure:"socks5"`
	Transport TransportConfig    `mapstructure:"transport"`
	Logging   LoggingConfig      `mapstructure:"logging"`
}

ConsumerConfig holds configuration for the consumer (Machine B).

func LoadConsumerConfig

func LoadConsumerConfig(path string) (*ConsumerConfig, error)

LoadConsumerConfig loads consumer config from a YAML file using viper.

type LoggingConfig

type LoggingConfig struct {
	Level string `mapstructure:"level"` // "debug", "info", "warn", "error"
}

LoggingConfig holds logging settings.

type ProviderConfig

type ProviderConfig struct {
	Broker    BrokerClientConfig `mapstructure:"broker"`
	Provider  ProviderOptions    `mapstructure:"provider"`
	Transport TransportConfig    `mapstructure:"transport"`
	Logging   LoggingConfig      `mapstructure:"logging"`
}

ProviderConfig holds configuration for the provider (Machine C).

func LoadProviderConfig

func LoadProviderConfig(path string) (*ProviderConfig, error)

LoadProviderConfig loads provider config from a YAML file using viper.

type ProviderOptions

type ProviderOptions struct {
	ScrubHeaders bool          `mapstructure:"scrub_headers"`
	DialTimeout  time.Duration `mapstructure:"dial_timeout"`
}

ProviderOptions holds provider-specific settings.

type ServerConfig

type ServerConfig struct {
	Listen                string                     `mapstructure:"listen"`
	TLS                   TLSConfig                  `mapstructure:"tls"`
	StatusEndpointEnabled bool                       `mapstructure:"status_endpoint_enabled"` // Whether to expose GET /status endpoint (default: false)
	UnauthorizedRedirect  UnauthorizedRedirectConfig `mapstructure:"unauthorized_redirect"`   // Redirect settings for unauthorized requests
}

ServerConfig holds HTTP server settings.

type Socks5Config

type Socks5Config struct {
	Listen string `mapstructure:"listen"`
}

Socks5Config holds SOCKS5 proxy settings.

type TLSConfig

type TLSConfig struct {
	Enabled  bool   `mapstructure:"enabled"`
	CertFile string `mapstructure:"cert_file"`
	KeyFile  string `mapstructure:"key_file"`
}

TLSConfig holds TLS certificate paths.

type TransportConfig

type TransportConfig struct {
	PollInterval time.Duration `mapstructure:"poll_interval"`
	RetryBackoff time.Duration `mapstructure:"retry_backoff"`
	// CoalesceWindow bounds how long pollmux.Connector's Write() waits before
	// the first send of an idle-to-active burst, giving immediately-following
	// writes a chance to merge into the same HTTP request. Zero/unset uses
	// pollmux.DefaultCoalesceWindow (2ms).
	CoalesceWindow time.Duration `mapstructure:"coalesce_window"`
}

TransportConfig holds transport timing settings.

type TunnelConfig

type TunnelConfig struct {
	PollTimeout    time.Duration `mapstructure:"poll_timeout"`
	SessionTimeout time.Duration `mapstructure:"session_timeout"`
	// CoalesceWindow bounds how long the broker waits for more data to
	// accumulate on a long-poll response once at least one byte is
	// available, instead of flushing immediately. Zero/unset uses
	// pollmux.DefaultCoalesceWindow (2ms).
	CoalesceWindow time.Duration `mapstructure:"coalesce_window"`
	// PollBufferSize caps how many bytes one poll response may carry.
	// Zero/unset uses pollmux.DefaultPollBufferSize (256KiB).
	PollBufferSize int `mapstructure:"poll_buffer_size"`
	// MaxSendBytes caps a single request body. Zero/unset uses
	// pollmux.DefaultMaxSendBytes (1MiB).
	MaxSendBytes int `mapstructure:"max_send_bytes"`
	// HighWaterWarn logs a one-shot warning when either direction of a
	// session buffers this many bytes. Zero disables it.
	HighWaterWarn int `mapstructure:"high_water_warn"`
}

TunnelConfig holds tunnel timing settings.

type UnauthorizedRedirectConfig

type UnauthorizedRedirectConfig struct {
	Enabled bool   `mapstructure:"enabled"` // Whether to redirect unauthorized requests instead of returning 401/404
	URL     string `mapstructure:"url"`     // Redirect target URL (supports: "/path", "www.example.com", or "https://example.com")
}

UnauthorizedRedirectConfig holds redirect settings for unauthorized requests.

Jump to

Keyboard shortcuts

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