Create ansible role

This commit is contained in:
itdoginfo
2024-04-17 11:59:31 +03:00
parent 8ca4fb08d6
commit 0c893e7683
12 changed files with 973 additions and 0 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

@@ -0,0 +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 10
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

@@ -0,0 +1,28 @@
{
"log": {
"level": "debug"
},
"inbounds": [
{
"type": "tun",
"interface_name": "tun0",
"domain_strategy": "ipv4_only",
"inet4_address": "172.16.250.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
}
}