Documentation
¶
Index ¶
- Constants
- func ConnectURL(serverURL string) (string, error)
- func CredentialID(credentialValue string) (string, error)
- func CredentialMatches(credentialValue, token string) bool
- func CredentialPreview(credentialValue string) (string, error)
- func Dial(ctx context.Context, serverURL, token string) (*websocket.Conn, error)
- func NewCredential() (token, credentialValue string, err error)
- func Run(ctx context.Context, serverURL, token string) error
- func ValidateCatalogEntryTunnelReferences(ctx context.Context, client kclient.Client, ...) error
- func ValidateReference(ctx context.Context, client kclient.Client, name, target string) error
- func ValidateServerTunnelReferences(ctx context.Context, client kclient.Client, manifest types.MCPServerManifest) error
- type Authenticator
- type Manager
- func (m *Manager) AuthenticateRequest(req *http.Request) (*authenticator.Response, bool, error)
- func (m *Manager) BridgeAuthorization() (name, value string)
- func (m *Manager) BridgeHost() string
- func (m *Manager) BridgeURL(tunnelName, rawURL string) (string, error)
- func (m *Manager) Close()
- func (m *Manager) CloseAll()
- func (m *Manager) Connections() []apitypes.TunnelConnection
- func (m *Manager) ConnectionsContext(ctx context.Context) ([]apitypes.TunnelConnection, error)
- func (m *Manager) Disconnect(name string)
- func (m *Manager) DisconnectCredential(name, credentialID string)
- func (m *Manager) HTTPClient(tunnelName string, timeout time.Duration) (*http.Client, error)
- func (m *Manager) ReconcilePeers(desired map[string]string)
- func (m *Manager) ServeBridge(w http.ResponseWriter, r *http.Request)
- func (m *Manager) ServeConnect(w http.ResponseWriter, r *http.Request, name string)
- func (m *Manager) ServePeer(w http.ResponseWriter, r *http.Request)
- type PeerConfig
Constants ¶
const PeerConnectPath = "/tunnel/peer"
PeerConnectPath is the internal websocket endpoint used to connect Obot tunnel servers to one another.
Variables ¶
This section is empty.
Functions ¶
func ConnectURL ¶
ConnectURL returns the tunnel websocket endpoint on an Obot instance.
func CredentialID ¶
CredentialID returns the non-secret identifier used to narrow credential lookups before the full digest is verified.
func CredentialMatches ¶
CredentialMatches reports whether token matches a stored credential digest.
func CredentialPreview ¶
CredentialPreview returns the 16-byte preview stored with a credential.
func NewCredential ¶
NewCredential creates a 64-byte bearer token and the non-reversible value stored on an MCPTunnel.
func Run ¶
Run keeps a tunnel connected until ctx is canceled. Failed handshakes and lost connections are retried with bounded exponential backoff.
func ValidateCatalogEntryTunnelReferences ¶
func ValidateCatalogEntryTunnelReferences(ctx context.Context, client kclient.Client, manifest types.MCPServerCatalogEntryManifest) error
ValidateCatalogEntryTunnelReferences verifies every tunnel reference in a catalog manifest, including remote components embedded in a composite.
func ValidateReference ¶
ValidateReference checks that name identifies an MCPTunnel whose current AllowedURLs authorize target.
func ValidateServerTunnelReferences ¶
func ValidateServerTunnelReferences(ctx context.Context, client kclient.Client, manifest types.MCPServerManifest) error
ValidateServerTunnelReferences verifies every tunnel reference in a runtime server manifest, including remote components embedded in a composite.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator authenticates the credential stored on the MCPTunnel that owns the supplied bearer token. It yields a non-user principal restricted by the API authorizer to opening a tunnel connection.
func NewTunnelAuthenticator ¶
func NewTunnelAuthenticator(tunnels kclient.Reader) *Authenticator
NewTunnelAuthenticator creates a tunnel credential authenticator.
func (*Authenticator) AuthenticateRequest ¶
func (a *Authenticator) AuthenticateRequest(req *http.Request) (*authenticator.Response, bool, error)
AuthenticateRequest implements authenticator.Request.
type Manager ¶
type Manager struct {
PeerConfig
// contains filtered or unexported fields
}
Manager owns the tunnel sessions, the remotedialer peer mesh, and the HTTP bridge used by Obot's existing MCP HTTP client.
func NewManager ¶
func NewManager(ctx context.Context, bridgeBaseURL string, tunnels kclient.Reader, peerConfig PeerConfig) (*Manager, error)
NewManager creates a tunnel manager whose bridge is served from bridgeBaseURL. The caller must register ServeBridge on the HTTP server mux. Supplying a peer config enables remotedialer peering; the controller layer feeds discovered EndpointSlice peers through ReconcilePeers. An omitted or empty config keeps single-replica mode.
func (*Manager) AuthenticateRequest ¶
AuthenticateRequest authenticates requests generated for the internal tunnel bridge and websocket connections made by another Obot replica.
func (*Manager) BridgeAuthorization ¶
BridgeAuthorization returns the internal header that must accompany bridge requests. ServeBridge removes this header before forwarding the request to the tunnel client.
func (*Manager) BridgeHost ¶
BridgeHost returns the gateway host:port that must be allowlisted by the safe MCP HTTP client.
func (*Manager) BridgeURL ¶
BridgeURL converts an ordinary HTTP(S) target and MCPTunnel name into an internal URL on the gateway bridge.
func (*Manager) Close ¶
func (m *Manager) Close()
Close stops local tunnel sessions and all outgoing peer reconnect loops.
func (*Manager) CloseAll ¶
func (m *Manager) CloseAll()
CloseAll closes only the tunnel clients accepted by this replica. It must not disconnect sessions owned by healthy peers during a rolling shutdown.
func (*Manager) Connections ¶
func (m *Manager) Connections() []apitypes.TunnelConnection
Connections preserves the process-local snapshot returned by earlier versions of Manager. Use ConnectionsContext for an installation-wide view.
func (*Manager) ConnectionsContext ¶
ConnectionsContext returns a deterministic installation-wide snapshot of the configured tunnels that currently have a local or peer-advertised session. A connection may disappear immediately after the snapshot is taken.
func (*Manager) Disconnect ¶
Disconnect closes all tunnel clients with this name attached to this replica. Call DisconnectCredential when the previous credential ID is available so clients attached to other replicas can also be reached.
func (*Manager) DisconnectCredential ¶
DisconnectCredential closes all sessions using a tunnel's previous credential. Control connections are routed through remotedialer so clients attached to other replicas can also be reached.
func (*Manager) HTTPClient ¶
HTTPClient returns an HTTP client that routes every request through the named tunnel. Redirects rewritten by the bridge remain on the same tunnel.
func (*Manager) ReconcilePeers ¶
ReconcilePeers updates the remotedialer peer mesh to match desired. It is called by the all-replica EndpointSlice controller.
func (*Manager) ServeBridge ¶
func (m *Manager) ServeBridge(w http.ResponseWriter, r *http.Request)
ServeBridge forwards an HTTP request over the tunnel selected by the encoded internal bridge target in the request path.
func (*Manager) ServeConnect ¶
ServeConnect upgrades an authorized request for name. The name must come from the tunnel principal established by TunnelAuthenticator.
type PeerConfig ¶
PeerConfig configures authentication and discovery of the other Obot replicas that participate in the tunnel remotedialer mesh. An entirely empty config disables peering; otherwise every field is required.
func (PeerConfig) Enabled ¶
func (c PeerConfig) Enabled() bool
Enabled reports whether a valid config enables tunnel peering. Call Validate first when an invalid partial config must be distinguished from a disabled config.
func (PeerConfig) Validate ¶
func (c PeerConfig) Validate() error
Validate verifies that tunnel peering is either fully disabled or fully configured.