#!/data/data/com.termux/files/usr/bin/bash pkgrel='2a42' NC='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BOLD='\033[1;37m' curl https://www.google.com > /dev/null 2>&1 [[ $? != 0 ]] && { echo -e "${RED}Your internet access is questionable."; echo -e "Please check your Internet Conenction${NC}"; exit; } if [[ $(curl -sL "https://mb2.potat.cc:80/pkgrel/android") != $pkgrel ]]; then echo "Updating the wrapper script" curl -#L "https://mb2.potat.cc:80/src/mbtunnel-android.sh" -o $PREFIX/bin/mbtunnel chmod +x $PREFIX/bin/mbtunnel sync mbtunnel exit fi if [[ ! -f $(which nc) ]]; then INSTALL+=" netcat-openbsd" fi if [[ $INSTALL != "" ]]; then echo "Some packages were not found or out of date." echo "Updating" echo sleep 1 yes Y | pkg upgrade -y yes Y | pkg i $INSTALL -y fi setup(){ rm -rf $HOME/mbtunnel mkdir $HOME/mbtunnel getnix getwstunnel getgost } getnix(){ echo "Updating nix environment" curl -#L https://mb2.potat.cc:80/src/rootfs.tar.zst -o $HOME/mbtunnel/rootfs.tar.zst tar -xf $HOME/mbtunnel/rootfs.tar.zst -C $HOME/mbtunnel/ } getwstunnel(){ echo "Updating wstunnel binary" curl -#L https://github.com/erebe/wstunnel/releases/download/v10.1.9/wstunnel_10.1.9_linux_arm64.tar.gz -o $HOME/mbtunnel/wstunnel.tar.gz tar -xf $HOME/mbtunnel/wstunnel.tar.gz -C $HOME/mbtunnel/rootfs/root/ chmod +x $HOME/mbtunnel/rootfs/root/wstunnel } getgost(){ echo "Updating gost binary" curl -#L https://github.com/go-gost/gost/releases/download/v3.0.0/gost_3.0.0_linux_arm64.tar.gz -o $HOME/mbtunnel/gost.tar.gz tar -xf $HOME/mbtunnel/gost.tar.gz -C $HOME/mbtunnel/rootfs/root/ chmod +x $HOME/mbtunnel/rootfs/root/gost } nixsum="61260c99a912a220ed6cb36a6759b24f rootfs.tar.zst" wstunnelsum="9cadee456ae1d2cd54ee529f3f8f2157 wstunnel.tar.gz" gostsum="436e43e182f3c02343d685eb1091e32d gost.tar.gz" [[ ! -d $HOME/mbtunnel ]] && setup [[ ! -d $HOME/mbtunnel/rootfs ]] && setup cd mbtunnel [[ $(md5sum rootfs.tar.zst) != $nixsum ]] && getnix [[ $(md5sum wstunnel.tar.gz) != $wstunnelsum ]] && getwstunnel [[ $(md5sum gost.tar.gz) != $gostsum ]] && getgost echo -e "\n${BOLD}Everything seems up to date.${NC}" IP=$(ping -c1 -t1 -W1 mb2.potat.cc 2>&1 | tr -d '():' | awk '/^PING/{print $3}') nc -vzu 49.24.34.1 443 >& /dev/null if [[ $? != 0 ]] && [[ $1 != "tcp" ]]; then echo -e "\n\nTunneling Wireguard via UDP using QUIC relay" echo -e "${GREEN}You may now connect to Wireguard${NC}" LD_PRELOAD="" proot -r ./rootfs -0 -w / -b /dev -b /proc -b /sys /bin/bash -c "/root/gost -L \"udp://127.0.0.1:51280/${IP}:443?keepAlive=true&queue=4096\"" else echo -e "\n\nUDP/443 seems closed. Tunneling Wireguard via TCP using Websocket relay" echo -e "${GREEN}You may now connect to Wireguard${NC}" LD_PRELOAD="" proot -r ./rootfs -0 -w / -b /dev -b /proc -b /sys /bin/bash -c "/root/wstunnel client wss://${IP}:443 -L \"udp://51280:127.0.0.1:51280?timeout_sec=0\"" fi