add some script

This commit is contained in:
DESKTOP-0P848CA\edinl_6z7c6t
2021-11-20 09:06:19 +08:00
parent 78c06f8fc4
commit 669e21930b
17 changed files with 4867 additions and 1198 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
import http from 'http';
import Debug from 'debug';
import pump from 'pump';
import EventEmitter from 'events';
const http = require('http');
const Debug = require('debug');
const pump = require('pump');
const EventEmitter = require('events');
// A client encapsulates req/res handling using an agent
//
@@ -129,4 +129,4 @@ class Client extends EventEmitter {
}
}
export default Client;
module.exports = Client;
+6 -6
View File
@@ -1,10 +1,10 @@
import assert from 'assert';
import http from 'http';
import { Duplex } from 'stream';
import WebSocket from 'ws';
import net from 'net';
const assert = require('assert');
const http = require('http');
const { Duplex } = require('stream');
const WebSocket = require('ws');
const net = require('net');
import Client from './Client';
const Client from './Client';
class DummySocket extends Duplex {
constructor(options) {
+5 -10
View File
@@ -1,8 +1,5 @@
import { hri } from 'human-readable-ids';
import Debug from 'debug';
import Client from './Client';
import TunnelAgent from './TunnelAgent';
const Client = require('./Client');
const TunnelAgent = require('./TunnelAgent');
// Manage sets of clients
//
@@ -19,8 +16,6 @@ class ClientManager {
tunnels: 0
};
this.debug = Debug('lt:ClientManager');
// This is totally wrong :facepalm: this needs to be per-client...
this.graceTimeout = null;
}
@@ -34,7 +29,7 @@ class ClientManager {
// can't ask for id already is use
if (clients[id]) {
id = hri.random();
return;
}
const maxSockets = this.opt.max_tcp_sockets;
@@ -74,7 +69,7 @@ class ClientManager {
}
removeClient(id) {
this.debug('removing client: %s', id);
console.debug('removing client: %s', id)
const client = this.clients[id];
if (!client) {
return;
@@ -93,4 +88,4 @@ class ClientManager {
}
}
export default ClientManager;
module.exports = ClientManager;
+3 -3
View File
@@ -1,7 +1,7 @@
import assert from 'assert';
import net from 'net';
const assert = require('assert');
const net = require('net');
import ClientManager from './ClientManager';
const ClientManager = require('./ClientManager');
describe('ClientManager', () => {
it('should construct with no tunnels', () => {
+6 -6
View File
@@ -1,8 +1,8 @@
import { Agent } from 'http';
import net from 'net';
import assert from 'assert';
import log from 'book';
import Debug from 'debug';
const { Agent } = require('http');
const net = require('net');
const assert = require('assert');
const log = require('book');
const Debug = require('debug');
const DEFAULT_MAX_SOCKETS = 10;
@@ -172,4 +172,4 @@ class TunnelAgent extends Agent {
}
}
export default TunnelAgent;
module.exports = TunnelAgent;
+4 -4
View File
@@ -1,8 +1,8 @@
import http from 'http';
import net from 'net';
import assert from 'assert';
const http = require('http');
const net = require('net');
const assert = require('assert');
import TunnelAgent from './TunnelAgent';
const TunnelAgent = require('./TunnelAgent');
describe('TunnelAgent', () => {
it('should create an empty agent', async () => {