ws

package
v1.0.38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a single WebSocket connection

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

Hub manages WebSocket connections and log subscriptions

func NewHub

func NewHub(logStreamer *logger.LogStreamer, authManager *auth.Manager, enforcer *rbac.Enforcer, store *storage.Store, docker *docker.Client, sender *command.Sender, log *logger.Logger) *Hub

NewHub creates a new WebSocket hub

func (*Hub) MigrateServerContainer

func (h *Hub) MigrateServerContainer(serverID, newContainerID string)

MigrateServerContainer re-points every live subscription for serverID at the container's new ID (MINE-108). Without this, a client that subscribed before a container recreation keeps the old containerID, so a later unsubscribe or disconnect cleanup asks the LogStreamer to close a channel under a key it no longer knows about — leaking the channel and its forwarder goroutine.

It is called by the reconciler once it has observed (or performed) a recreation, and is a no-op for clients with no subscription for serverID.

func (*Hub) Run

func (h *Hub) Run()

Run starts the hub's main loop

func (*Hub) ServeHTTP

func (h *Hub) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles WebSocket upgrade requests

func (*Hub) SetCheckOrigin

func (h *Hub) SetCheckOrigin(check func(r *http.Request) bool)

SetCheckOrigin overrides the WebSocket upgrader origin validation function.

func (*Hub) SetOriginPolicy

func (h *Hub) SetOriginPolicy(allow []string, trustProxy bool)

SetOriginPolicy sets the browser origins that may open a console socket. An empty allowlist keeps same-host checks. X-Forwarded-Host is ignored unless trustProxy is set. A missing Origin header stays allowed for CLI clients.

func (*Hub) SetPool

func (h *Hub) SetPool(pool *docker.ClientPool)

SetPool sets the Docker client pool for multi-node support.

func (*Hub) Stop

func (h *Hub) Stop()

Stop terminates the Run loop, closes every connected client's done channel so their pumps exit, and releases anything blocked on register/unregister. Safe to call more than once and safe to call without Run having started.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL