bdy 1.22.6-dev → 1.22.7-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/distTs/package.json
CHANGED
|
@@ -25,6 +25,7 @@ class AgentManagerClass {
|
|
|
25
25
|
agent;
|
|
26
26
|
ws;
|
|
27
27
|
server;
|
|
28
|
+
connections;
|
|
28
29
|
system;
|
|
29
30
|
constructor() {
|
|
30
31
|
this.status = tunnel_1.TUNNEL_AGENT_STATUS.DISABLED;
|
|
@@ -36,6 +37,7 @@ class AgentManagerClass {
|
|
|
36
37
|
this.agent = null;
|
|
37
38
|
this.server = null;
|
|
38
39
|
this.ws = null;
|
|
40
|
+
this.connections = new Set();
|
|
39
41
|
if ((0, utils_1.isOsx)()) {
|
|
40
42
|
this.system = new osx_1.default();
|
|
41
43
|
}
|
|
@@ -51,16 +53,13 @@ class AgentManagerClass {
|
|
|
51
53
|
}
|
|
52
54
|
start(id, host, token, port, onProcessExit = () => { }) {
|
|
53
55
|
const onExit = () => {
|
|
54
|
-
logger_1.default.info('exit manager');
|
|
55
56
|
onProcessExit();
|
|
56
57
|
if (this.ws) {
|
|
57
|
-
logger_1.default.info('close websocket');
|
|
58
58
|
this.ws.clients.forEach((client) => client.terminate());
|
|
59
59
|
this.ws.close();
|
|
60
60
|
}
|
|
61
61
|
if (this.server) {
|
|
62
|
-
|
|
63
|
-
this.server.closeAllConnections();
|
|
62
|
+
this.connections.forEach((socket) => socket.resetAndDestroy());
|
|
64
63
|
this.server.close(() => {
|
|
65
64
|
process.exit(0);
|
|
66
65
|
});
|
|
@@ -547,12 +546,15 @@ class AgentManagerClass {
|
|
|
547
546
|
}
|
|
548
547
|
createServer() {
|
|
549
548
|
this.server = http_1.default.createServer((req, res) => this.processRequest(req, res));
|
|
549
|
+
this.server.on('connection', (socket) => {
|
|
550
|
+
this.connections.add(socket);
|
|
551
|
+
socket.on('close', () => this.connections.delete(socket));
|
|
552
|
+
});
|
|
550
553
|
const { WebSocketServer: WsServer } = require('ws');
|
|
551
554
|
this.ws = new WsServer({ noServer: true });
|
|
552
555
|
this.ws.on('connection', (con, id) => this.processWebsocketConnection(con, id));
|
|
553
556
|
this.server.on('upgrade', (req, socket, head) => this.processUpgrade(req, socket, head));
|
|
554
557
|
this.server.on('error', async (err) => {
|
|
555
|
-
logger_1.default.info(err);
|
|
556
558
|
if (err.code === 'EADDRINUSE') {
|
|
557
559
|
await this.disableAgentAndExit(texts_1.LOG_ERROR_STARTING_AGENT_SERVER);
|
|
558
560
|
}
|