UNPKG

@litert/televoke

Version:
63 lines 2.13 kB
"use strict"; /** * Copyright 2025 Angus.Fenying <fenying@litert.org> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.createTlsGateway = createTlsGateway; const LwDFX = require("@litert/lwdfx"); const node_events_1 = require("node:events"); const LwDFX_Transporter_1 = require("./LwDFX.Transporter"); class LwDfxTlsGateway extends node_events_1.EventEmitter { constructor(serverOpts, _gatewayOpts, _server) { super(); this._gatewayOpts = _gatewayOpts; this._server = _server; this._gateway = null; this._lwdfxServer = LwDFX.createServer({ ...serverOpts, alpWhitelist: ['televoke2'] }); this._lwdfxServer.on('connection', (conn) => { this._server.registerChannel(new LwDFX_Transporter_1.LwDFXTransporter('lwdfx/tls', conn)); }); } get running() { return !!this._gateway; } async start() { if (this._gateway) { return; } this._gateway = LwDFX.Tls.createGateway(this._lwdfxServer, this._gatewayOpts); try { await this._gateway.start(); } catch (e) { this._gateway = null; throw e; } } async stop() { if (!this._gateway) { return; } await this._gateway.stop(); this._gateway = null; } } function createTlsGateway(server, gatewayOpts, serverOpts = {}) { return new LwDfxTlsGateway(serverOpts, gatewayOpts, server); } //# sourceMappingURL=LwDFX.Tls.Server.js.map