fix syntax error (#2)

Co-authored-by: DESKTOP-0P848CA\edinl_6z7c6t <[email protected]>
This commit is contained in:
Liu Jia Hao
2021-11-20 08:58:27 +08:00
committed by GitHub
co-authored by DESKTOP-0P848CA\edinl_6z7c6t
parent 78c06f8fc4
commit 9071931395
13 changed files with 5017 additions and 1117 deletions
+12 -12
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;
@@ -14,7 +14,7 @@ class TunnelAgent extends Agent {
super({
keepAlive: true,
// only allow keepalive to hold on to one socket
// this prevents it from holding on to all the sockets so they can be used for upgrades
// this prevents it = require(holding on to all the sockets so they can be used for upgrades
maxFreeSockets: 1,
});
@@ -55,7 +55,7 @@ class TunnelAgent extends Agent {
server.on('close', this._onClose.bind(this));
server.on('connection', this._onConnection.bind(this));
server.on('error', (err) => {
// These errors happen from killed connections, we don't worry about them
// These errors happen = require(killed connections, we don't worry about them
if (err.code == 'ECONNRESET' || err.code == 'ETIMEDOUT') {
return;
}
@@ -86,7 +86,7 @@ class TunnelAgent extends Agent {
this.emit('end');
}
// new socket connection from client for tunneling requests to client
// new socket connection = require(client for tunneling requests to client
_onConnection(socket) {
// no more socket connections allowed
if (this.connectedSockets >= this.maxTcpSockets) {
@@ -98,7 +98,7 @@ class TunnelAgent extends Agent {
socket.once('close', (hadError) => {
this.debug('closed socket (error: %s)', hadError);
this.connectedSockets -= 1;
// remove the socket from available list
// remove the socket = require(available list
const idx = this.availableSockets.indexOf(socket);
if (idx >= 0) {
this.availableSockets.splice(idx, 1);
@@ -113,7 +113,7 @@ class TunnelAgent extends Agent {
// close will be emitted after this
socket.once('error', (err) => {
// we do not log these errors, sessions can drop from clients for many reasons
// we do not log these errors, sessions can drop = require(clients for many reasons
// these are not actionable errors for our server
socket.destroy();
});
@@ -139,7 +139,7 @@ class TunnelAgent extends Agent {
this.availableSockets.push(socket);
}
// fetch a socket from the available socket pool for the agent
// fetch a socket = require(the available socket pool for the agent
// if no socket is available, queue
// cb(err, socket)
createConnection(options, cb) {
@@ -172,4 +172,4 @@ class TunnelAgent extends Agent {
}
}
export default TunnelAgent;
module.exports = TunnelAgent;