Sfoglia il codice sorgente

Simpler tor bridge removal by nickname

Bob Mottram 8 anni fa
parent
commit
065394c83c
2 ha cambiato i file con 34 aggiunte e 17 eliminazioni
  1. 25
    16
      src/freedombone-sec
  2. 9
    1
      src/freedombone-utils-onion

+ 25
- 16
src/freedombone-sec Vedi File

797
 }
797
 }
798
 
798
 
799
 function remove_tor_bridge {
799
 function remove_tor_bridge {
800
+    bridge_removed=
800
     data=$(tempfile 2>/dev/null)
801
     data=$(tempfile 2>/dev/null)
801
     trap "rm -f $data" 0 1 2 5 15
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
     sel=$?
806
     sel=$?
808
     case $sel in
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
     esac
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
     fi
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
 function add_tor_bridge_relay {
833
 function add_tor_bridge_relay {

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

447
     bridge_ip_address="$1"
447
     bridge_ip_address="$1"
448
     bridge_type='obfs4'
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
     if grep "${bridge_str}" /etc/tor/torrc; then
459
     if grep "${bridge_str}" /etc/tor/torrc; then
452
         sed -i "/${bridge_str}/d" /etc/tor/torrc
460
         sed -i "/${bridge_str}/d" /etc/tor/torrc
453
     fi
461
     fi