Jelajahi Sumber

Rename and clarify debugging flags in config (#784)

Lennart Grahl 6 tahun lalu
induk
melakukan
9890b39201

+ 1 - 1
src/app.ts

@@ -148,7 +148,7 @@ angular.module('3ema', [
     function($log: ng.ILogService, CONFIG: threema.Config, browserService: BrowserService) {
         // For Safari (when in DEBUG mode), monkey-patch $log to show timestamps.
 
-        if (!(CONFIG.DEBUG && browserService.getBrowser().isSafari(false))) {
+        if (!(CONFIG.VERBOSE_DEBUGGING && browserService.getBrowser().isSafari(false))) {
             return;
         }
 

+ 8 - 5
src/config.ts

@@ -38,10 +38,13 @@ export default {
     // Push
     PUSH_URL: 'https://push-web.threema.ch/push',
 
-    // Debugging options
-    DEBUG: false,
-    MSG_DEBUGGING: false, // Log all incoming and outgoing messages
-    MSGPACK_DEBUGGING: false, // Log URLs to the msgpack visualizer
-    ICE_DEBUGGING: false,
+    // Very verbose logging that potentially affects performance and may also
+    // contain sensitive information.
+    VERBOSE_DEBUGGING: false,
+    // Logs all incoming and outgoing protocol messages.
+    MSG_DEBUGGING: false,
+    // Logs URLs to visualise MsgPack messages for all incoming and outgoing
+    // protocol messages.
+    MSGPACK_DEBUGGING: false,
 
 } as threema.Config;

+ 1 - 1
src/directives/compose_area.ts

@@ -93,7 +93,7 @@ export default [
                 const fileInput = select('input.file-input') as JQuery<HTMLInputElement>;
 
                 // Initialize compose area lib
-                const composeArea = ComposeArea.bind_to(composeDiv[0], CONFIG.DEBUG ? 'debug' : 'warn');
+                const composeArea = ComposeArea.bind_to(composeDiv[0], CONFIG.VERBOSE_DEBUGGING ? 'debug' : 'warn');
                 if (scope.onInit) {
                     scope.onInit(composeArea);
                 }

+ 1 - 1
src/services/push.ts

@@ -194,7 +194,7 @@ export class PushSession {
 
             // Send push
             this.$log.debug(this.logTag, `Sending push ${this.tries}/${this.config.triesMax} (ttl=${timeToLive})`);
-            if (this.service.config.DEBUG) {
+            if (this.service.config.VERBOSE_DEBUGGING) {
                 this.$log.debug(this.logTag, 'Push data:', `${data}`);
             }
             try {

+ 1 - 1
src/services/timeout.ts

@@ -39,7 +39,7 @@ export class TimeoutService {
      * Log a message on debug log level, but only if the `DEBUG` flag is enabled.
      */
     private logDebug(msg: string): void {
-        if (this.config.DEBUG) {
+        if (this.config.VERBOSE_DEBUGGING) {
             this.$log.debug(this.logTag, msg);
         }
     }

+ 7 - 7
src/services/webclient.ts

@@ -460,7 +460,7 @@ export class WebClientService {
         this.webrtcTask = new saltyrtcTaskWebrtc.WebRTCTask(true, maxPacketSize, this.config.SALTYRTC_LOG_LEVEL);
 
         // Create Relayed Data task instance
-        this.relayedDataTask = new saltyrtcTaskRelayedData.RelayedDataTask(this.config.DEBUG);
+        this.relayedDataTask = new saltyrtcTaskRelayedData.RelayedDataTask(this.config.VERBOSE_DEBUGGING);
 
         // Create new keystore if necessary
         if (!keyStore) {
@@ -498,7 +498,7 @@ export class WebClientService {
             builder = builder.withTrustedPeerKey(flags.peerTrustedKey);
         }
         this.salty = builder.asInitiator();
-        if (this.config.DEBUG) {
+        if (this.config.VERBOSE_DEBUGGING) {
             this.$log.debug('Public key:', this.salty.permanentKeyHex);
             this.$log.debug('Auth token:', this.salty.authTokenHex);
         }
@@ -578,7 +578,7 @@ export class WebClientService {
                 this.pcHelper = new PeerConnectionHelper(this.$log, this.$q, this.$timeout,
                     this.$rootScope, this.webrtcTask,
                     this.config.ICE_SERVERS,
-                    !this.config.ICE_DEBUGGING);
+                    !this.config.VERBOSE_DEBUGGING);
 
                 // On state changes in the PeerConnectionHelper class, let state service know about it
                 this.pcHelper.onConnectionStateChange = (state: threema.TaskConnectionState) => {
@@ -2896,7 +2896,7 @@ export class WebClientService {
                     if (!this.messages.update(receiver, msg)) {
                         const log = `Received message update for unknown message (id ${msg.id})`;
                         this.$log.error(this.logTag, log);
-                        if (this.config.DEBUG) {
+                        if (this.config.VERBOSE_DEBUGGING) {
                             this.messages.addStatusMessage(receiver, 'Warning: ' + log);
                             notify = true;
                         }
@@ -3959,7 +3959,7 @@ export class WebClientService {
 
         // Add to chunk cache
         if (cache) {
-            if (this.config.DEBUG && this.config.MSG_DEBUGGING) {
+            if (this.config.VERBOSE_DEBUGGING && this.config.MSG_DEBUGGING) {
                 this.$log.debug(`[Chunk] Caching chunk (retransmit/push=${retransmit}:`, chunk);
             }
             try {
@@ -3973,7 +3973,7 @@ export class WebClientService {
 
         // Send if ready
         if (!shouldQueue) {
-            if (this.config.DEBUG && this.config.MSG_DEBUGGING) {
+            if (this.config.VERBOSE_DEBUGGING && this.config.MSG_DEBUGGING) {
                 this.$log.debug(`[Chunk] Sending chunk (retransmit/push=${retransmit}:`, chunk);
             }
 
@@ -3992,7 +3992,7 @@ export class WebClientService {
      * Handle an incoming chunk from the underlying transport.
      */
     private receiveChunk(chunk: Uint8Array): void {
-        if (this.config.DEBUG && this.config.MSG_DEBUGGING) {
+        if (this.config.VERBOSE_DEBUGGING && this.config.MSG_DEBUGGING) {
             this.$log.debug('[Chunk] Received chunk:', chunk);
         }
 

+ 1 - 2
src/threema.d.ts

@@ -640,10 +640,9 @@ declare namespace threema {
         SALTYRTC_LOG_LEVEL: saltyrtc.LogLevel;
         ICE_SERVERS: RTCIceServer[];
         PUSH_URL: string;
-        DEBUG: boolean;
+        VERBOSE_DEBUGGING: boolean;
         MSG_DEBUGGING: boolean;
         MSGPACK_DEBUGGING: boolean;
-        ICE_DEBUGGING: boolean;
     }
 
     interface InitialConversationData {