Browse Source

Simpler tor bridge removal by nickname

Bob Mottram 8 years ago
parent
commit
065394c83c
2 changed files with 34 additions and 17 deletions
  1. 25
    16
      src/freedombone-sec
  2. 9
    1
      src/freedombone-utils-onion

+ 25
- 16
src/freedombone-sec View File

@@ -797,28 +797,37 @@ function add_tor_bridge {
797 797
 }
798 798
 
799 799
 function remove_tor_bridge {
800
+    bridge_removed=
800 801
     data=$(tempfile 2>/dev/null)
801 802
     trap "rm -f $data" 0 1 2 5 15
802
-    dialog --backtitle $"Freedombone Control Panel" \
803
-           --title $"Remove obfs4 Tor bridge" \
804
-           --form "\n" 7 60 1 \
805
-           $"IP address:" 1 1 "   .   .   .   " 1 15 16 16 \
806
-           2> $data
803
+    dialog --title $"Remove obfs4 Tor bridge" \
804
+           --backtitle $"Freedombone Control Panel" \
805
+           --inputbox $"Enter the IP address, key or Nickname of the bridge" 8 65 2>$data
807 806
     sel=$?
808 807
     case $sel in
809
-        1) return;;
810
-        255) return;;
808
+        0)
809
+            response=$(<$data)
810
+            if [ ${#response} -gt 2 ]; then
811
+                if [[ "${response}" != *" "* ]]; then
812
+                    if [[ "${response}" == *"."* ]]; then
813
+                        if grep "Bridge ${response}" /etc/tor/torrc; then
814
+                            tor_remove_bridge "${response}"
815
+                            bridge_removed=1
816
+                        fi
817
+                    else
818
+                        if grep " $response" /etc/tor/torrc; then
819
+                            tor_remove_bridge "${response}"
820
+                            bridge_removed=1
821
+                        fi
822
+                    fi
823
+                fi
824
+            fi
825
+            ;;
811 826
     esac
812
-    bridge_ip_address=$(cat $data | sed -n 1p)
813
-    if [[ "${bridge_ip_address}" == *" "* ]]; then
814
-        return
827
+    if [ $bridge_removed ]; then
828
+        dialog --title $"Remove obfs4 Tor bridge" \
829
+               --msgbox $"Bridge removed" 6 40
815 830
     fi
816
-    if [[ "${bridge_ip_address}" != *"."* ]]; then
817
-        return
818
-    fi
819
-    tor_remove_bridge "${bridge_ip_address}"
820
-    dialog --title $"Remove obfs4 Tor bridge" \
821
-           --msgbox $"Bridge removed" 6 40
822 831
 }
823 832
 
824 833
 function add_tor_bridge_relay {

+ 9
- 1
src/freedombone-utils-onion View File

@@ -447,7 +447,15 @@ function tor_remove_bridge {
447 447
     bridge_ip_address="$1"
448 448
     bridge_type='obfs4'
449 449
 
450
-    bridge_str="Bridge $bridge_type ${bridge_ip_address}"
450
+    if [[ "$bridge_ip_address" == *"."* ]]; then
451
+        bridge_str="Bridge $bridge_type ${bridge_ip_address}"
452
+    else
453
+        if grep " ${bridge_ip_address}" /etc/tor/torrc; then
454
+            bridge_str=" ${bridge_ip_address}"
455
+        else
456
+            return
457
+        fi
458
+    fi
451 459
     if grep "${bridge_str}" /etc/tor/torrc; then
452 460
         sed -i "/${bridge_str}/d" /etc/tor/torrc
453 461
     fi