Documentation
¶
Overview ¶
Package client implements the expose tunnel client that registers with the server, maintains a WebSocket session, and proxies traffic to a local port.
Index ¶
- Variables
- func ResolveMachineID(hostname string) string
- type Client
- func (c *Client) Run(ctx context.Context) error
- func (c *Client) SetAutoUpdate(enabled bool)
- func (c *Client) SetDisplay(d *Display)
- func (c *Client) SetLifecycleHooks(hooks LifecycleHooks)
- func (c *Client) SetLogger(l *slog.Logger)
- func (c *Client) SetTrafficSink(sink TrafficRecorder)
- func (c *Client) SetVersion(v string)
- type Display
- func (d *Display) Cleanup()
- func (d *Display) LogRequest(method, path string, status int, duration time.Duration, ...)
- func (d *Display) RecordTraffic(direction traffic.Direction, bytes int64)
- func (d *Display) SetLocalHealthTarget(localAddr string)
- func (d *Display) ShowBanner(version string)
- func (d *Display) ShowInfo(msg string)
- func (d *Display) ShowLatency(rtt time.Duration)
- func (d *Display) ShowReconnecting(reason string)
- func (d *Display) ShowTunnelInfo(publicURL, localAddr, tlsMode, tunnelID string, protected bool, ...)
- func (d *Display) ShowUpdateStatus(latestVersion string)
- func (d *Display) ShowVersions(clientVersion, serverVersion string, wafEnabled bool)
- func (d *Display) ShowWAFStats(blocked int64)
- func (d *Display) ShowWarning(msg string)
- func (d *Display) ToggleSessionDetails()
- func (d *Display) TrackWSClose(id string)
- func (d *Display) TrackWSOpen(id, path string, headers map[string][]string)
- type LifecycleHooks
- type RegisterFailureEvent
- type SessionDisconnectEvent
- type TrafficRecorder
- type TrafficSinkFunc
- type TunnelReadyEvent
Constants ¶
This section is empty.
Variables ¶
var ErrAutoUpdated = errors.New("binary updated; restart required")
ErrAutoUpdated is returned from Client.Run when the binary was replaced by the auto-updater and the caller should restart the process.
Functions ¶
func ResolveMachineID ¶ added in v0.14.0
ResolveMachineID returns a stable machine identifier for client-side naming and registration metadata, falling back to the provided hostname.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client connects to the expose server and proxies public traffic to a local port.
func New ¶
func New(cfg config.ClientConfig, logger *slog.Logger) *Client
New creates a Client with the given configuration and logger.
func (*Client) SetAutoUpdate ¶ added in v0.6.0
SetAutoUpdate enables background self-update. When enabled the client periodically checks for new releases and also reacts to server version changes detected during reconnection. If an update is applied the Run method returns ErrAutoUpdated.
func (*Client) SetDisplay ¶ added in v0.5.0
SetDisplay configures the interactive terminal display. When set, the client renders an ngrok-style interface instead of plain structured log output for tunnel status and request logging.
func (*Client) SetLifecycleHooks ¶ added in v0.16.0
func (c *Client) SetLifecycleHooks(hooks LifecycleHooks)
SetLifecycleHooks configures optional callbacks for tunnel lifecycle events.
func (*Client) SetTrafficSink ¶ added in v0.21.0
func (c *Client) SetTrafficSink(sink TrafficRecorder)
func (*Client) SetVersion ¶ added in v0.5.0
SetVersion sets the client version string for server exchange.
type Display ¶ added in v0.5.0
type Display struct {
// contains filtered or unexported fields
}
Display renders an ngrok-inspired terminal interface for the tunnel client. It redraws the entire screen on every state change so the header, counters, and request log are always visible. Safe for concurrent use.
func NewDisplay ¶ added in v0.5.0
NewDisplay creates a Display that writes to stdout. When color is true, ANSI escape codes are used for styling.
func (*Display) Cleanup ¶ added in v0.5.0
func (d *Display) Cleanup()
Cleanup restores the terminal cursor. Call on shutdown.
func (*Display) LogRequest ¶ added in v0.5.0
func (d *Display) LogRequest(method, path string, status int, duration time.Duration, headers map[string][]string)
LogRequest records an HTTP request and redraws. headers is used to extract the client IP (X-Forwarded-For) for tracking unique visitors. Pass nil if headers are not available.
func (*Display) RecordTraffic ¶ added in v0.21.0
func (*Display) SetLocalHealthTarget ¶ added in v0.22.0
func (*Display) ShowBanner ¶ added in v0.5.0
ShowBanner sets the version string and draws the initial screen.
func (*Display) ShowLatency ¶ added in v0.7.0
ShowLatency updates the displayed round-trip latency and redraws.
func (*Display) ShowReconnecting ¶ added in v0.5.0
ShowReconnecting sets the status to reconnecting and redraws.
func (*Display) ShowTunnelInfo ¶ added in v0.5.0
func (d *Display) ShowTunnelInfo(publicURL, localAddr, tlsMode, tunnelID string, protected bool, transport string)
ShowTunnelInfo updates the tunnel connection details and redraws.
func (*Display) ShowUpdateStatus ¶ added in v0.5.0
ShowUpdateStatus sets the available update version and redraws. Pass an empty string to indicate the client is up to date.
func (*Display) ShowVersions ¶ added in v0.5.0
ShowVersions sets the client and server version strings and redraws.
func (*Display) ShowWAFStats ¶ added in v0.9.0
ShowWAFStats updates the displayed WAF-blocked request count and redraws.
func (*Display) ShowWarning ¶ added in v0.5.0
ShowWarning sets the most recent warning notice and redraws.
func (*Display) ToggleSessionDetails ¶ added in v0.21.0
func (d *Display) ToggleSessionDetails()
ToggleSessionDetails shows or hides the extra session detail row.
func (*Display) TrackWSClose ¶ added in v0.5.0
TrackWSClose removes a WebSocket stream and redraws. A debounced display floor prevents the counter from briefly dipping during a page refresh (close + immediate reopen).
type LifecycleHooks ¶ added in v0.16.0
type LifecycleHooks struct {
OnTunnelReady func(TunnelReadyEvent)
OnRegisterFailure func(RegisterFailureEvent)
OnSessionDrop func(SessionDisconnectEvent)
}
LifecycleHooks allows callers to observe client lifecycle transitions without scraping log output.
type RegisterFailureEvent ¶ added in v0.16.0
RegisterFailureEvent is emitted when tunnel registration fails.
type SessionDisconnectEvent ¶ added in v0.16.0
type SessionDisconnectEvent struct {
Err error
}
SessionDisconnectEvent is emitted when an active tunnel session drops and the client will attempt to reconnect.
type TrafficRecorder ¶ added in v0.21.0
type TrafficSinkFunc ¶ added in v0.21.0
func (TrafficSinkFunc) RecordTraffic ¶ added in v0.21.0
func (f TrafficSinkFunc) RecordTraffic(direction traffic.Direction, bytes int64)
Source Files
¶
- client_errors.go
- client_forward_http.go
- client_register.go
- client_run.go
- client_traffic.go
- client_types.go
- client_update.go
- display_headers.go
- display_layout.go
- display_render.go
- display_state.go
- display_types.go
- session_runtime.go
- session_runtime_h3_multistream.go
- session_runtime_h3_workers.go
- session_runtime_ws.go
- session_runtime_ws_tracking.go
- session_transport.go