From 5625c795baebd9a011c0880476ca9501a5b4f3a6 Mon Sep 17 00:00:00 2001 From: Morozov Dmitriy Date: Mon, 3 Jun 2024 14:53:47 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=BE=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D0=B0=20=D0=BF=D0=BE=D0=BF=D1=8B=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=20=D1=81=D0=BA=D0=B0=D1=87=D0=BA=D0=B8=20=D1=81=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=D0=B0=20=D0=B4=D0=BE=D0=BC=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- getdomains-install.sh | 39 +++++++++++++++++++-------------- templates/openwrt-getdomains.j2 | 14 ++++++++++-- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/getdomains-install.sh b/getdomains-install.sh index 8578c94..f80fcf0 100755 --- a/getdomains-install.sh +++ b/getdomains-install.sh @@ -26,7 +26,7 @@ EOF add_mark() { grep -q "99 vpn" /etc/iproute2/rt_tables || echo '99 vpn' >> /etc/iproute2/rt_tables - + if ! uci show network | grep -q mark0x1; then printf "\033[32;1mConfigure mark rule\033[0m\n" uci add network rule @@ -49,9 +49,9 @@ add_tunnel() { while true; do read -r -p '' TUNNEL - case $TUNNEL in + case $TUNNEL in - 1) + 1) TUNNEL=wg break ;; @@ -61,12 +61,12 @@ add_tunnel() { break ;; - 3) + 3) TUNNEL=singbox break ;; - 4) + 4) TUNNEL=tun2socks break ;; @@ -114,7 +114,7 @@ add_tunnel() { if [ "$WG_ENDPOINT_PORT" = '51820' ]; then echo $WG_ENDPOINT_PORT fi - + uci set network.wg0=interface uci set network.wg0.proto='wireguard' uci set network.wg0.private_key=$WG_PRIVATE_KEY @@ -182,7 +182,7 @@ cat << 'EOF' > /etc/sing-box/config.json "inet4_address": "172.16.250.1/30", "auto_route": false, "strict_route": false, - "sniff": true + "sniff": true } ], "outbounds": [ @@ -275,7 +275,7 @@ add_zone() { uci set firewall.@zone[-1].family='ipv4' uci commit firewall fi - + if [ "$TUNNEL" == 0 ]; then printf "\033[32;1mForwarding setting skipped\033[0m\n" elif uci show firewall | grep -q "@forwarding.*name='$TUNNEL-lan'"; then @@ -354,7 +354,7 @@ add_set() { add_dns_resolver() { echo "Configure DNSCrypt2 or Stubby? It does matter if your ISP is spoofing DNS requests" DISK=$(df -m / | awk 'NR==2{ print $2 }') - if [[ "$DISK" -lt 32 ]]; then + if [[ "$DISK" -lt 32 ]]; then printf "\033[31;1mYour router a disk have less than 32MB. It is not recommended to install DNSCrypt, it takes 10MB\033[0m\n" fi echo "Select:" @@ -364,9 +364,9 @@ add_dns_resolver() { while true; do read -r -p '' DNS_RESOLVER - case $DNS_RESOLVER in + case $DNS_RESOLVER in - 1) + 1) echo "Skiped" break ;; @@ -376,7 +376,7 @@ add_dns_resolver() { break ;; - 3) + 3) DNS_RESOLVER=STUBBY break ;; @@ -408,7 +408,7 @@ add_dns_resolver() { uci add_list dhcp.@dnsmasq[0].server="127.0.0.53#53" uci add_list dhcp.@dnsmasq[0].server='/use-application-dns.net/' uci commit dhcp - + printf "\033[32;1mDnsmasq restart\033[0m\n" /etc/init.d/dnsmasq restart @@ -468,9 +468,9 @@ add_getdomains() { while true; do read -r -p '' COUNTRY - case $COUNTRY in + case $COUNTRY in - 1) + 1) COUNTRY=russia_inside break ;; @@ -480,12 +480,12 @@ add_getdomains() { break ;; - 3) + 3) COUNTRY=ukraine break ;; - 4) + 4) echo "Skiped" COUNTRY=0 break @@ -518,7 +518,12 @@ start () { EOF cat << 'EOF' >> /etc/init.d/getdomains count=0 + maxCount=10 while true; do + if [ ${count} -eq ${maxCount} ]; then + echo "Break on ${maxCount} attempt" + break + fi if curl -m 3 github.com; then curl -f $DOMAINS --output /tmp/dnsmasq.d/domains.lst break diff --git a/templates/openwrt-getdomains.j2 b/templates/openwrt-getdomains.j2 index 1331f57..5050402 100644 --- a/templates/openwrt-getdomains.j2 +++ b/templates/openwrt-getdomains.j2 @@ -22,7 +22,12 @@ start () { DOMAINS=https://raw.githubusercontent.com/itdoginfo/allow-domains/main/Ukraine/inside-dnsmasq-ipset.lst {% endif %} count=0 + maxCount=10 while true; do + if [ ${count} -eq ${maxCount} ]; then + echo "Break on ${maxCount} attempt" + break + fi if curl -m 3 github.com; then curl -f $DOMAINS --output /tmp/dnsmasq.d/domains.lst break @@ -46,7 +51,12 @@ start () { mkdir -p $dir count=0 + maxCount=10 while true; do + if [ ${count} -eq ${maxCount} ]; then + echo "Break on ${maxCount} attempt" + break + fi if curl -m 3 https://antifilter.download/; then {% if list_subnet %} curl -f -z $dir/subnet.lst https://antifilter.download/list/subnet.lst --output $dir/subnet.lst @@ -56,7 +66,7 @@ start () { {% endif %} {% if list_community %} curl -f -z $dir/community.lst https://community.antifilter.download/list/community.lst --output $dir/community.lst - {% endif %} + {% endif %} break else echo "antifilter.download is not available. Check the internet availability [$count]" @@ -66,5 +76,5 @@ start () { echo "Firewall restart" /etc/init.d/firewall restart - {% endif %} + {% endif %} } \ No newline at end of file From fb91e5c9f5689933200e44a9a9393173039e9ac8 Mon Sep 17 00:00:00 2001 From: Morozov Dmitriy Date: Tue, 4 Jun 2024 16:26:16 +0300 Subject: [PATCH 2/2] added sleep in getdomains --- getdomains-install.sh | 1 + templates/openwrt-getdomains.j2 | 2 ++ 2 files changed, 3 insertions(+) diff --git a/getdomains-install.sh b/getdomains-install.sh index f80fcf0..2444c26 100755 --- a/getdomains-install.sh +++ b/getdomains-install.sh @@ -530,6 +530,7 @@ cat << 'EOF' >> /etc/init.d/getdomains else echo "GitHub is not available. Check the internet availability [$count]" count=$((count+1)) + sleep 5 fi done diff --git a/templates/openwrt-getdomains.j2 b/templates/openwrt-getdomains.j2 index 5050402..95e3408 100644 --- a/templates/openwrt-getdomains.j2 +++ b/templates/openwrt-getdomains.j2 @@ -34,6 +34,7 @@ start () { else echo "GitHub is not available. Check the internet availability [$count]" count=$((count+1)) + sleep 5 fi done @@ -71,6 +72,7 @@ start () { else echo "antifilter.download is not available. Check the internet availability [$count]" count=$((count+1)) + sleep 5 fi done