Documentation
¶
Overview ¶
Package proxy manages background connections, tunnels, and active sessions for applications.
Index ¶
- type AuditEvent
- type Dialer
- type DirectDialer
- type Logger
- type Manager
- func (m *Manager) GetLocalSession(id string) *Session
- func (m *Manager) GetLocalSessionByApp(appName string) *Session
- func (m *Manager) List() ([]Session, error)
- func (m *Manager) Start(ctx context.Context, app apps.AppConfig, dialer Dialer, closer io.Closer) (*Session, error)
- func (m *Manager) Stop(id string) error
- type SSHDialer
- type Session
- type StateManager
- type TunnelDialer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditEvent ¶
type AuditEvent struct {
Event string `json:"event"`
App string `json:"app"`
Target string `json:"target"`
Upstream string `json:"upstream"`
LocalAddr string `json:"local_addr"`
Time time.Time `json:"time"`
Error string `json:"error,omitempty"`
}
AuditEvent represents a proxy lifecycle event.
type Dialer ¶
type Dialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
Dialer abstracts how we dial to an upstream service.
type DirectDialer ¶
type DirectDialer struct{}
DirectDialer connects directly over the local network.
func (DirectDialer) DialContext ¶
DialContext implements Dialer.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger helps record proxy audit events safely.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager coordinates all active proxy sessions, saving state to disk and handling TTLs.
func NewManager ¶
NewManager returns a new initialized proxy manager.
func (*Manager) GetLocalSession ¶
GetLocalSession returns an active session created by this process. This allows access to the session's internal state (like the HTTP Handler) which is not serialized to the JSON state file.
func (*Manager) GetLocalSessionByApp ¶
GetLocalSessionByApp returns an active session created by this process for the given app name.
type SSHDialer ¶
type SSHDialer struct {
Client *sshclient.HoneyClient
}
SSHDialer connects to the upstream by tunneling through an SSH connection.
type Session ¶
type Session struct {
ID string `json:"id"`
App apps.AppConfig `json:"app"`
LocalAddr string `json:"local_addr"` // Only set if a local port is bound
StartedAt time.Time `json:"started_at"`
ExpiresAt time.Time `json:"expires_at"`
PID int `json:"pid"`
// Handler is used for HTTP apps that should be routed by the main webserver.
// It is nil for TCP apps or when not running inside the webserver process.
Handler http.Handler `json:"-"`
// Stop handles tearing down the local listener and connections.
Stop context.CancelFunc `json:"-"`
}
Session represents an active application proxy session.
func StartHTTPProxy ¶
func StartHTTPProxy(ctx context.Context, app apps.AppConfig, dialer Dialer, sessionID string, closer io.Closer) (*Session, error)
StartHTTPProxy constructs an HTTP reverse proxy and optionally binds it to 127.0.0.1. If app.LocalPort is 0, it skips binding the listener (used by the webserver dynamic proxy).
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager persists session data to a JSON file so multiple CLI processes and the Web UI can discover and cleanly terminate running proxies.
func NewStateManager ¶
func NewStateManager() *StateManager
NewStateManager returns a StateManager configured for the local environment.
func (*StateManager) Add ¶
func (m *StateManager) Add(s Session) error
Add adds a new session to the state.
func (*StateManager) List ¶
func (m *StateManager) List() ([]Session, error)
List returns all active proxy sessions, removing expired ones from state.
func (*StateManager) Remove ¶
func (m *StateManager) Remove(id string) error
Remove removes a session from the state by ID.
type TunnelDialer ¶
type TunnelDialer struct {
// contains filtered or unexported fields
}
TunnelDialer uses a custom dial function to natively dial upstream connections in memory without opening an OS-level listener port.
func NewTunnelDialer ¶
func NewTunnelDialer(dialFn func(ctx context.Context, network, address string) (net.Conn, error)) *TunnelDialer
NewTunnelDialer creates a new generic TunnelDialer.
func (*TunnelDialer) DialContext ¶
DialContext connects directly to the background tunnel using the provided dial function.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package reverseproxy provides a Teleport-inspired HTTP reverse proxy.
|
Package reverseproxy provides a Teleport-inspired HTTP reverse proxy. |