Documentation
¶
Index ¶
- func ParseSSHDestination(dest string) (sshUser, host, port string)
- func WatchEntitiesWithRetry(ctx context.Context, client proto.WorldServiceClient, ...) (proto.WorldService_WatchEntitiesClient, error)
- type ConnectOption
- type Connection
- func Connect(serverURL string, options ...ConnectOption) (*Connection, error)
- func ConnectURL(ctx context.Context, server, wgConfigPath string, options ...ConnectOption) (*Connection, error)
- func ConnectWithSSH(serverAddr string, destination string) (*Connection, error)
- func ConnectWithWireGuard(serverAddr string, wgConfigPath string) (*Connection, error)
- type SSHTunnel
- type Tunnel
- type WireGuardConfig
- type WireGuardTunnel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseSSHDestination ¶ added in v0.0.23
ParseSSHDestination parses an OpenSSH-style destination string into user, host, and port. Accepted formats:
host host:port user@host user@host:port
func WatchEntitiesWithRetry ¶
func WatchEntitiesWithRetry(ctx context.Context, client proto.WorldServiceClient, req *proto.ListEntitiesRequest) (proto.WorldService_WatchEntitiesClient, error)
Types ¶
type ConnectOption ¶ added in v1.0.0
type ConnectOption func(*connectOpts)
ConnectOption configures an outbound connection.
func WithClientCert ¶ added in v1.0.0
func WithClientCert(cert tls.Certificate) ConnectOption
WithClientCert presents cert as the mTLS client certificate. It applies only to TLS (https) connections; plaintext connections ignore it.
type Connection ¶
type Connection struct {
*grpc.ClientConn
Tunnel io.Closer // nil for plain connections
}
Connection wraps a gRPC connection with optional tunnel (WireGuard, SSH, etc.)
func Connect ¶
func Connect(serverURL string, options ...ConnectOption) (*Connection, error)
Connect establishes a gRPC connection to the server. serverURL can be "host:port", "http://host", or "https://host".
func ConnectURL ¶ added in v0.0.23
func ConnectURL(ctx context.Context, server, wgConfigPath string, options ...ConnectOption) (*Connection, error)
ConnectURL establishes a working gRPC connection, parsing the server address for ssh:// URLs and optional WireGuard config. Unless the URL pins a scheme it tries TLS (with mTLS when a client cert is supplied) before plaintext; http:// forces plaintext, https:// forces TLS. Because gRPC dials lazily, each candidate is probed with GetLocalNode so only a transport+auth that actually works is returned.
func ConnectWithSSH ¶ added in v0.0.23
func ConnectWithSSH(serverAddr string, destination string) (*Connection, error)
ConnectWithSSH establishes a gRPC connection through an SSH tunnel. destination is an OpenSSH-style string: [user@]host[:port] serverAddr is the gRPC address as seen from the SSH host.
func ConnectWithWireGuard ¶
func ConnectWithWireGuard(serverAddr string, wgConfigPath string) (*Connection, error)
ConnectWithWireGuard establishes a gRPC connection through a WireGuard tunnel
func (*Connection) Close ¶
func (c *Connection) Close() error
Close closes the connection and tunnel if present
type SSHTunnel ¶ added in v0.0.23
type SSHTunnel struct {
// contains filtered or unexported fields
}
func NewSSHTunnel ¶ added in v0.0.23
NewSSHTunnel establishes an SSH connection to the given destination (user@host:port) using the SSH agent and default key files.
type Tunnel ¶ added in v0.0.23
Tunnel represents a network tunnel (SSH, WireGuard) that can dial connections and be closed.
type WireGuardConfig ¶
type WireGuardConfig struct {
PrivateKey string // client's WireGuard private key (base64)
Address netip.Addr // client's IP in the WireGuard network
PeerPublicKey string // server's WireGuard public key (base64)
Endpoint string // WireGuard endpoint (host:port)
}
WireGuardConfig holds the configuration for a WireGuard tunnel
func ParseWireGuardConfig ¶
func ParseWireGuardConfig(path string) (*WireGuardConfig, error)
ParseWireGuardConfig parses a standard WireGuard config file
type WireGuardTunnel ¶
type WireGuardTunnel struct {
// contains filtered or unexported fields
}
WireGuardTunnel represents an active userspace WireGuard tunnel
func ConnectViaWireGuard ¶
func ConnectViaWireGuard(serverAddr string, wgCfg *WireGuardConfig) (*grpc.ClientConn, *WireGuardTunnel, error)
ConnectViaWireGuard creates a gRPC connection through a WireGuard tunnel
func NewWireGuardTunnel ¶
func NewWireGuardTunnel(cfg *WireGuardConfig) (*WireGuardTunnel, error)
NewWireGuardTunnel creates a new userspace WireGuard tunnel
func (*WireGuardTunnel) Close ¶
func (t *WireGuardTunnel) Close() error
Close shuts down the WireGuard tunnel