Add a range option to server to specify specific port client attribution
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user