Documentation
¶
Overview ¶
Package tunnelclient provides the reusable Tunlease claim and reverse-tunnel client used by both the standalone CLI and embedding applications.
Index ¶
Constants ¶
const ( MaxPathsPerClaim = claimpath.MaxPathsPerClaim MaxPathLength = claimpath.MaxPathLength )
const DefaultControlPrefix = "/_tunlease"
New validates config and creates a reusable client. DefaultControlPrefix is the URL path prefix the gateway serves its control plane under on a same-domain deployment. The client adds it automatically so users only need to give the gateway's domain.
Variables ¶
This section is empty.
Functions ¶
func NormalizePath ¶
NormalizePath validates a callback path and removes a trailing slash. A trailing /* matches one child segment; /** matches the whole subtree.
Types ¶
type APIError ¶
type APIError struct {
Status int `json:"-"`
Code string `json:"error"`
Detail string `json:"detail"`
ClaimedBy string `json:"claimed_by"`
}
APIError is a structured error returned by the gateway.
type Claim ¶
type Claim struct {
ID string `json:"claim_id"`
Owner string `json:"owner"`
Paths []string `json:"paths"`
StartedAt time.Time `json:"started_at"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
Claim describes one active tunnel and its exclusively owned paths.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to a Tunlease gateway and opens reverse tunnels.
type Config ¶
type Config struct {
Gateway string
Token string
// Insecure skips TLS certificate verification of the gateway connection
// (API + tunnel WebSocket). Use only on trusted development networks.
// Ignored when HTTPClient is provided.
Insecure bool
// DefaultScheme is used when Gateway has no scheme. Defaults to "https".
// Set to "http" for a gateway without TLS (e.g. a local demo).
DefaultScheme string
HTTPClient *http.Client
}
Config configures a Client. HTTPClient is optional.
type Event ¶
type Event struct {
Type EventType
Claim Claim
Err error
Method string
Path string
Status int
Duration time.Duration
}
Event describes a best-effort, non-terminal lifecycle notification. Slow consumers may miss events; Claim, Done, and Err are authoritative.
type EventType ¶
type EventType string
EventType identifies a lifecycle change emitted by a Session.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session owns one active tunnel and its paths.
func (*Session) Done ¶
func (s *Session) Done() <-chan struct{}
Done closes when the session has released its tunnel or failed terminally.