diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua
index b294af40c..c9a264ed8 100644
--- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua
+++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua
@@ -631,8 +631,8 @@ function wizard_add()
ucic:set("glorytun","vpn","remoteip","10.255.255.1")
ucic:set("network","omr6in4","ipaddr","10.255.255.2")
ucic:set("network","omr6in4","peeraddr","10.255.255.1")
+ ucic:set("network","omrvpn","proto","none")
end
- ucic:set("network","omrvpn","proto","none")
else
ucic:set("glorytun","vpn","key","")
--ucic:set("glorytun","vpn","enable",0)
@@ -656,8 +656,8 @@ function wizard_add()
ucic:set("glorytun-udp","vpn","remoteip","10.255.254.1")
ucic:set("network","omr6in4","ipaddr","10.255.254.2")
ucic:set("network","omr6in4","peeraddr","10.255.254.1")
+ ucic:set("network","omrvpn","proto","none")
end
- ucic:set("network","omrvpn","proto","none")
else
ucic:set("glorytun-udp","vpn","key","")
end
@@ -677,9 +677,11 @@ function wizard_add()
ucic:set("dsvpn","vpn","key",dsvpn_key)
ucic:set("dsvpn","vpn","localip","10.255.251.2")
ucic:set("dsvpn","vpn","remoteip","10.255.251.1")
- ucic:set("network","omr6in4","ipaddr","10.255.251.2")
- ucic:set("network","omr6in4","peeraddr","10.255.251.1")
- ucic:set("network","omrvpn","proto","none")
+ if default_vpn == "dsvpn" then
+ ucic:set("network","omr6in4","ipaddr","10.255.251.2")
+ ucic:set("network","omr6in4","peeraddr","10.255.251.1")
+ ucic:set("network","omrvpn","proto","none")
+ end
else
ucic:set("dsvpn","vpn","key","")
--ucic:set("dsvpn","vpn","enable",0)
@@ -770,6 +772,7 @@ function wizard_add()
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/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")
diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm
index d8cda41f8..66a5b2b00 100644
--- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm
+++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm
@@ -306,6 +306,8 @@
<% if nixio.fs.access("/usr/sbin/ubond") then %><% end %>
<% elseif vpn == "openvpn" then %>
<% if nixio.fs.access("/etc/init.d/openvpn") then %><% end %>
+ <% elseif vpn == "openvpn_bonding" then %>
+ <% if nixio.fs.access("/etc/init.d/openvpnbonding") then %><% end %>
<%
end
end
@@ -319,7 +321,8 @@
<% if nixio.fs.access("/usr/sbin/dsvpn") then %><% end %>
<% if nixio.fs.access("/usr/sbin/mlvpn") then %><% end %>
<% if nixio.fs.access("/usr/sbin/ubond") then %><% end %>
- <% if nixio.fs.access("/usr/sbin/openvpn") then %><% end %>
+ <% if nixio.fs.access("/etc/init.d/openvpn") then %><% end %>
+ <% if nixio.fs.access("/etc/init.d/openvpnbonding") then %><% end %>
<%
end
diff --git a/openmptcprouter-full/Makefile b/openmptcprouter-full/Makefile
index 8578a2d95..9625904b5 100644
--- a/openmptcprouter-full/Makefile
+++ b/openmptcprouter-full/Makefile
@@ -80,7 +80,7 @@ MY_DEPENDS := \
!TARGET_mvebu:luci-proto-qmi wpad-basic kmod-mt7601u kmod-rtl8187 \
luci-app-mlvpn mlvpn 464xlat !TARGET_mvebu:kmod-usb-net-smsc75xx kmod-zram kmod-swconfig swconfig kmod-ipt-nat kmod-ipt-nat6 luci-app-https-dns-proxy kmod-tcp-nanqinlang (TARGET_x86_64||TARGET_arm64):kmod-tcp-bbr2 iptables-mod-ipopt igmpproxy ss iptraf-ng \
luci-app-acl block-mount blockd fstools luci-app-shutdown libwebp luci-proto-gre tcptraceroute luci-proto-mbim kmod-rtl8xxxu kmod-ath9k-htc luci-app-ttyd luci-mod-dashboard (TARGET_x86||TARGET_x86_64):rtl8192eu-firmware kmod-usb2 libustream-wolfssl (TARGET_x86||TARGET_x86_64):kmod-ixgbevf \
- hwinfo (TARGET_x86||TARGET_x86_64):dmidecode luci-app-packet-capture
+ hwinfo (TARGET_x86||TARGET_x86_64):dmidecode luci-app-packet-capture kmod-bonding luci-proto-bonding
# luci-theme-bootstrap luci-theme-openwrt-2020 luci-theme-openwrt luci-app-status
# luci-proto-bonding luci-app-statistics luci-proto-gre
# softethervpn5-client softethervpn5-server luci-app-nginx-ha
diff --git a/openmptcprouter/files/etc/init.d/openvpnbonding b/openmptcprouter/files/etc/init.d/openvpnbonding
new file mode 100755
index 000000000..f0ba915fa
--- /dev/null
+++ b/openmptcprouter/files/etc/init.d/openvpnbonding
@@ -0,0 +1,95 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2020 Ycarus (Yannick Chabanois) for OpenMPTCProuter
+# Released under GPL 3. See LICENSE for the full terms.
+
+{
+ START=70
+ STOP=10
+ USE_PROCD=1
+}
+
+_getremoteip() {
+ [ "$(uci -q get openmptcprouter.$1.master)" = "1" ] && remoteip=$(uci -q get openmptcprouter.$1.ip)
+}
+
+_openvpnbonding() {
+ local interface=$1
+ if [ "$(uci -q get openmptcprouter.${interface}.multipath)" = "master" ] || [ "$(uci -q get openmptcprouter.${interface}.multipath)" = "on" ]; then
+ nbintf=$(($nbintf+1))
+ remoteip=""
+ config_load openmptcprouter
+ config_foreach _getremoteip server
+ if [ -n "$remoteip" ]; then
+ localip=$(ubus call network.interface.$interface status | jsonfilter -e '@["ipv4-address"][0].address' | tr -d "\n")
+ uci -q batch <<-EOF >/dev/null
+ set openvpn.omr_bonding_${interface}=openvpn
+ set openvpn.omr_bonding_${interface}.dev="bond${interface}"
+ set openvpn.omr_bonding_${interface}.dev_type="tap"
+ set openvpn.omr_bonding_${interface}.cipher='AES-256-CBC'
+ set openvpn.omr_bonding_${interface}.port="6535${nbintf}"
+ set openvpn.omr_bonding_${interface}.remote="${remoteip}"
+ set openvpn.omr_bonding_${interface}.local="${localip}"
+ set openvpn.omr_bonding_${interface}.lport='0'
+ set openvpn.omr_bonding_${interface}.ncp_disable='1'
+ set openvpn.omr_bonding_${interface}.auth_nocache='1'
+ set openvpn.omr_bonding_${interface}.proto='udp'
+ set openvpn.omr_bonding_${interface}.client='1'
+ set openvpn.omr_bonding_${interface}.tls_client='1'
+ set openvpn.omr_bonding_${interface}.enabled='1'
+ set openvpn.omr_bonding_${interface}.key='/etc/luci-uploads/client.key'
+ set openvpn.omr_bonding_${interface}.cert='/etc/luci-uploads/client.crt'
+ set openvpn.omr_bonding_${interface}.ca='/etc/luci-uploads/ca.crt'
+ commit openvpn
+ EOF
+ if [ "$(uci -q get network.omrvpn.slaves | grep bond${interface})" = "" ]; then
+ uci -q add_list network.omrvpn.slaves="bond${interface}"
+ fi
+ /etc/init.d/openvpn start omr_bonding_${interface}
+ ip link set bond${interface} master bonding-omrvpn
+ fi
+ fi
+}
+
+_disable_openvpnbonding()
+{
+ name=$1
+ if [ "$(echo $name | grep omr_bonding)" != "" ]; then
+ uci -q set openvpn.${name}.enabled='0'
+ fi
+}
+
+start_service()
+{
+ if [ "$(uci -q get openmptcprouter.settings.vpn)" = "openvpn_bonding" ]; then
+ nbintf=0
+ uci -q batch <<-EOF >/dev/null
+ set network.omrvpn.proto='bonding'
+ set network.omrvpn.bonding_policy='balance-rr'
+ set network.omrvpn.packets_per_slave='1'
+ set network.omrvpn.xmit_hash_policy='layer2'
+ set network.omrvpn.all_slaves_active='0'
+ set network.omrvpn.netmask='255.255.255.0'
+ set network.omrvpn.ipaddr='10.255.248.2'
+ set network.omrvpn.link_monitoring='mii'
+ set network.omrvpn.miimon='10'
+ set network.omrvpn.downdelay='100'
+ set network.omrvpn.updelay='20'
+ set network.omrvpn.use_carrier='1'
+ commit network
+ EOF
+ config_load openmptcprouter
+ config_foreach _openvpnbonding interface
+ ip link set bonding-omrvpn up
+ uci -q batch <<-EOF >/dev/null
+ commit network
+ EOF
+ else
+ config_load openvpn
+ config_foreach _disable_openvpnbonding
+ uci -q commit openvpn
+ fi
+}
+
+service_triggers() {
+ procd_add_reload_trigger "openvpn" "network"
+}
\ No newline at end of file