mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add option to enable/disable contact to external sites
This commit is contained in:
parent
42dc25894a
commit
9e50e93153
4 changed files with 59 additions and 29 deletions
|
@ -237,6 +237,10 @@ function wizard_add()
|
|||
-- Enable/disable IPv6
|
||||
local disable_ipv6 = luci.http.formvalue("enableipv6") or "1"
|
||||
set_ipv6_state(disable_ipv6)
|
||||
|
||||
-- Enable/disable external check
|
||||
local externalcheck = luci.http.formvalue("externalcheck") or "1"
|
||||
ucic:set("openmptcprouter","settings","external_check",externalcheck)
|
||||
|
||||
-- Get VPN set by default
|
||||
local default_vpn = luci.http.formvalue("default_vpn") or "glorytun_tcp"
|
||||
|
|
|
@ -128,6 +128,12 @@
|
|||
<input type="checkbox" name="enableipv6" class="cbi-input-checkbox" value="0" <% if luci.model.uci.cursor():get("openmptcprouter","settings","disable_ipv6") == "0" then %>checked<% end %>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Enable external check%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input type="checkbox" name="externalcheck" class="cbi-input-checkbox" value="0" <% if luci.model.uci.cursor():get("openmptcprouter","settings","external_check") == "0" then %>checked<% end %>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Master interface selection%></label>
|
||||
<div class="cbi-value-field">
|
||||
|
|
|
@ -75,6 +75,16 @@ _post_tracking() {
|
|||
done
|
||||
}
|
||||
|
||||
_ping_server() {
|
||||
local serverip=$(uci -q get openmptcprouter.$1.ip)
|
||||
local deviceip=$2
|
||||
_ping $serverip $deviceip no
|
||||
statusp=$?
|
||||
if $(exit $statusp); then
|
||||
serverip_ping=true
|
||||
fi
|
||||
}
|
||||
|
||||
_ping() {
|
||||
local host=$1
|
||||
local deviceip=$2
|
||||
|
@ -145,6 +155,7 @@ while true; do
|
|||
OMR_TRACKER_LATENCY=
|
||||
OMR_TRACKER_TIMEOUT=$((rto / 1000 + (rto % 1000 ? 1 : 0)))
|
||||
OMR_TRACKER_LIST_HOSTS=""
|
||||
serverip_ping=false
|
||||
|
||||
if [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then
|
||||
# retrieve iface ip and gateway
|
||||
|
@ -190,33 +201,40 @@ while true; do
|
|||
if ! $(exit $status); then
|
||||
OMR_TRACKER_STATUS_MSG="gateway down"
|
||||
fi
|
||||
# Check if route is not used
|
||||
while ! ip route add $OMR_TRACKER_HOST via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE src $OMR_TRACKER_DEVICE_IP > /dev/null 2&>1
|
||||
do
|
||||
ip route del "$OMR_TRACKER_HOST" via "$OMR_TRACKER_DEVICE_GATEWAY" dev "$OMR_TRACKER_DEVICE" src "$OMR_TRACKER_DEVICE_IP" > /dev/null 2&>1
|
||||
sleep 1
|
||||
_restart
|
||||
done
|
||||
serverip_ping=false
|
||||
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
|
||||
_ping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
statusb=$?
|
||||
elif [ "$OMR_TRACKER_TYPE" = "httping" ]; then
|
||||
_httping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
statusb=$?
|
||||
elif [ "$OMR_TRACKER_TYPE" = "dns" ]; then
|
||||
_dns "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
statusb=$?
|
||||
config_load openmptcprouter
|
||||
config_foreach _ping_server server $OMR_TRACKER_DEVICE_IP
|
||||
fi
|
||||
ip route del "$OMR_TRACKER_HOST" via "$OMR_TRACKER_DEVICE_GATEWAY" dev "$OMR_TRACKER_DEVICE" src "$OMR_TRACKER_DEVICE_IP" > /dev/null 2&>1
|
||||
if $(exit $statusb); then
|
||||
OMR_TRACKER_STATUS_MSG=""
|
||||
OMR_TRACKER_STATUS="OK"
|
||||
break
|
||||
else
|
||||
if [ "$OMR_TRACKER_LIST_HOSTS" = "" ]; then
|
||||
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_HOST"
|
||||
if [ "$serverip_ping" = false ]; then
|
||||
# Check if route is not used
|
||||
while ! ip route add $OMR_TRACKER_HOST via $OMR_TRACKER_DEVICE_GATEWAY dev $OMR_TRACKER_DEVICE src $OMR_TRACKER_DEVICE_IP > /dev/null 2&>1
|
||||
do
|
||||
ip route del "$OMR_TRACKER_HOST" via "$OMR_TRACKER_DEVICE_GATEWAY" dev "$OMR_TRACKER_DEVICE" src "$OMR_TRACKER_DEVICE_IP" > /dev/null 2&>1
|
||||
sleep 1
|
||||
_restart
|
||||
done
|
||||
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
|
||||
_ping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
statusb=$?
|
||||
elif [ "$OMR_TRACKER_TYPE" = "httping" ]; then
|
||||
_httping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
statusb=$?
|
||||
elif [ "$OMR_TRACKER_TYPE" = "dns" ]; then
|
||||
_dns "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
statusb=$?
|
||||
fi
|
||||
ip route del "$OMR_TRACKER_HOST" via "$OMR_TRACKER_DEVICE_GATEWAY" dev "$OMR_TRACKER_DEVICE" src "$OMR_TRACKER_DEVICE_IP" > /dev/null 2&>1
|
||||
if $(exit $statusb); then
|
||||
OMR_TRACKER_STATUS_MSG=""
|
||||
OMR_TRACKER_STATUS="OK"
|
||||
break
|
||||
else
|
||||
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_LIST_HOSTS,$OMR_TRACKER_HOST"
|
||||
if [ "$OMR_TRACKER_LIST_HOSTS" = "" ]; then
|
||||
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_HOST"
|
||||
else
|
||||
OMR_TRACKER_LIST_HOSTS="$OMR_TRACKER_LIST_HOSTS,$OMR_TRACKER_HOST"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
elif ! $(exit $status); then
|
||||
|
|
|
@ -10,11 +10,13 @@ log() {
|
|||
|
||||
get_ip() {
|
||||
uci -q set openmptcprouter.omr=router
|
||||
uci -q set openmptcprouter.omr.detected_public_ipv4="$(wget -4 -qO- -T 3 http://ip.openmptcprouter.com)"
|
||||
uci -q set openmptcprouter.omr.detected_ss_ipv4=$(curl -s -4 --socks5 "${proxy}" --max-time 3 http://ip.openmptcprouter.com)
|
||||
if [ "$(uci -q get openmptcprouter.settings.disable_ipv6)" != "1" ]; then
|
||||
uci -q set openmptcprouter.omr.detected_public_ipv6=$(wget -6 -qO- -T 3 http://ip.openmptcprouter.com)
|
||||
# uci -q set openmptcprouter.omr.detected_ss_ipv6=$(curl -s -6 --socks5 ":::1111" --max-time 3 http://ip.openmptcprouter.com)
|
||||
if [ "$(uci -q openmptcprouter.settings.external_check)" != "0" ]; then
|
||||
uci -q set openmptcprouter.omr.detected_public_ipv4="$(wget -4 -qO- -T 3 http://ip.openmptcprouter.com)"
|
||||
uci -q set openmptcprouter.omr.detected_ss_ipv4=$(curl -s -4 --socks5 "${proxy}" --max-time 3 http://ip.openmptcprouter.com)
|
||||
if [ "$(uci -q get openmptcprouter.settings.disable_ipv6)" != "1" ]; then
|
||||
uci -q set openmptcprouter.omr.detected_public_ipv6=$(wget -6 -qO- -T 3 http://ip.openmptcprouter.com)
|
||||
# uci -q set openmptcprouter.omr.detected_ss_ipv6=$(curl -s -6 --socks5 ":::1111" --max-time 3 http://ip.openmptcprouter.com)
|
||||
fi
|
||||
fi
|
||||
uci -q commit openmptcprouter.omr
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue