X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fstatus-area-applet-tor.vala;h=8bb41fa81bdab38292d15bbacbeb06a4711df42c;hb=579a260bd3cc8a6bcaadb6e44317a65ff14b03a9;hp=b0a21d22488c29beb4f17fb36981a3ece5bf135c;hpb=e79438fe385e6f0315edc4e5a5ca99e6831c08fe;p=tor-status diff --git a/src/status-area-applet-tor.vala b/src/status-area-applet-tor.vala index b0a21d2..8bb41fa 100644 --- a/src/status-area-applet-tor.vala +++ b/src/status-area-applet-tor.vala @@ -37,6 +37,7 @@ class TorStatusMenuItem : HD.StatusMenuItem { private const string GCONF_DIR_TOR = "/apps/maemo/tor"; private const string GCONF_KEY_TOR_ENABLED = GCONF_DIR_TOR + "/enabled"; private const string GCONF_KEY_BRIDGES = GCONF_DIR_TOR + "/bridges"; + private const string GCONF_KEY_EXITNODES = GCONF_DIR_TOR + "/exit_nodes"; private const string GCONF_DIR_PROXY_HTTP = "/system/http_proxy"; private const string GCONF_KEY_PROXY_HTTP_ENABLED = GCONF_DIR_PROXY_HTTP + "/use_http_proxy"; @@ -189,6 +190,20 @@ class TorStatusMenuItem : HD.StatusMenuItem { "Failed to set up bridge relays"); } } + + var exits = gconf.get_list (GCONF_KEY_EXITNODES, GConf.ValueType.STRING); + + if (exits.length () > 0) { + // Enable strict exit nodes + tor_control.set_conf_list ("ExitNodes", exits); + tor_control.set_conf_bool ("StrictExitNodes", true); + + bool strict = yield tor_control.get_conf_bool_async ("StrictExitNodes"); + if (!strict) { + Hildon.Banner.show_information (null, null, + "Failed to set up strict exit nodes"); + } + } } /** @@ -208,7 +223,7 @@ class TorStatusMenuItem : HD.StatusMenuItem { 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", ""); + hash = hash.str ("\n16:").offset (1).replace ("\n", ""); if (hash == null) { Hildon.Banner.show_information (null, null, @@ -295,7 +310,7 @@ class TorStatusMenuItem : HD.StatusMenuItem { backup.mode = gconf.get_string (GCONF_KEY_PROXY_MODE); } catch (Error e) { - error ("Error saving proxy settings: %s", e.message); + critical ("Error saving proxy settings: %s", e.message); backup = new ProxyBackup (); backup.use_http_proxy = false; @@ -321,7 +336,7 @@ class TorStatusMenuItem : HD.StatusMenuItem { gconf.set_string (GCONF_KEY_PROXY_MODE, "manual"); } catch (Error e) { - error ("Error changing proxy settings: %s", e.message); + critical ("Error changing proxy settings: %s", e.message); } } @@ -343,7 +358,7 @@ class TorStatusMenuItem : HD.StatusMenuItem { gconf.set_string (GCONF_KEY_PROXY_MODE, backup.mode); backup = null; } catch (Error e) { - error ("Error restoring proxy: %s", e.message); + critical ("Error restoring proxy: %s", e.message); } } @@ -356,6 +371,14 @@ class TorStatusMenuItem : HD.StatusMenuItem { } /** + * Show the exit node configuration dialog + */ + private void exit_nodes_clicked_cb () { + var dialog = new ExitNodeDialog (tor_control); + dialog.show (); + } + + /** * Check whether the IP address consists of four numbers in the 0..255 range */ bool is_valid_ip_address (string address) { @@ -404,7 +427,7 @@ class TorStatusMenuItem : HD.StatusMenuItem { private void button_clicked_cb () { var dialog = new Gtk.Dialog (); var content = (Gtk.VBox) dialog.get_content_area (); - content.set_size_request (-1, 2*70); + content.set_size_request (-1, 3*70); dialog.set_title (_("Tor: anonymity online")); @@ -422,6 +445,15 @@ class TorStatusMenuItem : HD.StatusMenuItem { button.clicked.connect (bridges_clicked_cb); content.pack_start (button, true, true, 0); + button = new Hildon.Button.with_text (Hildon.SizeType.FINGER_HEIGHT, + Hildon.ButtonArrangement.VERTICAL, + _("Restrict exit nodes"), + get_exit_node_list ()); + button.set_style (Hildon.ButtonStyle.PICKER); + button.set_alignment (0, 0.5f, 0, 0.5f); + button.clicked.connect (exit_nodes_clicked_cb); + content.pack_start (button, true, true, 0); + dialog.add_button (_("Log"), RESPONSE_LOG); dialog.add_button (_("Save"), Gtk.ResponseType.ACCEPT); @@ -473,6 +505,26 @@ class TorStatusMenuItem : HD.StatusMenuItem { return list; } + private string get_exit_node_list () { + string list = null; + var exits = new SList (); + try { + exits = gconf.get_list (GCONF_KEY_EXITNODES, GConf.ValueType.STRING); + } catch (Error e) { + error ("Error loading exit nodes: %s", e.message); + } + foreach (string exit in exits) { + if (list == null) + list = exit; + else + list += ", " + exit; + } + if (list == null) + list = _("None"); + + return list; + } + /** * Callback for the ConIc connection-event signal */ @@ -543,7 +595,7 @@ class TorStatusMenuItem : HD.StatusMenuItem { try { tor_enabled = gconf.get_bool (GCONF_KEY_TOR_ENABLED); } catch (Error e) { - error ("Failed to get GConf setting: %s", e.message); + critical ("Failed to get GConf setting: %s", e.message); } tor_connected = false;