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

Site used to detect public IPv4 or IPv6 can be changed by settings

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-07-29 10:36:22 +02:00
parent 6e3e48a693
commit 9edcbba492
5 changed files with 33 additions and 11 deletions

View file

@ -1,7 +1,9 @@
#!/bin/sh
checkip=$(dig +short A ip.openmptcprouter.com | tr -d "\n")
check_ipv4_website="$(uci -q get openmptcprouter.settings.check_ipv4_website)"
[ -z "$check_ipv4_website" ] && check_ipv4_website="http://ip.openmptcprouter.com"
checkip=$(echo $check_ipv4_website | sed -e 's/https:\/\///' -e 's/http:\/\///' | xargs dig +short A | tr -d "\n")
ipset add ss_rules_dst_bypass_all $checkip > /dev/null 2>&1
ip="$(curl -s -4 -m 3 --interface $1 http://ip.openmptcprouter.com)"
ip="$(curl -s -4 -m 3 --interface $1 $check_ipv4_website)"
ipset del ss_rules_dst_bypass_all $checkip > /dev/null 2>&1
if expr "$ip" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then
echo $ip