mirror of
				https://github.com/Ysurac/openmptcprouter-feeds.git
				synced 2025-03-09 15:40:03 +00:00 
			
		
		
		
	Fix MPTCP over VPN with Wireguard
This commit is contained in:
		
							parent
							
								
									44dc902961
								
							
						
					
					
						commit
						2e533166cc
					
				
					 3 changed files with 81 additions and 21 deletions
				
			
		| 
						 | 
				
			
			@ -1211,7 +1211,7 @@ function interfaces_status()
 | 
			
		|||
	    -- Detect WAN gateway status
 | 
			
		||||
	    local gw_ping = "UP"
 | 
			
		||||
	    local gw_ping6 = "UP"
 | 
			
		||||
	    if ifname ~= nil and not (ifname:match("^tun.*") or interface:match("^ovpn.*")) then
 | 
			
		||||
	    if ifname ~= nil and not (ifname:match("^tun.*") or interface:match("^ovpn.*") or interface:match("^wg.*")) then
 | 
			
		||||
	        if proto ~= "dhcpv6" then
 | 
			
		||||
			gateway = ut.trim(sys.exec("ip -4 r list dev " .. ifname .. " | grep via | grep -v default | grep -v metric | awk '{print $1}' | tr -d '\n'"))
 | 
			
		||||
		end
 | 
			
		||||
| 
						 | 
				
			
			@ -1421,7 +1421,7 @@ function interfaces_status()
 | 
			
		|||
	    local publicIP6 = ""
 | 
			
		||||
 | 
			
		||||
	    if connectivity ~= "ERROR" then
 | 
			
		||||
		    if ifname ~= nil and ifname:match("^tun.*") and interface:match("^ovpn.*") then
 | 
			
		||||
		    if ifname ~= nil and (ifname:match("^tun.*") and interface:match("^ovpn.*")) then
 | 
			
		||||
			    publicIP = uci:get("openmptcprouter",interface:sub(5),"publicip") or ""
 | 
			
		||||
			    if ifname ~= nil and ipaddr ~= "" and publicIP == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
 | 
			
		||||
				    publicIP = ut.trim(sys.exec("omr-ip-intf " .. get_device(interface:sub(5))))
 | 
			
		||||
| 
						 | 
				
			
			@ -1430,6 +1430,15 @@ function interfaces_status()
 | 
			
		|||
			    if ifname ~= nil and ip6addr ~= "" and publicIP6 == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
 | 
			
		||||
				    publicIP6 = ut.trim(sys.exec("omr-ip6-intf " .. get_device(interface:sub(5))))
 | 
			
		||||
			    end
 | 
			
		||||
		    elseif ifname ~= nil and interface:match("^wg.*") then
 | 
			
		||||
			    publicIP = uci:get("openmptcprouter",interface:sub(3),"publicip") or ""
 | 
			
		||||
			    if ifname ~= nil and ipaddr ~= "" and publicIP == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
 | 
			
		||||
				    publicIP = ut.trim(sys.exec("omr-ip-intf " .. get_device(interface:sub(3))))
 | 
			
		||||
			    end
 | 
			
		||||
			    publicIP6 = uci:get("openmptcprouter",interface:sub(3),"publicip6") or ""
 | 
			
		||||
			    if ifname ~= nil and ip6addr ~= "" and publicIP6 == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
 | 
			
		||||
				    publicIP6 = ut.trim(sys.exec("omr-ip6-intf " .. get_device(interface:sub(3))))
 | 
			
		||||
			    end
 | 
			
		||||
		    else
 | 
			
		||||
			    publicIP = uci:get("openmptcprouter",interface,"publicip") or ""
 | 
			
		||||
			    if ifname ~= nil and ipaddr ~= "" and publicIP == "" and mArray.openmptcprouter["external_check"] ~= false and mArray.openmptcprouter["dns"] == true then
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,10 @@ set_route() {
 | 
			
		|||
	[ -z "$SETDEFAULT" ] && SETDEFAULT="yes"
 | 
			
		||||
	multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
 | 
			
		||||
	[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
	}
 | 
			
		||||
	interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +45,10 @@ set_route6() {
 | 
			
		|||
	[ -z "$SETDEFAULT" ] && SETDEFAULT="yes"
 | 
			
		||||
	multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
 | 
			
		||||
	[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
	}
 | 
			
		||||
	interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +84,10 @@ set_server_default_route() {
 | 
			
		|||
		[ "$disabled" = "1" ] && return
 | 
			
		||||
		multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath)
 | 
			
		||||
		[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo "off")
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		}
 | 
			
		||||
		if [ "$serverip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(ip route show dev $OMR_TRACKER_DEVICE metric 1 | grep $serverip | grep $OMR_TRACKER_DEVICE_GATEWAY)" = "" ] && [ "$multipath_config_route" != "off" ]; then
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Set server $server ($serverip) default route via $OMR_TRACKER_DEVICE_GATEWAY"
 | 
			
		||||
			if [ "$(ip r show $serverip | grep nexthop)" != "" ]; then
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +109,10 @@ set_server_default_route6() {
 | 
			
		|||
		[ "$disabled" = "1" ] && return
 | 
			
		||||
		multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath)
 | 
			
		||||
		[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo "off")
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		}
 | 
			
		||||
		if [ "$serverip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY6" != "" ] && [ -n "$OMR_TRACKER_DEVICE" ] && [ "$(ip -6 route show dev $OMR_TRACKER_DEVICE metric 1 | grep $serverip | grep $OMR_TRACKER_DEVICE_GATEWAY6)" = "" ] && [ "$multipath_config_route" != "off" ]; then
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.debug)" = "true" ] && _log "Set server $server ($serverip) default route via $OMR_TRACKER_DEVICE_GATEWAY6"
 | 
			
		||||
			if [ "$(ip -6 r show $serverip | grep nexthop)" != "" ]; then
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +159,10 @@ set_routes_intf() {
 | 
			
		|||
	local INTERFACE=$1
 | 
			
		||||
	multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
 | 
			
		||||
	[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo 'off')"
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
	}
 | 
			
		||||
	interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
 | 
			
		||||
