HubBroker class
The brain of the Hub: authenticates peers, registers nodes, authorizes and brokers sessions, and relays session bytes between clients and nodes.
Transport-agnostic — it is driven by accepting OmnyShellConnections, so it can run over the real TLS WebSocket endpoint or an in-memory loopback in tests. The default relay strategy is the NAT-friendly tunnel: session frames are forwarded over the node's persistent connection with their channel id rewritten between the two ends.
Constructors
- HubBroker({required Authenticator authenticator, required Authorizer authorizer, NodeRegistry? registry, SessionRouter? router, AuditLog? audit, Clock clock = const SystemClock(), Duration heartbeatTimeout = const Duration(seconds: 30), void logger(String message)?, HttpProxyService? aiProxy, PortRange? tunnelPortRange, Object tunnelBindHost = '0.0.0.0', String tunnelPublicHost = '', SecurityContext? tunnelSecurityContext})
- Creates a hub broker.
Properties
- aiProxy → HttpProxyService?
-
Proxies authenticated clients' outbound AI HTTPS requests, or
nullto disable AI proxying (config discovery then reports unavailable and proxy requests are rejected). The browser client uses this because it cannot call provider APIs directly (CORS).final - audit → AuditLog
-
The audit log.
final
- authenticator → Authenticator
-
Authenticates node and client credentials.
final
-
Authorizes session opens.
final
- clock → Clock
-
The clock (also used by the heartbeat monitor).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- heartbeatTimeout → Duration
-
How long a node may go silent before being declared offline.
final
- hubUid ↔ String?
-
This hub's deterministic UID, advertised in the challenge
helloso peers can identify and pin it. Set by OmnyShellHub at startup.getter/setter pair - logger → void Function(String message)?
-
Optional diagnostic logger.
final
- monitor → HeartbeatMonitor
-
The heartbeat monitor (exposed for manual ticking in tests).
no setter
- registry → NodeRegistry
-
The node registry.
final
- router → SessionRouter
-
The session routing table.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tunnelBindHost → Object
-
The host the Hub binds tunnel listeners to (matches the hub's own bind
host so external consumers can reach them).
final
- tunnelPortRange → PortRange?
-
The public TCP port range tunnels may bind, or
nullto disable tunneling (fail closed). Validated against specific-port requests and used for dynamic allocation.final - tunnelPublicHost → String
-
The host advertised to clients for tunnel public ports. When empty, the
client substitutes the Hub's own hostname (e.g. when the Hub binds a
wildcard address).
final
- tunnels → TunnelRegistry
-
Active tunnels (public listeners + metadata) and their in-use ports.
final
- tunnelSecurityContext ↔ SecurityContext?
-
The TLS context used to terminate TLS on public ports of tunnels opened
with
secure: true, ornullwhen secure tunnels are unavailable.getter/setter pair
Methods
-
accept(
OmnyShellConnection connection) → void -
Accepts a newly-connected peer, issues the challenge
hello, and begins handling its frames. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
) → void - Starts the liveness watchdog.
-
stop(
) → void - Stops the watchdog and closes every peer connection so nodes and clients observe the shutdown (and nodes begin reconnecting).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited