feat(remoteingress (edge/hub/protocol)): add dynamic port configuration: handshake, FRAME_CONFIG frames, and hot-reloadable listeners

This commit is contained in:
2026-02-18 18:20:53 +00:00
parent 072362a8e6
commit d869589663
8 changed files with 314 additions and 72 deletions

View File

@@ -43,6 +43,7 @@ export interface IEdgeConfig {
export class RemoteIngressEdge extends EventEmitter {
private bridge: InstanceType<typeof plugins.smartrust.RustBridge<TEdgeCommands>>;
private started = false;
private statusInterval: ReturnType<typeof setInterval> | undefined;
constructor() {
super();
@@ -79,6 +80,14 @@ export class RemoteIngressEdge extends EventEmitter {
this.bridge.on('management:publicIpDiscovered', (data: { ip: string }) => {
this.emit('publicIpDiscovered', data);
});
this.bridge.on('management:portsAssigned', (data: { listenPorts: number[] }) => {
console.log(`[RemoteIngressEdge] Ports assigned by hub: ${data.listenPorts.join(', ')}`);
this.emit('portsAssigned', data);
});
this.bridge.on('management:portsUpdated', (data: { listenPorts: number[] }) => {
console.log(`[RemoteIngressEdge] Ports updated by hub: ${data.listenPorts.join(', ')}`);
this.emit('portsUpdated', data);
});
}
/**
@@ -113,12 +122,30 @@ export class RemoteIngressEdge extends EventEmitter {
});
this.started = true;
// Start periodic status logging
this.statusInterval = setInterval(async () => {
try {
const status = await this.getStatus();
console.log(
`[RemoteIngressEdge] Status: connected=${status.connected}, ` +
`streams=${status.activeStreams}, ports=[${status.listenPorts.join(',')}], ` +
`publicIp=${status.publicIp ?? 'unknown'}`
);
} catch {
// Bridge may be shutting down
}
}, 60_000);
}
/**
* Stop the edge and kill the Rust process.
*/
public async stop(): Promise<void> {
if (this.statusInterval) {
clearInterval(this.statusInterval);
this.statusInterval = undefined;
}
if (this.started) {
try {
await this.bridge.sendCommand('stopEdge', {} as Record<string, never>);