start method
Implementation
Future<void> start() async {
_loadState();
// Plain bind (issue #943 review): no SO_REUSEPORT — two simultaneous
// hubs on one port must stay a LOUD failure, not a silent split-brain
// (kernel load-balancing connections across split rosters; on Windows
// SO_REUSEADDR would let a bind sail over a foreign holder). The
// dying-predecessor vector is covered one level up: hubServe's
// healthz pre-probe + bind retry turn a stale port into "already
// running" or a bounded retry, not a hard red.
_server = await HttpServer.bind(
bind == 'lan' ? InternetAddress.anyIPv4 : InternetAddress.loopbackIPv4,
port,
);
// Issue #792: the relay authenticates on EVERY scope. A protected hub
// demands its master secret; an open loopback hub still gets an
// ephemeral per-serve secret — loopback is an address, not an auth
// method (any local process can hit it).
_relaySecret ??= _masterSecret ?? _newEnrollmentSecret();
unawaited(_serve());
}