mirror of
https://github.com/itdoginfo/ansible-openwrt-hirkn.git
synced 2025-12-31 20:03:35 +05:00
Create ansible role
This commit is contained in:
5
domain-routing-openwrt/templates/config-sing-box.j2
Normal file
5
domain-routing-openwrt/templates/config-sing-box.j2
Normal 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'
|
||||
8
domain-routing-openwrt/templates/openwrt-30-vpnroute.j2
Normal file
8
domain-routing-openwrt/templates/openwrt-30-vpnroute.j2
Normal 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 %}
|
||||
70
domain-routing-openwrt/templates/openwrt-getdomains.j2
Normal file
70
domain-routing-openwrt/templates/openwrt-getdomains.j2
Normal 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 %}
|
||||
}
|
||||
28
domain-routing-openwrt/templates/sing-box-json.j2
Normal file
28
domain-routing-openwrt/templates/sing-box-json.j2
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user