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

Push latest scripts changes

This commit is contained in:
Ycarus (Yannick Chabanois) 2022-08-09 18:36:09 +00:00
parent 2b5afea3a1
commit 4fbb8d08f3
10 changed files with 108 additions and 44 deletions

View file

@ -38,12 +38,12 @@ REINSTALL=${REINSTALL:-yes}
SPEEDTEST=${SPEEDTEST:-yes}
LOCALFILES=${LOCALFILES:-no}
INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | grep -m 1 -Po '(?<=dev )(\S+)' | tr -d "\n")}
KERNEL_VERSION="5.4.132"
KERNEL_PACKAGE_VERSION="1.19+4f508aa"
KERNEL_VERSION="5.4.207"
KERNEL_PACKAGE_VERSION="1.22"
KERNEL_RELEASE="${KERNEL_VERSION}-mptcp_${KERNEL_PACKAGE_VERSION}"
if [ "$UPSTREAM" = "yes" ]; then
KERNEL_VERSION="5.15.13"
KERNEL_PACKAGE_VERSION="1.5"
KERNEL_VERSION="5.15.57"
KERNEL_PACKAGE_VERSION="1.6"
KERNEL_RELEASE="${KERNEL_VERSION}-mptcp_${KERNEL_VERSION}-${KERNEL_PACKAGE_VERSION}"
fi
GLORYTUN_UDP_VERSION="32267e86a6da05b285bb3bf2b136c105dc0af4bb"
@ -55,15 +55,12 @@ MLVPN_BINARY_VERSION="3.0.0+20211028.git.ddafba3"
UBOND_VERSION="f9fb6aa0a65e8e20950977bda970c90012f830d7"
OBFS_VERSION="486bebd9208539058e57e23a12f23103016e09b4"
OBFS_BINARY_VERSION="0.0.5-1"
OMR_ADMIN_VERSION="027d5c8e80ef469d33e43f6cbf3103b30e55ea1c"
if [ "$UPSTREAM" = "yes" ]; then
OMR_ADMIN_VERSION="2a8f642f89a982d2c26c3e176f6c4c1e3e91ffcb"
fi
OMR_ADMIN_BINARY_VERSION="0.3+20210508"
OMR_ADMIN_VERSION="20314b11f21eb5878ba62c85d874528e0e394024"
OMR_ADMIN_BINARY_VERSION="0.3+20220715"
DSVPN_VERSION="3b99d2ef6c02b2ef68b5784bec8adfdd55b29b1a"
DSVPN_BINARY_VERSION="0.1.4-2"
V2RAY_VERSION="4.43.0"
V2RAY_PLUGIN_VERSION="4.35.1"
V2RAY_PLUGIN_VERSION="4.43.0"
EASYRSA_VERSION="3.0.6"
SHADOWSOCKS_VERSION="7407b214f335f0e2068a8622ef3674d868218e17"
if [ "$UPSTREAM" = "yes" ]; then
@ -73,6 +70,7 @@ IPROUTE2_VERSION="29da83f89f6e1fe528c59131a01f5d43bcd0a000"
SHADOWSOCKS_BINARY_VERSION="3.3.5-3"
DEFAULT_USER="openmptcprouter"
VPS_DOMAIN=${VPS_DOMAIN:-$(wget -4 -qO- -T 2 http://hostname.openmptcprouter.com)}
VPS_PUBLIC_IP=${VPS_PUBLIC_IP:-$(wget -4 -qO- -T 2 http://ip.openmptcprouter.com)}
VPSPATH="server-test"
VPSURL="https://www.openmptcprouter.com/"
REPO="repo.openmptcprouter.com"
@ -182,7 +180,11 @@ echo "Remove lock and update packages list..."
rm -f /var/lib/dpkg/lock
rm -f /var/lib/dpkg/lock-frontend
rm -f /var/cache/apt/archives/lock
apt-get update --allow-releaseinfo-change
if [ "$ID" = "debian" ] && [ "$VERSION_ID" = "9" ]; then
apt-get update
else
apt-get update --allow-releaseinfo-change
fi
rm -f /var/lib/dpkg/lock
rm -f /var/lib/dpkg/lock-frontend
rm -f /var/cache/apt/archives/lock
@ -283,6 +285,18 @@ apt-get update --allow-releaseinfo-change
sleep 2
apt-get -y install dirmngr patch rename curl libcurl4 unzip pkg-config
if [ -z "$(dpkg-query -l | grep grub)" ]; then
if [ -d /boot/grub2 ]; then
apt-get -y install grub2
elif [ -d /boot/grub ]; then
apt-get -y install grub-legacy
fi
[ -n "$(grep 'net.ifnames=0' /boot/grub/grub.cfg)" ] && [ ! -f /etc/default/grub ] && {
echo 'GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"' > /etc/default/grub
}
fi
if [ "$SOURCES" = "yes" ]; then
wget -O /tmp/linux-image-${KERNEL_RELEASE}_amd64.deb ${VPSURL}kernel/linux-image-${KERNEL_RELEASE}_amd64.deb
wget -O /tmp/linux-headers-${KERNEL_RELEASE}_amd64.deb ${VPSURL}kernel/linux-headers-${KERNEL_RELEASE}_amd64.deb
@ -317,6 +331,7 @@ if [ "$LOCALFILES" = "no" ]; then
else
cd ${DIR}
fi
[ -f /boot/grub/grub.cfg ] && [ -z "$(grep ${KERNEL_VERSION}-mptcp /boot/grub/grub.cfg)" ] && [ -n "$(which grub-mkconfig)" ] && grub-mkconfig -o /boot/grub/grub.cfg
rm -f /etc/grub.d/30_os-prober
bash update-grub.sh ${KERNEL_VERSION}-mptcp
bash update-grub.sh ${KERNEL_RELEASE}
@ -430,7 +445,7 @@ if [ "$SOURCES" = "yes" ]; then
rm -f /var/lib/dpkg/lock-frontend
cd /tmp
#dpkg -i shadowsocks-libev_*.deb
dpkg -i omr-shadowsocks-libev_*.deb
dpkg -i omr-shadowsocks-libev_*.deb 2>&1 >/dev/null
#mkdir -p /usr/lib/shadowsocks-libev
#cp -f /tmp/shadowsocks-libev-${SHADOWSOCKS_VERSION}/src/*.ebpf /usr/lib/shadowsocks-libev
#rm -rf /tmp/shadowsocks-libev-${SHADOWSOCKS_VERSION}
@ -530,8 +545,9 @@ if [ "$OMR_ADMIN" = "yes" ]; then
apt-get -y install python3-passlib python3-jwt python3-netaddr libuv1 python3-uvloop
fi
fi
apt-get -y --allow-downgrades install python3-uvicorn jq ipcalc python3-netifaces python3-aiofiles python3-psutil python3-requests
apt-get -y --allow-downgrades install python3-uvicorn jq ipcalc python3-netifaces python3-aiofiles python3-psutil python3-requests pwgen
echo '-- pip3 install needed python modules'
echo "If you see any error here, I really don't care: it's about a not used module for home users"
#pip3 install pyjwt passlib uvicorn fastapi netjsonconfig python-multipart netaddr
#pip3 -q install fastapi netjsonconfig python-multipart uvicorn -U
pip3 -q install fastapi jsonschema netjsonconfig python-multipart jinja2 -U
@ -901,6 +917,34 @@ if [ "$WIREGUARD" = "yes" ]; then
EOF
fi
systemctl enable wg-quick@wg0
if [ ! -f /etc/wireguard/client-wg0.conf ]; then
cd /etc/wireguard
umask 077; wg genkey | tee vpn-client-private.key | wg pubkey > vpn-client-public.key
cat > /etc/wireguard/client-wg0.conf <<-EOF
[Interface]
PrivateKey = $(cat /etc/wireguard/vpn-server-private.key | tr -d "\n")
ListenPort = 65311
Address = 10.255.246.1/24
SaveConfig = true
[Peer]
PublicKey = $(cat /etc/wireguard/vpn-client-public.key | tr -d "\n")
AllowedIPs = 10.255.246.2/32
EOF
fi
if [ ! -f /root/wireguard-client.conf ]; then
cat > /root/wireguard-client.conf <<-EOF
[Interface]
Address = 10.255.246.2/24
PrivateKey = $(cat /etc/wireguard/vpn-client-private.key | tr -d "\n")
[Peer]
PublicKey = $(cat /etc/wireguard/vpn-server-public.key | tr -d "\n")
Endpoint = ${VPS_PUBLIC_IP}:65312
AllowedIPs = 0.0.0.0/0, ::/0, 192.168.100.0/24
EOF
fi
systemctl enable wg-quick@client-wg0
echo "Install wireguard done"
fi
@ -964,7 +1008,7 @@ if [ "$OPENVPN" = "yes" ]; then
make-cadir /etc/openvpn/ca
fi
cd /etc/openvpn/ca
./easyrsa init-pki
./easyrsa init-pki 2>&1 >/dev/null
./easyrsa --batch build-ca nopass
EASYRSA_CERT_EXPIRE=3650 ./easyrsa build-server-full server nopass
EASYRSA_CERT_EXPIRE=3650 ./easyrsa build-client-full "openmptcprouter" nopass
@ -1024,6 +1068,7 @@ fi
if [ "$SOURCES" = "yes" ]; then
rm -f /var/lib/dpkg/lock
rm -f /var/lib/dpkg/lock-frontend
rm -f /usr/bin/glorytun
apt-get install -y --no-install-recommends build-essential git ca-certificates meson pkg-config
rm -rf /tmp/glorytun-udp
cd /tmp
@ -1068,7 +1113,8 @@ if [ "$SOURCES" = "yes" ]; then
cd /tmp
rm -rf /tmp/glorytun-udp
else
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install omr-glorytun=${GLORYTUN_UDP_BINARY_VERSION}
rm -f /usr/local/bin/glorytun
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install --reinstall omr-glorytun=${GLORYTUN_UDP_BINARY_VERSION}
GLORYTUN_PASS="$(cat /etc/glorytun-udp/tun0.key | tr -d '\n')"
fi
[ "$(ip -6 a)" != "" ] && sed -i 's/0.0.0.0/::/g' /etc/glorytun-udp/tun0
@ -1138,6 +1184,7 @@ if [ "$SOURCES" = "yes" ]; then
fi
rm -f /var/lib/dpkg/lock
rm -f /var/lib/dpkg/lock-frontend
rm -f /usr/bin/glorytun-tcp
apt-get -y install build-essential pkg-config autoconf automake
rm -rf /tmp/glorytun-0.0.35
cd /tmp
@ -1172,7 +1219,8 @@ if [ "$SOURCES" = "yes" ]; then
cd /tmp
rm -rf /tmp/glorytun-0.0.35
else
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install omr-glorytun-tcp=${GLORYTUN_TCP_BINARY_VERSION}
rm -f /usr/local/bin/glorytun-tcp
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-overwrite" install --reinstall omr-glorytun-tcp=${GLORYTUN_TCP_BINARY_VERSION}
fi
[ "$(ip -6 a)" != "" ] && sed -i 's/0.0.0.0/::/g' /etc/glorytun-tcp/tun0
@ -1281,6 +1329,7 @@ else
sed -i 's:10.0.0.2:$OMR_ADDR:g' /etc/shorewall/rules
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall6/*
fi
[ -z "$(grep nf_conntrack_sip /etc/modprobe.d/blacklist.conf)" ] && echo 'blacklist nf_conntrack_sip' >> /etc/modprobe.d/blacklist.conf
if [ "$ID" = "debian" ] && [ "$VERSION_ID" = "10" ]; then
apt-get -y install iptables
update-alternatives --set iptables /usr/sbin/iptables-legacy

View file

@ -117,7 +117,7 @@ if [ -f /proc/sys/net/mptcp/mptcp_enabled ]; then
else
ID=$(ip mptcp endpoint show | grep "dev $DEVICE" | awk '{print $3}')
IFF=$(ip mptcp endpoint show | grep "dev $DEVICE" | awk '{print $4}')
IP=$(ifconfig $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
RMID=$(ip mptcp endpoint show | grep '::ffff' | awk '{ print $3 }')
[ -n "$RMID" ] && ip mptcp endpoint delete id $RMID 2>&1 >/dev/null
case $TYPE in

View file

@ -20,26 +20,32 @@ _multipath() {
}
_glorytun_udp() {
[ -z "$(glorytun show dev gt-udp-tun0 2>/dev/null | grep tunnel)" ] && {
logger -t "OMR-Service" "Restart Glorytun-UDP"
systemctl -q restart 'glorytun-udp@*'
}
for intf in /etc/glorytun-udp/tun*; do
[ "$(echo $intf | grep key)" = "" ] && /etc/glorytun-udp/post.sh ${intf}
done
if [ -n "$(systemctl -a | grep 'glorytun-udp')" ]; then
[ -z "$(glorytun show dev gt-udp-tun0 2>/dev/null | grep tunnel)" ] && {
logger -t "OMR-Service" "Restart Glorytun-UDP"
systemctl -q restart 'glorytun-udp@*'
sleep 10
}
for intf in /etc/glorytun-udp/tun*; do
[ "$(echo $intf | grep key)" = "" ] && /etc/glorytun-udp/post.sh ${intf}
done
fi
}
_glorytun_tcp() {
for intf in /etc/glorytun-tcp/tun*; do
[ "$(echo $intf | grep key)" = "" ] && /etc/glorytun-tcp/post.sh ${intf}
done
if [ -f /etc/openmptcprouter-vps-admin/current-vpn ] && [ "$(cat /etc/openmptcprouter-vps-admin/current-vpn)" = "glorytun_tcp" ]; then
localip="$(cat /etc/glorytun-tcp/tun0 | grep LOCALIP | cut -d '=' -f2)"
[ -z "$localip" ] && localip="10.255.255.1"
remoteip="$(echo $localip | sed 's/\.1/\.2/')"
if [ "$(ping -c 5 -w 5 $remoteip | grep '100%')" != "" ] && [ "$(expr $(date +%s) - $(stat -c %Y /proc/$(pgrep glorytun-tcp)/exe ))" -gt "300" ]; then
logger -t "OMR-Service" "No answer from VPN client end, restart Glorytun-TCP"
systemctl restart glorytun-tcp@tun0
if [ -n "$(systemctl -a | grep 'glorytun-tcp')" ]; then
for intf in /etc/glorytun-tcp/tun*; do
[ "$(echo $intf | grep key)" = "" ] && /etc/glorytun-tcp/post.sh ${intf}
done
if [ -f /etc/openmptcprouter-vps-admin/current-vpn ] && [ "$(cat /etc/openmptcprouter-vps-admin/current-vpn)" = "glorytun_tcp" ]; then
localip="$(cat /etc/glorytun-tcp/tun0 | grep LOCALIP | cut -d '=' -f2)"
[ -z "$localip" ] && localip="10.255.255.1"
remoteip="$(echo $localip | sed 's/\.1/\.2/')"
if [ "$(ping -c 5 -w 5 $remoteip | grep '100%')" != "" ] && ([ -z "$(pgrep glorytun-tcp)" ] || [ "$(expr $(date +%s) - $(stat -c %Y /proc/$(pgrep glorytun-tcp)/exe ))" -gt "300" ]); then
logger -t "OMR-Service" "No answer from VPN client end, restart Glorytun-TCP"
systemctl restart glorytun-tcp@tun0
sleep 10
fi
fi
fi
}
@ -49,19 +55,22 @@ _dsvpn() {
}
_shadowsocks() {
[ -z "$(pgrep ss-server)" ] && {
[ -n "$(systemctl -a | grep 'shadowsocks')" ] && [ -z "$(pgrep ss-server)" ] && {
logger -t "OMR-Service" "ss-server not detected, restart Shadowsocks"
systemctl restart shadowsocks-libev-manager@manager
}
}
_wireguard() {
[ -z "$(ip a show dev wg0 | grep '10.255.247.1')" ] && ip a add 10.255.247.1/24 dev wg0 2>&1 >/dev/null
if [ -n "$(systemctl -a | grep 'wg')" ]; then
[ -z "$(ip a show dev wg0 | grep '10.255.247.1')" ] && ip a add 10.255.247.1/24 dev wg0 2>&1 >/dev/null
[ -z "$(ip a show dev client-wg0 | grep '10.255.246.1')" ] && ip a add 10.255.246.1/24 dev client-wg0 2>&1 >/dev/null
fi
}
_omr_api() {
[ -z "$(curl -s -k -m 30 https://127.0.0.1:65500/)" ] && {
[ -z "$(pgrep curl)" ] && [ -z "$(curl -s -k -m 30 https://127.0.0.1:65500/)" ] && {
logger -t "OMR-Service" "Restart OMR-Admin"
systemctl -q restart omr-admin
}
@ -71,7 +80,7 @@ _lan_route() {
cat /etc/openmptcprouter-vps-admin/omr-admin-config.json | jq -c '.users[0][]' |
while IFS=$"\n" read -r c; do
vpnremoteip=$(echo "$c" | jq -r '.vpnremoteip')
if [ -n "$vpnremoteip" ] && [ "$vpnremoteip" != "null" ]; then
if [ -n "$vpnremoteip" ] && [ "$vpnremoteip" != "null" ] && [ -n "$(grep lanips /etc/openmptcprouter-vps-admin/omr-admin-config.json)" ]; then
echo "$c" | jq -c -r '.lanips[] //empty' |
while IFS=$"\n" read -r d; do
network=$(ipcalc -n $d | grep Network | awk '{print $2}')

Binary file not shown.

View file

@ -20,6 +20,7 @@ vpn gt-udp-tun+ nosmurfs,tcpflags
vpn mlvpn+ nosmurfs,tcpflags
vpn tun+ nosmurfs,tcpflags
vpn wg+ nosmurfs,tcpflags
vpncl client-wg+ nosmurfs,tcpflags
vpn dsvpn+ nosmurfs,tcpflags
vpn gre-user+ nosmurfs,tcpflags
vpn omr-bonding nosmurfs,tcpflags

View file

@ -19,6 +19,8 @@ fw vpn ACCEPT
fw net ACCEPT
net all DROP
vpn vpn DROP
vpncl vpn ACCEPT
vpn vpncl ACCEPT
# THE FOLLOWING POLICY MUST BE LAST
all all REJECT

View file

@ -137,7 +137,7 @@ ADMINISABSENTMINDED=Yes
AUTOCOMMENT=Yes
AUTOHELPERS=Yes
AUTOHELPERS=No
AUTOMAKE=No
@ -149,13 +149,13 @@ BLACKLIST="NEW,INVALID,UNTRACKED"
CLAMPMSS=No
CLEAR_TC=Yes
CLEAR_TC=No
COMPLETE=No
DEFER_DNS_RESOLUTION=Yes
DELETE_THEN_ADD=Yes
DELETE_THEN_ADD=No
DETECT_DNAT_IPADDRS=No
@ -163,7 +163,7 @@ DISABLE_IPV6=No
DOCKER=No
DONT_LOAD=
DONT_LOAD=nf_conntrack_sip
DYNAMIC_BLACKLIST=Yes
@ -233,7 +233,7 @@ SAVE_ARPTABLES=No
SAVE_IPSETS=No
TC_ENABLED=Simple
TC_ENABLED=No
TC_EXPERT=No

View file

@ -25,4 +25,6 @@ ACCEPT tun+ -
ACCEPT - tun+
ACCEPT wg+ -
ACCEPT - wg+
ACCEPT client-wg+ -
ACCEPT - client-wg+

View file

@ -1,3 +1,3 @@
#INTERFACE TYPE IN-BANDWIDTH OUT-BANDWIDTH
$NET_IFACE External
$VPS_IFACE Internal
#$VPS_IFACE Internal

View file

@ -16,4 +16,5 @@
fw firewall
net ipv4
vpn ipv4
vpncl ipv4