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

Refresh MTCPoverVPN ip in post tracking and some fixes

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-05-20 10:06:51 +02:00
parent 75637bbb9a
commit 10fa57001b

View file

@ -124,8 +124,8 @@ set_server_all_routes() {
routesintf="" routesintf=""
config_load network config_load network
config_foreach set_routes_intf interface config_foreach set_routes_intf interface
[ -n "$routesintf" ] && [ "$(echo $routesintf | grep $OMR_TRACKER_DEVICE_GATEWAY)" != "" ] && { [ -n "$routesintf" ] && [ "$(echo $routesintf | grep $OMR_TRACKER_DEVICE_GATEWAY | grep $OMR_TRACKER_DEVICE)" != "" ] && {
_log "Set server $server default route $serverip $routesintf" _log "Set server $server ($serverip) default route $serverip $routesintf"
ip route replace $serverip scope global $routesintf ip route replace $serverip scope global $routesintf
} }
fi fi
@ -250,6 +250,15 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
if [ -n "$OMR_TRACKER_DEVICE_IP" ]; then if [ -n "$OMR_TRACKER_DEVICE_IP" ]; then
glorytun-udp path $OMR_TRACKER_DEVICE_IP dev tun0 down > /dev/null 2>&1 glorytun-udp path $OMR_TRACKER_DEVICE_IP dev tun0 down > /dev/null 2>&1
fi fi
if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" = "1" ]; then
VPN_BASE_INTF="$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.baseintf)"
VPN_BASE_INTF_IP=$(ubus call network.interface.$VPN_BASE_INTF status | jsonfilter -e '@["ipv4-address"][0].address' | tr -d "\n")
uci -q batch <<-EOF >/dev/null
set openvpn.$VPN_BASE_INTF.local=$VPN_BASE_INTF_IP
commit openvpn
EOF
/etc/init.d/openvpn restart $VPN_BASE_INTF
fi
config_load openmptcprouter config_load openmptcprouter
config_foreach del_server_route server config_foreach del_server_route server
#if [ "$(uci -q get openmptcprouter.settings.master)" = "balancing" ]; then #if [ "$(uci -q get openmptcprouter.settings.master)" = "balancing" ]; then
@ -473,28 +482,28 @@ if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(
fi fi
[ -n "$ipaddr" ] && { [ -n "$ipaddr" ] && {
# Check if we can get a IPv6 address, if yes enable RA else disable # Check if we can get a IPv6 address, if yes enable RA else disable
local check_ipv6_website="$(uci -q get openmptcprouter.settings.check_ipv6_website)" #local check_ipv6_website="$(uci -q get openmptcprouter.settings.check_ipv6_website)"
[ -z "$check_ipv6_website" ] && check_ipv6_website="http://ipv6.openmptcprouter.com/" #[ -z "$check_ipv6_website" ] && check_ipv6_website="http://ipv6.openmptcprouter.com/"
local ip6addr="$(curl -s -6 -m 2 $check_ipv6_website)" #local ip6addr="$(curl -s -6 -m 2 $check_ipv6_website)"
[ -z "$ip6addr" ] && { #[ -z "$ip6addr" ] && {
local ip6addr="$(curl -s -6 -m 2 http://ifconfig.co/)" # local ip6addr="$(curl -s -6 -m 2 http://ifconfig.co/)"
} #}
if [ "$(uci -q get openmptcprouter.settings.ipv6_disable)" = "0" ]; then #if [ "$(uci -q get openmptcprouter.settings.ipv6_disable)" = "0" ]; then
if [ -n "$ip6addr" ] && [ "$(uci -q get dhcp.lan.ra_default)" != 1 ]; then # if [ -n "$ip6addr" ] && [ "$(uci -q get dhcp.lan.ra_default)" != 1 ]; then
_log "Enable IPv6 RA" # _log "Enable IPv6 RA"
uci -q set dhcp.lan.ra=server # uci -q set dhcp.lan.ra=server
uci -q set dhcp.lan.ra_default=1 # uci -q set dhcp.lan.ra_default=1
uci -q set dhcp.lan.dhcpv6=server # uci -q set dhcp.lan.dhcpv6=server
/etc/init.d/odhcpd start > /dev/null 2>&1 # /etc/init.d/odhcpd start > /dev/null 2>&1
/etc/init.d/odhcpd enable > /dev/null 2>&1 # /etc/init.d/odhcpd enable > /dev/null 2>&1
elif [ -z "$ip6addr" ] && [ "$(uci -q set dhcp.lan.ra_default)" = 1 ]; then # elif [ -z "$ip6addr" ] && [ "$(uci -q set dhcp.lan.ra_default)" = 1 ]; then
_log "Disable IPv6 RA" # _log "Disable IPv6 RA"
uci -q delete dhcp.lan.ra # uci -q delete dhcp.lan.ra
uci -q delete dhcp.lan.dhcpv6 # uci -q delete dhcp.lan.dhcpv6
/etc/init.d/odhcpd start > /dev/null 2>&1 # /etc/init.d/odhcpd start > /dev/null 2>&1
/etc/init.d/odhcpd enable > /dev/null 2>&1 # /etc/init.d/odhcpd enable > /dev/null 2>&1
fi # fi
fi #fi
if [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ]; then if [ "$(uci -q get openmptcprouter.settings.external_check)" != "0" ]; then
local asn="$(wget -4 -qO- -T 4 http://api.iptoasn.com/v1/as/ip/$ipaddr | jsonfilter -q -e '@.as_description')" local asn="$(wget -4 -qO- -T 4 http://api.iptoasn.com/v1/as/ip/$ipaddr | jsonfilter -q -e '@.as_description')"
[ -z "$asn" ] && { [ -z "$asn" ] && {