server

package
v1.0.40 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Running

func Running() bool

Running returns true if the server is already running.

func SocketPath

func SocketPath() string

SocketPath returns the path to the latch unix socket.

Types

type AuditEvent

type AuditEvent struct {
	Time       string `json:"time"`
	Event      string `json:"event"`                 // "connect", "disconnect", "reject"
	Source     string `json:"source"`                // "local", "ssh", "web", "relay", "web-relay"
	RemoteAddr string `json:"remote_addr,omitempty"` // client IP:port
	KeyFP      string `json:"key_fp,omitempty"`      // SSH key fingerprint
	KeyComment string `json:"key_comment,omitempty"` // SSH key comment
	Session    string `json:"session,omitempty"`
	Duration   string `json:"duration,omitempty"` // only on disconnect
	Reason     string `json:"reason,omitempty"`   // only on reject
}

AuditEvent is a single audit log entry.

type ConnInfo

type ConnInfo struct {
	ID          uint64
	Source      string // "local", "ssh", "relay"
	RemoteAddr  string
	KeyComment  string
	KeyFP       string
	Session     string
	ConnectedAt time.Time
	// contains filtered or unexported fields
}

ConnInfo describes an active client connection.

type Server

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

Server is the latch daemon, managing sessions over a unix socket.

func New

func New(cfg *config.Config) *Server

New returns a new server using the default socket path and given config.

func (*Server) Close

func (s *Server) Close()

Close shuts down all listeners and sessions.

func (*Server) Listen

func (s *Server) Listen() error

Listen creates the unix socket and starts listening.

func (*Server) ListenRemote

func (s *Server) ListenRemote(addr string) error

ListenRemote starts an SSH server for remote clients.

func (*Server) ListenWeb

func (s *Server) ListenWeb(addr, certPath, keyPath string) error

ListenWeb starts an HTTPS+WSS server for browser access. Auto-generates a self-signed TLS certificate if none exists. Set certPath/keyPath to empty strings to use defaults (~/.latch/tls.{crt,key}).

func (*Server) RequestUDPBridge added in v1.0.1

func (s *Server) RequestUDPBridge(targetPort uint16) (relayPort int, relayAddr string, stream *quic.Stream, err error)

RequestUDPBridge asks the relay to bridge a public UDP port to a local mosh port. Returns the relay's public port, public address, and the QUIC stream (kept open for the bridge lifetime).

func (*Server) Serve

func (s *Server) Serve() error

Serve accepts connections until the listener is closed.

func (*Server) StartRelay

func (s *Server) StartRelay(addr, user, device, caFile string) error

StartRelay starts the persistent relay connection. Incoming relay streams are SSH ciphertext — they go through the same SSH server handshake as direct SSH connections.

func (*Server) StopRelay

func (s *Server) StopRelay()

StopRelay stops the relay connection.

Jump to

Keyboard shortcuts

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