diff --git a/src/bin/CommandPolykey.ts b/src/bin/CommandPolykey.ts index 2e590ea23..a80c2bd28 100644 --- a/src/bin/CommandPolykey.ts +++ b/src/bin/CommandPolykey.ts @@ -66,11 +66,6 @@ class CommandPolykey extends commander.Command { // Set the logger according to the verbosity this.logger.setLevel(binUtils.verboseToLogLevel(opts.verbose)); // Set the logger formatter according to the format - this.logger.handlers.forEach((handler) => - handler.setFormatter( - formatting.format`${formatting.date}:${formatting.level}:${formatting.key}:${formatting.msg}`, - ), - ); if (opts.format === 'json') { this.logger.handlers.forEach((handler) => handler.setFormatter(formatting.jsonFormatter), diff --git a/src/network/ConnectionForward.ts b/src/network/ConnectionForward.ts index e23389219..ad4384e29 100644 --- a/src/network/ConnectionForward.ts +++ b/src/network/ConnectionForward.ts @@ -42,7 +42,6 @@ class ConnectionForward extends Connection { data: Buffer, remoteInfo: { address: string; port: number }, ) => { - this.logger.info(`forward Connection received message: ${data}`); // Ignore messages not intended for this target if (remoteInfo.address !== this.host || remoteInfo.port !== this.port) { return; @@ -60,9 +59,6 @@ class ConnectionForward extends Connection { this.startKeepAliveTimeout(); } if (msg.type === 'ping') { - this.logger.info( - `FG -- Forward received ping, responding with pong and resolving readyP`, - ); this.resolveReadyP(); // Respond with ready message await this.send(networkUtils.pongBuffer); @@ -79,7 +75,7 @@ class ConnectionForward extends Connection { * Handler is removed and not executed when `end` is initiated here */ protected handleEnd = async () => { - this.logger.info('Receives tlsSocket ending'); + this.logger.debug('Receives tlsSocket ending'); if (this.utpConn.destroyed) { this.tlsSocket.destroy(); this.logger.debug('Destroyed tlsSocket'); @@ -98,7 +94,6 @@ class ConnectionForward extends Connection { * If already stopped, then this does nothing */ protected handleClose = async () => { - this.logger.info(`TLS Close`); await this.stop(); }; @@ -130,7 +125,6 @@ class ConnectionForward extends Connection { // Promise for abortion and timeout const { p: abortedP, resolveP: resolveAbortedP } = promise(); if (ctx.signal.aborted) { - this.logger.info(`Forward was aborted with: ${ctx.signal.reason}`); // This is for arbitrary abortion reason provided by the caller // Re-throw the default timeout error as a network timeout error if ( @@ -145,17 +139,14 @@ class ConnectionForward extends Connection { this.resolveReadyP = resolveReadyP; this.utpSocket.on('message', this.handleMessage); const handleStartError = (e) => { - this.logger.info(`TLS error connection ${e}`); rejectErrorP(e); }; // Normal sockets defaults to `allowHalfOpen: false` // But UTP defaults to `allowHalfOpen: true` // Setting `allowHalfOpen: false` on UTP is buggy and cannot be used - this.logger.info(`Starting UTP connection to ${this.host}:${this.port}`); this.utpConn = this.utpSocket.connect(this.port, this.host, { allowHalfOpen: true, }); - this.logger.info('Starting TLS connection'); this.tlsSocket = tls.connect( { key: Buffer.from(this.tlsConfig.keyPrivatePem, 'ascii'), @@ -173,22 +164,16 @@ class ConnectionForward extends Connection { let punchInterval; try { // Send punch signal - this.logger.info(`Forward starting pings to ${this.host}:${this.port}`); - this.logger.info(`C -- Forward sending ping`); await this.send(networkUtils.pingBuffer); punchInterval = setInterval(async () => { - this.logger.info(`C -- Forward sending ping`); await this.send(networkUtils.pingBuffer); }, this.punchIntervalTime); - this.logger.info(`forward racing ready and secure with error and abort`); await Promise.race([ Promise.all([readyP, secureConnectP]), errorP, abortedP, ]); - this.logger.info(`forward race succeeded`); } catch (e) { - this.logger.error(`race threw error ${e}`); // Clean up partial start // TLSSocket isn't established yet, so it is destroyed if (!this.tlsSocket.destroyed) { @@ -205,7 +190,6 @@ class ConnectionForward extends Connection { this.tlsSocket.on('error', this.handleError); this.tlsSocket.off('error', handleStartError); if (ctx.signal.aborted) { - this.logger.info(`Forward was aborted with: ${ctx.signal.reason}`); // Clean up partial start // TLSSocket isn't established yet, so it is destroyed if (!this.tlsSocket.destroyed) { @@ -229,7 +213,7 @@ class ConnectionForward extends Connection { // Clean up partial start this.utpSocket.off('message', this.handleMessage); // TLSSocket is established, and is ended gracefully - this.logger.info('Sends tlsSocket ending'); + this.logger.debug('Sends tlsSocket ending'); // Graceful exit has its own end handler this.tlsSocket.removeAllListeners('end'); await this.endGracefully(this.tlsSocket); diff --git a/src/network/ConnectionReverse.ts b/src/network/ConnectionReverse.ts index 0c4271d33..6a2b29608 100644 --- a/src/network/ConnectionReverse.ts +++ b/src/network/ConnectionReverse.ts @@ -42,7 +42,6 @@ class ConnectionReverse extends Connection { data: Buffer, remoteInfo: { address: string; port: number }, ) => { - this.logger.info(`reverse Connection received message: ${data}`); // Ignore messages not intended for this target if (remoteInfo.address !== this.host || remoteInfo.port !== this.port) { return; @@ -60,10 +59,8 @@ class ConnectionReverse extends Connection { this.startKeepAliveTimeout(); } if (msg.type === 'ping') { - this.logger.info(`E -- Reverse received ping, responding with pong`); await this.send(networkUtils.pongBuffer); } else if (msg.type === 'pong') { - this.logger.info(`H -- Reverse received pong, resolving ready`); this.resolveReadyP(); } }; @@ -78,7 +75,7 @@ class ConnectionReverse extends Connection { * Handler is removed and not executed when `end` is initiated here */ protected handleEnd = async () => { - this.logger.info('Receives serverSocket ending'); + this.logger.debug('Receives serverSocket ending'); this.logger.debug('Responds serverSocket ending'); this.serverSocket.end(); this.serverSocket.destroy(); @@ -92,7 +89,6 @@ class ConnectionReverse extends Connection { * If already stopped, then this does nothing */ protected handleClose = async () => { - this.logger.info('reverse socket closing'); await this.stop(); }; @@ -126,7 +122,6 @@ class ConnectionReverse extends Connection { // Promise for abortion and timeout const { p: abortedP, resolveP: resolveAbortedP } = promise(); if (ctx.signal.aborted) { - this.logger.info(`Reverse was aborted with: ${ctx.signal.reason}`); // This is for arbitrary abortion reason provided by the caller // Re-throw the default timeout error as a network timeout error if ( @@ -140,9 +135,6 @@ class ConnectionReverse extends Connection { } this.resolveReadyP = resolveReadyP; this.utpSocket.on('message', this.handleMessage); - this.logger.info( - `reverse creating socket to ${this.serverHost}:${this.serverPort}`, - ); this.serverSocket = net.connect(this.serverPort, this.serverHost, () => { const proxyAddressInfo = this.serverSocket.address() as AddressInfo; this.proxyHost = proxyAddressInfo.address as Host; @@ -154,7 +146,6 @@ class ConnectionReverse extends Connection { resolveSocketP(); }); const handleStartError = (e) => { - this.logger.info(`reverse error ${e}`); rejectErrorP(e); }; this.serverSocket.once('error', handleStartError); @@ -162,24 +153,14 @@ class ConnectionReverse extends Connection { this.serverSocket.on('close', this.handleClose); let punchInterval; try { - this.logger.info('Reverse racing socket, error and abort stage 1'); await Promise.race([socketP, errorP, abortedP]); - this.logger.info( - 'B -- Connection Reverse has connected to the GRPC Agent server', - ); // Send punch & ready signal - this.logger.info(`Reverse starting pinging to ${this.host}:${this.port}`); - this.logger.info('D -- Reverse sending ping'); await this.send(networkUtils.pingBuffer); punchInterval = setInterval(async () => { - this.logger.info('D -- Reverse sending ping'); await this.send(networkUtils.pingBuffer); }, this.punchIntervalTime); - this.logger.info('Reverse racing ready, error and abort stage 2'); await Promise.race([readyP, errorP, abortedP]); - this.logger.info('Racing completed'); } catch (e) { - this.logger.info(`racing error ${e}`); // Clean up partial start // Socket isn't established yet, so it is destroyed this.serverSocket.destroy(); @@ -193,7 +174,6 @@ class ConnectionReverse extends Connection { this.serverSocket.on('error', this.handleError); this.serverSocket.off('error', handleStartError); if (ctx.signal.aborted) { - this.logger.info(`reverse aborted`); // Clean up partial start // Socket isn't established yet, so it is destroyed this.serverSocket.destroy(); diff --git a/src/network/Proxy.ts b/src/network/Proxy.ts index 41eb40bd3..11dbbdbc6 100644 --- a/src/network/Proxy.ts +++ b/src/network/Proxy.ts @@ -477,7 +477,6 @@ class Proxy { await clientSocketWrite( 'HTTP/1.1 200 Connection Established\r\n' + '\r\n', ); - this.logger.info(`A -- GRPC client connected to Proxy TCP server`); this.logger.info(`Handled CONNECT to ${proxyAddress}`); }); };