Browse Source

Tor bridges accessible from control panel

Bob Mottram 8 years ago
parent
commit
e1cca214bf
1 changed files with 60 additions and 3 deletions
  1. 60
    3
      src/freedombone-sec

+ 60
- 3
src/freedombone-sec View File

752
 }
752
 }
753
 
753
 
754
 function show_tor_bridges {
754
 function show_tor_bridges {
755
-    echo -n ''
755
+    if ! grep "bridge " /etc/tor/torrc; then
756
+        echo $'No Tor bridges have been added'
757
+        return
758
+    fi
759
+    clear
760
+    grep "bridge " /etc/tor/torrc
756
 }
761
 }
757
 
762
 
758
 function add_tor_bridge {
763
 function add_tor_bridge {
759
-    echo -n ''
764
+    data=$(tempfile 2>/dev/null)
765
+    trap "rm -f $data" 0 1 2 5 15
766
+    dialog --backtitle $"Freedombone Control Panel" \
767
+           --title $"Add obfs4 Tor bridge" \
768
+           --form "\n" 9 60 4 \
769
+           $"IP address:" 1 1 "   .   .   .   " 1 15 16 16 \
770
+           $"Port:      " 2 1 "" 2 15 5 5 \
771
+           $"Key:       " 3 1 "" 3 15 250 250 \
772
+           2> $data
773
+    sel=$?
774
+    case $sel in
775
+        1) return;;
776
+        255) return;;
777
+    esac
778
+    bridge_ip_address=$(cat $data | sed -n 1p)
779
+    bridge_port=$(cat $data | sed -n 2p)
780
+    bridge_key=$(cat $data | sed -n 3p)
781
+    if [[ "${bridge_ip_address}" == *" "* ]]; then
782
+        return
783
+    fi
784
+    if [[ "${bridge_ip_address}" != *"."* ]]; then
785
+        return
786
+    fi
787
+    if [ ${#bridge_port} -eq 0 ]; then
788
+        return
789
+    fi
790
+    if [ ${#bridge_key} -eq 0 ]; then
791
+        return
792
+    fi
793
+    tor_add_bridge "${bridge_ip_address}" "${bridge_port}" "${bridge_key}"
794
+    dialog --title $"Add obfs4 Tor bridge" \
795
+           --msgbox $"Bridge added" 6 40
760
 }
796
 }
761
 
797
 
762
 function remove_tor_bridge {
798
 function remove_tor_bridge {
763
-    echo -n ''
799
+    data=$(tempfile 2>/dev/null)
800
+    trap "rm -f $data" 0 1 2 5 15
801
+    dialog --backtitle $"Freedombone Control Panel" \
802
+           --title $"Remove obfs4 Tor bridge" \
803
+           --form "\n" 7 60 1 \
804
+           $"IP address:" 1 1 "   .   .   .   " 1 15 16 16 \
805
+           2> $data
806
+    sel=$?
807
+    case $sel in
808
+        1) return;;
809
+        255) return;;
810
+    esac
811
+    bridge_ip_address=$(cat $data | sed -n 1p)
812
+    if [[ "${bridge_ip_address}" == *" "* ]]; then
813
+        return
814
+    fi
815
+    if [[ "${bridge_ip_address}" != *"."* ]]; then
816
+        return
817
+    fi
818
+    tor_remove_bridge "${bridge_ip_address}"
819
+    dialog --title $"Remove obfs4 Tor bridge" \
820
+           --msgbox $"Bridge removed" 6 40
764
 }
821
 }
765
 
822
 
766
 function menu_security_settings {
823
 function menu_security_settings {