Documentation
¶
Overview ¶
Package etunnel is the Go SDK for etunnel tunnels: expose a local service on the public internet with one call.
t, err := etunnel.Connect(ctx, etunnel.Options{Server: "wss://t.example.com/tunnel", LocalAddr: ":8080"})
fmt.Println(t.URL()) // https://quick-fox-42.t.example.com
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultServer = "wss://t.etun.uk/tunnel"
DefaultServer is the connect target when Options.Server is empty; overridable at link time: -ldflags "-X etunnel/sdk.DefaultServer=wss://t.example.com/tunnel"
Functions ¶
func NormalizeServerURL ¶
NormalizeServerURL canonicalizes a server address into a ws(s) URL.
Types ¶
type Options ¶
type Options struct {
// Server is the tunnel server endpoint, e.g. "wss://t.example.com/tunnel".
// A bare host gets "wss://" and "/tunnel" defaults.
Server string
// LocalAddr is the local service address to expose ("127.0.0.1:8080").
LocalAddr string
// Subdomain requests a custom subdomain (requires a paid plan token).
Subdomain string
// Token is a paid plan API key.
Token string
// Client is a free-form client identification string.
Client string
// OnLog, when set, receives lifecycle log lines.
OnLog func(format string, args ...any)
}
Options configures a tunnel.
type Tunnel ¶
type Tunnel struct {
// contains filtered or unexported fields
}
Tunnel is one live reverse tunnel.
func Connect ¶
Connect establishes a reverse tunnel and returns it once the server has assigned a public hostname.
func (*Tunnel) CloseReason ¶
CloseReason returns why the tunnel ended ("" while running).
func (*Tunnel) Done ¶
func (t *Tunnel) Done() <-chan struct{}
Done is closed when the tunnel ends (server closed it, TTL expired, connection lost or Close was called).
func (*Tunnel) ExpiresAt ¶
ExpiresAt returns the tunnel expiry reported by the server (zero = none).