1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-vps.git synced 2025-02-12 11:21:56 +00:00

Update API, kernel and add OpenVPN Bonding support

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-12-16 15:44:13 +00:00
parent 3a0fde41b4
commit e0fbb8faa9
5 changed files with 57 additions and 12 deletions

View file

@ -15,7 +15,7 @@ OBFS=${OBFS:-yes}
V2RAY_PLUGIN=${V2RAY_PLUGIN:-yes} V2RAY_PLUGIN=${V2RAY_PLUGIN:-yes}
V2RAY=${V2RAY:-yes} V2RAY=${V2RAY:-yes}
V2RAY_UUID=${V2RAY_UUID:-$(cat /proc/sys/kernel/random/uuid | tr -d "\n")} V2RAY_UUID=${V2RAY_UUID:-$(cat /proc/sys/kernel/random/uuid | tr -d "\n")}
UPDATE_OS=${UPDATE_OS:-yes} UPDATE_O7S=${UPDATE_OS:-yes}
UPDATE=${UPDATE:-yes} UPDATE=${UPDATE:-yes}
TLS=${TLS:-yes} TLS=${TLS:-yes}
OMR_ADMIN=${OMR_ADMIN:-yes} OMR_ADMIN=${OMR_ADMIN:-yes}
@ -32,17 +32,17 @@ NOINTERNET=${NOINTERNET:-no}
SPEEDTEST=${SPEEDTEST:-no} SPEEDTEST=${SPEEDTEST:-no}
LOCALFILES=${LOCALFILES:-no} LOCALFILES=${LOCALFILES:-no}
INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | grep -m 1 -Po '(?<=dev )(\S+)' | tr -d "\n")} INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | grep -m 1 -Po '(?<=dev )(\S+)' | tr -d "\n")}
KERNEL_VERSION="5.4.74" KERNEL_VERSION="5.4.81"
KERNEL_PACKAGE_VERSION="1.14+9d3f35b" KERNEL_PACKAGE_VERSION="1.15+9d3f35b"
KERNEL_RELEASE="${KERNEL_VERSION}-mptcp_${KERNEL_PACKAGE_VERSION}" KERNEL_RELEASE="${KERNEL_VERSION}-mptcp_${KERNEL_PACKAGE_VERSION}"
GLORYTUN_UDP_VERSION="32267e86a6da05b285bb3bf2b136c105dc0af4bb" GLORYTUN_UDP_VERSION="32267e86a6da05b285bb3bf2b136c105dc0af4bb"
#MLVPN_VERSION="8f9720978b28c1954f9f229525333547283316d2" #MLVPN_VERSION="8f9720978b28c1954f9f229525333547283316d2"
MLVPN_VERSION="f45cec350a6879b8b020143a78134a022b5df2a7" MLVPN_VERSION="f45cec350a6879b8b020143a78134a022b5df2a7"
UBOND_VERSION="672100fb57913ffd29caad63517e145a5974b078" UBOND_VERSION="672100fb57913ffd29caad63517e145a5974b078"
OBFS_VERSION="486bebd9208539058e57e23a12f23103016e09b4" OBFS_VERSION="486bebd9208539058e57e23a12f23103016e09b4"
OMR_ADMIN_VERSION="774aceb357e989676ed9a06d411db41bdfa3bf03" OMR_ADMIN_VERSION="595b55f7309b8b940b6599bb49c824376750860e"
DSVPN_VERSION="3b99d2ef6c02b2ef68b5784bec8adfdd55b29b1a" DSVPN_VERSION="3b99d2ef6c02b2ef68b5784bec8adfdd55b29b1a"
#V2RAY_VERSION="v1.1.0" V2RAY_VERSION="4.31.0"
V2RAY_PLUGIN_VERSION="v1.4.3" V2RAY_PLUGIN_VERSION="v1.4.3"
EASYRSA_VERSION="3.0.6" EASYRSA_VERSION="3.0.6"
SHADOWSOCKS_VERSION="38871da8baf5cfa400983dcdf918397e48655203" SHADOWSOCKS_VERSION="38871da8baf5cfa400983dcdf918397e48655203"
@ -51,7 +51,7 @@ VPS_DOMAIN=${VPS_DOMAIN:-$(wget -4 -qO- -T 2 http://hostname.openmptcprouter.com
VPSPATH="server-test" VPSPATH="server-test"
VPSURL="https://www.openmptcprouter.com/" VPSURL="https://www.openmptcprouter.com/"
OMR_VERSION="0.1018-test" OMR_VERSION="0.1023-test"
DIR=$( pwd ) DIR=$( pwd )
#" #"
@ -389,7 +389,7 @@ if [ "$OMR_ADMIN" = "yes" ]; then
echo '-- pip3 install needed python modules' echo '-- pip3 install needed python modules'
#pip3 install pyjwt passlib uvicorn fastapi netjsonconfig python-multipart netaddr #pip3 install pyjwt passlib uvicorn fastapi netjsonconfig python-multipart netaddr
#pip3 -q install fastapi netjsonconfig python-multipart uvicorn -U #pip3 -q install fastapi netjsonconfig python-multipart uvicorn -U
pip3 -q install fastapi netjsonconfig python-multipart -U pip3 -q install fastapi jsonschema netjsonconfig python-multipart jinja2 -U
mkdir -p /etc/openmptcprouter-vps-admin/omr-6in4 mkdir -p /etc/openmptcprouter-vps-admin/omr-6in4
mkdir -p /etc/openmptcprouter-vps-admin/intf mkdir -p /etc/openmptcprouter-vps-admin/intf
[ ! -f "/etc/openmptcprouter-vps-admin/current-vpn" ] && echo "glorytun_tcp" > /etc/openmptcprouter-vps-admin/current-vpn [ ! -f "/etc/openmptcprouter-vps-admin/current-vpn" ] && echo "glorytun_tcp" > /etc/openmptcprouter-vps-admin/current-vpn
@ -563,7 +563,10 @@ if systemctl -q is-active v2ray.service; then
fi fi
if [ "$V2RAY" = "yes" ]; then if [ "$V2RAY" = "yes" ]; then
apt-get -y -o Dpkg::Options::="--force-overwrite" install v2ray #apt-get -y -o Dpkg::Options::="--force-overwrite" install v2ray
wget -O /tmp/v2ray-${V2RAY_VERSION}-amd64.deb ${VPSURL}/debian/v2ray-${V2RAY_VERSION}-amd64.deb
dpkg --force-all -i -B /tmp/v2ray-${V2RAY_VERSION}-amd64.deb
rm -f /tmp/v2ray-${V2RAY_VERSION}-amd64.deb
if [ ! -f /etc/v2ray/v2ray-server.json ]; then if [ ! -f /etc/v2ray/v2ray-server.json ]; then
wget -O /etc/v2ray/v2ray-server.json ${VPSURL}${VPSPATH}/v2ray-server.json wget -O /etc/v2ray/v2ray-server.json ${VPSURL}${VPSPATH}/v2ray-server.json
sed -i "s:V2RAY_UUID:$V2RAY_UUID:g" /etc/v2ray/v2ray-server.json sed -i "s:V2RAY_UUID:$V2RAY_UUID:g" /etc/v2ray/v2ray-server.json
@ -765,13 +768,37 @@ if [ "$OPENVPN" = "yes" ]; then
if [ "$LOCALFILES" = "no" ]; then if [ "$LOCALFILES" = "no" ]; then
wget -O /etc/openvpn/tun0.conf ${VPSURL}${VPSPATH}/openvpn-tun0.conf wget -O /etc/openvpn/tun0.conf ${VPSURL}${VPSPATH}/openvpn-tun0.conf
wget -O /etc/openvpn/tun1.conf ${VPSURL}${VPSPATH}/openvpn-tun1.conf wget -O /etc/openvpn/tun1.conf ${VPSURL}${VPSPATH}/openvpn-tun1.conf
wget -O /etc/openvpn/bonding1.conf ${VPSURL}${VPSPATH}/openvpn-bonding1.conf
wget -O /etc/openvpn/bonding2.conf ${VPSURL}${VPSPATH}/openvpn-bonding2.conf
wget -O /etc/openvpn/bonding3.conf ${VPSURL}${VPSPATH}/openvpn-bonding3.conf
wget -O /etc/openvpn/bonding4.conf ${VPSURL}${VPSPATH}/openvpn-bonding4.conf
wget -O /etc/openvpn/bonding5.conf ${VPSURL}${VPSPATH}/openvpn-bonding5.conf
wget -O /etc/openvpn/bonding6.conf ${VPSURL}${VPSPATH}/openvpn-bonding6.conf
wget -O /etc/openvpn/bonding7.conf ${VPSURL}${VPSPATH}/openvpn-bonding7.conf
wget -O /etc/openvpn/bonding8.conf ${VPSURL}${VPSPATH}/openvpn-bonding8.conf
else else
cp ${DIR}/openvpn-tun0.conf /etc/openvpn/tun0.conf cp ${DIR}/openvpn-tun0.conf /etc/openvpn/tun0.conf
cp ${DIR}/openvpn-tun1.conf /etc/openvpn/tun1.conf cp ${DIR}/openvpn-tun1.conf /etc/openvpn/tun1.conf
cp ${DIR}/openvpn-bonding1.conf /etc/openvpn/bonding1.conf
cp ${DIR}/openvpn-bonding2.conf /etc/openvpn/bonding2.conf
cp ${DIR}/openvpn-bonding3.conf /etc/openvpn/bonding3.conf
cp ${DIR}/openvpn-bonding4.conf /etc/openvpn/bonding4.conf
cp ${DIR}/openvpn-bonding5.conf /etc/openvpn/bonding5.conf
cp ${DIR}/openvpn-bonding6.conf /etc/openvpn/bonding6.conf
cp ${DIR}/openvpn-bonding7.conf /etc/openvpn/bonding7.conf
cp ${DIR}/openvpn-bonding8.conf /etc/openvpn/bonding8.conf
fi fi
mkdir -p /etc/openvpn/ccd mkdir -p /etc/openvpn/ccd
systemctl enable openvpn@tun0.service systemctl enable openvpn@tun0.service
systemctl enable openvpn@tun1.service systemctl enable openvpn@tun1.service
systemctl enable openvpn@bonding1.service
systemctl enable openvpn@bonding2.service
systemctl enable openvpn@bonding3.service
systemctl enable openvpn@bonding4.service
systemctl enable openvpn@bonding5.service
systemctl enable openvpn@bonding6.service
systemctl enable openvpn@bonding7.service
systemctl enable openvpn@bonding8.service
fi fi
echo 'Glorytun UDP' echo 'Glorytun UDP'
@ -1039,6 +1066,10 @@ if ([ "$ID" = "debian" ] && [ "$VERSION_ID" = "10" ]) || ([ "$ID" = "ubuntu" ] &
sed -i 's:DROP_DEFAULT=Drop:DROP_DEFAULT="Broadcast(DROP),Multicast(DROP)":g' /etc/shorewall6/shorewall6.conf sed -i 's:DROP_DEFAULT=Drop:DROP_DEFAULT="Broadcast(DROP),Multicast(DROP)":g' /etc/shorewall6/shorewall6.conf
sed -i 's:REJECT_DEFAULT=Reject:REJECT_DEFAULT="Broadcast(DROP),Multicast(DROP)":g' /etc/shorewall6/shorewall6.conf sed -i 's:REJECT_DEFAULT=Reject:REJECT_DEFAULT="Broadcast(DROP),Multicast(DROP)":g' /etc/shorewall6/shorewall6.conf
fi fi
if [ "$(ip r | awk '/default/&&/src/ {print $7}')" != "" ]; then
sed -i "s/MASQUERADE/SNAT($(ip r | awk '/default/&&/src/ {print $7}'))/" /etc/shorewall/snat
fi
if [ "$TLS" = "yes" ]; then if [ "$TLS" = "yes" ]; then
VPS_CERT=0 VPS_CERT=0

View file

@ -3,7 +3,7 @@
set -e set -e
if [ ! -f "$2" ]; then if [ ! -f "$2" ]; then
echo "usage: $(basename "$0") FILE" echo "usage: $(basename "$0") start FILE"
exit 1 exit 1
fi fi

View file

@ -62,9 +62,9 @@ _gre_tunnels() {
if [ -f "$intf" ]; then if [ -f "$intf" ]; then
. "$(readlink -f "$intf")" . "$(readlink -f "$intf")"
iface="$(basename $intf)" iface="$(basename $intf)"
if [ "$(ip tunnel show $iface 2>/dev/null | awk '{print $4}')" != "$REMOTEIP" ]; then if [ "$(ip tunnel show $iface 2>/dev/null | awk '{print $4}')" != "$OMR_ADDR" ]; then
ip tunnel del $iface 2>&1 >/dev/null ip tunnel del $iface 2>&1 >/dev/null
ip tunnel add $iface mode gre local $INTFADDR remote $REMOTEIP ip tunnel add $iface mode gre local $INTFADDR remote $OMR_ADDR
ip link set $iface up ip link set $iface up
ip addr add $LOCALIP dev $iface ip addr add $LOCALIP dev $iface
ip route add $NETWORK dev $iface 2>&1 >/dev/null ip route add $NETWORK dev $iface 2>&1 >/dev/null
@ -73,7 +73,20 @@ _gre_tunnels() {
done done
} }
_openvpn_bonding() {
if [ "$(ip link show ovpnbonding1)" != "" ] && [ "$(ip link show ovpnbonding1 | grep SLAVE)" = "" ]; then
ip link set opvpnbonding1 master omr-bonding 2>&1 >/dev/null
ip link set opvpnbonding2 master omr-bonding 2>&1 >/dev/null
ip link set opvpnbonding3 master omr-bonding 2>&1 >/dev/null
ip link set opvpnbonding4 master omr-bonding 2>&1 >/dev/null
ip link set opvpnbonding5 master omr-bonding 2>&1 >/dev/null
ip link set opvpnbonding6 master omr-bonding 2>&1 >/dev/null
ip link set opvpnbonding7 master omr-bonding 2>&1 >/dev/null
ip link set opvpnbonding8 master omr-bonding 2>&1 >/dev/null
fi
}
ip link add omr-bonding type bond 2>&1 >/dev/null
while true; do while true; do
_glorytun_udp _glorytun_udp
_glorytun_tcp _glorytun_tcp
@ -81,5 +94,6 @@ while true; do
_omr_api _omr_api
_lan_route _lan_route
_gre_tunnels _gre_tunnels
_openvpn_bonding
sleep 10 sleep 10
done done

Binary file not shown.

View file

@ -21,4 +21,4 @@ vpn mlvpn+ nosmurfs,tcpflags
vpn tun+ nosmurfs,tcpflags vpn tun+ nosmurfs,tcpflags
vpn dsvpn+ nosmurfs,tcpflags vpn dsvpn+ nosmurfs,tcpflags
vpn gre-user+ nosmurfs,tcpflags vpn gre-user+ nosmurfs,tcpflags
vpn omr-bonding nosmurfs,tcpflags