| 
						 | 
				
			
			@ -155,7 +170,8 @@ set_routes_intf() {
 | 
			
		|||
	interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
 | 
			
		||||
	#multipath_current_config=$(multipath $interface_if | grep 'deactivated')
 | 
			
		||||
	interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
 | 
			
		||||
	if [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_if" != "" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
	interface_vpn=$(uci -q get openmptcprouter.$INTERFACE.vpn || echo "0")
 | 
			
		||||
	if [ "$interface_vpn" = "0" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_if" != "" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
		interface_gw="$(uci -q get network.$INTERFACE.gateway)"
 | 
			
		||||
		if [ -z "$interface_gw" ]; then
 | 
			
		||||
			interface_gw=$(ubus call network.interface.$INTERFACE status 2>/dev/null | jsonfilter -q -l 1 -e '@.inactive.route[@.target="0.0.0.0"].nexthop' | tr -d "\n")
 | 
			
		||||
| 
						 | 
				
			
			@ -197,7 +213,10 @@ set_routes_intf6() {
 | 
			
		|||
	local INTERFACE=$1
 | 
			
		||||
	multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
 | 
			
		||||
	[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo 'off')"
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
	}
 | 
			
		||||
	interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
 | 
			
		||||
| 
						 | 
				
			
			@ -205,7 +224,8 @@ set_routes_intf6() {
 | 
			
		|||
	interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
 | 
			
		||||
	#multipath_current_config=$(multipath $interface_if | grep 'deactivated')
 | 
			
		||||
	interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
 | 
			
		||||
	if [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_if" != "" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
	interface_vpn=$(uci -q get openmptcprouter.$INTERFACE.vpn || echo "0")
 | 
			
		||||
	if [ "$interface_vpn" = "0" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_if" != "" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
		interface_gw="$(uci -q get network.$INTERFACE.ip6gw)"
 | 
			
		||||
		interface_ip6="$(uci -q get network.$INTERFACE.ip6)"
 | 
			
		||||
		if [ -z "$interface_gw" ]; then
 | 
			
		||||
| 
						 | 
				
			
			@ -263,14 +283,18 @@ set_route_balancing() {
 | 
			
		|||
	INTERFACE=$1
 | 
			
		||||
	multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
 | 
			
		||||
	[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo 'off')"
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
	}
 | 
			
		||||
	interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
 | 
			
		||||
	[ -n "$(echo $interface_if | grep '@')" ] && interface_if=$(ifstatus "$INTERFACE" | jsonfilter -q -e '@["device"]')
 | 
			
		||||
	interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
 | 
			
		||||
	interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
 | 
			
		||||
	if [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
	interface_vpn=$(uci -q get openmptcprouter.$INTERFACE.vpn || echo "0")
 | 
			
		||||
	if [ "$interface_vpn" = "0" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
		interface_gw="$(uci -q get network.$INTERFACE.gateway)"
 | 
			
		||||
		if [ -z "$interface_gw" ]; then
 | 
			
		||||
			interface_gw=$(ubus call network.interface.$INTERFACE status 2>/dev/null | jsonfilter -q -l 1 -e '@.inactive.route[@.target="0.0.0.0"].nexthop' | tr -d "\n")
 | 
			
		||||
| 
						 | 
				
			
			@ -307,14 +331,18 @@ set_route_balancing6() {
 | 
			
		|||
	INTERFACE=$1
 | 
			
		||||
	multipath_config_route=$(uci -q get openmptcprouter.$INTERFACE.multipath)
 | 
			
		||||
	[ -z "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$INTERFACE.multipath || echo "off")
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo 'off')"
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.$INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${INTERFACE}.multipath || echo "off")"
 | 
			
		||||
	}
 | 
			
		||||
	interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
	[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
 | 
			
		||||
	[ -n "$(echo $interface_if | grep '@')" ] && interface_if=$(ifstatus "$INTERFACE" | jsonfilter -q -e '@["device"]')
 | 
			
		||||
	interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
 | 
			
		||||
	interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
 | 
			
		||||
	if [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
	interface_vpn=$(uci -q get openmptcprouter.$INTERFACE.vpn || echo "0")
 | 
			
		||||
	if [ "$interface_vpn" = "0" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
		interface_gw="$(uci -q get network.$INTERFACE.gateway)"
 | 
			
		||||
		interface_ip6="$(uci -q get network.$INTERFACE.ip6)"
 | 
			
		||||
		if [ -z "$interface_gw" ]; then
 | 
			
		||||
| 
						 | 
				
			
			@ -377,7 +405,10 @@ set_server_all_routes() {
 | 
			
		|||
		interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
 | 
			
		||||
		multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath || echo "off")
 | 
			
		||||
		[ "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo 'off')
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		}
 | 
			
		||||
		if [ "$serverip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
			routesintf=""
 | 
			
		||||
			routesintfbackup=""
 | 
			
		||||
| 
						 | 
				
			
			@ -418,8 +449,10 @@ set_server_all_routes6() {
 | 
			
		|||
		[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
 | 
			
		||||
		interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
 | 
			
		||||
		multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath || echo "off")
 | 
			
		||||
		[ "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo 'off')
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		}
 | 
			
		||||
		if [ "$serverip" != "" ] && [ "$OMR_TRACKER_DEVICE_GATEWAY6" != "" ] && [ "$multipath_config_route" != "off" ] && [ "$interface_up" = "true" ]; then
 | 
			
		||||
			routesintf=""
 | 
			
		||||
			routesintfbackup=""
 | 
			
		||||
| 
						 | 
				
			
			@ -460,7 +493,10 @@ set_server_route() {
 | 
			
		|||
		[ -z "$metric" ] && metric=$(uci -q get network.$OMR_TRACKER_INTERFACE.metric)
 | 
			
		||||
		multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath)
 | 
			
		||||
		[ "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo "off")
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		}
 | 
			
		||||
		interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.ifname)
 | 
			
		||||
		[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
		[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
| 
						 | 
				
			
			@ -492,7 +528,10 @@ set_server_route6() {
 | 
			
		|||
		[ -z "$metric" ] && metric=$(uci -q get network.$OMR_TRACKER_INTERFACE.metric)
 | 
			
		||||
		multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath)
 | 
			
		||||
		[ "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo "off")
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
			[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
		}
 | 
			
		||||
		interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.ifname)
 | 
			
		||||
		[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
		[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
 | 
			
		||||
| 
						 | 
				
			
			@ -813,6 +852,14 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
 | 
			
		|||
	exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" = "1" ]; then
 | 
			
		||||
	if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.state)" != "up" ]; then
 | 
			
		||||
		uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up'
 | 
			
		||||
		uci -q commit openmptcprouter
 | 
			
		||||
	fi
 | 
			
		||||
	exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ "$OMR_TRACKER_PREV_STATUS" != "" ] && [ "$OMR_TRACKER_PREV_STATUS" != "$OMR_TRACKER_STATUS" ]; then
 | 
			
		||||
	_log "$OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) switched up"
 | 
			
		||||
	mail_alert="$(uci -q get omr-tracker.$OMR_TRACKER_INTERFACE.mail_alert)"
 | 
			
		||||
| 
						 | 
				
			
			@ -840,7 +887,11 @@ fi
 | 
			
		|||
 | 
			
		||||
multipath_config=$(uci -q get "openmtpcprouter.$OMR_TRACKER_INTERFACE.multipath")
 | 
			
		||||
[ -z "$multipath_config" ] && multipath_config=$(uci -q get "network.$OMR_TRACKER_INTERFACE.multipath" || echo "off")
 | 
			
		||||
[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && multipath_config="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
[ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipathvpn)" = "1" ] && {
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ] && multipath_config_route="$(uci -q get openmptcprouter.ovpn${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
	[ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "wireguard" ] && multipath_config_route="$(uci -q get openmptcprouter.wg${OMR_TRACKER_INTERFACE}.multipath || echo "off")"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [ "$multipath_config" = "master" ]; then
 | 
			
		||||
	#if ([ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && ([ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ] || [ "$(uci -q get openmptcprouter.settings.vpn)" = "mlvpn" ]); then
 | 
			
		||||
	if ([ "$default_gw" != "$OMR_TRACKER_DEVICE_GATEWAY" ] || [ "$default_gw" = "" ]) && [ "$OMR_TRACKER_DEVICE_GATEWAY" != "" ] && [ "$(uci -q get openmptcprouter.settings.master)" != "balancing" ]; then
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -173,7 +173,7 @@ _set_wireguard_vps() {
 | 
			
		|||
		local interface=$1
 | 
			
		||||
		proto=$(uci -q get network.${interface}.proto)
 | 
			
		||||
		if [ "$proto" = "wireguard" ]; then
 | 
			
		||||
			ip="$(uci -q get network.${interface}.addresses)"
 | 
			
		||||
			ip="$(uci -q get network.${interface}.addresses | cut -d/ -f1)"
 | 
			
		||||
			key="$(uci -q get network.${interface}.public_key)"
 | 
			
		||||
			if [ -z "$ipskey" ]; then
 | 
			
		||||
				ipskey='{"ip": "'$ip'", "key": "'$key'"}'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue