feat(remoteingress): add remote ingress performance configuration and expose tunnel transport metrics
This commit is contained in:
@@ -9,6 +9,7 @@ export interface ITunnelManagerConfig {
|
||||
certPem?: string;
|
||||
keyPem?: string;
|
||||
};
|
||||
performance?: import('../../ts_interfaces/data/remoteingress.js').IRemoteIngressPerformanceConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20,6 +21,7 @@ export class TunnelManager {
|
||||
private config: ITunnelManagerConfig;
|
||||
private edgeStatuses: Map<string, IRemoteIngressStatus> = new Map();
|
||||
private reconcileInterval: ReturnType<typeof setInterval> | null = null;
|
||||
private syncChain: Promise<void> = Promise.resolve();
|
||||
|
||||
constructor(manager: RemoteIngressManager, config: ITunnelManagerConfig = {}) {
|
||||
this.manager = manager;
|
||||
@@ -66,7 +68,8 @@ export class TunnelManager {
|
||||
tunnelPort: this.config.tunnelPort ?? 8443,
|
||||
targetHost: this.config.targetHost ?? '127.0.0.1',
|
||||
tls: this.config.tls,
|
||||
});
|
||||
...(this.config.performance ? { performance: this.config.performance } : {}),
|
||||
} as any);
|
||||
|
||||
// Send allowed edges to the hub
|
||||
await this.syncAllowedEdges();
|
||||
@@ -107,20 +110,23 @@ export class TunnelManager {
|
||||
if (existing) {
|
||||
existing.activeTunnels = rustEdge.activeStreams;
|
||||
existing.lastHeartbeat = Date.now();
|
||||
this.applyRustStatus(existing, rustEdge);
|
||||
// Update peer address if available from Rust hub
|
||||
if (rustEdge.peerAddr) {
|
||||
existing.publicIp = rustEdge.peerAddr;
|
||||
}
|
||||
} else {
|
||||
// Missed edgeConnected event — add entry
|
||||
this.edgeStatuses.set(rustEdge.edgeId, {
|
||||
const status: IRemoteIngressStatus = {
|
||||
edgeId: rustEdge.edgeId,
|
||||
connected: true,
|
||||
publicIp: rustEdge.peerAddr || null,
|
||||
activeTunnels: rustEdge.activeStreams,
|
||||
lastHeartbeat: Date.now(),
|
||||
connectedAt: rustEdge.connectedAt * 1000,
|
||||
});
|
||||
};
|
||||
this.applyRustStatus(status, rustEdge);
|
||||
this.edgeStatuses.set(rustEdge.edgeId, status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,8 +143,22 @@ export class TunnelManager {
|
||||
* Call this after creating/deleting/updating edges.
|
||||
*/
|
||||
public async syncAllowedEdges(): Promise<void> {
|
||||
const edges = this.manager.getAllowedEdges();
|
||||
await this.hub.updateAllowedEdges(edges);
|
||||
const run = this.syncChain.catch(() => {}).then(async () => {
|
||||
const edges = this.manager.getAllowedEdges();
|
||||
await this.hub.updateAllowedEdges(edges as any);
|
||||
});
|
||||
this.syncChain = run;
|
||||
await run;
|
||||
}
|
||||
|
||||
private applyRustStatus(status: IRemoteIngressStatus, rustEdge: any): void {
|
||||
status.transportMode = rustEdge.transportMode;
|
||||
status.fallbackUsed = rustEdge.fallbackUsed;
|
||||
status.performance = rustEdge.performance;
|
||||
status.flowControl = rustEdge.flowControl;
|
||||
status.queues = rustEdge.queues;
|
||||
status.traffic = rustEdge.traffic;
|
||||
status.udp = rustEdge.udp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user