goclient

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSSHDestination added in v0.0.23

func ParseSSHDestination(dest string) (sshUser, host, port string)

ParseSSHDestination parses an OpenSSH-style destination string into user, host, and port. Accepted formats:

host
host:port
user@host
user@host:port

Types

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) (*Connection, error)

Connect establishes a gRPC connection to the server. serverURL can be "host:port", "https://host", or "https://user:pass@host".

func ConnectURL added in v0.0.23

func ConnectURL(server, wgConfigPath string) (*Connection, error)

ConnectURL establishes a gRPC connection, parsing the server address for ssh:// URLs and optional WireGuard config.

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

func NewSSHTunnel(destination string) (*SSHTunnel, error)

NewSSHTunnel establishes an SSH connection to the given destination (user@host:port) using the SSH agent and default key files.

func (*SSHTunnel) Close added in v0.0.23

func (t *SSHTunnel) Close() error

func (*SSHTunnel) Dial added in v0.0.23

func (t *SSHTunnel) Dial(ctx context.Context, address string) (net.Conn, error)

type Tunnel added in v0.0.23

type Tunnel interface {
	Dial(ctx context.Context, address string) (net.Conn, error)
	Close() error
}

Tunnel represents a network tunnel (SSH, WireGuard) that can dial connections and be closed.

func ParseServer added in v0.0.23

func ParseServer(server, wgConfigPath string) (tunnel Tunnel, remoteAddr, label string, err error)

ParseServer parses a server address and optional WireGuard config path, returning a tunnel (if any), the resolved remote address, and a display label.

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

func (*WireGuardTunnel) Dial

func (t *WireGuardTunnel) Dial(ctx context.Context, address string) (net.Conn, error)

Dial creates a TCP connection through the WireGuard tunnel

Jump to

Keyboard shortcuts

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