Add a range option to server to specify specific port client attribution

This commit is contained in:
Olivier MICHAUD
2021-05-17 21:35:38 +02:00
parent 3ebcab8830
commit 3c06736520
3 changed files with 20 additions and 4 deletions
+4
View File
@@ -3,6 +3,7 @@ import Debug from 'debug';
import Client from './Client';
import TunnelAgent from './TunnelAgent';
import PortManager from "./PortManager";
// Manage sets of clients
//
@@ -13,6 +14,7 @@ class ClientManager {
// id -> client instance
this.clients = new Map();
this.portManager = new PortManager({range: this.opt.range||null})
// statistics
this.stats = {
@@ -39,6 +41,7 @@ class ClientManager {
const maxSockets = this.opt.max_tcp_sockets;
const agent = new TunnelAgent({
portManager: this.portManager,
clientId: id,
maxSockets: 10,
});
@@ -79,6 +82,7 @@ class ClientManager {
if (!client) {
return;
}
this.portManager.release(client.agent.port);
--this.stats.tunnels;
delete this.clients[id];
client.close();