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));
size_group.add_widget (label);
hbox.pack_start (label, false, false, 0);
var ip_entry = new Hildon.Entry (Hildon.SizeType.FINGER_HEIGHT);
- Hildon.gtk_entry_set_input_mode (ip_entry, Hildon.GtkInputMode.NUMERIC |
- Hildon.GtkInputMode.SPECIAL);
+ ip_entry.set ("hildon-input-mode", Hildon.GtkInputMode.NUMERIC |
+ Hildon.GtkInputMode.SPECIAL);
hbox.pack_start (ip_entry, true, true, 0);
content.pack_start (hbox, false, false, 0);
size_group.add_widget (label);
hbox.pack_start (label, false, false, 0);
var port_entry = new Hildon.Entry (Hildon.SizeType.FINGER_HEIGHT);
- Hildon.gtk_entry_set_input_mode (port_entry, Hildon.GtkInputMode.NUMERIC);
+ port_entry.set ("hildon-input-mode", Hildon.GtkInputMode.NUMERIC);
hbox.pack_start (port_entry, true, true, 0);
content.pack_start (hbox, true, true, 0);
size_group.add_widget (label);
hbox.pack_start (label, false, false, 0);
var fingerprint_entry = new Hildon.Entry (Hildon.SizeType.FINGER_HEIGHT);
- Hildon.gtk_entry_set_input_mode (fingerprint_entry, Hildon.GtkInputMode.HEXA);
+ fingerprint_entry.set ("hildon-input-mode", Hildon.GtkInputMode.HEXA);
hbox.pack_start (fingerprint_entry, true, true, 0);
content.pack_start (hbox, true, true, 0);
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 ();
}
dialog.set_title (_("Log"));
var pannable = new Hildon.PannableArea ();
+ pannable.mov_mode = Hildon.MovementMode.BOTH;
var label = new Gtk.Label (tor_log);
pannable.add_with_viewport (label);
content.pack_start (pannable, true, true, 0);