Tidy up logging
This commit is contained in:
parent
49ca7f0a57
commit
b48f50e819
5 changed files with 12 additions and 11 deletions
|
@ -92,7 +92,7 @@ class Connection extends EventEmitter {
|
|||
}
|
||||
|
||||
async destroy() {
|
||||
l.info(`Killing connection to ${this.address}:${this.port}`, new Error().stack);
|
||||
l.notice(`Killing connection to ${this.address}:${this.port}`, new Error().stack);
|
||||
if(this.framer instanceof FramedTransport)
|
||||
await this.framer.destroy();
|
||||
else {
|
||||
|
@ -104,7 +104,7 @@ class Connection extends EventEmitter {
|
|||
|
||||
async handle_frame(bytes) {
|
||||
try {
|
||||
l.info(`FRAME length`, bytes.length, `frame`, bytes);
|
||||
// l.info(`FRAME length`, bytes.length, `frame`, bytes);
|
||||
let decrypted = decrypt_bytes(this.session_key, bytes);
|
||||
if(decrypted === null) {
|
||||
l.warn(`Decryption of message failed`);
|
||||
|
@ -121,7 +121,7 @@ class Connection extends EventEmitter {
|
|||
async handle_message(msg_text) {
|
||||
const msg = JSON.parse(msg_text);
|
||||
|
||||
l.info(`RECEIVE:${msg.event}`, msg.message);
|
||||
l.debug(`RECEIVE:${msg.event}`, msg.message);
|
||||
|
||||
if(msg.event == "rekey" && !this.rekey_in_progress) {
|
||||
// Set and forget here
|
||||
|
@ -134,7 +134,7 @@ class Connection extends EventEmitter {
|
|||
async send(event, message) {
|
||||
if(typeof event !== "string") throw new Error(`Error: Expected string for event name, but got value of type ${typeof event}.`);
|
||||
|
||||
l.info(`SEND event`, event, `message`, message);
|
||||
l.debug(`SEND event`, event, `message`, message);
|
||||
|
||||
// Rekey at semi-regular intervals, but only if we're not already in the process of doing so
|
||||
if(new Date() - this.rekey_last > this.rekey_interval && !this.rekey_in_progress)
|
||||
|
|
|
@ -42,7 +42,7 @@ class FramedTransport extends EventEmitter {
|
|||
* @return {void}
|
||||
*/
|
||||
handle_chunk(chunk) {
|
||||
l.debug(`CHUNK length`, chunk.length, `buffer length`, this.buffer === null ? 0 : this.buffer.length);
|
||||
// l.debug(`CHUNK length`, chunk.length, `buffer length`, this.buffer === null ? 0 : this.buffer.length);
|
||||
if(this.buffer instanceof Buffer) {
|
||||
this.buffer = Buffer.concat([ this.buffer, chunk ]);
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ export default async function rekey(connection, secret_join) {
|
|||
|
||||
// 3: Compute new shared key
|
||||
const their_round2 = (await once(connection, "message-rekey"))[0];
|
||||
l.debug(`THEIR_ROUND2`, their_round2);
|
||||
|
||||
|
||||
if(typeof their_round2 !== "object"
|
||||
|| their_round2.round !== 2
|
||||
|| typeof their_round2.content !== "string")
|
||||
|
|
|
@ -22,8 +22,9 @@ export default async function() {
|
|||
|
||||
const socket = await Connection.Create(test_key, "::1", settings.cli.port);
|
||||
|
||||
socket.on("message", (event, msg) => {
|
||||
l.notice(`<<< ${event}: ${JSON.stringify(msg)}`);
|
||||
socket.on("message", (_event, _msg) => {
|
||||
// noop
|
||||
// l.notice(`<<< ${event}: ${JSON.stringify(msg)}`);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@ export default async function() {
|
|||
l.notice("client connected");
|
||||
const connection = await Connection.Wrap(test_key, client);
|
||||
connection.send("test-server", "hello\n");
|
||||
connection.on("message", (event, msg) => {
|
||||
l.notice(`<<< ${event}: ${JSON.stringify(msg)}`);
|
||||
connection.on("message", (_event, _msg) => {
|
||||
// noop
|
||||
//l.notice(`<<< ${event}: ${JSON.stringify(msg)}`);
|
||||
});
|
||||
let id = setInterval(async () => {
|
||||
const rt = await connection.send("test-server", (new Date()).toString());
|
||||
|
|
Loading…
Reference in a new issue