Documentation
¶
Overview ¶
pkg/tunnel/cloudflare.go
Cloudflared provider — anonymous tunnel, no account required. Uses trycloudflare.com (Cloudflare Quick Tunnels).
pkg/tunnel/expose.go
High-level Expose function used by `ork deploy --expose` and `ork tunnel expose`. Detects the local port, starts the tunnel, and persists state under a named key.
pkg/tunnel/ngrok.go
ngrok provider — free-tier tunnels, requires an account and auth token.
pkg/tunnel/provider.go
Provider interface and auto-selection logic for tunnel providers. Cloudflared is the default (no account required); ngrok is the fallback.
pkg/tunnel/state.go
Multi-tunnel daemon state — persisted to ~/.orkestra/tunnel-state.json as a map[name]State so multiple tunnels (per app, controlcenter) coexist.
Index ¶
- func Expose(ctx context.Context, opts ExposeOptions) (string, error)
- func LoadAllStates() (map[string]State, error)
- func RemoveAllStates() error
- func RemoveTunnelState(name string) error
- func SaveTunnelState(name string, s State) error
- type CloudflaredProvider
- func (c *CloudflaredProvider) Authenticate(_ context.Context, _ string) error
- func (c *CloudflaredProvider) Available() bool
- func (c *CloudflaredProvider) Install(ctx context.Context) error
- func (c *CloudflaredProvider) Name() string
- func (c *CloudflaredProvider) Start(ctx context.Context, localPort int) (string, int, error)
- func (c *CloudflaredProvider) Stop(pid int) error
- type ExposeOptions
- type NgrokProvider
- func (n *NgrokProvider) Authenticate(_ context.Context, token string) error
- func (n *NgrokProvider) Available() bool
- func (n *NgrokProvider) Install(_ context.Context) error
- func (n *NgrokProvider) Name() string
- func (n *NgrokProvider) Start(ctx context.Context, localPort int) (string, int, error)
- func (n *NgrokProvider) Stop(pid int) error
- type Provider
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Expose ¶
func Expose(ctx context.Context, opts ExposeOptions) (string, error)
Expose starts or reuses a named tunnel and returns the public URL. State is persisted to ~/.orkestra/tunnel-state.json under opts.Name.
func LoadAllStates ¶
LoadAllStates reads all persisted tunnel entries.
func RemoveTunnelState ¶
RemoveTunnelState removes one entry from the state map. The file is deleted entirely when the map becomes empty.
func SaveTunnelState ¶
SaveTunnelState writes or updates the named tunnel entry.
Types ¶
type CloudflaredProvider ¶
type CloudflaredProvider struct{}
CloudflaredProvider implements Provider for Cloudflare Quick Tunnels.
func (*CloudflaredProvider) Authenticate ¶
func (c *CloudflaredProvider) Authenticate(_ context.Context, _ string) error
Authenticate is a no-op — trycloudflare.com requires no account or token.
func (*CloudflaredProvider) Available ¶
func (c *CloudflaredProvider) Available() bool
func (*CloudflaredProvider) Install ¶
func (c *CloudflaredProvider) Install(ctx context.Context) error
func (*CloudflaredProvider) Name ¶
func (c *CloudflaredProvider) Name() string
func (*CloudflaredProvider) Start ¶
Start launches cloudflared as a detached background process and returns the public URL once it appears in cloudflared's log output.
cloudflared's stderr is redirected to a log FILE (not a pipe). This is critical: OS pipes cause SIGPIPE in cloudflared when our process exits and the read end is closed. Files don't have this problem — cloudflared keeps writing to the file after we exit.
func (*CloudflaredProvider) Stop ¶
func (c *CloudflaredProvider) Stop(pid int) error
type ExposeOptions ¶
type ExposeOptions struct {
// Name identifies the tunnel in the state map (e.g. "my-app", "controlcenter").
// Falls back to ServiceName when empty.
Name string
// Provider is the explicit provider name ("cloudflared" or "ngrok").
// Empty means auto-select.
Provider string
// Token is passed to Provider.Authenticate when non-empty.
Token string
// LocalPort overrides auto-detection when non-zero.
LocalPort int
// ServiceName is the Kubernetes service name to port-forward to as a
// fallback (e.g. "my-app-orkestra-svc", "orkestra-cc").
ServiceName string
// Namespace is the target namespace for the service port-forward.
Namespace string
// ServicePort is the container port on the service (default "80").
ServicePort string
// PortForward is kept for compatibility but has no effect when ServiceName
// and Namespace are set — port-forward is always preferred in that case.
// Left here so callers that explicitly set it true do not break.
PortForward bool
}
ExposeOptions controls how the tunnel is started.
type NgrokProvider ¶
type NgrokProvider struct{}
NgrokProvider implements Provider for ngrok.
func (*NgrokProvider) Authenticate ¶
func (n *NgrokProvider) Authenticate(_ context.Context, token string) error
Authenticate configures the ngrok auth token.
func (*NgrokProvider) Available ¶
func (n *NgrokProvider) Available() bool
func (*NgrokProvider) Install ¶
func (n *NgrokProvider) Install(_ context.Context) error
Install prints guidance — ngrok is not auto-downloaded because it requires an account and the installer is platform-specific.
func (*NgrokProvider) Name ¶
func (n *NgrokProvider) Name() string
func (*NgrokProvider) Start ¶
Start launches ngrok as a detached background process.
ngrok's stdout is redirected to a log file (not a pipe) so that our process exiting doesn't deliver SIGPIPE to ngrok while it's still initializing.
func (*NgrokProvider) Stop ¶
func (n *NgrokProvider) Stop(pid int) error
type Provider ¶
type Provider interface {
// Name returns the provider identifier used in state files and output.
Name() string
// Available reports whether the provider binary is in PATH or ~/.orkestra/bin.
Available() bool
// Install downloads and installs the provider binary when not available.
Install(ctx context.Context) error
// Authenticate stores credentials (no-op for cloudflared).
Authenticate(ctx context.Context, token string) error
// Start launches a background tunnel to localPort and returns the public URL
// once it is available. The daemon outlives the process that called Start.
Start(ctx context.Context, localPort int) (url string, pid int, err error)
// Stop terminates the daemon identified by pid.
Stop(pid int) error
}
Provider is implemented by every supported tunnel backend.
func Select ¶
Select returns the first available provider in priority order. cloudflared comes first (no account). ngrok is second.
func SelectByName ¶
SelectByName returns a provider by explicit name.
type State ¶
type State struct {
Name string `json:"name"`
Provider string `json:"provider"`
PID int `json:"pid"`
PortForwardPID int `json:"portForwardPid,omitempty"`
URL string `json:"url"`
LocalPort int `json:"localPort"`
StartedAt time.Time `json:"startedAt"`
}
State records one running tunnel daemon.
func LoadTunnelState ¶
LoadTunnelState returns the state for name, or nil when not found.