From 065394c83cb18e68d99224869cb816749bd129b9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 22 Dec 2016 13:13:48 +0000 Subject: [PATCH] Simpler tor bridge removal by nickname --- src/freedombone-sec | 41 ++++++++++++++++++++++--------------- src/freedombone-utils-onion | 10 ++++++++- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/freedombone-sec b/src/freedombone-sec index d9726306..0d742980 100755 --- a/src/freedombone-sec +++ b/src/freedombone-sec @@ -797,28 +797,37 @@ function add_tor_bridge { } function remove_tor_bridge { + bridge_removed= data=$(tempfile 2>/dev/null) trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle $"Freedombone Control Panel" \ - --title $"Remove obfs4 Tor bridge" \ - --form "\n" 7 60 1 \ - $"IP address:" 1 1 " . . . " 1 15 16 16 \ - 2> $data + dialog --title $"Remove obfs4 Tor bridge" \ + --backtitle $"Freedombone Control Panel" \ + --inputbox $"Enter the IP address, key or Nickname of the bridge" 8 65 2>$data sel=$? case $sel in - 1) return;; - 255) return;; + 0) + response=$(<$data) + if [ ${#response} -gt 2 ]; then + if [[ "${response}" != *" "* ]]; then + if [[ "${response}" == *"."* ]]; then + if grep "Bridge ${response}" /etc/tor/torrc; then + tor_remove_bridge "${response}" + bridge_removed=1 + fi + else + if grep " $response" /etc/tor/torrc; then + tor_remove_bridge "${response}" + bridge_removed=1 + fi + fi + fi + fi + ;; esac - bridge_ip_address=$(cat $data | sed -n 1p) - if [[ "${bridge_ip_address}" == *" "* ]]; then - return + if [ $bridge_removed ]; then + dialog --title $"Remove obfs4 Tor bridge" \ + --msgbox $"Bridge removed" 6 40 fi - if [[ "${bridge_ip_address}" != *"."* ]]; then - return - fi - tor_remove_bridge "${bridge_ip_address}" - dialog --title $"Remove obfs4 Tor bridge" \ - --msgbox $"Bridge removed" 6 40 } function add_tor_bridge_relay { diff --git a/src/freedombone-utils-onion b/src/freedombone-utils-onion index 279fa695..e242f5e7 100755 --- a/src/freedombone-utils-onion +++ b/src/freedombone-utils-onion @@ -447,7 +447,15 @@ function tor_remove_bridge { bridge_ip_address="$1" bridge_type='obfs4' - bridge_str="Bridge $bridge_type ${bridge_ip_address}" + if [[ "$bridge_ip_address" == *"."* ]]; then + bridge_str="Bridge $bridge_type ${bridge_ip_address}" + else + if grep " ${bridge_ip_address}" /etc/tor/torrc; then + bridge_str=" ${bridge_ip_address}" + else + return + fi + fi if grep "${bridge_str}" /etc/tor/torrc; then sed -i "/${bridge_str}/d" /etc/tor/torrc fi