Browse Source

Resolve dns via tor

Bob Mottram 9 years ago
parent
commit
f7c0fc974a
1 changed files with 30 additions and 0 deletions
  1. 30
    0
      src/freedombone

+ 30
- 0
src/freedombone View File

@@ -3850,6 +3850,35 @@ function install_tor {
3850 3850
     echo 'install_tor' >> $COMPLETION_FILE
3851 3851
 }
3852 3852
 
3853
+function resolve_dns_via_tor {
3854
+    if [[ $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
3855
+        return
3856
+    fi
3857
+    if grep -Fxq "resolve_dns_via_tor" $COMPLETION_FILE; then
3858
+        return
3859
+    fi
3860
+    if [ ! -f /etc/tor/torrc ]; then
3861
+        echo $'tor was not installed'
3862
+        exit 52952
3863
+    fi
3864
+
3865
+    # resolve DNS via tor
3866
+    if ! grep 'DNSPort 53' /etc/tor/torrc; then
3867
+        echo 'DNSPort 53' >> /etc/tor/torrc
3868
+        echo 'AutomapHostsOnResolve 1' >> /etc/tor/torrc
3869
+        echo 'AutomapHostsSuffixes .exit,.onion' >> /etc/tor/torrc
3870
+        systemctl restart tor
3871
+    fi
3872
+
3873
+    # don't change resolv.conf
3874
+    sed -i 's|, domain-name-servers||g' /etc/dhcp/dhclient.conf
3875
+
3876
+    # point resolv.conf to tor
3877
+    echo 'nameserver 127.0.0.1:53' > /etc/resolv.conf
3878
+
3879
+    echo 'resolve_dns_via_tor' >> $COMPLETION_FILE
3880
+}
3881
+
3853 3882
 function enable_ssh_via_onion {
3854 3883
     if [[ $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
3855 3884
         return
@@ -10380,6 +10409,7 @@ create_repo_sources
10380 10409
 configure_dns
10381 10410
 initial_setup
10382 10411
 install_tor
10412
+resolve_dns_via_tor
10383 10413
 enable_ssh_via_onion
10384 10414
 check_date
10385 10415
 install_dynamicdns