Documentation
¶
Index ¶
- Constants
- func ApplyPersistentConfig(cfg *Config, persistent *PersistentConfig, flags *FlagValues)
- func ClearToken() error
- func SavePersistentConfig(cfg *PersistentConfig) error
- func UpdatePersistentConfig(cfg *Config, saveToken bool) error
- type Client
- func (c *Client) Close() error
- func (c *Client) GetInspector() *inspector.Inspector
- func (c *Client) GetP2PManager() *p2p.Manager
- func (c *Client) GetStats() Stats
- func (c *Client) IsConnected() bool
- func (c *Client) IsP2PMode() bool
- func (c *Client) Start(ctx context.Context) error
- func (c *Client) StartInspector(port int) error
- type Config
- type FlagValues
- type PersistentConfig
- type Stats
Constants ¶
const ( // ConfigDirName is the name of the configuration directory. ConfigDirName = ".wormhole" // ConfigFileName is the name of the configuration file. ConfigFileName = "config.yaml" )
Variables ¶
This section is empty.
Functions ¶
func ApplyPersistentConfig ¶
func ApplyPersistentConfig(cfg *Config, persistent *PersistentConfig, flags *FlagValues)
ApplyPersistentConfig applies the persistent configuration to the runtime config. Command-line flags take precedence over persistent config.
func ClearToken ¶
func ClearToken() error
ClearToken removes the saved token from persistent config.
func SavePersistentConfig ¶
func SavePersistentConfig(cfg *PersistentConfig) error
SavePersistentConfig saves the persistent configuration to disk.
func UpdatePersistentConfig ¶
UpdatePersistentConfig updates the persistent config from the runtime config. This is typically called after successful authentication to save the token.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the wormhole client.
func (*Client) GetInspector ¶
GetInspector returns the inspector instance.
func (*Client) GetP2PManager ¶
GetP2PManager returns the P2P manager instance.
func (*Client) IsConnected ¶
IsConnected returns whether the client is connected.
func (*Client) StartInspector ¶
StartInspector starts the inspector UI server.
type Config ¶
type Config struct {
// ServerAddr is the server address to connect to.
ServerAddr string
// LocalPort is the local port to expose.
LocalPort int
// LocalHost is the local host to forward to.
LocalHost string
// Subdomain is the requested subdomain (optional).
Subdomain string
// Token is the authentication token (optional).
Token string
// InspectorPort is the port for the inspector UI (0 to disable).
InspectorPort int
// TLSEnabled enables TLS for server connection.
TLSEnabled bool
// TLSInsecure skips TLS certificate verification.
TLSInsecure bool
// MuxConfig is the multiplexer configuration.
MuxConfig tunnel.MuxConfig
// ReconnectInterval is the initial reconnect interval.
ReconnectInterval time.Duration
// MaxReconnectInterval is the maximum reconnect interval.
MaxReconnectInterval time.Duration
// ReconnectBackoff is the backoff multiplier for reconnection.
ReconnectBackoff float64
// MaxReconnectAttempts is the maximum number of reconnection attempts (0 for unlimited).
MaxReconnectAttempts int
// HeartbeatInterval is the interval between heartbeats.
HeartbeatInterval time.Duration
// HeartbeatTimeout is the timeout for heartbeat responses.
HeartbeatTimeout time.Duration
// P2PEnabled enables P2P direct connection attempts.
P2PEnabled bool
// P2PConfig is the P2P manager configuration.
P2PConfig p2p.ManagerConfig
}
Config holds the client configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default client configuration.
type FlagValues ¶
type FlagValues struct {
ServerAddrSet bool
TokenSet bool
SubdomainSet bool
TLSSet bool
TLSInsecureSet bool
InspectorPortSet bool
P2PEnabledSet bool
}
FlagValues tracks which command-line flags were explicitly set.
type PersistentConfig ¶
type PersistentConfig struct {
// ServerAddr is the default server address.
ServerAddr string `yaml:"server_addr,omitempty"`
// Token is the authentication token.
Token string `yaml:"token,omitempty"`
// Subdomain is the preferred subdomain.
Subdomain string `yaml:"subdomain,omitempty"`
// TLSEnabled enables TLS for server connection.
TLSEnabled bool `yaml:"tls_enabled,omitempty"`
// TLSInsecure skips TLS certificate verification.
TLSInsecure bool `yaml:"tls_insecure,omitempty"`
// InspectorPort is the default inspector UI port.
InspectorPort int `yaml:"inspector_port,omitempty"`
// P2PEnabled enables P2P direct connection attempts.
P2PEnabled *bool `yaml:"p2p_enabled,omitempty"`
}
PersistentConfig represents the configuration that is persisted to disk. Only a subset of Config fields are persisted (user-facing settings).
func LoadPersistentConfig ¶
func LoadPersistentConfig() (*PersistentConfig, error)
LoadPersistentConfig loads the persistent configuration from disk. Returns an empty config if the file doesn't exist.