From 95dbd1e6ddeef1253b671c1a9abc314cbd350351 Mon Sep 17 00:00:00 2001 From: shinyoshiaki Date: Fri, 3 Jan 2025 13:28:19 +0900 Subject: [PATCH] logging --- packages/ice/src/ice.ts | 12 +++++------- packages/ice/src/stun/protocol.ts | 2 +- packages/ice/src/stun/transaction.ts | 12 ++++++------ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/ice/src/ice.ts b/packages/ice/src/ice.ts index 0d3919a0..a9d0f87d 100644 --- a/packages/ice/src/ice.ts +++ b/packages/ice/src/ice.ts @@ -106,20 +106,22 @@ export class Connection implements IceConnection { } async restart() { + this.generation++; + this.localUsername = randomString(4); this.localPassword = randomString(22); this.remoteUsername = ""; this.remotePassword = ""; - this.checkList = []; this.localCandidates = []; + this._remoteCandidates = []; this.remoteCandidatesEnd = false; this.localCandidatesEnd = false; this.state = "new"; this.lookup?.close?.(); this.lookup = undefined; - this._remoteCandidates = []; this.nominated = undefined; this.nominating = false; + this.checkList = []; this.checkListDone = false; this.checkListState = new PQueue(); this.earlyChecks = []; @@ -138,8 +140,6 @@ export class Connection implements IceConnection { this.queryConsentHandle = undefined; this.promiseGatherCandidates = undefined; - this.generation++; - if (this.options.localPasswordPrefix) { this.localPassword = this.options.localPasswordPrefix + @@ -909,9 +909,7 @@ export class Connection implements IceConnection { log( "failure case", request.toJSON(), - exc.response - ? JSON.stringify(exc.response.toJSON(), null, 2) - : undefined, + exc.response ? JSON.stringify(exc.response.toJSON(), null, 2) : error, { localUsername, remoteUsername, diff --git a/packages/ice/src/stun/protocol.ts b/packages/ice/src/stun/protocol.ts index 679c4576..46116bc2 100644 --- a/packages/ice/src/stun/protocol.ts +++ b/packages/ice/src/stun/protocol.ts @@ -61,7 +61,7 @@ export class StunProtocol implements Protocol { } return; } - log("parseMessage", addr, message.toJSON()); + // log("parseMessage", addr, message.toJSON()); if ( (message.messageClass === classes.RESPONSE || message.messageClass === classes.ERROR) && diff --git a/packages/ice/src/stun/transaction.ts b/packages/ice/src/stun/transaction.ts index 2e5ac49f..a25d6f7e 100644 --- a/packages/ice/src/stun/transaction.ts +++ b/packages/ice/src/stun/transaction.ts @@ -42,12 +42,12 @@ export class Transaction { const res = await this.onResponse.asPromise(); return res; } catch (error) { - log( - "transaction run failed", - error, - this.protocol.type, - this.request.toJSON(), - ); + // log( + // "transaction run failed", + // error, + // this.protocol.type, + // this.request.toJSON(), + // ); throw error; } finally {