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

Fix related to MPTCP over VPN

This commit is contained in:
Ycarus (Yannick Chabanois) 2021-05-17 12:29:08 +02:00
parent 54baf79957
commit d0c34a4cc8
4 changed files with 28 additions and 11 deletions

View file

@ -908,12 +908,12 @@ function wizard_add()
luci.sys.call("/etc/init.d/glorytun-udp restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/mlvpn restart >/dev/null 2>/dev/null")
--luci.sys.call("/etc/init.d/ubond restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/mptcpovervpn restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/openvpn restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/openvpnbonding restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/dsvpn restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/omr-tracker start >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/omr-6in4 restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/mptcpovervpn restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/vnstat restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/v2ray restart >/dev/null 2>/dev/null")
luci.http.redirect(luci.dispatcher.build_url("admin/system/" .. menuentry:lower() .. "/status"))

View file

@ -171,7 +171,7 @@ set_routes_intf() {
#multipath_current_config=$(multipath $interface_if | grep 'deactivated')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
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
if ([ "$interface_vpn" = "0" ] || [ "$(uci -q get openmptcprouter.settings.allmptcpovervpn)" = "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")
@ -225,7 +225,7 @@ set_routes_intf6() {
#multipath_current_config=$(multipath $interface_if | grep 'deactivated')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
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
if ([ "$interface_vpn" = "0" ] || [ "$(uci -q get openmptcprouter.settings.allmptcpovervpn)" = "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
@ -294,7 +294,7 @@ set_route_balancing() {
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
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
if ([ "$interface_vpn" = "0" ] || [ "$(uci -q get openmptcprouter.settings.allmptcpovervpn)" = "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")
@ -342,7 +342,7 @@ set_route_balancing6() {
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
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
if ([ "$interface_vpn" = "0" ] || [ "$(uci -q get openmptcprouter.settings.allmptcpovervpn)" = "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
@ -672,7 +672,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
if [ -n "$OMR_TRACKER_DEVICE_IP6" ]; then
glorytun-udp path addr $OMR_TRACKER_DEVICE_IP6 dev tun0 set down > /dev/null 2>&1
fi
if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" = "1" ]; then
if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.vpn)" = "1" ] && [ "$(uci -q get openmptcprouter.settings.mptcpovervpn)" = "openvpn" ]; 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

View file

@ -1,5 +1,5 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2019 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
# Copyright (C) 2019 - 2021 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
# Released under GPL 3. See LICENSE for the full terms.
{
@ -25,7 +25,7 @@ _getremoteip() {
mptcp_over_vpn() {
local interface=$1
nbintf=$(($nbintf+1))
[ -n "$(uci show firewall.zone_wan.network | grep $interface)" ] && nbintf=$(($nbintf+1))
if [ "$(uci -q get openmptcprouter.${interface}.multipathvpn)" = "1" ]; then
if [ "$(uci -q get network.${interface})" = "" ]; then
uci -q batch <<-EOF >/dev/null
@ -218,6 +218,17 @@ start_service()
[ -z "$vpn" ] && vpn="openvpn"
config_load openmptcprouter
config_foreach mptcp_over_vpn interface
if [ "$nbintf" = "$nbintfvpn" ] && [ "$nbintf" != "0" ] && [ "$nbintfvpn" != "0" ]; then
uci -q batch <<-EOF >/dev/null
set openmptcprouter.settings.allmptcpovervpn='1'
commit openmptcprouter
EOF
else
uci -q batch <<-EOF >/dev/null
set openmptcprouter.settings.allmptcpovervpn='0'
commit openmptcprouter
EOF
fi
if [ "$nbintf" = "$nbintfvpn" ] && [ "$nbintf" != "0" ]; then
if [ "$vpn" = "openvpn" ]; then
uci -q batch <<-EOF >/dev/null
@ -286,6 +297,8 @@ start_service()
uci -q batch <<-EOF >/dev/null
commit shadowsocks-libev
EOF
/etc/init.d/shadowsocks restart
/etc/init.d/openvpn restart
elif [ "$(uci -q get shadowsocks-libev.hivpn1)" != "" ]; then
for c in $(seq 1 $NBCPU); do
uci -q batch <<-EOF >/dev/null

View file

@ -185,8 +185,12 @@ _set_wireguard_vps() {
config_load network
config_foreach _get_wg_ipskey interface
local settings
settings='{"peers": ['$ipskey']}'
echo $(_set_json "wireguard" "$settings")
if [ -n "$ipskey" ]; then
settings='{"peers": ['$ipskey']}'
echo $(_set_json "wireguard" "$settings")
else
echo 1
fi
}
get_openvpn_key() {
@ -1808,7 +1812,7 @@ _config_service() {
[ -z "$(_set_openvpn_vps)" ] && error=1
[ -z "$(_set_mlvpn_vps)" ] && error=1
_set_vps_firewall
_set_wireguard_vps
[ -z "$(_set_wireguard_vps)" ] && error=1
fi
_backup_list
redirect_port="0"