1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00

Merge branch 'develop' into master

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-11-09 19:50:51 +01:00
commit 3e459a2d3a
3 changed files with 37 additions and 21 deletions

View file

@ -56,12 +56,12 @@ _bypass_domain() {
domain=$(echo $domain | sed 's:^\.::') domain=$(echo $domain | sed 's:^\.::')
#logger -t "omr-bypass" "Get IPs of $domain..." #logger -t "omr-bypass" "Get IPs of $domain..."
if [ -z $RELOAD ]; then if [ -z $RELOAD ]; then
resolve=$(dig a +timeout=1 +nocmd +noall +answer $domain | awk '{print $5}') resolve=$(dig a +timeout=1 +tries=1 +nocmd +noall +answer $domain | awk '{print $5}')
for ip in $resolve; do for ip in $resolve; do
_bypass_ip $ip $intf _bypass_ip $ip $intf
done done
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
resolve=$(dig aaaa +timeout=1 +nocmd +noall +answer $domain | awk '{print $5}') resolve=$(dig aaaa +timeout=1 +tries=1 +nocmd +noall +answer $domain | awk '{print $5}')
for ip in $resolve; do for ip in $resolve; do
_bypass_ip $ip $intf _bypass_ip $ip $intf
done done
@ -100,7 +100,7 @@ _bypass_mac() {
-A omr-bypass -m mac --mac-source $mac -j MARK --set-mark 0x539 -A omr-bypass -m mac --mac-source $mac -j MARK --set-mark 0x539
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
-A omr-bypass6 -m mac --mac-source $mac -j MARK --set-mark 0x6539 -A omr-bypass6 -m mac --mac-source $mac -j MARK --set-mark 0x6539
@ -113,7 +113,7 @@ _bypass_mac() {
-A omr-bypass -m mac --mac-source $mac -j MARK --set-mark 0x539$intfid -A omr-bypass -m mac --mac-source $mac -j MARK --set-mark 0x539$intfid
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
-A omr-bypass6 -m mac --mac-source $mac -j MARK --set-mark 0x6539$intfid -A omr-bypass6 -m mac --mac-source $mac -j MARK --set-mark 0x6539$intfid
@ -205,7 +205,7 @@ _bypass_dest_port() {
-A omr-bypass-local --protocol $proto --destination-port $dport -j MARK --set-mark 0x539 -A omr-bypass-local --protocol $proto --destination-port $dport -j MARK --set-mark 0x539
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
-A omr-bypass6 --protocol $proto --destination-port $dport -j MARK --set-mark 0x6539 -A omr-bypass6 --protocol $proto --destination-port $dport -j MARK --set-mark 0x6539
@ -223,7 +223,7 @@ _bypass_dest_port() {
-A omr-bypass-local --protocol $proto --destination-port $dport -j MARK --set-mark 0x539$intfid -A omr-bypass-local --protocol $proto --destination-port $dport -j MARK --set-mark 0x539$intfid
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
-A omr-bypass6 --protocol $proto --destination-port $dport -j MARK --set-mark 0x6539$intfid -A omr-bypass6 --protocol $proto --destination-port $dport -j MARK --set-mark 0x6539$intfid
@ -260,7 +260,7 @@ _bypass_src_port() {
-A omr-bypass-local --protocol $proto --source-port $sport -j MARK --set-mark 0x539 -A omr-bypass-local --protocol $proto --source-port $sport -j MARK --set-mark 0x539
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
-A omr-bypass6 --protocol $proto --source-port $sport -j MARK --set-mark 0x6539 -A omr-bypass6 --protocol $proto --source-port $sport -j MARK --set-mark 0x6539
@ -278,7 +278,7 @@ _bypass_src_port() {
-A omr-bypass-local --protocol $proto --source-port $sport -j MARK --set-mark 0x539$intfid -A omr-bypass-local --protocol $proto --source-port $sport -j MARK --set-mark 0x539$intfid
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
-A omr-bypass6 --protocol $proto --source-port $sport -j MARK --set-mark 0x6539$intfid -A omr-bypass6 --protocol $proto --source-port $sport -j MARK --set-mark 0x6539$intfid
@ -306,7 +306,7 @@ _bypass_proto() {
-A omr-bypass-dpi -m ndpi --proto $proto -j MARK --set-mark 0x539 -A omr-bypass-dpi -m ndpi --proto $proto -j MARK --set-mark 0x539
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
-A omr-bypass6-dpi -m ndpi --proto $proto -j MARK --set-mark 0x6539 -A omr-bypass6-dpi -m ndpi --proto $proto -j MARK --set-mark 0x6539
@ -319,7 +319,7 @@ _bypass_proto() {
-A omr-bypass-dpi -m ndpi --proto $proto -j MARK --set-mark 0x539$intfid -A omr-bypass-dpi -m ndpi --proto $proto -j MARK --set-mark 0x539$intfid
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
-A omr-bypass6-dpi -m ndpi --proto $proto -j MARK --set-mark 0x6539$intfid -A omr-bypass6-dpi -m ndpi --proto $proto -j MARK --set-mark 0x6539$intfid
@ -333,7 +333,22 @@ _bypass_proto() {
if [ -n "$domains" ]; then if [ -n "$domains" ]; then
for domain in $domains; do for domain in $domains; do
if [ -n "$domain" ]; then if [ -n "$domain" ]; then
_bypass_domain $domain $intf domain="$(echo $domain | sed 's/^\.//')"
if [ "$(echo $domain | grep '\.$')" != "" ]; then
tlds=`curl --max-time 4 -s -k https://data.iana.org/TLD/tlds-alpha-by-domain.txt`
if [ -n "tlds" ]; then
i=0
for tld in $tlds; do
i=$((i+1))
tld="$(echo $tld | awk '{print tolower($0)}')"
if [ "$i" -gt "11" ] && [ "$(dig a +timeout=1 +tries=1 +retry=1 +nocmd +noall +answer ${domain}${tld})" != "" ]; then
_bypass_domain ${domain}${tld} $intf
fi
done
fi
else
_bypass_domain $domain $intf
fi
fi fi
done done
fi fi
@ -354,7 +369,7 @@ _intf_rule_ss_rules() {
COMMIT COMMIT
EOF EOF
fi fi
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
if [ "$(ip6tables --wait=40 -t mangle -L -n | grep omr6_dst_bypass_$intf)" = "" ]; then if [ "$(ip6tables --wait=40 -t mangle -L -n | grep omr6_dst_bypass_$intf)" = "" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
@ -393,7 +408,7 @@ _intf_rule_v2ray_rules() {
COMMIT COMMIT
EOF EOF
fi fi
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
if [ "$(ip6tables --wait=40 -t mangle -L -n | grep omr6_dst_bypass_$intf)" = "" ]; then if [ "$(ip6tables --wait=40 -t mangle -L -n | grep omr6_dst_bypass_$intf)" = "" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
@ -524,7 +539,7 @@ _ss_rules_config() {
COMMIT COMMIT
EOF EOF
fi fi
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
if [ "$(ip6tables --wait=40 -t mangle -L -n | grep 'match-set omr6_dst_bypass_all dst MARK set')" = "" ]; then if [ "$(ip6tables --wait=40 -t mangle -L -n | grep 'match-set omr6_dst_bypass_all dst MARK set')" = "" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
@ -563,7 +578,7 @@ _v2ray_rules_config() {
COMMIT COMMIT
EOF EOF
fi fi
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
if [ "$(ip6tables --wait=40 -t mangle -L -n | grep 'match-set omr6_dst_bypass_all dst MARK set')" = "" ]; then if [ "$(ip6tables --wait=40 -t mangle -L -n | grep 'match-set omr6_dst_bypass_all dst MARK set')" = "" ]; then
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
@ -622,7 +637,7 @@ start_service() {
-I OUTPUT -m addrtype ! --dst-type LOCAL -j omr-bypass-local -I OUTPUT -m addrtype ! --dst-type LOCAL -j omr-bypass-local
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-save --counters | grep -v omr-bypass6 | ip6tables-restore -w --counters ip6tables-save --counters | grep -v omr-bypass6 | ip6tables-restore -w --counters
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle
@ -696,7 +711,7 @@ start_service() {
-A POSTROUTING -m addrtype --dst-type LOCAL -j omr-bypass-dpi -A POSTROUTING -m addrtype --dst-type LOCAL -j omr-bypass-dpi
COMMIT COMMIT
EOF EOF
if [ "$disableipv6" != "1" ]; then if [ "$disableipv6" = "0" ]; then
ip6tables-save --counters | grep -v omr-bypass6-dpi | ip6tables-restore -w --counters ip6tables-save --counters | grep -v omr-bypass6-dpi | ip6tables-restore -w --counters
ip6tables-restore -w --wait=60 --noflush <<-EOF ip6tables-restore -w --wait=60 --noflush <<-EOF
*mangle *mangle

View file

@ -659,7 +659,7 @@ function interfaces_status()
-- dns -- dns
mArray.openmptcprouter["dns"] = false mArray.openmptcprouter["dns"] = false
local timeout = uci:get("openmptcprouter","settings","status_getip_timeout") or "2" local timeout = uci:get("openmptcprouter","settings","status_getip_timeout") or "2"
local dns_test = sys.exec("dig +timeout=" .. timeout .. " openmptcprouter.com | grep 'ANSWER: 0'") local dns_test = sys.exec("dig +timeout=" .. timeout .. " +tries=1 openmptcprouter.com | grep 'ANSWER: 0'")
if dns_test == "" then if dns_test == "" then
mArray.openmptcprouter["dns"] = true mArray.openmptcprouter["dns"] = true
end end
@ -683,7 +683,7 @@ function interfaces_status()
if uci:get("openmptcprouter","settings","external_check") ~= "0" and mArray.openmptcprouter["dns"] == true then if uci:get("openmptcprouter","settings","external_check") ~= "0" and mArray.openmptcprouter["dns"] == true then
mArray.openmptcprouter["wan_addr"] = ut.trim(sys.exec("curl -4 -s -m " .. timeout .. " " .. check_ipv4_website)) mArray.openmptcprouter["wan_addr"] = ut.trim(sys.exec("curl -4 -s -m " .. timeout .. " " .. check_ipv4_website))
if mArray.openmptcprouter["wan_addr"] == "" then if mArray.openmptcprouter["wan_addr"] == "" then
mArray.openmptcprouter["wan_addr"] = ut.trim(sys.exec("dig TXT +timeout=" .. timeout .. " +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'\"' '{print $2}'")) mArray.openmptcprouter["wan_addr"] = ut.trim(sys.exec("dig TXT +timeout=" .. timeout .. " +tries=1 +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'\"' '{print $2}'"))
end end
if mArray.openmptcprouter["ipv6"] == "enabled" then if mArray.openmptcprouter["ipv6"] == "enabled" then
mArray.openmptcprouter["wan_addr6"] = uci:get("openmptcprouter","omr","public_detected_ipv6") or "" mArray.openmptcprouter["wan_addr6"] = uci:get("openmptcprouter","omr","public_detected_ipv6") or ""

View file

@ -43,7 +43,8 @@ while true; do
[ "$ipv6_gw" = "::" ] && ipv6_gw='fe80::a00:1' [ "$ipv6_gw" = "::" ] && ipv6_gw='fe80::a00:1'
[ -z "$ipv6_gw" ] && ipv6_gw='fe80::a00:1' [ -z "$ipv6_gw" ] && ipv6_gw='fe80::a00:1'
#[ -z "$ipv6_gw" ] && ipv6_gw='fe80::aff:ff01' #[ -z "$ipv6_gw" ] && ipv6_gw='fe80::aff:ff01'
ip -6 route add ${ipv6_gw} dev 6in4-omr6in4 ip -6 route add ${ipv6_gw} dev 6in4-omr6in4 > /dev/null 2>&1
ip -6 route 2002::/16 dev 6in4-omr6in4 > /dev/null 2>&1
ip -6 route replace default via ${ipv6_gw} dev 6in4-omr6in4 > /dev/null 2>&1 ip -6 route replace default via ${ipv6_gw} dev 6in4-omr6in4 > /dev/null 2>&1
if [ "$(uci -q get openmptcprouter.settings.uci_route)" = "1" ]; then if [ "$(uci -q get openmptcprouter.settings.uci_route)" = "1" ]; then
uci -q batch <<-EOF uci -q batch <<-EOF