diff --git a/src/freedombone-sec b/src/freedombone-sec index cf65c0a1..c807abb6 100755 --- a/src/freedombone-sec +++ b/src/freedombone-sec @@ -752,15 +752,72 @@ function store_passwords { } function show_tor_bridges { - echo -n '' + if ! grep "bridge " /etc/tor/torrc; then + echo $'No Tor bridges have been added' + return + fi + clear + grep "bridge " /etc/tor/torrc } function add_tor_bridge { - echo -n '' + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --backtitle $"Freedombone Control Panel" \ + --title $"Add obfs4 Tor bridge" \ + --form "\n" 9 60 4 \ + $"IP address:" 1 1 " . . . " 1 15 16 16 \ + $"Port: " 2 1 "" 2 15 5 5 \ + $"Key: " 3 1 "" 3 15 250 250 \ + 2> $data + sel=$? + case $sel in + 1) return;; + 255) return;; + esac + bridge_ip_address=$(cat $data | sed -n 1p) + bridge_port=$(cat $data | sed -n 2p) + bridge_key=$(cat $data | sed -n 3p) + if [[ "${bridge_ip_address}" == *" "* ]]; then + return + fi + if [[ "${bridge_ip_address}" != *"."* ]]; then + return + fi + if [ ${#bridge_port} -eq 0 ]; then + return + fi + if [ ${#bridge_key} -eq 0 ]; then + return + fi + tor_add_bridge "${bridge_ip_address}" "${bridge_port}" "${bridge_key}" + dialog --title $"Add obfs4 Tor bridge" \ + --msgbox $"Bridge added" 6 40 } function remove_tor_bridge { - echo -n '' + 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 + sel=$? + case $sel in + 1) return;; + 255) return;; + esac + bridge_ip_address=$(cat $data | sed -n 1p) + if [[ "${bridge_ip_address}" == *" "* ]]; then + return + 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 menu_security_settings {