Skip to content

Commit 854ef56

Browse files
committed
tests: cleaning up debug output
[ci skip]
1 parent e2f85ce commit 854ef56

File tree

9 files changed

+37
-130
lines changed

9 files changed

+37
-130
lines changed

src/agent/service/nodesHolePunchMessageSend.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function nodesHolePunchMessageSend({
7070
const [host, port] = networkUtils.parseAddress(
7171
call.request.getProxyAddress(),
7272
);
73-
logger.info(
73+
logger.debug(
7474
`Received signalling message to target ${call.request.getSrcId()}@${host}:${port}`,
7575
);
7676
// Ignore failure
@@ -93,7 +93,7 @@ function nodesHolePunchMessageSend({
9393
connectionInfo!.remotePort,
9494
);
9595
call.request.setProxyAddress(proxyAddress);
96-
logger.info(
96+
logger.debug(
9797
`Relaying signalling message from ${srcNodeId}@${
9898
connectionInfo!.remoteHost
9999
}:${
@@ -109,7 +109,6 @@ function nodesHolePunchMessageSend({
109109
callback(null, response);
110110
return;
111111
} catch (e) {
112-
console.error(e);
113112
callback(grpcUtils.fromError(e, true));
114113
!agentUtils.isAgentClientError(e) &&
115114
logger.error(`${nodesHolePunchMessageSend.name}:${e}`);

src/bin/CommandPolykey.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ class CommandPolykey extends commander.Command {
6565
this.exitHandlers.errFormat = opts.format === 'json' ? 'json' : 'error';
6666
// Set the logger according to the verbosity
6767
this.logger.setLevel(binUtils.verboseToLogLevel(opts.verbose));
68-
this.logger.handlers.forEach((handler) =>
69-
handler.setFormatter(
70-
formatting.format`${formatting.date}:${formatting.level}:${formatting.keys}:${formatting.msg}`,
71-
),
72-
);
7368
// Set the logger formatter according to the format
7469
if (opts.format === 'json') {
7570
this.logger.handlers.forEach((handler) =>

src/config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ const config = {
8383
clientPort: 0 as Port,
8484
},
8585
proxyConfig: {
86-
connConnectTime: 10000,
86+
connConnectTime: 2000,
8787
connKeepAliveTimeoutTime: 20000,
8888
connEndTime: 1000,
89-
connPunchIntervalTime: 250,
89+
connPunchIntervalTime: 100,
9090
connKeepAliveIntervalTime: 1000,
9191
},
9292
nodeConnectionManagerConfig: {
93-
connConnectTime: 10000,
94-
connTimeoutTime: 600000000, // FIXME: revert back.
93+
connConnectTime: 2000,
94+
connTimeoutTime: 60000,
9595
initialClosestNodes: 3,
9696
},
9797
// This is not used by the `PolykeyAgent` which defaults to `{}`

src/grpc/utils/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ function toError(
207207
cause: error,
208208
},
209209
);
210-
console.error(remoteError);
211210
if (error instanceof errors.ErrorPolykey) {
212211
remoteError.exitCode = error.exitCode;
213212
}

src/network/ConnectionForward.ts

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import Connection from './Connection';
1313
import * as networkUtils from './utils';
1414
import * as networkErrors from './errors';
1515
import * as keysUtils from '../keys/utils';
16-
import * as nodesUtils from '../nodes/utils';
1716
import { promise } from '../utils';
1817
import * as contextsErrors from '../contexts/errors';
1918
import { timedCancellable, context } from '../contexts/index';
@@ -43,15 +42,6 @@ class ConnectionForward extends Connection {
4342
data: Buffer,
4443
remoteInfo: { address: string; port: number },
4544
) => {
46-
if (remoteInfo.port !== 1314) {
47-
console.log(
48-
new Date(),
49-
'CONNECTION FORWARD RECEIVED MESSAGE',
50-
nodesUtils.encodeNodeId(this.nodeId),
51-
remoteInfo,
52-
data,
53-
);
54-
}
5545
// Ignore messages not intended for this target
5646
if (remoteInfo.address !== this.host || remoteInfo.port !== this.port) {
5747
return;
@@ -69,14 +59,6 @@ class ConnectionForward extends Connection {
6959
this.startKeepAliveTimeout();
7060
}
7161
if (msg.type === 'ping') {
72-
if (remoteInfo.port !== 1314) {
73-
console.log(
74-
new Date(),
75-
'CONNECTION FORWARD RECEIVED PING MESSAGE, RESPONDING WITH PONG',
76-
nodesUtils.encodeNodeId(this.nodeId),
77-
remoteInfo,
78-
);
79-
}
8062
this.resolveReadyP();
8163
// Respond with ready message
8264
await this.send(networkUtils.pongBuffer);
@@ -93,7 +75,7 @@ class ConnectionForward extends Connection {
9375
* Handler is removed and not executed when `end` is initiated here
9476
*/
9577
protected handleEnd = async () => {
96-
this.logger.info('Receives tlsSocket ending');
78+
this.logger.debug('Receives tlsSocket ending');
9779
if (this.utpConn.destroyed) {
9880
this.tlsSocket.destroy();
9981
this.logger.debug('Destroyed tlsSocket');
@@ -112,7 +94,6 @@ class ConnectionForward extends Connection {
11294
* If already stopped, then this does nothing
11395
*/
11496
protected handleClose = async () => {
115-
this.logger.info('Receives tlsSocket close');
11697
await this.stop();
11798
};
11899

@@ -144,7 +125,7 @@ class ConnectionForward extends Connection {
144125
// Promise for abortion and timeout
145126
const { p: abortedP, resolveP: resolveAbortedP } = promise<void>();
146127
if (ctx.signal.aborted) {
147-
this.logger.info(`Failed to start Connection Forward: aborted`);
128+
this.logger.debug(`Failed to start Connection Forward: aborted`);
148129
// This is for arbitrary abortion reason provided by the caller
149130
// Re-throw the default timeout error as a network timeout error
150131
if (
@@ -184,32 +165,14 @@ class ConnectionForward extends Connection {
184165
let punchInterval;
185166
try {
186167
// Send punch signal
187-
// if (this.port !== 1314) {
188-
// console.log(
189-
// new Date(),
190-
// 'CONNECTION FORWARD SENDING PING MESSAGE',
191-
// nodesUtils.encodeNodeId(this.nodeId),
192-
// this.host,
193-
// this.port,
194-
// );
195-
// }
196168
await this.send(networkUtils.pingBuffer);
197169
punchInterval = setInterval(async () => {
198-
// If (this.port !== 1314) {
199-
// console.log(
200-
// new Date(),
201-
// 'CONNECTION FORWARD SENDING PING MESSAGE',
202-
// nodesUtils.encodeNodeId(this.nodeId),
203-
// this.host,
204-
// this.port,
205-
// );
206-
// }
207170
await this.send(networkUtils.pingBuffer);
208171
}, this.punchIntervalTime);
209172
await Promise.race([
210173
Promise.all([readyP, secureConnectP]),
211174
errorP,
212-
// abortedP,
175+
abortedP,
213176
]);
214177
} catch (e) {
215178
// Clean up partial start
@@ -219,7 +182,7 @@ class ConnectionForward extends Connection {
219182
this.tlsSocket.destroy();
220183
}
221184
this.utpSocket.off('message', this.handleMessage);
222-
this.logger.info(`Failed to start Connection Forward: ${e.message}`);
185+
this.logger.debug(`Failed to start Connection Forward: ${e.message}`);
223186
throw new networkErrors.ErrorConnectionStart(undefined, {
224187
cause: e,
225188
});
@@ -229,7 +192,7 @@ class ConnectionForward extends Connection {
229192
this.tlsSocket.on('error', this.handleError);
230193
this.tlsSocket.off('error', handleStartError);
231194
if (ctx.signal.aborted) {
232-
this.logger.info(`Failed to start Connection Forward: aborted`);
195+
this.logger.debug(`Failed to start Connection Forward: aborted`);
233196
// Clean up partial start
234197
// TLSSocket isn't established yet, so it is destroyed
235198
if (!this.tlsSocket.destroyed) {
@@ -250,7 +213,7 @@ class ConnectionForward extends Connection {
250213
try {
251214
networkUtils.verifyServerCertificateChain(this.nodeId, serverCertChain);
252215
} catch (e) {
253-
this.logger.info(
216+
this.logger.debug(
254217
`Failed to start Connection Forward: verification failed`,
255218
);
256219
// Clean up partial start

src/network/ConnectionReverse.ts

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ class ConnectionReverse extends Connection {
4242
data: Buffer,
4343
remoteInfo: { address: string; port: number },
4444
) => {
45-
// If (remoteInfo.port !== 1314) {
46-
// console.log(
47-
// new Date(),
48-
// 'CONNECTION REVERSE RECEIVED MESSAGE',
49-
// remoteInfo,
50-
// data,
51-
// );
52-
// }
5345
// Ignore messages not intended for this target
5446
if (remoteInfo.address !== this.host || remoteInfo.port !== this.port) {
5547
return;
@@ -67,22 +59,8 @@ class ConnectionReverse extends Connection {
6759
this.startKeepAliveTimeout();
6860
}
6961
if (msg.type === 'ping') {
70-
if (remoteInfo.port !== 1314) {
71-
console.log(
72-
new Date(),
73-
'CONNECTION REVERSE RECEIVED PING MESSAGE, RESPONDING WITH PONG',
74-
remoteInfo,
75-
);
76-
}
7762
await this.send(networkUtils.pongBuffer);
7863
} else if (msg.type === 'pong') {
79-
if (remoteInfo.port !== 1314) {
80-
console.log(
81-
new Date(),
82-
'CONNECTION REVERSE RECEIVED PONG MESSAGE, RESOLVING READY',
83-
remoteInfo,
84-
);
85-
}
8664
this.resolveReadyP();
8765
}
8866
};
@@ -144,7 +122,7 @@ class ConnectionReverse extends Connection {
144122
// Promise for abortion and timeout
145123
const { p: abortedP, resolveP: resolveAbortedP } = promise<void>();
146124
if (ctx.signal.aborted) {
147-
this.logger.info(`Failed to start Connection Reverse: aborted`);
125+
this.logger.debug(`Failed to start Connection Reverse: aborted`);
148126
// This is for arbitrary abortion reason provided by the caller
149127
// Re-throw the default timeout error as a network timeout error
150128
if (
@@ -176,31 +154,15 @@ class ConnectionReverse extends Connection {
176154
this.serverSocket.on('close', this.handleClose);
177155
let punchInterval;
178156
try {
179-
await Promise.race([socketP, errorP, /*abortedP*/]);
157+
await Promise.race([socketP, errorP, abortedP]);
180158
// Send punch & ready signal
181-
// if (this.port !== 1314) {
182-
// console.log(
183-
// new Date(),
184-
// 'CONNECTION REVERSE SENDING PING MESSAGE',
185-
// this.host,
186-
// this.port,
187-
// );
188-
// }
189159
await this.send(networkUtils.pingBuffer);
190160
punchInterval = setInterval(async () => {
191-
// If (this.port !== 1314) {
192-
// console.log(
193-
// new Date(),
194-
// 'CONNECTION REVERSE SENDING PING MESSAGE',
195-
// this.host,
196-
// this.port,
197-
// );
198-
// }
199161
await this.send(networkUtils.pingBuffer);
200162
}, this.punchIntervalTime);
201-
await Promise.race([readyP, errorP, /*abortedP*/]);
163+
await Promise.race([readyP, errorP, abortedP]);
202164
} catch (e) {
203-
this.logger.info(`Failed to start Connection Reverse: ${e.message}`);
165+
this.logger.debug(`Failed to start Connection Reverse: ${e.message}`);
204166
// Clean up partial start
205167
// Socket isn't established yet, so it is destroyed
206168
this.serverSocket.destroy();
@@ -214,7 +176,7 @@ class ConnectionReverse extends Connection {
214176
this.serverSocket.on('error', this.handleError);
215177
this.serverSocket.off('error', handleStartError);
216178
if (ctx.signal.aborted) {
217-
this.logger.info(`Failed to start Connection Reverse: aborted`);
179+
this.logger.debug(`Failed to start Connection Reverse: aborted`);
218180
// Clean up partial start
219181
// Socket isn't established yet, so it is destroyed
220182
this.serverSocket.destroy();

src/nodes/NodeConnectionManager.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ class NodeConnectionManager {
704704
const rlyNode = nodesUtils.encodeNodeId(relayNodeId);
705705
const srcNode = nodesUtils.encodeNodeId(sourceNodeId);
706706
const tgtNode = nodesUtils.encodeNodeId(targetNodeId);
707-
this.logger.info(
707+
this.logger.debug(
708708
`sendSignallingMessage sending Signalling message relay: ${rlyNode}, source: ${srcNode}, target: ${tgtNode}, proxy: ${proxyAddress}`,
709709
);
710710
const relayMsg = new nodesPB.Relay();
@@ -812,21 +812,15 @@ class NodeConnectionManager {
812812
seedNodeId,
813813
this.keyManager.getNodeId(),
814814
nodeId,
815-
).catch(() => console.log('failed to relay message'));
815+
).catch(() => {});
816816
});
817817
}
818818
try {
819819
await this.holePunchForward(nodeId, host, port, ctx);
820820
} catch (e) {
821-
console.log(
822-
'pinging failed',
823-
nodesUtils.encodeNodeId(nodeId),
824-
!isSeedNode,
825-
);
826821
return false;
827822
}
828823
// FIXME: clean up in a finally block, holePunchPromises should be cancelled
829-
console.log('pinging succ', nodesUtils.encodeNodeId(nodeId), !isSeedNode);
830824
return true;
831825
}
832826

src/nodes/NodeManager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,6 @@ class NodeManager {
10811081
});
10821082
if (block) {
10831083
try {
1084-
console.log('awaiting ping');
10851084
await pingAndSetTask.promise();
10861085
} catch (e) {
10871086
if (!(e instanceof nodesErrors.ErrorNodeGraphSameNodeId)) throw e;

0 commit comments

Comments
 (0)