Added install script, openwrt 23.05, sing-box, tun2socks

This commit is contained in:
itdoginfo
2023-10-13 14:48:19 +03:00
parent fc9646eff1
commit 9b2bfbe1b3
10 changed files with 1499 additions and 558 deletions

View File

@@ -0,0 +1,5 @@
config sing-box 'main'
option enabled '1'
option user 'root'
option conffile '/etc/sing-box/config.json'
option workdir '/usr/share/sing-box'

View File

@@ -1,3 +1,8 @@
#!/bin/sh
{% if tunnel == "wg" %}
ip route add table vpn default dev wg0
{% elif (tunnel == "openvpn") or (tunnel == "singbox") or (tunnel == "tun2socks") %}
sleep 5
ip route add table vpn default dev tun0
{% endif %}

View File

@@ -0,0 +1,70 @@
#!/bin/sh /etc/rc.common
START=99
start () {
{% if ansible_distribution_major_version >= "22" and country == "russia-inside" %}
DOMAINS=https://raw.githubusercontent.com/itdoginfo/allow-domains/main/Russia/inside-dnsmasq-nfset.lst
{% endif %}
{% if ansible_distribution_major_version >= "22" and country == "russia-outside" %}
DOMAINS=https://raw.githubusercontent.com/itdoginfo/allow-domains/main/Russia/outside-dnsmasq-nfset.lst
{% endif %}
{% if ansible_distribution_major_version >= "22" and country == "ukraine" %}
DOMAINS=https://raw.githubusercontent.com/itdoginfo/allow-domains/main/Ukraine/inside-dnsmasq-nfset.lst
{% endif %}
{% if ansible_distribution_major_version < "22" and country == "russia-inside" %}
DOMAINS=https://raw.githubusercontent.com/itdoginfo/allow-domains/main/Russia/inside-dnsmasq-ipset.lst
{% endif %}
{% if ansible_distribution_major_version < "22" and country == "russia-outside" %}
DOMAINS=https://raw.githubusercontent.com/itdoginfo/allow-domains/main/Russia/outside-dnsmasq-ipset.lst
{% endif %}
{% if ansible_distribution_major_version < "22" and country == "ukraine" %}
DOMAINS=https://raw.githubusercontent.com/itdoginfo/allow-domains/main/Ukraine/inside-dnsmasq-ipset.lst
{% endif %}
count=0
while true; do
if curl -m 3 github.com; then
curl -f $DOMAINS --output /tmp/dnsmasq.d/domains.lst
break
else
echo "GitHub is not available. Check the internet availability [$count]"
count=$((count+1))
fi
done
if dnsmasq --conf-file=/tmp/dnsmasq.d/domains.lst --test 2>&1 | grep -q "syntax check OK"; then
/etc/init.d/dnsmasq restart
fi
{% if ansible_distribution_major_version >= "22" and (list_ip or list_community) %}
echo "Flush sets"
nft flush ruleset
{% endif %}
{% if list_subnet or list_ip or list_community %}
dir=/tmp/lst
mkdir -p $dir
count=0
while true; do
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
{% endif %}
{% if list_ip %}
curl -f -z $dir/ip.lst https://antifilter.download/list/ip.lst --output $dir/ip.lst
{% endif %}
{% if list_community %}
curl -f -z $dir/community.lst https://community.antifilter.download/list/community.lst --output $dir/community.lst
{% endif %}
break
else
echo "antifilter.download is not available. Check the internet availability [$count]"
count=$((count+1))
fi
done
echo "Firewall restart"
/etc/init.d/firewall restart
{% endif %}
}

View File

@@ -1,116 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
script () {
dir=/tmp/lst
SUBNET=https://antifilter.download/list/subnet.lst
IP=https://antifilter.download/list/ip.lst
COMMUNITY=https://community.antifilter.download/list/community.lst
DOMAINS=https://community.antifilter.download/list/domains.lst
{% if download_utility == "curl" %}
download () {
count=0
while [ ! -f $dir/$1 ]; do
if [ $count -gt 10 ]; then
echo Exit
exit 1
else
echo "Try $count"
curl -f -z $dir/$1 $2 --output $dir/$1
count=$((count+1))
sleep 5
fi
done
}
{% elif download_utility == "wget" %}
download () {
count=0
while [ ! -f $dir/$1 ]; do
if [ $count -gt 10 ]; then
echo Exit
exit 1
else
echo "Try $count"
wget -P $dir $2
count=$((count+1))
sleep 5
fi
done
}
{% endif %}
mkdir -p $dir
{% if ansible_distribution_major_version == "22" and (list_ip or list_community) %}
echo "Flush sets"
nft flush ruleset
{% endif %}
echo "Run download lists"
{% if download_utility == "curl" %}
{% if list_subnet %}
curl -f -z $dir/subnet.lst $SUBNET --output $dir/subnet.lst
download subnet.lst $SUBNET
{% endif %}
{% if list_ip %}
curl -f -z $dir/ip.lst $IP --output $dir/ip.lst
download ip.lst $IP
{% endif %}
{% if list_community %}
curl -f -z $dir/community.lst $COMMUNITY --output $dir/community.lst
download community.lst $COMMUNITY
{% endif %}
{% if list_domains and (ansible_distribution_major_version < "22" and dnsmasqfull_version.stdout) or ( ansible_distribution_major_version == "22" and dnsmasqfull_version.stdout >= "2.87") %}
curl -f -z $dir/domains.lst $DOMAINS --output $dir/domains.lst
download domains.lst $DOMAINS
{% endif %}
{% elif download_utility == "wget" %}
{% if list_subnet %}
rm -f /$dir/subnet.lst && wget -P $dir $SUBNET
download subnet.lst $SUBNET
{% endif %}
{% if list_ip %}
rm -f /$dir/ip.lst && wget -P $dir $IP
download ip.lst $IP
{% endif %}
{% if list_community %}
rm -f /$dir/community.lst && wget -P $dir $COMMUNITY
download community.lst $COMMUNITY
{% endif %}
{% if list_domains and (ansible_distribution_major_version < "22" and dnsmasqfull_version.stdout) or ( ansible_distribution_major_version == "22" and dnsmasqfull_version.stdout >= "2.87") %}
rm -f /$dir/domains.lst && wget -P $dir $DOMAINS
download domains.lst $DOMAINS
{% endif %}
{% endif %}
{% if list_domains %}
{% if ansible_distribution_major_version == "22" and dnsmasqfull_version.stdout >= "2.87" %}
sed "s/.*/nftset=\/&\/4#inet#fw4#vpn_domains/" $dir/domains.lst > /tmp/dnsmasq.d/domains
{% elif ansible_distribution_major_version < "22" and dnsmasqfull_version.stdout %}
sed "s/.*/ipset=\/&\/vpn_domains/" $dir/domains.lst > /tmp/dnsmasq.d/domains
{% endif %}
echo "Dnsmasq restart"
/etc/init.d/dnsmasq restart
{% endif %}
echo "Firewall restart"
/etc/init.d/firewall restart
}
start () {
script
}
restart () {
script
}
reload () {
script
}

View File

@@ -0,0 +1,28 @@
{
"log": {
"level": "debug"
},
"inbounds": [
{
"type": "tun",
"interface_name": "tun0",
"domain_strategy": "ipv4_only",
"inet4_address": "172.19.0.1/30",
"auto_route": false,
"strict_route": false,
"sniff": true
}
],
"outbounds": [
{
"type": "$TYPE",
"server": "$HOST",
"server_port": $PORT,
"method": "$METHOD",
"password": "$PASS"
}
],
"route": {
"auto_detect_interface": true
}
}