feat(remoteingress): add ability to generate remote ingress connection tokens and UI copy action; add hubDomain config option; update remoteingress dependency to ^3.1.1
This commit is contained in:
@@ -177,5 +177,46 @@ export class RemoteIngressHandler {
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Get a connection token for an edge
|
||||
this.typedrouter.addTypedHandler(
|
||||
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRemoteIngressConnectionToken>(
|
||||
'getRemoteIngressConnectionToken',
|
||||
async (dataArg, toolsArg) => {
|
||||
const manager = this.opsServerRef.dcRouterRef.remoteIngressManager;
|
||||
if (!manager) {
|
||||
return { success: false, message: 'RemoteIngress not configured' };
|
||||
}
|
||||
|
||||
const edge = manager.getEdge(dataArg.edgeId);
|
||||
if (!edge) {
|
||||
return { success: false, message: 'Edge not found' };
|
||||
}
|
||||
if (!edge.enabled) {
|
||||
return { success: false, message: 'Edge is disabled' };
|
||||
}
|
||||
|
||||
const hubHost = dataArg.hubHost
|
||||
|| this.opsServerRef.dcRouterRef.options.remoteIngressConfig?.hubDomain;
|
||||
if (!hubHost) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'No hub hostname configured. Set hubDomain in remoteIngressConfig or provide hubHost.',
|
||||
};
|
||||
}
|
||||
|
||||
const hubPort = this.opsServerRef.dcRouterRef.options.remoteIngressConfig?.tunnelPort ?? 8443;
|
||||
|
||||
const token = plugins.remoteingress.encodeConnectionToken({
|
||||
hubHost,
|
||||
hubPort,
|
||||
edgeId: edge.id,
|
||||
secret: edge.secret,
|
||||
});
|
||||
|
||||
return { success: true, token };
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user