Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(federation): the WebSocket fallback listener defaults to loopback; an empty host counts as unset (#4520)

Dragan Spiridonov16d9b7fd58f0
diff --git a/v3/@claude-flow/plugin-agent-federation/README.md b/v3/@claude-flow/plugin-agent-federation/README.md
index 32de1e6417..e34211a276 100644
--- a/v3/@claude-flow/plugin-agent-federation/README.md
+++ b/v3/@claude-flow/plugin-agent-federation/README.md
@@ -31,7 +31,7 @@ npx -y -p @claude-flow/plugin-agent-federation@latest ruflo-federation --help
```bash
FEDERATION_NODE_NAME=my-node # default: hostname
-FEDERATION_BIND_HOST=0.0.0.0 # default: 0.0.0.0
+FEDERATION_BIND_HOST=127.0.0.1 # default: 127.0.0.1 (0.0.0.0 accepts other hosts)
FEDERATION_BIND_PORT=8443 # default: 8443
FEDERATION_TRUST_LEVEL=untrusted # default: untrusted
```
diff --git a/v3/@claude-flow/plugin-agent-federation/__tests__/unit/midstream-aware-loader.test.ts b/v3/@claude-flow/plugin-agent-federation/__tests__/unit/midstream-aware-loader.test.ts
index 044b03b0e6..6c69a44edb 100644
--- a/v3/@claude-flow/plugin-agent-federation/__tests__/unit/midstream-aware-loader.test.ts
+++ b/v3/@claude-flow/plugin-agent-federation/__tests__/unit/midstream-aware-loader.test.ts
@@ -36,6 +36,8 @@ vi.mock('agentic-flow/transport/loader', async () => {
};
});
+const wsServerOptions = vi.hoisted(() => [] as Array<{ port?: number; host?: string }>);
+
vi.mock('ws', async () => {
class MockWebSocket {
on() {}
@@ -43,6 +45,9 @@ vi.mock('ws', async () => {
close() {}
}
class MockWebSocketServer {
+ constructor(options: { port?: number; host?: string }) {
+ wsServerOptions.push(options);
+ }
on(event: string, handler: () => void) {
if (event === 'listening') queueMicrotask(handler);
}
@@ -146,6 +151,21 @@ describe('loadFederationTransport — ADR-120 Step 2', () => {
expect(typeof loaded.transport.listen).toBe('function');
});
+ it('the fallback listener binds loopback unless a host is configured', async () => {
+ const mod = await import('agentic-flow/transport/loader');
+ const loaderFn = (mod as unknown as { loadQuicTransport: ReturnType<typeof vi.fn> })
+ .loadQuicTransport;
+ for (let i = 0; i < 3; i++) loaderFn.mockResolvedValueOnce({ send: vi.fn() });
+
+ wsServerOptions.length = 0;
+ for (const host of [undefined, '0.0.0.0', '']) {
+ const loaded = await loadFederationTransport({ port: 0, host });
+ await loaded.transport.listen!(0);
+ }
+
+ expect(wsServerOptions.map((o) => o.host)).toEqual(['127.0.0.1', '0.0.0.0', '127.0.0.1']);
+ });
+
it('returned envelope has the documented LoadedFederationTransport shape', async () => {
const loaded = await loadFederationTransport();
expect(Object.keys(loaded).sort()).toEqual(
diff --git a/v3/@claude-flow/plugin-agent-federation/src/plugin.ts b/v3/@claude-flow/plugin-agent-federation/src/plugin.ts
index 6d98512b65..0a140f691e 100644
--- a/v3/@claude-flow/plugin-agent-federation/src/plugin.ts
+++ b/v3/@claude-flow/plugin-agent-federation/src/plugin.ts
@@ -440,7 +440,8 @@ export class AgentFederationPlugin implements ClaudeFlowPlugin {
const listenPort = config['port'] as number | undefined;
if (transport && typeof listenPort === 'number' && transport.listen) {
// Loopback unless the operator names an interface: the listener is plaintext.
- const listenHost = (config['host'] as string | undefined) ?? '127.0.0.1';
+ // An empty host would bind every interface, so it counts as unset.
+ const listenHost = (config['host'] as string | undefined) || '127.0.0.1';
if (listenHost !== '127.0.0.1' && listenHost !== 'localhost' && listenHost !== '::1') {
context.logger.warn(`Federation listener on ${listenHost} is plaintext WebSocket; keep it on a private network (tailnet, WireGuard) or behind TLS`);
}
diff --git a/v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts b/v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts
index 1936d17622..c04e2e0518 100644
--- a/v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts
+++ b/v3/@claude-flow/plugin-agent-federation/src/transport/midstream-aware-loader.ts
@@ -180,7 +180,9 @@ class WebSocketFallbackTransport implements AgentTransport {
this.handlers.push(handler);
}
- async listen(port = Number(this.config.port ?? 0), host = String(this.config.host ?? '0.0.0.0')): Promise<void> {
+ // Loopback unless a host is configured, like the plugin listener; an empty
+ // host would bind every interface, so it counts as unset.
+ async listen(port = Number(this.config.port ?? 0), host = this.config.host || '127.0.0.1'): Promise<void> {
const { WebSocketServer } = await import('ws');
const server = new WebSocketServer({ port, host }) as WebSocketServerLike;
this.server = server;