Documentation
¶
Overview ¶
Package tunnel provides management for tunnel services like Cloudflare and ngrok.
Index ¶
- Variables
- type Config
- type Manager
- func (m *Manager) ActiveCount() int
- func (m *Manager) Get(id string) (*Tunnel, error)
- func (m *Manager) GetWithPathFilter(id, pathFilter string) (*Tunnel, error)
- func (m *Manager) List() []TunnelInfo
- func (m *Manager) ListByPath(pathFilter string) []TunnelInfo
- func (m *Manager) Shutdown(ctx context.Context) error
- func (m *Manager) Start(ctx context.Context, id string, config Config) (*Tunnel, error)
- func (m *Manager) Stop(ctx context.Context, id string) error
- func (m *Manager) StopAll(ctx context.Context) error
- func (m *Manager) StopByProjectPath(ctx context.Context, projectPath string) ([]string, error)
- type Provider
- type State
- type Tunnel
- func (t *Tunnel) Done() <-chan struct{}
- func (t *Tunnel) ID() string
- func (t *Tunnel) Info() TunnelInfo
- func (t *Tunnel) OnURL(fn func(url string))
- func (t *Tunnel) Path() string
- func (t *Tunnel) PublicURL() string
- func (t *Tunnel) Start(ctx context.Context) error
- func (t *Tunnel) State() State
- func (t *Tunnel) Stop(ctx context.Context) error
- func (t *Tunnel) WaitForURL(ctx context.Context) (string, error)
- type TunnelInfo
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTunnelExists is returned when trying to create a tunnel with an existing ID. ErrTunnelExists = errors.New("tunnel already exists") // ErrTunnelNotFound is returned when a tunnel ID is not found. ErrTunnelNotFound = errors.New("tunnel not found") // ErrTunnelAmbiguous is returned when a fuzzy lookup matches multiple tunnels. ErrTunnelAmbiguous = errors.New("tunnel ID is ambiguous - multiple matches") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Provider Provider
LocalPort int
LocalHost string // defaults to "localhost"
BinaryPath string // optional: path to tunnel binary, otherwise uses PATH
ID string // tunnel identifier
Path string // project path for session scoping
}
Config holds tunnel configuration.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages tunnel instances.
func (*Manager) ActiveCount ¶
ActiveCount returns the number of active tunnels.
func (*Manager) Get ¶
Get returns a tunnel by ID with fuzzy matching support. First tries exact match, then looks for tunnels where the ID contains the search string as a component (for compound IDs).
func (*Manager) GetWithPathFilter ¶ added in v0.8.0
GetWithPathFilter retrieves a tunnel by ID with fuzzy matching, filtered by path. If pathFilter is non-empty, only tunnels with matching Path are considered for fuzzy lookup. Exact matches are always returned regardless of path filter.
func (*Manager) List ¶
func (m *Manager) List() []TunnelInfo
List returns information about all tunnels.
func (*Manager) ListByPath ¶ added in v0.8.0
func (m *Manager) ListByPath(pathFilter string) []TunnelInfo
ListByPath returns tunnels filtered by project path. If pathFilter is empty, returns all tunnels.
func (*Manager) StopAll ¶ added in v0.7.6
StopAll stops all running tunnels. Unlike Shutdown, this does NOT set shuttingDown flag, allowing new tunnels to be started afterward. This is used for cleanup when the last client disconnects.
func (*Manager) StopByProjectPath ¶ added in v0.8.0
StopByProjectPath stops all tunnels for a specific project path. This is used for session-scoped cleanup when a client disconnects. Returns the list of stopped tunnel IDs.
type Tunnel ¶
type Tunnel struct {
// contains filtered or unexported fields
}
Tunnel represents a running tunnel instance.
func (*Tunnel) Done ¶
func (t *Tunnel) Done() <-chan struct{}
Done returns a channel that's closed when the tunnel exits.
type TunnelInfo ¶
type TunnelInfo struct {
ID string `json:"id"`
Provider Provider `json:"provider"`
State string `json:"state"`
PublicURL string `json:"public_url,omitempty"`
LocalAddr string `json:"local_addr"`
Path string `json:"path,omitempty"`
Error string `json:"error,omitempty"`
}
TunnelInfo contains information about a tunnel.