Your ROOT_URL in app.ini is unix://git.lalonde.me:3000/ but you are visiting https://git.lalonde.me/matth/subgraph-gnome-shell-extension-tor/commit/2c2e970f5bbbdde81989bafa59b9bc8b886d8b9c You should set ROOT_URL correctly, otherwise the web may not work correctly.

Make log messages distinguishable from other extensions

log statement in Log.debug is commented out by default. It makes sense
to make this configurable by the user later on.
master
Frank Ploss 9 years ago
parent 0d0b75cc77
commit 2c2e970f5b

@ -23,6 +23,7 @@ const Gtk = imports.gi.Gtk;
const Main = imports.ui.main;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Log = Me.imports.log.Log;
const TorButton = Me.imports.ui.tor_button.TorButton;
const TorControlClient = Me.imports.tor_control_client.TorControlClient;
@ -42,6 +43,7 @@ function enable() {
torButton = new TorButton(torControlClient);
Main.panel.addToStatusArea(torButton.Name, torButton);
torControlClient.openConnection();
Log.debug('Enabled Tor extension');
}
function disable() {
@ -50,4 +52,6 @@ function disable() {
if (torButton !== null)
torButton.destroy();
Log.debug('Disabled Tor extension');
}

@ -0,0 +1,9 @@
const Log = {
warn: function(message) {
log('[tor control] ' + message);
},
debug: function(message) {
//log('[tor control] DEBUG: ' + message);
}
}

@ -24,6 +24,9 @@ const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Signals = imports.signals;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Log = Me.imports.log.Log;
const TorConnectionError = new Lang.Class({
Name: 'TorConnectionError',
@ -58,6 +61,7 @@ const TorControlClient = new Lang.Class({
},
openConnection: function() {
Log.debug('Trying to reconnect ...');
try {
this._connect(this._host, this._port);
this._updateProtocolInfo();
@ -65,10 +69,13 @@ const TorControlClient = new Lang.Class({
this._authenticate();
this.emit('changed-connection-state', 'ready');
this.stopAutoRetry();
Log.debug('Connected to Tor control port');
} catch (e if e instanceof TorConnectionError) {
Log.debug('Could not connect to Tor control port');
this.closeConnection(e.message);
this.startAutoRetry();
} catch (e if e instanceof TorProtocolError) {
Log.debug('Tor control protocol error: ' + e.message);
this.closeConnection(e.message);
this.startAutoRetry();
}
@ -92,16 +99,19 @@ const TorControlClient = new Lang.Class({
return;
this._autoRetryTimerId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, Lang.bind(this, function() {
//log('Retrying to open connection ...');
this.openConnection();
return this._connection === null || !this._connection.is_connected();
}));
Log.debug('Started auto retry (timer id=' + this._autoRetryTimerId + ')');
},
stopAutoRetry: function() {
if (this._autoRetryTimerId === null)
return;
Log.debug('Stopping auto retry (timer id=' + this._autoRetryTimerId + ')');
GLib.source_remove(this._autoRetryTimerId);
this._autoRetryTimerId = null;
},

Loading…
Cancel
Save