Pid polipo_pid;
ProxyBackup backup;
string tor_log;
+ TorControl.Connection tor_control;
+ string password;
/**
* Update status area icon and status menu button value
proxy_setup ();
update_status ();
}
+ if ("Opening Control listener on 127.0.0.1:9051" in line) {
+ tor_control = new TorControl.Connection ();
+ tor_control_auth.begin ();
+ }
} else {
// FIXME
Hildon.Banner.show_information (null, null, "DEBUG: %s".printf (line));
}
/**
+ * Authenticate with Tor on the control channel
+ */
+ private async void tor_control_auth () throws Error {
+ yield tor_control.authenticate_async (password);
+
+ var bridges = new SList<string> ();
+ try {
+ bridges = gconf.get_list (GCONF_KEY_BRIDGES, GConf.ValueType.STRING);
+ } catch (Error e) {
+ error ("Error loading bridges: %s", e.message);
+ return;
+ }
+
+ if (bridges.length () <= 0)
+ return;
+
+ // Enable bridge relays
+ tor_control.set_conf_list ("Bridge", bridges);
+ tor_control.set_conf_bool ("UseBridges", true);
+
+ bool use = yield tor_control.get_conf_bool_async ("UseBridges");
+ if (!use) {
+ Hildon.Banner.show_information (null, null,
+ "Failed to set up bridge relays");
+ }
+ }
+
+ /**
* Start Tor and setup proxy settings
*/
private void start_tor () {
try {
if (tor_pid == (Pid) 0) {
+ string[] tor_hash_argv = {
+ "/usr/sbin/tor",
+ "--hash-password", "",
+ null
+ };
+ var tv = TimeVal ();
+ Random.set_seed ((uint32) tv.tv_usec);
+ password = "tor-status-%8x".printf (Random.next_int ());
+ tor_hash_argv[2] = password;
+ string hash;
+ Process.spawn_sync ("/tmp", tor_hash_argv, null, 0, null, out hash);
+ hash = hash.str ("16:").replace ("\n", "");
+
+ if (hash == null) {
+ Hildon.Banner.show_information (null, null,
+ "Failed to get hash");
+ return;
+ }
+
+ string[] tor_argv = {
+ "/usr/sbin/tor",
+ "--ControlPort", "9051",
+ "--HashedControlPassword", "",
+ null
+ };
+ tor_argv[4] = hash;
Process.spawn_async_with_pipes ("/tmp",
- { "/usr/sbin/tor" },
+ tor_argv,
null,
SpawnFlags.SEARCH_PATH,
null,
try {
bridges = gconf.get_list (GCONF_KEY_BRIDGES, GConf.ValueType.STRING);
} catch (Error e) {
- error ("Error loading bridges: %s", e.message);
+ Hildon.Banner.show_information (null, null, "Error loading bridges: %s".printf (e.message));
}
var list_store = new Gtk.ListStore (1, typeof (string));
store.@get (iter, 0, out bridge);
bridges.append (bridge);
} while (store.iter_next (ref iter));
- gconf.set_list (GCONF_KEY_BRIDGES, GConf.ValueType.STRING,
- bridges);
+ try {
+ gconf.set_list (GCONF_KEY_BRIDGES,
+ GConf.ValueType.STRING,
+ bridges);
+ } catch (Error e) {
+ Hildon.Banner.show_information (dialog, null,
+ "Failed to save bridge relay list: %s".printf (e.message));
+ }
}
dialog.destroy ();
}
store.append (out iter);
}
store.@set (iter, 0, "%s:%d".printf (ip_entry.get_text (), port));
-
- bridges = gconf.get_list (GCONF_KEY_BRIDGES, GConf.ValueType.STRING);
+ try {
+ bridges = gconf.get_list (GCONF_KEY_BRIDGES,
+ GConf.ValueType.STRING);
+ } catch (Error e) {
+ Hildon.Banner.show_information (null, null,
+ "Error loading bridges: %s".printf (e.message));
+ }
if (path == null) {
bridges.append ("%s:%d".printf (ip_entry.get_text (), port));
} else {
bridges.append (bridge);
} while (store.iter_next (ref iter));
}
- gconf.set_list (GCONF_KEY_BRIDGES, GConf.ValueType.STRING, bridges);
+ try {
+ gconf.set_list (GCONF_KEY_BRIDGES,
+ GConf.ValueType.STRING,
+ bridges);
+ } catch (Error e) {
+ Hildon.Banner.show_information (dialog, null,
+ "Failed to save bridge relay list: %s".printf (e.message));
+ }
dialog.destroy ();
}