Skip to content

Commit

Permalink
Add DNSCrypt starter script and menu option. Fix Settings screen to i…
Browse files Browse the repository at this point in the history
…nherit config parameters for default instead of first selection. Fix typo in cache server failover. Add DNSCrypt resolvers to Settings and link to resolver README. Tidy up meile_config.py. Add all resolvers to konstants
  • Loading branch information
freQniK committed Jul 7, 2024
1 parent e7d002e commit 25fcc4b
Show file tree
Hide file tree
Showing 9 changed files with 1,516 additions and 38 deletions.
8 changes: 0 additions & 8 deletions src/bin/routes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ if [[ ${STATE} = "up" ]]; then
echo "Add normal route for proxy..."
echo "ip route add ${PROXY_IP} via ${GATEWAY} metric 1"
ip route add ${PROXY_IP} via ${GATEWAY} metric 1
#ip route add 185.38.27.139 via ${GATEWAY}
#ip route add 190.211.255.227 via ${GATEWAY}
#ip route add 194.102.227.5 via ${GATEWAY}

# Setting up DNSCRYPT-proxy
#echo "Setting up dnscrypt-proxy..."
#/home/${USER}/.meile-gui/bin/dnscrypt-proxy -config /home/${USER}/.meile-gui/bin/dnscrypt-proxy.toml &
#bash -c 'echo "nameserver 127.0.0.1" > /etc/resolv.conf'

# start tun2socks
echo "Starting tun2socks..."
Expand Down
24 changes: 24 additions & 0 deletions src/bin/run_dnscrypt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

if [[ "${1^^}" == "UP" ]]; then
DNS_SERVER="127.0.0.1"
else
DNS_SERVER="1.1.1.1"
fi

for interface in $(resolvectl status | grep "Link" | awk '{print $2}'); do
resolvectl dns "$interface" $DNS_SERVER
done

resolvectl status


if [[ "${1^^}" == "UP" ]]; then
echo "Setting up dnscrypt-proxy..."
/home/${USER}/.meile-gui/bin/dnscrypt-proxy -config /home/${USER}/.meile-gui/dnscrypt-proxy.toml &

else
echo "Stopping dnscrypt-proxy..."
pkill -11 dnscrypt-proxy
fi

17 changes: 9 additions & 8 deletions src/cli/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import requests
from requests.exceptions import ReadTimeout, ConnectionError, HTTPError
from urllib3.exceptions import InsecureRequestWarning
from urllib3.exceptions import InsecureRequestWarning, ResponseError
from subprocess import Popen, PIPE, STDOUT
from datetime import datetime,timedelta
import time
Expand Down Expand Up @@ -106,19 +106,20 @@ def get_nodes(self, latency, *kwargs):
#N = random.randint(0, len(HTTParams.NODE_API) -1)
try:
r = http.get(CACHE_SERVER)
if r.status_code == 502:
print(f"Reponse 502 from {CACHE_SERVER}. Switching to backup server.")
CACHE_SERVER = HTTParams.NODE_APIS[random.randint(0, len(HTTParams.NODE_API)-1)]
continue
r.raise_for_status()
except (ReadTimeout, ConnectionError, HTTPError):
print(f"Read timed out for {CACHE_SERVER}. Switching to backup server.")
CACHE_SERVER = HTTParams.NODE_APIS[random.randint(0, len(HTTParams.NODE_API)-1)]
print(f"Server error for {CACHE_SERVER}. Switching to backup server.")
CACHE_SERVER = HTTParams.NODE_APIS[random.randint(0, len(HTTParams.NODE_APIS)-1)]
continue
except requests.RequestException as e:
print(f"Server error for {CACHE_SERVER}. Switching to backup server.")
CACHE_SERVER = HTTParams.NODE_APIS[random.randint(0, len(HTTParams.NODE_APIS)-1)]
continue
data = r.json()
if not data:
retries += 1
if retries >= 2:
CACHE_SERVER = HTTParams.NODE_APIS[random.randint(0, len(HTTParams.NODE_API)-1)]
CACHE_SERVER = HTTParams.NODE_APIS[random.randint(0, len(HTTParams.NODE_APIS)-1)]
continue
#rint(data)
for node in data:
Expand Down
Loading

0 comments on commit 25fcc4b

Please sign in to comment.