├── .github ├── wgcf.sh └── workflows │ ├── glibc.yml │ ├── sync.yml │ └── wgcf.yml ├── LICENSE ├── README.md ├── english ├── README.md ├── misakawarp.sh ├── warp-cli │ ├── README.md │ ├── changeport.sh │ ├── netfilxcli.sh │ ├── switch.sh │ ├── uninstall.sh │ └── warp-cli.sh ├── wgcf-warp │ ├── README.md │ ├── netfilx4.sh │ ├── netfilx6.sh │ ├── switchwarp.sh │ ├── uninstall.sh │ ├── warp46.sh │ ├── warp4d.sh │ ├── warp64.sh │ ├── warp6d.sh │ └── warpd.sh └── wireproxy-warp │ ├── README.md │ ├── changeport.sh │ ├── netfilx-wireproxy.sh │ ├── uninstall.sh │ ├── warp4.sh │ └── warp6.sh ├── files ├── README.md ├── resolvconf ├── warp-teams.sh ├── warp-up.sh ├── wgcf-fetchlog.txt ├── wgcf-latest-linux-386 ├── wgcf-latest-linux-amd64 ├── wgcf-latest-linux-arm64 ├── wgcf-latest-linux-armv5 ├── wgcf-latest-linux-armv6 ├── wgcf-latest-linux-armv7 ├── wgcf-latest-linux-s390x ├── wireguard-go ├── wireguard-go-amd64 ├── wireguard-go-arm64 ├── wireguard-go-s390x ├── wireproxy-amd64 ├── wireproxy-arm64 └── wireproxy-s390x ├── misakawarp.sh ├── warp-cli ├── README.md ├── changeport.sh ├── netfilxcli.sh ├── switch.sh ├── uninstall.sh └── warp-cli.sh ├── wgcf-warp ├── README.md ├── netfilx4.sh ├── netfilx6.sh ├── switchwarp.sh ├── uninstall.sh ├── warp46.sh ├── warp4d.sh ├── warp64.sh ├── warp6d.sh └── warpd.sh └── wireproxy-warp ├── README.md ├── changeport.sh ├── netfilx-wireproxy.sh ├── uninstall.sh ├── warp4.sh └── warp6.sh /.github/wgcf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -f ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-386 ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-amd64 ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-armv5 ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-armv6 ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-armv7 ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-arm64 ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-s390x ${GITHUB_WORKSPACE}/files/wgcf-fetchlog.txt 4 | 5 | actions_date=$(date) 6 | repo_last_ver=$(curl -Ls "https://api.github.com/repos/ViRb3/wgcf/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') 7 | repo_ver_name=$(curl -Ls "https://api.github.com/repos/ViRb3/wgcf/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed "s/v//g") 8 | 9 | wget -N https://github.com/ViRb3/wgcf/releases/download/$repo_last_ver/wgcf_"$repo_ver_name"_linux_386 -O ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-386 10 | wget -N https://github.com/ViRb3/wgcf/releases/download/$repo_last_ver/wgcf_"$repo_ver_name"_linux_amd64 -O ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-amd64 11 | wget -N https://github.com/ViRb3/wgcf/releases/download/$repo_last_ver/wgcf_"$repo_ver_name"_linux_armv5 -O ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-armv5 12 | wget -N https://github.com/ViRb3/wgcf/releases/download/$repo_last_ver/wgcf_"$repo_ver_name"_linux_armv6 -O ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-armv6 13 | wget -N https://github.com/ViRb3/wgcf/releases/download/$repo_last_ver/wgcf_"$repo_ver_name"_linux_armv7 -O ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-armv7 14 | wget -N https://github.com/ViRb3/wgcf/releases/download/$repo_last_ver/wgcf_"$repo_ver_name"_linux_arm64 -O ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-arm64 15 | wget -N https://github.com/ViRb3/wgcf/releases/download/$repo_last_ver/wgcf_"$repo_ver_name"_linux_s390x -O ${GITHUB_WORKSPACE}/files/wgcf-latest-linux-s390x 16 | 17 | cat < ${GITHUB_WORKSPACE}/files/wgcf-fetchlog.txt 18 | # wgcf fetch log generated by GitHub Actions 19 | 20 | Last Version: $repo_last_ver 21 | Fetch Date: $actions_date 22 | EOF 23 | 24 | rm -f wgcf.sh 25 | -------------------------------------------------------------------------------- /.github/workflows/glibc.yml: -------------------------------------------------------------------------------- 1 | name: "Build glibc & make" 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | Building: 8 | name: "Build on CentOS 7" 9 | runs-on: ubuntu-latest 10 | container: docker.io/centos:7 11 | steps: 12 | - uses: actions/checkout@v3 13 | - name: Install dependencies 14 | run: | 15 | yum -y install gcc bison make centos-release-scl wget 16 | yum -y install devtoolset-8-gcc 17 | yum -y install devtoolset-8-gcc-c++ 18 | yum -y install devtoolset-8-binutils 19 | mkdir -p /opt/release/ 20 | - name: Build make v4.3 21 | run: | 22 | wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz 23 | tar -xzf make-4.3.tar.gz 24 | cd make-4.3 25 | ./configure 26 | make 27 | make install 28 | echo y | cp -f ./make /usr/bin/ 29 | cp ./make /opt/release/ 30 | cd ~ 31 | - name: Build glibc v2.28 32 | run: | 33 | source /opt/rh/devtoolset-8/enable 34 | wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz 35 | tar -zxf glibc-2.28.tar.gz 36 | mkdir -p ./glibc-2.28/build 37 | cd ./glibc-2.28/build 38 | ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin 39 | make 40 | make install 41 | cd ..; cd .. 42 | tar -czf /opt/release/glibc-2.28.tar.gz ./glibc-2.28 43 | - name: Binaries Release 44 | uses: softprops/action-gh-release@v1 45 | with: 46 | tag_name: Glibc 47 | files: /opt/release/* 48 | env: 49 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} 50 | -------------------------------------------------------------------------------- /.github/workflows/sync.yml: -------------------------------------------------------------------------------- 1 | name: Sync to Bitbucket and Gitlab 2 | 3 | on: 4 | push: 5 | delete: 6 | workflow_dispatch: 7 | 8 | jobs: 9 | to_bitbucket: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | with: 14 | fetch-depth: 0 15 | - uses: pixta-dev/repository-mirroring-action@v1 16 | with: 17 | target_repo_url: 18 | git@bitbucket.org:misakano7545/warp-script.git 19 | ssh_private_key: 20 | ${{ secrets.SSH_PRIVATEKEY }} 21 | to_gitlab: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v3 25 | with: 26 | fetch-depth: 0 27 | - uses: pixta-dev/repository-mirroring-action@v1 28 | with: 29 | target_repo_url: 30 | git@gitlab.com:misaka-blog/warp-script.git 31 | ssh_private_key: 32 | ${{ secrets.SSH_PRIVATEKEY }} 33 | -------------------------------------------------------------------------------- /.github/workflows/wgcf.yml: -------------------------------------------------------------------------------- 1 | name: Fetch wgcf latest version 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: 30 12 * * * 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | - name: Checking and fetching wgcf latest version 15 | run: | 16 | wget -N https://raw.githubusercontent.com/Misaka-blog/Misaka-WARP-Script/master/.github/wgcf.sh 17 | bash wgcf.sh 18 | - name: Git uploading 19 | env: 20 | GIT_USERNAME: ${{ secrets.GIT_USERNAME }} 21 | GIT_EMAIL: ${{ secrets.GIT_EMAIL }} 22 | run: | 23 | git config --global user.email "$GIT_EMAIL" 24 | git config --global user.name "$GIT_USERNAME" 25 | git add . 26 | git commit -m "Uploaded by Github Actions, Date: $(date)" 27 | git push 28 | - name: Refreshing Jsdelivr 29 | run: | 30 | curl https://purge.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_386 31 | curl https://purge.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_amd64 32 | curl https://purge.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_armv5 33 | curl https://purge.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_armv6 34 | curl https://purge.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_armv7 35 | curl https://purge.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_arm64 36 | curl https://purge.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_s390x 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Misaka WARP 脚本 2 | 3 | 支持手工菜单+全自动化脚本安装。支持AMD64、ARM64和S390X CPU架构的VPS、支持KVM、ZVM、OpenVZ和LXC虚拟化架构的VPS 4 | 5 | 已集成至:https://github.com/Misaka-blog/Xray-script 6 | 7 | 如对脚本不放心,可使用此沙箱先测一遍再使用:https://killercoda.com/playgrounds/scenario/ubuntu 8 | 9 | 详细讲解视频:7月份会出 10 | 11 | ## 使用方法 12 | 13 | ```shell 14 | wget -N --no-check-certificate https://raw.githubusercontents.com/misaka-gh/Misaka-WARP-Script/master/misakawarp.sh && bash misakawarp.sh 15 | ``` 16 | 17 | 快捷方式 `bash misakawarp.sh` 18 | 19 | > 如提示 `wget: command not found` 请安装wget后再执行本脚本 20 | 21 | > CentOS: `yum install -y wget` Debian / Ubuntu: `apt install -y wget` 22 | 23 | ## WARP的一些好处 24 | 25 | 解锁奈飞流媒体 (部分地区的WARP IP已凉) 26 | 27 | 避免 Google Recaptcha 验证码或是使用 Google 学术搜索 28 | 29 | 可调用 IPv4 接口,使青龙和V2P等项目能正常运行 30 | 31 | 由于可以双向转输数据,能做对方VPS的跳板和探针,替代 HE tunnelbroker 32 | 33 | 能让 IPv6 only VPS 上做的节点支持 Telegram 34 | 35 | IPv6 建的节点能在只支持 IPv4 的 PassWall、ShadowSocksR Plus+ 上使用 36 | 37 | ## 调整IPv4或IPv6优先 38 | 39 | 为了防止安装时脚本修改优先级情况导致失联,故使用VPS的默认IP优先级。如有需要配置可以参考P3Terx的文章: 40 | 41 | https://p3terx.com/archives/use-cloudflare-warp-to-add-extra-ipv4-or-ipv6-network-support-to-vps-servers-for-free.html#toc_8 42 | 43 | ## 各客户端差异及对比 44 | 45 | ![image](https://user-images.githubusercontent.com/96560028/160945334-9572ec6d-7b10-4081-a83a-2d1c475ea2e3.png) 46 | 47 | ## WARP+或WARP Teams账户获取 48 | 49 | WARP+:https://owo.misaka.rest/cfwarp-plus/ 50 | 51 | WARP Teams:https://owo.misaka.rest/cf-teams/ 52 | 53 | ## 常见问题 54 | 55 | ### 1. 为什么连不上Wgcf-WARP或WireProxy-WARP代理模式 56 | 57 | 1. 查看 https://www.cloudflarestatus.com/ ,如你的VPS区域后面出现Re-routed即为无法连接。请等待官方修复 58 | 59 | 2. 香港地区目前已被CloudFlare限制使用第三方客户端 60 | 61 | ![image](https://user-images.githubusercontent.com/96560028/160244784-25c40a97-d398-4d4f-9deb-d82c5e9b69ef.png) 62 | 63 | ### 2. 在申请Wgcf-WARP或WireProxy-WARP账号出现429 Too Many Requests错误 64 | 65 | ![image](https://user-images.githubusercontent.com/96560028/163660825-bb989575-f165-4bd3-aa59-a8f747c4589e.png) 66 | 67 | 由于部分时间段WARP的服务繁忙,可能会出现此问题。因此脚本自带自动重试申请WARP账号功能,直到申请到账号才过下一步的安装启动WARP工作 68 | 69 | 建议安装好WARP后备份 `/etc/wireguard/wgcf-account.toml`账号配置文件,以防部分情况下服务繁忙无法申请账号造成无法安装Wgcf-WARP或WireProxy-WARP代理模式 70 | 71 | ### 3. 如何使用已备份的wgcf-account.toml账号文件 72 | 73 | 只需要把文件放到`/root`文件夹,然后等待脚本自动识别即可 74 | 75 | 如使用本脚本安装wgcf-warp时,安装wireproxy-warp会自动使用wgcf-warp的账号配置文件,反之同理 76 | 77 | ### 4. 无法在Wgcf-WARP或Wireproxy-WARP使用WARP+账号? 78 | 79 | 这是因为你的WARP+流量不够导致的,还是乖乖刷好足够流量再尝试吧 80 | 81 | ## 赞助我们 82 | 83 | ![afdian-MisakaNo.jpg](https://s2.loli.net/2021/12/25/SimocqwhVg89NQJ.jpg) 84 | 85 | ## 交流群 86 | [Telegram](https://t.me/misakanetcn) 87 | 88 | ## 鸣谢列表 89 | 90 | Fscarmen:https://github.com/fscarmen/warp 91 | 92 | P3Terx:https://github.com/P3TERX/warp.sh 93 | 94 | WireProxy:https://github.com/octeep/wireproxy 95 | 96 | Wgcf:https://github.com/ViRb3/wgcf 97 | 98 | CloudFlare WARP Linux Client:https://blog.cloudflare.com/zh-cn/announcing-warp-for-linux-and-proxy-mode-zh-cn/ 99 | -------------------------------------------------------------------------------- /english/README.md: -------------------------------------------------------------------------------- 1 | # Misaka WARP Script 2 | 3 | ## Usage 4 | 5 | ```shell 6 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/english/misakawarp.sh && bash misakawarp.sh 7 | ``` 8 | 9 | Shortcut: `bash misakawarp.sh` 10 | 11 | ## Some of the benefits of WARP 12 | 13 | Unlock Netlifx restriction (WARP IP got restricted in some locations) 14 | 15 | Avoid Google Recaptcha or use Google Academic Search 16 | 17 | Can be used as a springboard and probe for the other VPS as it can transfer data in both directions, replacing HE tunnelbroker 18 | 19 | Telegram support for nodes built on IPv6 only VPS 20 | 21 | IPv6-built nodes can be used on IPv4-only PassWall and ShadowSocksR Plus+ 22 | 23 | ## Adjust IPv4 or IPv6 priority 24 | 25 | The default IP priority of the VPS is used in order to prevent lost connections due to scripted priority changes during installation. If you need to configure it, you can refer to the P3Terx article (in Chinese) at 26 | 27 | https://p3terx.com/archives/use-cloudflare-warp-to-add-extra-ipv4-or-ipv6-network-support-to-vps-servers-for-free.html#toc_8 28 | 29 | ## WARP+ or WARP Teams account access (written in Chinese) 30 | 31 | WARP+: https://owo.misaka.rest/cfwarp-plus/ 32 | 33 | WARP Teams: https://owo.misaka.rest/cf-teams/ 34 | 35 | ## Frequently Asked Questions 36 | 37 | ### 1. Why can't I connect to Wgcf-WARP or WireProxy-WARP proxy mode 38 | 39 | 1. Check https://www.cloudflarestatus.com/, if your VPS region appears after Re-routed that is unable to connect. Please wait for the official fixing 40 | 41 | 2. Hong Kong region has been restricted by CloudFlare to use third-party clients 42 | 43 | ![image](https://user-images.githubusercontent.com/96560028/160244784-25c40a97-d398-4d4f-9deb-d82c5e9b69ef.png) 44 | 45 | ### 2. 429 Too Many Requests error when applying for Wgcf-WARP or WireProxy-WARP account 46 | 47 | ![image](https://user-images.githubusercontent.com/96560028/163660825-bb989575-f165-4bd3-aa59-a8f747c4589e.png) 48 | 49 | This problem may occur due to the busy service of WARP during some hours. Therefore, the script comes with the function of automatically retrying to apply for a WARP account until the account is applied before the next step of installing and starting WARP. 50 | 51 | It is recommended to backup the `/etc/wireguard/wgcf-account.toml` account configuration file after installing WARP, in case the service is too busy to apply for an account in some cases, thus preventing the installation of Wgcf-WARP or WireProxy-WARP proxy mode. 52 | 53 | ### 3. How to use the backed up wgcf-account.toml account file 54 | 55 | Just put the file in the `/root` folder and wait for the script to recognize it automatically 56 | 57 | If you use this script to install wgcf-warp, the installation of wireproxy-warp will automatically use the wgcf-warp account configuration file, and the reverse is also true -------------------------------------------------------------------------------- /english/warp-cli/README.md: -------------------------------------------------------------------------------- 1 | # Misaka WARP 脚本 - WARP-Cli 2 | 3 | 使用官方CloudFlare WARP客户端开启Socks5代理,实现VPS内的代理上网 4 | 5 | > PS: 由于CloudFlare对WARP-Cli客户端的限制,本脚本只能在amd64的IPv4 only或原生双栈的VPS使用 6 | 7 | ## 使用方法 8 | 9 | ### 安装WARP-Cli并设置代理模式 10 | 11 | ```shell 12 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/warp-cli.sh && bash warp-cli.sh 13 | ``` 14 | 15 | ### 修改WARP-Cli代理端口 16 | 17 | ```shell 18 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/changeport.sh && bash changeport.sh 19 | ``` 20 | 21 | ### 开启/关闭WARP-Cli代理模式 22 | 23 | ```shell 24 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/switch.sh && bash switch.sh 25 | ``` 26 | 27 | 28 | ### 卸载WARP-Cli 29 | 30 | ```shell 31 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/uninstall.sh && bash uninstall.sh 32 | ``` 33 | 34 | ### 刷Netfilx IP 35 | 36 | ```shell 37 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/netfilxcli.sh && bash netfilxcli.sh 38 | ``` 39 | 40 | 可搭配 [Screen 管理脚本](https://github.com/Misaka-blog/screenManager) 使用最佳 41 | 42 | ## 赞助我们 43 | 44 | ![afdian-MisakaNo.jpg](https://s2.loli.net/2021/12/25/SimocqwhVg89NQJ.jpg) 45 | 46 | ## 交流群 47 | [Telegram](https://t.me/misakanetcn) 48 | -------------------------------------------------------------------------------- /english/warp-cli/changeport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | red() { 3 | echo -e "\033[31m\033[01m$1\033[0m" 4 | } 5 | green() { 6 | echo -e "\033[32m\033[01m$1\033[0m" 7 | } 8 | yellow() { 9 | echo -e "\033[33m\033[01m$1\033[0m" 10 | } 11 | 12 | # 判断系统及定义系统安装依赖方式 13 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 14 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 15 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 16 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 17 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 18 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 19 | 20 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 21 | 22 | for i in "${CMD[@]}"; do 23 | SYS="$i" && [[ -n $SYS ]] && break 24 | done 25 | 26 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 27 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 28 | done 29 | 30 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 31 | [[ -z $(type -P warp-cli) ]] && red "WARP-Cli代理模式未安装,脚本即将退出!" && rm -f changeport.sh && exit 1 32 | 33 | changeport(){ 34 | if [[ $(warp-cli --accept-tos status) =~ Connected ]]; then 35 | warp-cli --accept-tos disconnect 36 | fi 37 | read -p "请输入WARP Cli使用的代理端口(默认40000):" WARPCliPort 38 | [[ -z $WARPCliPort ]] && WARPCliPort=40000 39 | warp-cli --accept-tos set-proxy-port "$WARPCliPort" >/dev/null 2>&1 40 | yellow "正在启动Warp-Cli代理模式" 41 | warp-cli --accept-tos connect >/dev/null 2>&1 42 | socks5Status=$(curl -sx socks5h://localhost:$WARPCliPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 2 | grep warp | cut -d= -f2) 43 | until [[ $socks5Status =~ on|plus ]]; do 44 | red "启动Warp-Cli代理模式失败,正在尝试重启" 45 | warp-cli --accept-tos disconnect >/dev/null 2>&1 46 | warp-cli --accept-tos connect >/dev/null 2>&1 47 | socks5Status=$(curl -sx socks5h://localhost:$WARPCliPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 2 | grep warp | cut -d= -f2) 48 | sleep 5 49 | done 50 | warp-cli --accept-tos enable-always-on >/dev/null 2>&1 51 | green "WARP-Cli代理模式已启动成功并成功修改代理端口!" 52 | yellow "本地Socks5代理为: 127.0.0.1:$WARPCliPort" 53 | rm -f changeport.sh 54 | } 55 | 56 | changeport -------------------------------------------------------------------------------- /english/warp-cli/netfilxcli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | green() { 7 | echo -e "\033[32m\033[01m$1\033[0m" 8 | } 9 | yellow() { 10 | echo -e "\033[33m\033[01m$1\033[0m" 11 | } 12 | 13 | # 判断系统及定义系统安装依赖方式 14 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 15 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 16 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 17 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 18 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 19 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 20 | 21 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 22 | 23 | for i in "${CMD[@]}"; do 24 | SYS="$i" && [[ -n $SYS ]] && break 25 | done 26 | 27 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 28 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 29 | done 30 | 31 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 32 | [[ -z $(type -P warp-cli) ]] && red "WARP-Cli代理模式未安装,脚本即将退出!" && rm -f wireproxy-netfilx.sh && exit 1 33 | 34 | WARPCliPort=$(warp-cli --accept-tos settings 2>/dev/null | grep 'WarpProxy on port' | awk -F "port " '{print $2}') 35 | 36 | check(){ 37 | NetfilxStatus=$(curl -sx socks5h://localhost:$WARPCliPort -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/81215567" 2>&1) 38 | if [[ $NetfilxStatus == "200" ]]; then 39 | success 40 | fi 41 | if [[ $NetfilxStatus =~ "403"|"404" ]]; then 42 | failed 43 | fi 44 | if [[ -z $NetfilxStatus ]] || [[ $NetfilxStatus == "000" ]]; then 45 | retry 46 | fi 47 | } 48 | 49 | retry(){ 50 | warp-cli --accept-tos disconnect >/dev/null 2>&1 51 | warp-cli --accept-tos connect >/dev/null 2>&1 52 | check 53 | } 54 | 55 | success(){ 56 | WARPCliIP=$(curl -sx socks5h://localhost:$WARPCliPort https://ip.gs -k --connect-timeout 8) 57 | green "当前WireProxy-WARP的IP:$WARPCliIP 已解锁Netfilx" 58 | yellow "等待1小时后,脚本将会自动重新检查Netfilx解锁状态" 59 | sleep 1h 60 | check 61 | } 62 | 63 | failed(){ 64 | WARPCliIP=$(curl -sx socks5h://localhost:$WARPCliPort https://ip.gs -k --connect-timeout 8) 65 | red "当前WireProxy-WARP的IP:$WARPCliIP 未解锁Netfilx,脚本将在15秒后重新测试Netfilx解锁情况" 66 | sleep 15 67 | warp-cli --accept-tos disconnect >/dev/null 2>&1 68 | warp-cli --accept-tos connect >/dev/null 2>&1 69 | check 70 | } 71 | 72 | check 73 | -------------------------------------------------------------------------------- /english/warp-cli/switch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | red() { 3 | echo -e "\033[31m\033[01m$1\033[0m" 4 | } 5 | green() { 6 | echo -e "\033[32m\033[01m$1\033[0m" 7 | } 8 | yellow() { 9 | echo -e "\033[33m\033[01m$1\033[0m" 10 | } 11 | 12 | # 判断系统及定义系统安装依赖方式 13 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 14 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 15 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 16 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 17 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 18 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 19 | 20 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 21 | 22 | for i in "${CMD[@]}"; do 23 | SYS="$i" && [[ -n $SYS ]] && break 24 | done 25 | 26 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 27 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 28 | done 29 | 30 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 31 | [[ -z $(type -P warp-cli) ]] && red "WARP-Cli代理模式未安装,脚本即将退出!" && exit 1 32 | 33 | switch(){ 34 | if [[ $(warp-cli --accept-tos status) =~ Connected ]]; then 35 | warp-cli --accept-tos disconnect >/dev/null 2>&1 36 | green "WARP-Cli代理模式关闭成功!" 37 | rm -f switch.sh 38 | exit 1 39 | fi 40 | if [[ $(warp-cli --accept-tos status) =~ Disconnected ]]; then 41 | yellow "正在启动Warp-Cli代理模式" 42 | warp-cli --accept-tos connect >/dev/null 2>&1 43 | until [[ $(warp-cli --accept-tos status) =~ Connected ]]; do 44 | red "启动Warp-Cli代理模式失败,正在尝试重启" 45 | warp-cli --accept-tos disconnect >/dev/null 2>&1 46 | warp-cli --accept-tos connect >/dev/null 2>&1 47 | sleep 5 48 | done 49 | warp-cli --accept-tos enable-always-on >/dev/null 2>&1 50 | WARPCliPort=$(warp-cli --accept-tos settings 2>/dev/null | grep 'WarpProxy on port' | awk -F "port " '{print $2}') 51 | green "WARP-Cli代理模式启动成功!" 52 | yellow "本地Socks5代理为:127.0.0.1:$WARPCliPort" 53 | rm -f switch.sh 54 | exit 1 55 | fi 56 | } 57 | 58 | switch 59 | -------------------------------------------------------------------------------- /english/warp-cli/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 34 | [[ -z $(type -P warp-cli) ]] && red "WARP-Cli代理模式未安装,脚本即将退出" && rm -f uninstall.sh && exit 1 35 | 36 | uninstall(){ 37 | warp-cli --accept-tos disconnect >/dev/null 2>&1 38 | warp-cli --accept-tos disable-always-on >/dev/null 2>&1 39 | warp-cli --accept-tos delete >/dev/null 2>&1 40 | ${PACKAGE_UNINSTALL[int]} cloudflare-warp 2>/dev/null 41 | systemctl disable --now warp-svc >/dev/null 2>&1 42 | green "WARP-Cli代理模式已彻底卸载成功!" 43 | rm -f uninstall.sh 44 | } 45 | 46 | uninstall -------------------------------------------------------------------------------- /english/warp-cli/warp-cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P warp-cli) ]] && red "WARP-Cli代理模式已经安装,脚本即将退出" && rm -f warp-cli.sh && exit 1 37 | 38 | arch=`uname -m` 39 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | check_tun(){ 43 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 44 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 45 | if [[ $vpsvirt == "openvz" ]]; then 46 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 47 | else 48 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 49 | exit 1 50 | fi 51 | fi 52 | } 53 | 54 | checkCentOS8(){ 55 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 56 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 57 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 58 | if [[ $comfirmCentOSStream == "y" ]]; then 59 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 60 | sleep 1 61 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 62 | yum clean all && yum makecache 63 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 64 | else 65 | red "已取消升级过程,脚本即将退出!" 66 | exit 1 67 | fi 68 | fi 69 | } 70 | 71 | install_warpcli_centos(){ 72 | ${PACKAGE_INSTALL[int]} epel-release 73 | ${PACKAGE_INSTALL[int]} curl wget sudo net-tools 74 | rpm -ivh http://pkg.cloudflareclient.com/cloudflare-release-el8.rpm 75 | ${PACKAGE_INSTALL[int]} cloudflare-warp 76 | } 77 | 78 | install_warpcli_debian(){ 79 | ${PACKAGE_UPDATE[int]} 80 | ${PACKAGE_INSTALL[int]} lsb-release 81 | [[ -z $(type -P gpg 2>/dev/null) ]] && ${PACKAGE_INSTALL[int]} gnupg 82 | [[ -z $(apt list 2>/dev/null | grep apt-transport-https | grep installed) ]] && ${PACKAGE_INSTALL[int]} apt-transport-https 83 | curl https://pkg.cloudflareclient.com/pubkey.gpg | apt-key add - 84 | echo "deb http://pkg.cloudflareclient.com/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/cloudflare-client.list 85 | ${PACKAGE_UPDATE[int]} 86 | ${PACKAGE_INSTALL[int]} cloudflare-warp 87 | } 88 | 89 | install_warpcli_ubuntu(){ 90 | ${PACKAGE_UPDATE[int]} 91 | ${PACKAGE_INSTALL[int]} curl wget sudo lsb-release 92 | curl https://pkg.cloudflareclient.com/pubkey.gpg | apt-key add - 93 | echo "deb http://pkg.cloudflareclient.com/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/cloudflare-client.list 94 | ${PACKAGE_UPDATE[int]} 95 | ${PACKAGE_INSTALL[int]} cloudflare-warp 96 | } 97 | 98 | register_warpcli(){ 99 | warp-cli --accept-tos register >/dev/null 2>&1 100 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 101 | read -p "按键许可证密钥(26个字符):" WPPlusKey 102 | if [[ -n $WPPlusKey ]]; then 103 | warp-cli --accept-tos set-license "$WPPlusKey" >/dev/null 2>&1 && sleep 1 104 | if [[ $(warp-cli --accept-tos account) =~ Limited ]]; then 105 | green "WARP+账户启用成功" 106 | else 107 | red "WARP+账户启用失败,即将使用WARP免费版账户" 108 | fi 109 | fi 110 | warp-cli --accept-tos set-mode proxy >/dev/null 2>&1 111 | } 112 | 113 | set_proxy_port(){ 114 | read -p "请输入WARP Cli使用的代理端口(默认40000):" WARPCliPort 115 | [[ -z $WARPCliPort ]] && WARPCliPort=40000 116 | warp-cli --accept-tos set-proxy-port "$WARPCliPort" >/dev/null 2>&1 117 | } 118 | 119 | start_warpcli(){ 120 | yellow "正在启动Warp-Cli代理模式" 121 | warp-cli --accept-tos connect >/dev/null 2>&1 122 | # socks5Status=$(curl -sx socks5h://localhost:$WARPCliPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 2 | grep warp | cut -d= -f2) 123 | until [[ $(warp-cli --accept-tos status) =~ Connected ]]; do 124 | red "启动Warp-Cli代理模式失败,正在尝试重启" 125 | warp-cli --accept-tos disconnect >/dev/null 2>&1 126 | warp-cli --accept-tos connect >/dev/null 2>&1 127 | # socks5Status=$(curl -sx socks5h://localhost:$WARPCliPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 2 | grep warp | cut -d= -f2) 128 | sleep 8 129 | done 130 | warp-cli --accept-tos enable-always-on >/dev/null 2>&1 131 | socks5IP=$(curl -sx socks5h://localhost:$WARPCliPort ip.gs -k --connect-timeout 8) 132 | green "WARP-Cli代理模式已启动成功!" 133 | yellow "本地Socks5代理为: 127.0.0.1:$WARPCliPort" 134 | yellow "WARP-Cli代理模式的IP为:$socks5IP" 135 | rm -f warp-cli.sh 136 | } 137 | 138 | install(){ 139 | [[ -z $(curl -s4m8 ip.gs ) ]] && red "WARP-Cli代理模式目前不支持IPv6 Only的VPS,脚本退出" && exit 1 140 | if [[ $arch == "amd64" || $arch == "x86_64" ]]; then 141 | [[ $SYSTEM == "CentOS" ]] && [[ ! ${vsid} =~ 8 ]] && yellow "当前系统版本:Centos $vsid \nWARP-Cli代理模式仅支持Centos 8系统" && exit 1 142 | [[ $SYSTEM == "Debian" ]] && [[ ! ${vsid} =~ 9|10|11 ]] && yellow "当前系统版本:Debian $vsid \nWARP-Cli代理模式仅支持Debian 9-11系统" && exit 1 143 | [[ $SYSTEM == "Ubuntu" ]] && [[ ! ${vsid} =~ 16|20 ]] && yellow "当前系统版本:Ubuntu $vsid \nWARP-Cli代理模式仅支持Ubuntu 16.04/20.04系统" && exit 1 144 | 145 | [[ $SYSTEM == "CentOS" ]] && install_warpcli_centos 146 | [[ $SYSTEM == "Debian" ]] && install_warpcli_debian 147 | [[ $SYSTEM == "Ubuntu" ]] && install_warpcli_ubuntu 148 | 149 | register_warpcli 150 | set_proxy_port 151 | start_warpcli 152 | else 153 | red "不支持的CPU架构!脚本即将退出" 154 | fi 155 | } 156 | 157 | check_tun 158 | checkCentOS8 159 | install 160 | -------------------------------------------------------------------------------- /english/wgcf-warp/README.md: -------------------------------------------------------------------------------- 1 | # Misaka WARP 脚本 - Wgcf WARP 2 | 3 | 使用基于WireGuard的Wgcf非官方CloudFlare WARP客户端,实现VPS内的代理上网 4 | 5 | ## 使用方法 6 | 7 | 请谨慎选择脚本,否则VPS失联不关我的事。 8 | 9 | ### 原生 IPv4 VPS + IPv6 WARP 10 | 11 | ```shell 12 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warp46.sh && bash warp46.sh 13 | ``` 14 | 15 | ### 原生 IPv4 VPS + 双栈 WARP 16 | 17 | ```shell 18 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warp4d.sh && bash warp4d.sh 19 | ``` 20 | 21 | ### 原生 IPv6 VPS + IPv4 WARP 22 | 23 | ```shell 24 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warp64.sh && bash warp64.sh 25 | ``` 26 | 27 | ### 原生 IPv6 VPS + 双栈 WARP 28 | 29 | ```shell 30 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warp6d.sh && bash warp6d.sh 31 | ``` 32 | 33 | ### 原生双栈 VPS + 双栈 WARP 34 | 35 | ```shell 36 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warpd.sh && bash warpd.sh 37 | ``` 38 | 39 | ### 开启 / 关闭 WARP 40 | 41 | ```shell 42 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/switchwarp.sh && bash switchwarp.sh 43 | ``` 44 | 45 | ### 卸载 WARP 46 | 47 | ```shell 48 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/uninstall.sh && bash uninstall.sh 49 | ``` 50 | 51 | ### 刷Netfilx IP (IPv4) 52 | 53 | ```shell 54 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/netfilx4.sh && bash netfilx4.sh 55 | ``` 56 | 57 | ### 刷Netfilx IP (IPv6) 58 | 59 | ```shell 60 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/netfilx6.sh && bash netfilx6.sh 61 | ``` 62 | 63 | 可搭配 [Screen 管理脚本](https://github.com/Misaka-blog/screenManager) 使用最佳 64 | 65 | ## 赞助我们 66 | 67 | ![afdian-MisakaNo.jpg](https://s2.loli.net/2021/12/25/SimocqwhVg89NQJ.jpg) 68 | 69 | ## 交流群 70 | [Telegram](https://t.me/misakanetcn) 71 | -------------------------------------------------------------------------------- /english/wgcf-warp/netfilx4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | green() { 7 | echo -e "\033[32m\033[01m$1\033[0m" 8 | } 9 | yellow() { 10 | echo -e "\033[33m\033[01m$1\033[0m" 11 | } 12 | 13 | # 判断系统及定义系统安装依赖方式 14 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 15 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 16 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 17 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 18 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 19 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 20 | 21 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 22 | 23 | for i in "${CMD[@]}"; do 24 | SYS="$i" && [[ -n $SYS ]] && break 25 | done 26 | 27 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 28 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 29 | done 30 | 31 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 32 | [[ -z $(type -P wg-quick) ]] && red "Wgcf-WARP代理模式未安装,脚本即将退出!" && rm -f netfilx4.sh && exit 1 33 | 34 | check(){ 35 | NetfilxStatus=$(curl -4 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.39" -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/81215567" 2>&1) 36 | if [[ $NetfilxStatus == "200" ]]; then 37 | success 38 | fi 39 | if [[ $NetfilxStatus =~ "403"|"404" ]]; then 40 | failed 41 | fi 42 | if [[ -z $NetfilxStatus ]] || [[ $NetfilxStatus == "000" ]]; then 43 | retry 44 | fi 45 | } 46 | 47 | retry(){ 48 | wg-quick down wgcf >/dev/null 2>&1 49 | wg-quick up wgcf >/dev/null 2>&1 50 | check 51 | } 52 | 53 | success(){ 54 | WgcfWARPIP=$(curl -s4m8 https://ip.gs -k) 55 | green "当前Wgcf-WARP的IP:$WgcfWARPIP 已解锁Netfilx" 56 | yellow "等待1小时后,脚本将会自动重新检查Netfilx解锁状态" 57 | sleep 1h 58 | check 59 | } 60 | 61 | failed(){ 62 | WgcfWARPIP=$(curl -s4m8 https://ip.gs -k) 63 | red "当前Wgcf-WARP的IP:$WgcfWARPIP 未解锁Netfilx,脚本将在15秒后重新测试Netfilx解锁情况" 64 | sleep 15 65 | wg-quick down wgcf >/dev/null 2>&1 66 | wg-quick up wgcf >/dev/null 2>&1 67 | check 68 | } 69 | 70 | check 71 | -------------------------------------------------------------------------------- /english/wgcf-warp/netfilx6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | green() { 7 | echo -e "\033[32m\033[01m$1\033[0m" 8 | } 9 | yellow() { 10 | echo -e "\033[33m\033[01m$1\033[0m" 11 | } 12 | 13 | # 判断系统及定义系统安装依赖方式 14 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 15 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 16 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 17 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 18 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 19 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 20 | 21 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 22 | 23 | for i in "${CMD[@]}"; do 24 | SYS="$i" && [[ -n $SYS ]] && break 25 | done 26 | 27 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 28 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 29 | done 30 | 31 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 32 | [[ -z $(type -P wg-quick) ]] && red "Wgcf-WARP代理模式未安装,脚本即将退出!" && rm -f netfilx4.sh && exit 1 33 | 34 | check(){ 35 | NetfilxStatus=$(curl -6 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.39" -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/81215567" 2>&1) 36 | if [[ $NetfilxStatus == "200" ]]; then 37 | success 38 | fi 39 | if [[ $NetfilxStatus =~ "403"|"404" ]]; then 40 | failed 41 | fi 42 | if [[ -z $NetfilxStatus ]] || [[ $NetfilxStatus == "000" ]]; then 43 | retry 44 | fi 45 | } 46 | 47 | retry(){ 48 | wg-quick down wgcf >/dev/null 2>&1 49 | wg-quick up wgcf >/dev/null 2>&1 50 | check 51 | } 52 | 53 | success(){ 54 | WgcfWARPIP=$(curl -s6m8 https://ip.gs -k) 55 | green "当前Wgcf-WARP的IP:$WgcfWARPIP 已解锁Netfilx" 56 | yellow "等待1小时后,脚本将会自动重新检查Netfilx解锁状态" 57 | sleep 1h 58 | check 59 | } 60 | 61 | failed(){ 62 | WgcfWARPIP=$(curl -s6m8 https://ip.gs -k) 63 | red "当前Wgcf-WARP的IP:$WgcfWARPIP 未解锁Netfilx,脚本将在15秒后重新测试Netfilx解锁情况" 64 | sleep 15 65 | wg-quick down wgcf >/dev/null 2>&1 66 | wg-quick up wgcf >/dev/null 2>&1 67 | check 68 | } 69 | 70 | check 71 | -------------------------------------------------------------------------------- /english/wgcf-warp/switchwarp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 34 | [[ -z $(type -P wg-quick) ]] && red "未安装Wgcf-WARP,脚本即将退出" && rm -f switch.sh && exit 1 35 | 36 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 37 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 38 | 39 | if [[ $WgcfWARP4Status =~ on|plus ]] || [[ $WgcfWARP6Status =~ on|plus ]]; then 40 | wg-quick down wgcf >/dev/null 2>&1 41 | systemctl disable wg-quick@wgcf >/dev/null 2>&1 42 | green "Wgcf-WARP关闭成功!" 43 | exit 1 44 | fi 45 | 46 | if [[ $WgcfWARP4Status == off ]] || [[ $WgcfWARP6Status == off ]]; then 47 | wg-quick up wgcf >/dev/null 2>&1 48 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 49 | green "Wgcf-WARP启动成功!" 50 | exit 1 51 | fi 52 | -------------------------------------------------------------------------------- /english/wgcf-warp/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 34 | [[ -z $(type -P wg-quick) ]] && red "Wgcf-WARP未安装,脚本即将退出" && rm -f uninstall.sh && exit 1 35 | 36 | uninstall(){ 37 | wg-quick down wgcf 2>/dev/null 38 | systemctl disable wg-quick@wgcf 2>/dev/null 39 | ${PACKAGE_UNINSTALL[int]} wireguard-tools wireguard-dkms 2>/dev/null 40 | [[ -z $(type -P wireproxy) ]] && rm -f /usr/local/bin/wgcf 41 | rm -f /etc/wireguard/wgcf.conf 42 | rm -f /etc/wireguard/wgcf-account.toml 43 | rm -f /usr/bin/wireguard-go 44 | if [[ -e /etc/gai.conf ]]; then 45 | sed -i '/^precedence[ ]*::ffff:0:0\/96[ ]*100/d' /etc/gai.conf 46 | fi 47 | green "Wgcf-WARP 已彻底卸载成功!" 48 | rm -f uninstall.sh 49 | } 50 | 51 | uninstall 52 | -------------------------------------------------------------------------------- /english/wgcf-warp/warp46.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warp46.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == "openvz" ]]; then 59 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 60 | else 61 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 62 | exit 1 63 | fi 64 | fi 65 | } 66 | 67 | checkCentOS8(){ 68 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 69 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 70 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 71 | if [[ $comfirmCentOSStream == "y" ]]; then 72 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 73 | sleep 1 74 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 75 | yum clean all && yum makecache 76 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 77 | else 78 | red "已取消升级过程,脚本即将退出!" 79 | exit 1 80 | fi 81 | fi 82 | } 83 | 84 | install_wireguard_centos(){ 85 | ${PACKAGE_INSTALL[int]} epel-release 86 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 87 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 88 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 89 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 90 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 91 | ${PACKAGE_INSTALL[int]} wireguard-dkms 92 | fi 93 | fi 94 | } 95 | 96 | install_wireguard_debian(){ 97 | ${PACKAGE_INSTALL[int]} lsb-release 98 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 99 | ${PACKAGE_UPDATE[int]} 100 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 101 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 102 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 103 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 104 | ${PACKAGE_INSTALL[int]} --no-install-recommends install wireguard-dkms 105 | fi 106 | fi 107 | } 108 | 109 | install_wireguard_ubuntu(){ 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 111 | } 112 | 113 | install_wireguard(){ 114 | ${PACKAGE_UPDATE[int]} 115 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 116 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 117 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 118 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 119 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 120 | if [[ $vpsvirt =~ lxc|openvz ]]; then 121 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go -O /usr/bin/wireguard-go 122 | chmod +x /usr/bin/wireguard-go 123 | fi 124 | if [[ $vpsvirt == zvm ]]; then 125 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go-s390x -O /usr/bin/wireguard-go 126 | chmod +x /usr/bin/wireguard-go 127 | fi 128 | } 129 | 130 | install_wgcf(){ 131 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 132 | chmod +x /usr/local/bin/wgcf 133 | } 134 | 135 | register_wgcf(){ 136 | rm -f wgcf-account.toml 137 | until [[ -a wgcf-account.toml ]]; do 138 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 139 | yes | wgcf register 140 | sleep 5 141 | done 142 | chmod +x wgcf-account.toml 143 | } 144 | 145 | generate_wgcf_config(){ 146 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 147 | read -p "按键许可证密钥(26个字符):" WPPlusKey 148 | if [[ -n $WPPlusKey ]]; then 149 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 150 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 151 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 152 | if [[ -n $WPPlusName ]]; then 153 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 154 | else 155 | wgcf update 156 | fi 157 | fi 158 | wgcf generate 159 | chmod +x wgcf-profile.conf 160 | sed -i '/0\.\0\/0/d' wgcf-profile.conf 161 | sed -i 's/engage.cloudflareclient.com/162.159.193.10/g' wgcf-profile.conf 162 | sed -i 's/1.1.1.1/1.1.1.1,8.8.8.8,8.8.4.4,2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844/g' wgcf-profile.conf 163 | } 164 | 165 | get_best_mtu(){ 166 | v66=`curl -s6m8 https://ip.gs -k` 167 | v44=`curl -s4m8 https://ip.gs -k` 168 | MTUy=1500 169 | MTUc=10 170 | if [[ -n ${v66} && -z ${v44} ]]; then 171 | ping='ping6' 172 | IP1='2606:4700:4700::1001' 173 | IP2='2001:4860:4860::8888' 174 | else 175 | ping='ping' 176 | IP1='1.1.1.1' 177 | IP2='8.8.8.8' 178 | fi 179 | while true; do 180 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 181 | MTUc=1 182 | MTUy=$((${MTUy} + ${MTUc})) 183 | else 184 | MTUy=$((${MTUy} - ${MTUc})) 185 | if [[ ${MTUc} = 1 ]]; then 186 | break 187 | fi 188 | fi 189 | if [[ ${MTUy} -le 1360 ]]; then 190 | MTUy='1360' 191 | break 192 | fi 193 | done 194 | MTU=$((${MTUy} - 80)) 195 | green "MTU最佳值=$MTU 已设置完毕" 196 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 197 | } 198 | 199 | cpto_wireguard(){ 200 | if [[ ! -d "/etc/wireguard" ]]; then 201 | mkdir /etc/wireguard 202 | fi 203 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 204 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 205 | } 206 | 207 | start_wgcf(){ 208 | yellow "正在启动 Wgcf-WARP" 209 | wg-quick up wgcf >/dev/null 2>&1 210 | WgcfWARPStatus=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 211 | until [[ $WgcfWARPStatus =~ "on"|"plus" ]]; do 212 | red "无法启动Wgcf-WARP,正在尝试重启" 213 | wg-quick down wgcf >/dev/null 2>&1 214 | wg-quick up wgcf >/dev/null 2>&1 215 | WgcfWARPStatus=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 216 | sleep 8 217 | done 218 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 219 | WgcfIPv6=$(curl -s6m8 https://ip.gs -k) 220 | green "Wgcf-WARP 已启动成功" 221 | yellow "Wgcf-WARP的IPv6 IP为:$WgcfIPv6" 222 | rm -f warp46.sh 223 | } 224 | 225 | install(){ 226 | install_wireguard 227 | [[ -z $(type -P wgcf) ]] && install_wgcf 228 | register_wgcf 229 | generate_wgcf_config 230 | get_best_mtu 231 | cpto_wireguard 232 | start_wgcf 233 | } 234 | 235 | check_tun 236 | checkCentOS8 237 | install 238 | -------------------------------------------------------------------------------- /english/wgcf-warp/warp4d.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warp4d.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == "openvz" ]]; then 59 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 60 | else 61 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 62 | exit 1 63 | fi 64 | fi 65 | } 66 | 67 | checkCentOS8(){ 68 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 69 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 70 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 71 | if [[ $comfirmCentOSStream == "y" ]]; then 72 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 73 | sleep 1 74 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 75 | yum clean all && yum makecache 76 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 77 | else 78 | red "已取消升级过程,脚本即将退出!" 79 | exit 1 80 | fi 81 | fi 82 | } 83 | 84 | install_wireguard_centos(){ 85 | ${PACKAGE_INSTALL[int]} epel-release 86 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 87 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 88 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 89 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 90 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 91 | ${PACKAGE_INSTALL[int]} wireguard-dkms 92 | fi 93 | fi 94 | } 95 | 96 | install_wireguard_debian(){ 97 | ${PACKAGE_INSTALL[int]} lsb-release 98 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 99 | ${PACKAGE_UPDATE[int]} 100 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 101 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 102 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 103 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 104 | ${PACKAGE_INSTALL[int]} --no-install-recommends wireguard-dkms 105 | fi 106 | fi 107 | } 108 | 109 | install_wireguard_ubuntu(){ 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 111 | } 112 | 113 | install_wireguard(){ 114 | ${PACKAGE_UPDATE[int]} 115 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 116 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 117 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 118 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 119 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 120 | if [[ $vpsvirt =~ lxc|openvz ]]; then 121 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go -O /usr/bin/wireguard-go 122 | chmod +x /usr/bin/wireguard-go 123 | fi 124 | if [[ $vpsvirt == zvm ]]; then 125 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go-s390x -O /usr/bin/wireguard-go 126 | chmod +x /usr/bin/wireguard-go 127 | fi 128 | } 129 | 130 | install_wgcf(){ 131 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 132 | chmod +x /usr/local/bin/wgcf 133 | } 134 | 135 | register_wgcf(){ 136 | rm -f wgcf-account.toml 137 | until [[ -a wgcf-account.toml ]]; do 138 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 139 | yes | wgcf register 140 | sleep 5 141 | done 142 | chmod +x wgcf-account.toml 143 | } 144 | 145 | generate_wgcf_config(){ 146 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 147 | read -p "按键许可证密钥(26个字符):" WPPlusKey 148 | if [[ -n $WPPlusKey ]]; then 149 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 150 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 151 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 152 | if [[ -n $WPPlusName ]]; then 153 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 154 | else 155 | wgcf update 156 | fi 157 | fi 158 | wgcf generate 159 | chmod +x wgcf-profile.conf 160 | sed -i "7 s/^/PostUp = ip -4 rule add from $(ip route get 1.1.1.1 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 161 | sed -i "8 s/^/PostDown = ip -4 rule delete from $(ip route get 1.1.1.1 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 162 | sed -i 's/engage.cloudflareclient.com/162.159.193.10/g' wgcf-profile.conf 163 | sed -i 's/1.1.1.1/1.1.1.1,8.8.8.8,8.8.4.4,2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844/g' wgcf-profile.conf 164 | } 165 | 166 | get_best_mtu(){ 167 | v66=`curl -s6m8 https://ip.gs -k` 168 | v44=`curl -s4m8 https://ip.gs -k` 169 | MTUy=1500 170 | MTUc=10 171 | if [[ -n ${v66} && -z ${v44} ]]; then 172 | ping='ping6' 173 | IP1='2606:4700:4700::1001' 174 | IP2='2001:4860:4860::8888' 175 | else 176 | ping='ping' 177 | IP1='1.1.1.1' 178 | IP2='8.8.8.8' 179 | fi 180 | while true; do 181 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 182 | MTUc=1 183 | MTUy=$((${MTUy} + ${MTUc})) 184 | else 185 | MTUy=$((${MTUy} - ${MTUc})) 186 | if [[ ${MTUc} = 1 ]]; then 187 | break 188 | fi 189 | fi 190 | if [[ ${MTUy} -le 1360 ]]; then 191 | MTUy='1360' 192 | break 193 | fi 194 | done 195 | MTU=$((${MTUy} - 80)) 196 | green "MTU最佳值=$MTU 已设置完毕" 197 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 198 | } 199 | 200 | cpto_wireguard(){ 201 | if [[ ! -d "/etc/wireguard" ]]; then 202 | mkdir /etc/wireguard 203 | fi 204 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 205 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 206 | } 207 | 208 | start_wgcf(){ 209 | yellow "正在启动 Wgcf-WARP" 210 | wg-quick up wgcf >/dev/null 2>&1 211 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 212 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 213 | until [[ $WgcfWARP4Status =~ on|plus ]] && [[ $WgcfWARP6Status =~ on|plus ]]; do 214 | red "无法启动Wgcf-WARP,正在尝试重启" 215 | wg-quick down wgcf >/dev/null 2>&1 216 | wg-quick up wgcf >/dev/null 2>&1 217 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 218 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 219 | sleep 8 220 | done 221 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 222 | WgcfIPv4=$(curl -s4m8 https://ip.gs -k) 223 | WgcfIPv6=$(curl -s6m8 https://ip.gs -k) 224 | green "Wgcf-WARP 已启动成功" 225 | yellow "Wgcf-WARP的IPv4 IP为:$WgcfIPv4" 226 | yellow "Wgcf-WARP的IPv6 IP为:$WgcfIPv6" 227 | rm -f warp4d.sh 228 | } 229 | 230 | install(){ 231 | install_wireguard 232 | [[ -z $(type -P wgcf) ]] && install_wgcf 233 | register_wgcf 234 | generate_wgcf_config 235 | get_best_mtu 236 | cpto_wireguard 237 | start_wgcf 238 | } 239 | 240 | check_tun 241 | checkCentOS8 242 | install 243 | -------------------------------------------------------------------------------- /english/wgcf-warp/warp64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warp64.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == lxc ]]; then 59 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 60 | red "检测到未开启TUN模块,请到VPS厂商的控制面板处开启" 61 | exit 1 62 | else 63 | yellow "检测到您的VPS为LXC架构,且支持内核级别的Wireguard,继续安装" 64 | fi 65 | elif [[ $vpsvirt == "openvz" ]]; then 66 | wget -N --no-check-certificate https://gitlab.com/misaka-blog/tun-script/-/raw/master/tun.sh && bash tun.sh 67 | else 68 | red "检测到未开启TUN模块,请到VPS厂商的控制面板处开启" 69 | exit 1 70 | fi 71 | fi 72 | } 73 | 74 | checkCentOS8(){ 75 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 76 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 77 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 78 | if [[ $comfirmCentOSStream == "y" ]]; then 79 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 80 | sleep 1 81 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 82 | yum clean all && yum makecache 83 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 84 | else 85 | red "已取消升级过程,脚本即将退出!" 86 | exit 1 87 | fi 88 | fi 89 | } 90 | 91 | install_wireguard_centos(){ 92 | ${PACKAGE_INSTALL[int]} epel-release 93 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 94 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 95 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 96 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 97 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 98 | ${PACKAGE_INSTALL[int]} wireguard-dkms 99 | fi 100 | fi 101 | } 102 | 103 | install_wireguard_debian(){ 104 | ${PACKAGE_INSTALL[int]} lsb-release 105 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 106 | ${PACKAGE_UPDATE[int]} 107 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 108 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 109 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 111 | ${PACKAGE_INSTALL[int]} --no-install-recommends wireguard-dkms 112 | fi 113 | fi 114 | } 115 | 116 | install_wireguard_ubuntu(){ 117 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 118 | } 119 | 120 | install_wireguard(){ 121 | ${PACKAGE_UPDATE[int]} 122 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 123 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 124 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 125 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 126 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 127 | if [[ $vpsvirt =~ lxc|openvz ]]; then 128 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 129 | wget -N --no-check-certificate https://gitlab.com/misaka-blog/warp-script/-/raw/master/files/wireguard-go -O /usr/bin/wireguard-go 130 | chmod +x /usr/bin/wireguard-go 131 | fi 132 | fi 133 | if [[ $vpsvirt == zvm ]]; then 134 | wget -N --no-check-certificate https://gitlab.com/misaka-blog/warp-script/-/raw/master/files/wireguard-go-s390x -O /usr/bin/wireguard-go 135 | chmod +x /usr/bin/wireguard-go 136 | fi 137 | } 138 | 139 | install_wgcf(){ 140 | wget -N --no-check-certificate https://gitlab.com/misaka-blog/warp-script/-/raw/master/files/wgcf-latest-linux-$(archAffix) -O /usr/local/bin/wgcf 141 | chmod +x /usr/local/bin/wgcf 142 | } 143 | 144 | register_wgcf(){ 145 | rm -f wgcf-account.toml 146 | until [[ -a wgcf-account.toml ]]; do 147 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 148 | yes | wgcf register 149 | sleep 5 150 | done 151 | chmod +x wgcf-account.toml 152 | } 153 | 154 | generate_wgcf_config(){ 155 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 156 | read -p "按键许可证密钥(26个字符):" WPPlusKey 157 | if [[ -n $WPPlusKey ]]; then 158 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 159 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 160 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 161 | if [[ -n $WPPlusName ]]; then 162 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 163 | else 164 | wgcf update 165 | fi 166 | fi 167 | wgcf generate 168 | chmod +x wgcf-profile.conf 169 | sed -i '/\:\:\/0/d' wgcf-profile.conf 170 | sed -i 's/engage.cloudflareclient.com/[2606:4700:d0::a29f:c001]/g' wgcf-profile.conf 171 | sed -i 's/1.1.1.1/2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844,1.1.1.1,8.8.8.8,8.8.4.4/g' wgcf-profile.conf 172 | } 173 | 174 | get_best_mtu(){ 175 | v66=`curl -s6m8 https://ip.gs -k` 176 | v44=`curl -s4m8 https://ip.gs -k` 177 | MTUy=1500 178 | MTUc=10 179 | if [[ -n ${v66} && -z ${v44} ]]; then 180 | ping='ping6' 181 | IP1='2606:4700:4700::1001' 182 | IP2='2001:4860:4860::8888' 183 | else 184 | ping='ping' 185 | IP1='1.1.1.1' 186 | IP2='8.8.8.8' 187 | fi 188 | while true; do 189 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 190 | MTUc=1 191 | MTUy=$((${MTUy} + ${MTUc})) 192 | else 193 | MTUy=$((${MTUy} - ${MTUc})) 194 | if [[ ${MTUc} = 1 ]]; then 195 | break 196 | fi 197 | fi 198 | if [[ ${MTUy} -le 1360 ]]; then 199 | MTUy='1360' 200 | break 201 | fi 202 | done 203 | MTU=$((${MTUy} - 80)) 204 | green "MTU最佳值=$MTU 已设置完毕" 205 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 206 | } 207 | 208 | cpto_wireguard(){ 209 | if [[ ! -d "/etc/wireguard" ]]; then 210 | mkdir /etc/wireguard 211 | fi 212 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 213 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 214 | } 215 | 216 | start_wgcf(){ 217 | yellow "正在启动 Wgcf-WARP" 218 | wg-quick up wgcf >/dev/null 2>&1 219 | WgcfWARPStatus=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 220 | until [[ $WgcfWARPStatus =~ on|plus ]]; do 221 | red "无法启动Wgcf-WARP,正在尝试重启" 222 | wg-quick down wgcf >/dev/null 2>&1 223 | wg-quick up wgcf >/dev/null 2>&1 224 | WgcfWARPStatus=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 225 | sleep 8 226 | done 227 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 228 | WgcfIPv4=$(curl -s4m8 https://ip.gs -k) 229 | green "Wgcf-WARP 已启动成功" 230 | yellow "Wgcf-WARP的IPv4 IP为:$WgcfIPv4" 231 | rm -f warp64.sh 232 | } 233 | 234 | install(){ 235 | install_wireguard 236 | [[ -z $(type -P wgcf) ]] && install_wgcf 237 | register_wgcf 238 | generate_wgcf_config 239 | get_best_mtu 240 | cpto_wireguard 241 | start_wgcf 242 | } 243 | 244 | check_tun 245 | checkCentOS8 246 | install -------------------------------------------------------------------------------- /english/wgcf-warp/warp6d.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warp6d.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == "openvz" ]]; then 59 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 60 | else 61 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 62 | exit 1 63 | fi 64 | fi 65 | } 66 | 67 | checkCentOS8(){ 68 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 69 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 70 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 71 | if [[ $comfirmCentOSStream == "y" ]]; then 72 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 73 | sleep 1 74 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 75 | yum clean all && yum makecache 76 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 77 | else 78 | red "已取消升级过程,脚本即将退出!" 79 | exit 1 80 | fi 81 | fi 82 | } 83 | 84 | install_wireguard_centos(){ 85 | ${PACKAGE_INSTALL[int]} epel-release 86 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 87 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 88 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 89 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 90 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 91 | ${PACKAGE_INSTALL[int]} wireguard-dkms 92 | fi 93 | fi 94 | } 95 | 96 | install_wireguard_debian(){ 97 | ${PACKAGE_INSTALL[int]} lsb-release 98 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 99 | ${PACKAGE_UPDATE[int]} 100 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 101 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 102 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 103 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 104 | ${PACKAGE_INSTALL[int]} --no-install-recommends wireguard-dkms 105 | fi 106 | fi 107 | } 108 | 109 | install_wireguard_ubuntu(){ 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 111 | } 112 | 113 | install_wireguard(){ 114 | ${PACKAGE_UPDATE[int]} 115 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 116 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 117 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 118 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 119 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 120 | if [[ $vpsvirt =~ lxc|openvz ]]; then 121 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go -O /usr/bin/wireguard-go 122 | chmod +x /usr/bin/wireguard-go 123 | fi 124 | if [[ $vpsvirt == zvm ]]; then 125 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go-s390x -O /usr/bin/wireguard-go 126 | chmod +x /usr/bin/wireguard-go 127 | fi 128 | } 129 | 130 | install_wgcf(){ 131 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 132 | chmod +x /usr/local/bin/wgcf 133 | } 134 | 135 | register_wgcf(){ 136 | rm -f wgcf-account.toml 137 | until [[ -a wgcf-account.toml ]]; do 138 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 139 | yes | wgcf register 140 | sleep 5 141 | done 142 | chmod +x wgcf-account.toml 143 | } 144 | 145 | generate_wgcf_config(){ 146 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 147 | read -p "按键许可证密钥(26个字符):" WPPlusKey 148 | if [[ -n $WPPlusKey ]]; then 149 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 150 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 151 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 152 | if [[ -n $WPPlusName ]]; then 153 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 154 | else 155 | wgcf update 156 | fi 157 | fi 158 | wgcf generate 159 | chmod +x wgcf-profile.conf 160 | sed -i "7 s/^/PostUp = ip -6 rule add from $(ip route get 2606:4700:4700::1001 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 161 | sed -i "8 s/^/PostDown = ip -6 rule delete from $(ip route get 2606:4700:4700::1001 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 162 | sed -i 's/engage.cloudflareclient.com/[2606:4700:d0::a29f:c001]/g' wgcf-profile.conf 163 | sed -i 's/1.1.1.1/2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844,1.1.1.1,8.8.8.8,8.8.4.4/g' wgcf-profile.conf 164 | } 165 | 166 | get_best_mtu(){ 167 | v66=`curl -s6m8 https://ip.gs -k` 168 | v44=`curl -s4m8 https://ip.gs -k` 169 | MTUy=1500 170 | MTUc=10 171 | if [[ -n ${v66} && -z ${v44} ]]; then 172 | ping='ping6' 173 | IP1='2606:4700:4700::1001' 174 | IP2='2001:4860:4860::8888' 175 | else 176 | ping='ping' 177 | IP1='1.1.1.1' 178 | IP2='8.8.8.8' 179 | fi 180 | while true; do 181 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 182 | MTUc=1 183 | MTUy=$((${MTUy} + ${MTUc})) 184 | else 185 | MTUy=$((${MTUy} - ${MTUc})) 186 | if [[ ${MTUc} = 1 ]]; then 187 | break 188 | fi 189 | fi 190 | if [[ ${MTUy} -le 1360 ]]; then 191 | MTUy='1360' 192 | break 193 | fi 194 | done 195 | MTU=$((${MTUy} - 80)) 196 | green "MTU最佳值=$MTU 已设置完毕" 197 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 198 | } 199 | 200 | cpto_wireguard(){ 201 | if [[ ! -d "/etc/wireguard" ]]; then 202 | mkdir /etc/wireguard 203 | fi 204 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 205 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 206 | } 207 | 208 | start_wgcf(){ 209 | yellow "正在启动 Wgcf-WARP" 210 | wg-quick up wgcf >/dev/null 2>&1 211 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 212 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 213 | until [[ $WgcfWARP4Status =~ on|plus ]] && [[ $WgcfWARP6Status =~ on|plus ]]; do 214 | red "无法启动Wgcf-WARP,正在尝试重启" 215 | wg-quick down wgcf >/dev/null 2>&1 216 | wg-quick up wgcf >/dev/null 2>&1 217 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 218 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 219 | sleep 8 220 | done 221 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 222 | WgcfIPv4=$(curl -s4m8 https://ip.gs -k) 223 | WgcfIPv6=$(curl -s6m8 https://ip.gs -k) 224 | green "Wgcf-WARP 已启动成功" 225 | yellow "Wgcf-WARP的IPv4 IP为:$WgcfIPv4" 226 | yellow "Wgcf-WARP的IPv6 IP为:$WgcfIPv6" 227 | rm -f warp6d.sh 228 | } 229 | 230 | install(){ 231 | install_wireguard 232 | [[ -z $(type -P wgcf) ]] && install_wgcf 233 | register_wgcf 234 | generate_wgcf_config 235 | get_best_mtu 236 | cpto_wireguard 237 | start_wgcf 238 | } 239 | 240 | check_tun 241 | checkCentOS8 242 | install 243 | -------------------------------------------------------------------------------- /english/wgcf-warp/warpd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warpd.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == "openvz" ]]; then 59 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 60 | else 61 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 62 | exit 1 63 | fi 64 | fi 65 | } 66 | 67 | checkCentOS8(){ 68 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 69 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 70 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 71 | if [[ $comfirmCentOSStream == "y" ]]; then 72 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 73 | sleep 1 74 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 75 | yum clean all && yum makecache 76 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 77 | else 78 | red "已取消升级过程,脚本即将退出!" 79 | exit 1 80 | fi 81 | fi 82 | } 83 | 84 | install_wireguard_centos(){ 85 | ${PACKAGE_INSTALL[int]} epel-release 86 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 87 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 88 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 89 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 90 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 91 | ${PACKAGE_INSTALL[int]} wireguard-dkms 92 | fi 93 | fi 94 | } 95 | 96 | install_wireguard_debian(){ 97 | ${PACKAGE_INSTALL[int]} lsb-release 98 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 99 | ${PACKAGE_UPDATE[int]} 100 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 101 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 102 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 103 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 104 | ${PACKAGE_INSTALL[int]} --no-install-recommends wireguard-dkms 105 | fi 106 | fi 107 | } 108 | 109 | install_wireguard_ubuntu(){ 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 111 | } 112 | 113 | install_wireguard(){ 114 | ${PACKAGE_UPDATE[int]} 115 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 116 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 117 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 118 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 119 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 120 | if [[ $vpsvirt =~ lxc|openvz ]]; then 121 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go -O /usr/bin/wireguard-go 122 | chmod +x /usr/bin/wireguard-go 123 | fi 124 | if [[ $vpsvirt == zvm ]]; then 125 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go-s390x -O /usr/bin/wireguard-go 126 | chmod +x /usr/bin/wireguard-go 127 | fi 128 | } 129 | 130 | install_wgcf(){ 131 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 132 | chmod +x /usr/local/bin/wgcf 133 | } 134 | 135 | register_wgcf(){ 136 | rm -f wgcf-account.toml 137 | until [[ -a wgcf-account.toml ]]; do 138 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 139 | yes | wgcf register 140 | sleep 5 141 | done 142 | chmod +x wgcf-account.toml 143 | } 144 | 145 | generate_wgcf_config(){ 146 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 147 | read -p "按键许可证密钥(26个字符):" WPPlusKey 148 | if [[ -n $WPPlusKey ]]; then 149 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 150 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 151 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 152 | if [[ -n $WPPlusName ]]; then 153 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 154 | else 155 | wgcf update 156 | fi 157 | fi 158 | wgcf generate 159 | chmod +x wgcf-profile.conf 160 | sed -i "7 s/^/PostUp = ip -4 rule add from $(ip route get 1.1.1.1 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 161 | sed -i "8 s/^/PostDown = ip -4 rule delete from $(ip route get 1.1.1.1 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 162 | sed -i "9 s/^/PostUp = ip -6 rule add from $(ip route get 2606:4700:4700::1001 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 163 | sed -i "10 s/^/PostDown = ip -6 rule delete from $(ip route get 2606:4700:4700::1001 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 164 | sed -i 's/1.1.1.1/1.1.1.1,8.8.8.8,8.8.4.4,2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844/g' wgcf-profile.conf 165 | } 166 | 167 | get_best_mtu(){ 168 | v66=`curl -s6m8 https://ip.gs -k` 169 | v44=`curl -s4m8 https://ip.gs -k` 170 | MTUy=1500 171 | MTUc=10 172 | if [[ -n ${v66} && -z ${v44} ]]; then 173 | ping='ping6' 174 | IP1='2606:4700:4700::1001' 175 | IP2='2001:4860:4860::8888' 176 | else 177 | ping='ping' 178 | IP1='1.1.1.1' 179 | IP2='8.8.8.8' 180 | fi 181 | while true; do 182 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 183 | MTUc=1 184 | MTUy=$((${MTUy} + ${MTUc})) 185 | else 186 | MTUy=$((${MTUy} - ${MTUc})) 187 | if [[ ${MTUc} = 1 ]]; then 188 | break 189 | fi 190 | fi 191 | if [[ ${MTUy} -le 1360 ]]; then 192 | MTUy='1360' 193 | break 194 | fi 195 | done 196 | MTU=$((${MTUy} - 80)) 197 | green "MTU最佳值=$MTU 已设置完毕" 198 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 199 | } 200 | 201 | cpto_wireguard(){ 202 | if [[ ! -d "/etc/wireguard" ]]; then 203 | mkdir /etc/wireguard 204 | fi 205 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 206 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 207 | } 208 | 209 | start_wgcf(){ 210 | yellow "正在启动 Wgcf-WARP" 211 | wg-quick up wgcf >/dev/null 2>&1 212 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 213 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 214 | until [[ $WgcfWARP4Status =~ on|plus ]] && [[ $WgcfWARP6Status =~ on|plus ]]; do 215 | red "无法启动Wgcf-WARP,正在尝试重启" 216 | wg-quick down wgcf >/dev/null 2>&1 217 | wg-quick up wgcf >/dev/null 2>&1 218 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 219 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 220 | sleep 8 221 | done 222 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 223 | WgcfIPv4=$(curl -s4m8 https://ip.gs -k) 224 | WgcfIPv6=$(curl -s6m8 https://ip.gs -k) 225 | green "Wgcf-WARP 已启动成功" 226 | yellow "Wgcf-WARP的IPv4 IP为:$WgcfIPv4" 227 | yellow "Wgcf-WARP的IPv6 IP为:$WgcfIPv6" 228 | rm -f warpd.sh 229 | } 230 | 231 | install(){ 232 | install_wireguard 233 | install_wgcf 234 | register_wgcf 235 | generate_wgcf_config 236 | get_best_mtu 237 | cpto_wireguard 238 | start_wgcf 239 | } 240 | 241 | check_tun 242 | checkCentOS8 243 | install 244 | -------------------------------------------------------------------------------- /english/wireproxy-warp/README.md: -------------------------------------------------------------------------------- 1 | # Misaka WARP 脚本 - WireProxy-WARP 代理模式 2 | 3 | 使用基于WireGuard的用户代理程序WireProxy,在VPS创建本地Socks5代理 4 | 5 | ## 使用方法 6 | 7 | ### IPv4 Only或原生双栈VPS 8 | 9 | ```shell 10 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/warp4.sh && bash warp4.sh 11 | ``` 12 | 13 | ### IPv6 Only VPS 14 | 15 | ```shell 16 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/warp6.sh && bash warp6.sh 17 | ``` 18 | 19 | ### 修改WireProxy端口 20 | 21 | ```shell 22 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/changeport.sh && bash changeport.sh 23 | ``` 24 | 25 | ### 卸载WireProxy-WARP 代理模式 26 | 27 | ```shell 28 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/uninstall.sh && bash uninstall.sh 29 | ``` 30 | 31 | ### 刷Netfilx IP 32 | 33 | ```shell 34 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/netfilx-wireproxy.sh && bash netfilx-wireproxy.sh 35 | ``` 36 | 37 | 可搭配 [Screen 管理脚本](https://github.com/Misaka-blog/screenManager) 使用最佳 38 | 39 | ## 开关WireProxy WARP 40 | 41 | 启动:`systemctl start wireproxy-warp` 42 | 43 | 关闭:`systemctl stop wireproxy-warp` 44 | 45 | 设置开机自启:`systemctl enable wireproxy-warp` 46 | 47 | 取消开机自启:`systemctl disable wireproxy-warp` 48 | 49 | ## 赞助我们 50 | 51 | ![afdian-MisakaNo.jpg](https://s2.loli.net/2021/12/25/SimocqwhVg89NQJ.jpg) 52 | 53 | ## 交流群 54 | [Telegram](https://t.me/misakanetcn) 55 | 56 | -------------------------------------------------------------------------------- /english/wireproxy-warp/changeport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | red() { 3 | echo -e "\033[31m\033[01m$1\033[0m" 4 | } 5 | green() { 6 | echo -e "\033[32m\033[01m$1\033[0m" 7 | } 8 | yellow() { 9 | echo -e "\033[33m\033[01m$1\033[0m" 10 | } 11 | 12 | # 判断系统及定义系统安装依赖方式 13 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 14 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 15 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 16 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 17 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 18 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 19 | 20 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 21 | 22 | for i in "${CMD[@]}"; do 23 | SYS="$i" && [[ -n $SYS ]] && break 24 | done 25 | 26 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 27 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 28 | done 29 | 30 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 31 | [[ -z $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式未安装,脚本即将退出!" && rm -f changeport.sh && exit 1 32 | 33 | changeport(){ 34 | systemctl stop wireproxy-warp 35 | read -p "请输入WARP Cli使用的代理端口(默认40000):" WireProxyPort 36 | [[ -z $WireProxyPort ]] && WireProxyPort=40000 37 | CurrentPort=$(grep BindAddress /etc/wireguard/proxy.conf) 38 | sed -i "s/$CurrentPort/BindAddress = 127.0.0.1:$WireProxyPort/g" /etc/wireguard/proxy.conf 39 | yellow "正在启动WireProxy-WARP代理模式" 40 | systemctl start wireproxy-warp 41 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 42 | until [[ $socks5Status =~ on|plus ]]; do 43 | red "启动WireProxy-WARP代理模式失败,正在尝试重启" 44 | systemctl stop wireproxy-warp 45 | systemctl start wireproxy-warp 46 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 47 | sleep 8 48 | done 49 | systemctl enable wireproxy-warp 50 | green "WireProxy-WARP代理模式已启动成功!" 51 | yellow "本地Socks5代理为: 127.0.0.1:$WireProxyPort" 52 | rm -f changeport.sh 53 | } 54 | 55 | changeport -------------------------------------------------------------------------------- /english/wireproxy-warp/netfilx-wireproxy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | green() { 7 | echo -e "\033[32m\033[01m$1\033[0m" 8 | } 9 | yellow() { 10 | echo -e "\033[33m\033[01m$1\033[0m" 11 | } 12 | 13 | # 判断系统及定义系统安装依赖方式 14 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 15 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 16 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 17 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 18 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 19 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 20 | 21 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 22 | 23 | for i in "${CMD[@]}"; do 24 | SYS="$i" && [[ -n $SYS ]] && break 25 | done 26 | 27 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 28 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 29 | done 30 | 31 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 32 | [[ -z $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式未安装,脚本即将退出!" && rm -f wireproxy-netfilx.sh && exit 1 33 | 34 | WireProxyPort=$(grep BindAddress /etc/wireguard/proxy.conf 2>/dev/null | sed "s/BindAddress = 127.0.0.1://g") 35 | 36 | check(){ 37 | NetfilxStatus=$(curl -sx socks5h://localhost:$WireProxyPort -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/81215567" 2>&1) 38 | if [[ $NetfilxStatus == "200" ]]; then 39 | success 40 | fi 41 | if [[ $NetfilxStatus =~ "403"|"404" ]]; then 42 | failed 43 | fi 44 | if [[ -z $NetfilxStatus ]] || [[ $NetfilxStatus == "000" ]]; then 45 | retry 46 | fi 47 | } 48 | 49 | retry(){ 50 | systemctl stop wireproxy-warp 51 | systemctl start wireproxy-warp 52 | check 53 | } 54 | 55 | success(){ 56 | WireProxyIP=$(curl -sx socks5h://localhost:$WireProxyPort https://ip.gs -k --connect-timeout 8) 57 | green "当前WireProxy-WARP的IP:$WireProxyIP 已解锁Netfilx" 58 | yellow "等待1小时后,脚本将会自动重新检查Netfilx解锁状态" 59 | sleep 1h 60 | check 61 | } 62 | 63 | failed(){ 64 | WireProxyIP=$(curl -sx socks5h://localhost:$WireProxyPort https://ip.gs -k --connect-timeout 8) 65 | red "当前WireProxy-WARP的IP:$WireProxyIP 未解锁Netfilx,脚本将在15秒后重新测试Netfilx解锁情况" 66 | sleep 15 67 | systemctl stop wireproxy-warp 68 | systemctl start wireproxy-warp 69 | check 70 | } 71 | 72 | check 73 | -------------------------------------------------------------------------------- /english/wireproxy-warp/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 34 | [[ -z $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式未安装,脚本即将退出" && rm -f uninstall.sh && exit 1 35 | 36 | uninstall(){ 37 | systemctl stop wireproxy-warp 38 | systemctl disable wireproxy-warp 39 | rm -f /etc/systemd/system/wireproxy-warp.service 40 | rm -f /usr/local/bin/wireproxy 41 | rm -f /etc/wireguard/proxy.conf 42 | if [[ ! -f /etc/wireguard/wgcf.conf ]]; then 43 | rm -f /etc/wireguard/wgcf-account.toml 44 | rm -f /usr/local/bin/wgcf 45 | fi 46 | green "WARP-Cli代理模式已彻底卸载成功!" 47 | rm -f uninstall.sh 48 | } 49 | 50 | uninstall 51 | -------------------------------------------------------------------------------- /english/wireproxy-warp/warp4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式已经安装,脚本即将退出" && rm -f warp4d.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | install_wgcf(){ 56 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 57 | chmod +x /usr/local/bin/wgcf 58 | } 59 | 60 | register_wgcf(){ 61 | rm -f wgcf-account.toml 62 | until [[ -a wgcf-account.toml ]]; do 63 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 64 | yes | wgcf register 65 | sleep 5 66 | done 67 | chmod +x wgcf-account.toml 68 | } 69 | 70 | generate_wgcf_config(){ 71 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 72 | read -p "按键许可证密钥(26个字符):" WPPlusKey 73 | if [[ -n $WPPlusKey ]]; then 74 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 75 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 76 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 77 | if [[ -n $WPPlusName ]]; then 78 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 79 | else 80 | wgcf update 81 | fi 82 | fi 83 | wgcf generate 84 | chmod +x wgcf-profile.conf 85 | } 86 | 87 | get_best_mtu(){ 88 | v66=`curl -s6m8 https://ip.gs -k` 89 | v44=`curl -s4m8 https://ip.gs -k` 90 | MTUy=1500 91 | MTUc=10 92 | if [[ -n ${v66} && -z ${v44} ]]; then 93 | ping='ping6' 94 | IP1='2606:4700:4700::1001' 95 | IP2='2001:4860:4860::8888' 96 | else 97 | ping='ping' 98 | IP1='1.1.1.1' 99 | IP2='8.8.8.8' 100 | fi 101 | while true; do 102 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 103 | MTUc=1 104 | MTUy=$((${MTUy} + ${MTUc})) 105 | else 106 | MTUy=$((${MTUy} - ${MTUc})) 107 | if [[ ${MTUc} = 1 ]]; then 108 | break 109 | fi 110 | fi 111 | if [[ ${MTUy} -le 1360 ]]; then 112 | MTUy='1360' 113 | break 114 | fi 115 | done 116 | MTU=$((${MTUy} - 80)) 117 | green "MTU最佳值=$MTU 已设置完毕" 118 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 119 | } 120 | 121 | make_wireproxy_file(){ 122 | read -p "请输入将要设置的Socks5端口(默认40000):" WireProxyPort 123 | [[ -z $WireProxyPort ]] && WireProxyPort=40000 124 | WgcfPrivateKey=$(grep PrivateKey wgcf-profile.conf | sed "s/PrivateKey = //g") 125 | WgcfPublicKey=$(grep PublicKey wgcf-profile.conf | sed "s/PublicKey = //g") 126 | 127 | if [[ ! -d "/etc/wireguard" ]]; then 128 | mkdir /etc/wireguard 129 | fi 130 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 131 | 132 | cat < /etc/wireguard/proxy.conf 133 | [Interface] 134 | Address = 172.16.0.2/32 135 | MTU = $MTU 136 | PrivateKey = $WgcfPrivateKey 137 | DNS = 1.1.1.1,8.8.8.8,8.8.4.4 138 | 139 | [Peer] 140 | PublicKey = $WgcfPublicKey 141 | Endpoint = 162.159.193.10:2408 142 | 143 | [Socks5] 144 | BindAddress = 127.0.0.1:$WireProxyPort 145 | EOF 146 | green "WireProxy-WARP代理模式配置文件已生成成功!" 147 | cat <<'TEXT' > /etc/systemd/system/wireproxy-warp.service 148 | [Unit] 149 | Description=CloudFlare WARP based for WireProxy, script by owo.misaka.rest 150 | After=network.target 151 | [Install] 152 | WantedBy=multi-user.target 153 | [Service] 154 | Type=simple 155 | WorkingDirectory=/root 156 | ExecStart=/usr/local/bin/wireproxy -c /etc/wireguard/proxy.conf 157 | Restart=always 158 | TEXT 159 | green "Systemd 系统守护服务设置成功!" 160 | rm -f wgcf-profile.conf 161 | } 162 | 163 | download_wireproxy(){ 164 | if [[ $arch == "amd64" || $arch == "x86_64" ]]; then 165 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-amd64 -O /usr/local/bin/wireproxy 166 | chmod +x /usr/local/bin/wireproxy 167 | fi 168 | if [[ $arch == "armv8" || $arch == "arm64" || $arch == "aarch64" ]]; then 169 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-arm64 -O /usr/local/bin/wireproxy 170 | chmod +x /usr/local/bin/wireproxy 171 | fi 172 | if [[ $arch == "s390x" ]]; then 173 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-s390x -O /usr/local/bin/wireproxy 174 | chmod +x /usr/local/bin/wireproxy 175 | fi 176 | } 177 | 178 | start_wireproxy_warp(){ 179 | yellow "正在启动WireProxy-WARP代理模式" 180 | systemctl start wireproxy-warp 181 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 182 | until [[ $socks5Status =~ on|plus ]]; do 183 | red "启动WireProxy-WARP代理模式失败,正在尝试重启" 184 | systemctl stop wireproxy-warp 185 | systemctl start wireproxy-warp 186 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 187 | sleep 8 188 | done 189 | systemctl enable wireproxy-warp 190 | socks5IP=$(curl -sx socks5h://localhost:$WireProxyPort https://ip.gs -k --connect-timeout 8) 191 | green "WireProxy-WARP代理模式已启动成功!" 192 | yellow "本地Socks5代理为: 127.0.0.1:$WireProxyPort" 193 | yellow "WireProxy-WARP代理模式的IP为:$socks5IP" 194 | rm -f warp4.sh 195 | } 196 | 197 | install(){ 198 | ${PACKAGE_UPDATE[int]} 199 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 200 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 201 | [[ -z $(type -P wgcf) ]] && install_wgcf 202 | register_wgcf 203 | generate_wgcf_config 204 | get_best_mtu 205 | make_wireproxy_file 206 | download_wireproxy 207 | start_wireproxy_warp 208 | } 209 | 210 | install 211 | -------------------------------------------------------------------------------- /english/wireproxy-warp/warp6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式已经安装,脚本即将退出" && rm -f warp4d.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | install_wgcf(){ 56 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 57 | chmod +x /usr/local/bin/wgcf 58 | } 59 | 60 | register_wgcf(){ 61 | rm -f wgcf-account.toml 62 | until [[ -a wgcf-account.toml ]]; do 63 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 64 | yes | wgcf register 65 | sleep 5 66 | done 67 | chmod +x wgcf-account.toml 68 | } 69 | 70 | generate_wgcf_config(){ 71 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 72 | read -p "按键许可证密钥(26个字符):" WPPlusKey 73 | if [[ -n $WPPlusKey ]]; then 74 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 75 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 76 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 77 | if [[ -n $WPPlusName ]]; then 78 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 79 | else 80 | wgcf update 81 | fi 82 | fi 83 | wgcf generate 84 | chmod +x wgcf-profile.conf 85 | } 86 | 87 | get_best_mtu(){ 88 | v66=`curl -s6m8 https://ip.gs -k` 89 | v44=`curl -s4m8 https://ip.gs -k` 90 | MTUy=1500 91 | MTUc=10 92 | if [[ -n ${v66} && -z ${v44} ]]; then 93 | ping='ping6' 94 | IP1='2606:4700:4700::1001' 95 | IP2='2001:4860:4860::8888' 96 | else 97 | ping='ping' 98 | IP1='1.1.1.1' 99 | IP2='8.8.8.8' 100 | fi 101 | while true; do 102 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 103 | MTUc=1 104 | MTUy=$((${MTUy} + ${MTUc})) 105 | else 106 | MTUy=$((${MTUy} - ${MTUc})) 107 | if [[ ${MTUc} = 1 ]]; then 108 | break 109 | fi 110 | fi 111 | if [[ ${MTUy} -le 1360 ]]; then 112 | MTUy='1360' 113 | break 114 | fi 115 | done 116 | MTU=$((${MTUy} - 80)) 117 | green "MTU最佳值=$MTU 已设置完毕" 118 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 119 | } 120 | 121 | make_wireproxy_file(){ 122 | read -p "请输入将要设置的Socks5端口(默认40000):" WireProxyPort 123 | [[ -z $WireProxyPort ]] && WireProxyPort=40000 124 | WgcfPrivateKey=$(grep PrivateKey wgcf-profile.conf | sed "s/PrivateKey = //g") 125 | WgcfPublicKey=$(grep PublicKey wgcf-profile.conf | sed "s/PublicKey = //g") 126 | 127 | if [[ ! -d "/etc/wireguard" ]]; then 128 | mkdir /etc/wireguard 129 | fi 130 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 131 | 132 | 133 | cat < /etc/wireguard/proxy.conf 134 | [Interface] 135 | Address = 172.16.0.2/32 136 | MTU = $MTU 137 | PrivateKey = $WgcfPrivateKey 138 | DNS = 1.1.1.1,8.8.8.8,8.8.4.4 139 | 140 | [Peer] 141 | PublicKey = $WgcfPublicKey 142 | Endpoint = [2606:4700:d0::a29f:c001]:2408 143 | 144 | [Socks5] 145 | BindAddress = 127.0.0.1:$WireProxyPort 146 | EOF 147 | green "WireProxy-WARP代理模式配置文件已生成成功!" 148 | cat <<'TEXT' > /etc/systemd/system/wireproxy-warp.service 149 | [Unit] 150 | Description=CloudFlare WARP based for WireProxy, script by owo.misaka.rest 151 | After=network.target 152 | [Install] 153 | WantedBy=multi-user.target 154 | [Service] 155 | Type=simple 156 | WorkingDirectory=/root 157 | ExecStart=/usr/local/bin/wireproxy -c /etc/wireguard/proxy.conf 158 | Restart=always 159 | TEXT 160 | green "Systemd 系统守护服务设置成功!" 161 | rm -f wgcf-profile.conf 162 | } 163 | 164 | download_wireproxy(){ 165 | if [[ $arch == "amd64" || $arch == "x86_64" ]]; then 166 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-amd64 -O /usr/local/bin/wireproxy 167 | chmod +x /usr/local/bin/wireproxy 168 | fi 169 | if [[ $arch == "armv8" || $arch == "arm64" || $arch == "aarch64" ]]; then 170 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-arm64 -O /usr/local/bin/wireproxy 171 | chmod +x /usr/local/bin/wireproxy 172 | fi 173 | if [[ $arch == "s390x" ]]; then 174 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-s390x -O /usr/local/bin/wireproxy 175 | chmod +x /usr/local/bin/wireproxy 176 | fi 177 | } 178 | 179 | start_wireproxy_warp(){ 180 | yellow "正在启动WireProxy-WARP代理模式" 181 | systemctl start wireproxy-warp 182 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 183 | until [[ $socks5Status =~ on|plus ]]; do 184 | red "启动WireProxy-WARP代理模式失败,正在尝试重启" 185 | systemctl stop wireproxy-warp 186 | systemctl start wireproxy-warp 187 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 188 | sleep 8 189 | done 190 | systemctl enable wireproxy-warp 191 | socks5IP=$(curl -sx socks5h://localhost:$WireProxyPort ip.gs -k --connect-timeout 8) 192 | green "WireProxy-WARP代理模式已启动成功!" 193 | yellow "本地Socks5代理为: 127.0.0.1:$WireProxyPort" 194 | yellow "WireProxy-WARP代理模式的IP为:$socks5IP" 195 | rm -f warp6.sh 196 | } 197 | 198 | install(){ 199 | ${PACKAGE_UPDATE[int]} 200 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 201 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 202 | [[ -z $(type -P wgcf) ]] && install_wgcf 203 | register_wgcf 204 | generate_wgcf_config 205 | get_best_mtu 206 | make_wireproxy_file 207 | download_wireproxy 208 | start_wireproxy_warp 209 | } 210 | 211 | install 212 | -------------------------------------------------------------------------------- /files/README.md: -------------------------------------------------------------------------------- 1 | # 文件夹说明 2 | 3 | 本文件夹存放的是脚本依赖的文件 4 | 5 | WireProxy:https://github.com/octeep/wireproxy 6 | 7 | Wgcf:https://github.com/ViRb3/wgcf -------------------------------------------------------------------------------- /files/warp-teams.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | URL=${URL:-'https://gist.githubusercontent.com/fscarmen/56aaf02d743551737c9973b8be7a3496/raw/61bf63e68e4e91152545679b8f11c72cac215128/2021.12.21'} 4 | TEAMS=$(curl -sSL "$URL" | sed "s/\"/\"/g") 5 | PRIVATEKEY=$(expr "$TEAMS" : '.*private_key">\([^<]*\).*') 6 | PUBLICKEY=$(expr "$TEAMS" : '.*public_key":"\([^&]*\).*') 7 | ADDRESS4=$(expr "$TEAMS" : '.*v4":"\(172[^&]*\).*') 8 | ADDRESS6=$(expr "$TEAMS" : '.*v6":"\([^[&]*\).*') 9 | 10 | echo $TEAMS -------------------------------------------------------------------------------- /files/warp-up.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin && export PATH 3 | # unlimited GB on Warp+ : bash this_one.sh 30 4 | ## 使用脚本前先将curl请求中的 abda0c91-6b67-4432-913a-fedb60b9bc7b 改为你自己邀请链接的值,获取方式: curl -m 10 -sI "https://warp.plus/GEXF1" | grep -oE "referrer=.*$" | cut -f2 -d= 5 | ### 为啥没在curl请求里面直接填这个变量!?因为不知道啥原因填进去总是错,猜测是-符号的引起的?! 6 | 7 | flowdata=${1:-10} 8 | license=$2 9 | 10 | ######## 11 | for ((i = 0; i < ${flowdata}; i++)); do 12 | if [[ $i == 0 ]]; then 13 | sleep_try=30 14 | sleep_min=20 15 | sleep_max=600 16 | echo $(date) Mission $flowdata GB 17 | fi 18 | 19 | install_id=$(tr -dc 'A-Za-z0-9' $sleep_max ]] && sleep_try=300 24 | [[ $sleep_try == $sleep_min ]] && sleep_try=$((sleep_try+1)) 25 | 26 | if [[ $status == 0 ]]; then 27 | sleep_try=$((sleep_try-1)) 28 | sleep $sleep_try 29 | rit[i]=$i 30 | echo -n $i-o- 31 | continue 32 | fi 33 | 34 | if [[ $status == 1 ]]; then 35 | sleep_try=$((sleep_try+2)) 36 | sleep $sleep_try 37 | bad[i]=$i 38 | echo -n $i-x- 39 | continue 40 | fi 41 | done 42 | 43 | echo; echo $(date) 此次运行共有warp+流量 ${#rit[*]} GB 获取成功 44 | -------------------------------------------------------------------------------- /files/wgcf-fetchlog.txt: -------------------------------------------------------------------------------- 1 | # wgcf fetch log generated by GitHub Actions 2 | 3 | Last Version: v2.2.15 4 | Fetch Date: Sat Jul 2 12:58:59 UTC 2022 5 | -------------------------------------------------------------------------------- /files/wgcf-latest-linux-386: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wgcf-latest-linux-386 -------------------------------------------------------------------------------- /files/wgcf-latest-linux-amd64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wgcf-latest-linux-amd64 -------------------------------------------------------------------------------- /files/wgcf-latest-linux-arm64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wgcf-latest-linux-arm64 -------------------------------------------------------------------------------- /files/wgcf-latest-linux-armv5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wgcf-latest-linux-armv5 -------------------------------------------------------------------------------- /files/wgcf-latest-linux-armv6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wgcf-latest-linux-armv6 -------------------------------------------------------------------------------- /files/wgcf-latest-linux-armv7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wgcf-latest-linux-armv7 -------------------------------------------------------------------------------- /files/wgcf-latest-linux-s390x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wgcf-latest-linux-s390x -------------------------------------------------------------------------------- /files/wireguard-go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wireguard-go -------------------------------------------------------------------------------- /files/wireguard-go-amd64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wireguard-go-amd64 -------------------------------------------------------------------------------- /files/wireguard-go-arm64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wireguard-go-arm64 -------------------------------------------------------------------------------- /files/wireguard-go-s390x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wireguard-go-s390x -------------------------------------------------------------------------------- /files/wireproxy-amd64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wireproxy-amd64 -------------------------------------------------------------------------------- /files/wireproxy-arm64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wireproxy-arm64 -------------------------------------------------------------------------------- /files/wireproxy-s390x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/misaka-gh/Misaka-WARP-Script/c7daf405ad3f6985d3e1270778d30dd50ce87e5a/files/wireproxy-s390x -------------------------------------------------------------------------------- /warp-cli/README.md: -------------------------------------------------------------------------------- 1 | # Misaka WARP 脚本 - WARP-Cli 2 | 3 | 使用官方CloudFlare WARP客户端开启Socks5代理,实现VPS内的代理上网 4 | 5 | > PS: 由于CloudFlare对WARP-Cli客户端的限制,本脚本只能在amd64的IPv4 only或原生双栈的VPS使用 6 | 7 | ## 使用方法 8 | 9 | ### 安装WARP-Cli并设置代理模式 10 | 11 | ```shell 12 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/warp-cli.sh && bash warp-cli.sh 13 | ``` 14 | 15 | ### 修改WARP-Cli代理端口 16 | 17 | ```shell 18 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/changeport.sh && bash changeport.sh 19 | ``` 20 | 21 | ### 开启/关闭WARP-Cli代理模式 22 | 23 | ```shell 24 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/switch.sh && bash switch.sh 25 | ``` 26 | 27 | 28 | ### 卸载WARP-Cli 29 | 30 | ```shell 31 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/uninstall.sh && bash uninstall.sh 32 | ``` 33 | 34 | ### 刷Netfilx IP 35 | 36 | ```shell 37 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/warp-cli/netfilxcli.sh && bash netfilxcli.sh 38 | ``` 39 | 40 | 可搭配 [Screen 管理脚本](https://github.com/Misaka-blog/screenManager) 使用最佳 41 | 42 | ## 赞助我们 43 | 44 | ![afdian-MisakaNo.jpg](https://s2.loli.net/2021/12/25/SimocqwhVg89NQJ.jpg) 45 | 46 | ## 交流群 47 | [Telegram](https://t.me/misakanetcn) 48 | -------------------------------------------------------------------------------- /warp-cli/changeport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | red() { 3 | echo -e "\033[31m\033[01m$1\033[0m" 4 | } 5 | green() { 6 | echo -e "\033[32m\033[01m$1\033[0m" 7 | } 8 | yellow() { 9 | echo -e "\033[33m\033[01m$1\033[0m" 10 | } 11 | 12 | # 判断系统及定义系统安装依赖方式 13 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 14 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 15 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 16 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 17 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 18 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 19 | 20 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 21 | 22 | for i in "${CMD[@]}"; do 23 | SYS="$i" && [[ -n $SYS ]] && break 24 | done 25 | 26 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 27 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 28 | done 29 | 30 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 31 | [[ -z $(type -P warp-cli) ]] && red "WARP-Cli代理模式未安装,脚本即将退出!" && rm -f changeport.sh && exit 1 32 | 33 | changeport(){ 34 | if [[ $(warp-cli --accept-tos status) =~ Connected ]]; then 35 | warp-cli --accept-tos disconnect 36 | fi 37 | read -p "请输入WARP Cli使用的代理端口(默认40000):" WARPCliPort 38 | [[ -z $WARPCliPort ]] && WARPCliPort=40000 39 | warp-cli --accept-tos set-proxy-port "$WARPCliPort" >/dev/null 2>&1 40 | yellow "正在启动Warp-Cli代理模式" 41 | warp-cli --accept-tos connect >/dev/null 2>&1 42 | socks5Status=$(curl -sx socks5h://localhost:$WARPCliPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 2 | grep warp | cut -d= -f2) 43 | until [[ $socks5Status =~ on|plus ]]; do 44 | red "启动Warp-Cli代理模式失败,正在尝试重启" 45 | warp-cli --accept-tos disconnect >/dev/null 2>&1 46 | warp-cli --accept-tos connect >/dev/null 2>&1 47 | socks5Status=$(curl -sx socks5h://localhost:$WARPCliPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 2 | grep warp | cut -d= -f2) 48 | sleep 5 49 | done 50 | warp-cli --accept-tos enable-always-on >/dev/null 2>&1 51 | green "WARP-Cli代理模式已启动成功并成功修改代理端口!" 52 | yellow "本地Socks5代理为: 127.0.0.1:$WARPCliPort" 53 | rm -f changeport.sh 54 | } 55 | 56 | changeport -------------------------------------------------------------------------------- /warp-cli/netfilxcli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | green() { 7 | echo -e "\033[32m\033[01m$1\033[0m" 8 | } 9 | yellow() { 10 | echo -e "\033[33m\033[01m$1\033[0m" 11 | } 12 | 13 | # 判断系统及定义系统安装依赖方式 14 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 15 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 16 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 17 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 18 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 19 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 20 | 21 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 22 | 23 | for i in "${CMD[@]}"; do 24 | SYS="$i" && [[ -n $SYS ]] && break 25 | done 26 | 27 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 28 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 29 | done 30 | 31 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 32 | [[ -z $(type -P warp-cli) ]] && red "WARP-Cli代理模式未安装,脚本即将退出!" && rm -f wireproxy-netfilx.sh && exit 1 33 | 34 | WARPCliPort=$(warp-cli --accept-tos settings 2>/dev/null | grep 'WarpProxy on port' | awk -F "port " '{print $2}') 35 | 36 | check(){ 37 | NetfilxStatus=$(curl -sx socks5h://localhost:$WARPCliPort -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/81215567" 2>&1) 38 | if [[ $NetfilxStatus == "200" ]]; then 39 | success 40 | fi 41 | if [[ $NetfilxStatus =~ "403"|"404" ]]; then 42 | failed 43 | fi 44 | if [[ -z $NetfilxStatus ]] || [[ $NetfilxStatus == "000" ]]; then 45 | retry 46 | fi 47 | } 48 | 49 | retry(){ 50 | warp-cli --accept-tos disconnect >/dev/null 2>&1 51 | warp-cli --accept-tos connect >/dev/null 2>&1 52 | check 53 | } 54 | 55 | success(){ 56 | WARPCliIP=$(curl -sx socks5h://localhost:$WARPCliPort https://ip.gs -k --connect-timeout 8) 57 | green "当前WireProxy-WARP的IP:$WARPCliIP 已解锁Netfilx" 58 | yellow "等待1小时后,脚本将会自动重新检查Netfilx解锁状态" 59 | sleep 1h 60 | check 61 | } 62 | 63 | failed(){ 64 | WARPCliIP=$(curl -sx socks5h://localhost:$WARPCliPort https://ip.gs -k --connect-timeout 8) 65 | red "当前WireProxy-WARP的IP:$WARPCliIP 未解锁Netfilx,脚本将在15秒后重新测试Netfilx解锁情况" 66 | sleep 15 67 | warp-cli --accept-tos disconnect >/dev/null 2>&1 68 | warp-cli --accept-tos connect >/dev/null 2>&1 69 | check 70 | } 71 | 72 | check 73 | -------------------------------------------------------------------------------- /warp-cli/switch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | red() { 3 | echo -e "\033[31m\033[01m$1\033[0m" 4 | } 5 | green() { 6 | echo -e "\033[32m\033[01m$1\033[0m" 7 | } 8 | yellow() { 9 | echo -e "\033[33m\033[01m$1\033[0m" 10 | } 11 | 12 | # 判断系统及定义系统安装依赖方式 13 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 14 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 15 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 16 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 17 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 18 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 19 | 20 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 21 | 22 | for i in "${CMD[@]}"; do 23 | SYS="$i" && [[ -n $SYS ]] && break 24 | done 25 | 26 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 27 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 28 | done 29 | 30 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 31 | [[ -z $(type -P warp-cli) ]] && red "WARP-Cli代理模式未安装,脚本即将退出!" && exit 1 32 | 33 | switch(){ 34 | if [[ $(warp-cli --accept-tos status) =~ Connected ]]; then 35 | warp-cli --accept-tos disconnect >/dev/null 2>&1 36 | green "WARP-Cli代理模式关闭成功!" 37 | rm -f switch.sh 38 | exit 1 39 | fi 40 | if [[ $(warp-cli --accept-tos status) =~ Disconnected ]]; then 41 | yellow "正在启动Warp-Cli代理模式" 42 | warp-cli --accept-tos connect >/dev/null 2>&1 43 | until [[ $(warp-cli --accept-tos status) =~ Connected ]]; do 44 | red "启动Warp-Cli代理模式失败,正在尝试重启" 45 | warp-cli --accept-tos disconnect >/dev/null 2>&1 46 | warp-cli --accept-tos connect >/dev/null 2>&1 47 | sleep 5 48 | done 49 | warp-cli --accept-tos enable-always-on >/dev/null 2>&1 50 | WARPCliPort=$(warp-cli --accept-tos settings 2>/dev/null | grep 'WarpProxy on port' | awk -F "port " '{print $2}') 51 | green "WARP-Cli代理模式启动成功!" 52 | yellow "本地Socks5代理为:127.0.0.1:$WARPCliPort" 53 | rm -f switch.sh 54 | exit 1 55 | fi 56 | } 57 | 58 | switch 59 | -------------------------------------------------------------------------------- /warp-cli/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 34 | [[ -z $(type -P warp-cli) ]] && red "WARP-Cli代理模式未安装,脚本即将退出" && rm -f uninstall.sh && exit 1 35 | 36 | uninstall(){ 37 | warp-cli --accept-tos disconnect >/dev/null 2>&1 38 | warp-cli --accept-tos disable-always-on >/dev/null 2>&1 39 | warp-cli --accept-tos delete >/dev/null 2>&1 40 | ${PACKAGE_UNINSTALL[int]} cloudflare-warp 2>/dev/null 41 | systemctl disable --now warp-svc >/dev/null 2>&1 42 | green "WARP-Cli代理模式已彻底卸载成功!" 43 | rm -f uninstall.sh 44 | } 45 | 46 | uninstall -------------------------------------------------------------------------------- /warp-cli/warp-cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P warp-cli) ]] && red "WARP-Cli代理模式已经安装,脚本即将退出" && rm -f warp-cli.sh && exit 1 37 | 38 | arch=`uname -m` 39 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | check_tun(){ 43 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 44 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 45 | if [[ $vpsvirt == "openvz" ]]; then 46 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 47 | else 48 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 49 | exit 1 50 | fi 51 | fi 52 | } 53 | 54 | checkCentOS8(){ 55 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 56 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 57 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 58 | if [[ $comfirmCentOSStream == "y" ]]; then 59 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 60 | sleep 1 61 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 62 | yum clean all && yum makecache 63 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 64 | else 65 | red "已取消升级过程,脚本即将退出!" 66 | exit 1 67 | fi 68 | fi 69 | } 70 | 71 | install_warpcli_centos(){ 72 | ${PACKAGE_INSTALL[int]} epel-release 73 | ${PACKAGE_INSTALL[int]} curl wget sudo net-tools 74 | rpm -ivh http://pkg.cloudflareclient.com/cloudflare-release-el8.rpm 75 | ${PACKAGE_INSTALL[int]} cloudflare-warp 76 | } 77 | 78 | install_warpcli_debian(){ 79 | ${PACKAGE_UPDATE[int]} 80 | ${PACKAGE_INSTALL[int]} lsb-release 81 | [[ -z $(type -P gpg 2>/dev/null) ]] && ${PACKAGE_INSTALL[int]} gnupg 82 | [[ -z $(apt list 2>/dev/null | grep apt-transport-https | grep installed) ]] && ${PACKAGE_INSTALL[int]} apt-transport-https 83 | curl https://pkg.cloudflareclient.com/pubkey.gpg | apt-key add - 84 | echo "deb http://pkg.cloudflareclient.com/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/cloudflare-client.list 85 | ${PACKAGE_UPDATE[int]} 86 | ${PACKAGE_INSTALL[int]} cloudflare-warp 87 | } 88 | 89 | install_warpcli_ubuntu(){ 90 | ${PACKAGE_UPDATE[int]} 91 | ${PACKAGE_INSTALL[int]} curl wget sudo lsb-release 92 | curl https://pkg.cloudflareclient.com/pubkey.gpg | apt-key add - 93 | echo "deb http://pkg.cloudflareclient.com/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/cloudflare-client.list 94 | ${PACKAGE_UPDATE[int]} 95 | ${PACKAGE_INSTALL[int]} cloudflare-warp 96 | } 97 | 98 | register_warpcli(){ 99 | warp-cli --accept-tos register >/dev/null 2>&1 100 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 101 | read -p "按键许可证密钥(26个字符):" WPPlusKey 102 | if [[ -n $WPPlusKey ]]; then 103 | warp-cli --accept-tos set-license "$WPPlusKey" >/dev/null 2>&1 && sleep 1 104 | if [[ $(warp-cli --accept-tos account) =~ Limited ]]; then 105 | green "WARP+账户启用成功" 106 | else 107 | red "WARP+账户启用失败,即将使用WARP免费版账户" 108 | fi 109 | fi 110 | warp-cli --accept-tos set-mode proxy >/dev/null 2>&1 111 | } 112 | 113 | set_proxy_port(){ 114 | read -p "请输入WARP Cli使用的代理端口(默认40000):" WARPCliPort 115 | [[ -z $WARPCliPort ]] && WARPCliPort=40000 116 | warp-cli --accept-tos set-proxy-port "$WARPCliPort" >/dev/null 2>&1 117 | } 118 | 119 | start_warpcli(){ 120 | yellow "正在启动Warp-Cli代理模式" 121 | warp-cli --accept-tos connect >/dev/null 2>&1 122 | # socks5Status=$(curl -sx socks5h://localhost:$WARPCliPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 2 | grep warp | cut -d= -f2) 123 | until [[ $(warp-cli --accept-tos status) =~ Connected ]]; do 124 | red "启动Warp-Cli代理模式失败,正在尝试重启" 125 | warp-cli --accept-tos disconnect >/dev/null 2>&1 126 | warp-cli --accept-tos connect >/dev/null 2>&1 127 | # socks5Status=$(curl -sx socks5h://localhost:$WARPCliPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 2 | grep warp | cut -d= -f2) 128 | sleep 8 129 | done 130 | warp-cli --accept-tos enable-always-on >/dev/null 2>&1 131 | socks5IP=$(curl -sx socks5h://localhost:$WARPCliPort ip.gs -k --connect-timeout 8) 132 | green "WARP-Cli代理模式已启动成功!" 133 | yellow "本地Socks5代理为: 127.0.0.1:$WARPCliPort" 134 | yellow "WARP-Cli代理模式的IP为:$socks5IP" 135 | rm -f warp-cli.sh 136 | } 137 | 138 | install(){ 139 | [[ -z $(curl -s4m8 ip.gs ) ]] && red "WARP-Cli代理模式目前不支持IPv6 Only的VPS,脚本退出" && exit 1 140 | if [[ $arch == "amd64" || $arch == "x86_64" ]]; then 141 | [[ $SYSTEM == "CentOS" ]] && [[ ! ${vsid} =~ 8 ]] && yellow "当前系统版本:Centos $vsid \nWARP-Cli代理模式仅支持Centos 8系统" && exit 1 142 | [[ $SYSTEM == "Debian" ]] && [[ ! ${vsid} =~ 9|10|11 ]] && yellow "当前系统版本:Debian $vsid \nWARP-Cli代理模式仅支持Debian 9-11系统" && exit 1 143 | [[ $SYSTEM == "Ubuntu" ]] && [[ ! ${vsid} =~ 16|20 ]] && yellow "当前系统版本:Ubuntu $vsid \nWARP-Cli代理模式仅支持Ubuntu 16.04/20.04系统" && exit 1 144 | 145 | [[ $SYSTEM == "CentOS" ]] && install_warpcli_centos 146 | [[ $SYSTEM == "Debian" ]] && install_warpcli_debian 147 | [[ $SYSTEM == "Ubuntu" ]] && install_warpcli_ubuntu 148 | 149 | register_warpcli 150 | set_proxy_port 151 | start_warpcli 152 | else 153 | red "不支持的CPU架构!脚本即将退出" 154 | fi 155 | } 156 | 157 | check_tun 158 | checkCentOS8 159 | install 160 | -------------------------------------------------------------------------------- /wgcf-warp/README.md: -------------------------------------------------------------------------------- 1 | # Misaka WARP 脚本 - Wgcf WARP 2 | 3 | 使用基于WireGuard的Wgcf非官方CloudFlare WARP客户端,实现VPS内的代理上网 4 | 5 | ## 使用方法 6 | 7 | 请谨慎选择脚本,否则VPS失联不关我的事。 8 | 9 | ### 原生 IPv4 VPS + IPv6 WARP 10 | 11 | ```shell 12 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warp46.sh && bash warp46.sh 13 | ``` 14 | 15 | ### 原生 IPv4 VPS + 双栈 WARP 16 | 17 | ```shell 18 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warp4d.sh && bash warp4d.sh 19 | ``` 20 | 21 | ### 原生 IPv6 VPS + IPv4 WARP 22 | 23 | ```shell 24 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warp64.sh && bash warp64.sh 25 | ``` 26 | 27 | ### 原生 IPv6 VPS + 双栈 WARP 28 | 29 | ```shell 30 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warp6d.sh && bash warp6d.sh 31 | ``` 32 | 33 | ### 原生双栈 VPS + 双栈 WARP 34 | 35 | ```shell 36 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/warpd.sh && bash warpd.sh 37 | ``` 38 | 39 | ### 开启 / 关闭 WARP 40 | 41 | ```shell 42 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/switchwarp.sh && bash switchwarp.sh 43 | ``` 44 | 45 | ### 卸载 WARP 46 | 47 | ```shell 48 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/uninstall.sh && bash uninstall.sh 49 | ``` 50 | 51 | ### 刷Netfilx IP (IPv4) 52 | 53 | ```shell 54 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/netfilx4.sh && bash netfilx4.sh 55 | ``` 56 | 57 | ### 刷Netfilx IP (IPv6) 58 | 59 | ```shell 60 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wgcf-warp/netfilx6.sh && bash netfilx6.sh 61 | ``` 62 | 63 | 可搭配 [Screen 管理脚本](https://github.com/Misaka-blog/screenManager) 使用最佳 64 | 65 | ## 赞助我们 66 | 67 | ![afdian-MisakaNo.jpg](https://s2.loli.net/2021/12/25/SimocqwhVg89NQJ.jpg) 68 | 69 | ## 交流群 70 | [Telegram](https://t.me/misakanetcn) 71 | -------------------------------------------------------------------------------- /wgcf-warp/netfilx4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | green() { 7 | echo -e "\033[32m\033[01m$1\033[0m" 8 | } 9 | yellow() { 10 | echo -e "\033[33m\033[01m$1\033[0m" 11 | } 12 | 13 | # 判断系统及定义系统安装依赖方式 14 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 15 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 16 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 17 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 18 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 19 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 20 | 21 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 22 | 23 | for i in "${CMD[@]}"; do 24 | SYS="$i" && [[ -n $SYS ]] && break 25 | done 26 | 27 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 28 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 29 | done 30 | 31 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 32 | [[ -z $(type -P wg-quick) ]] && red "Wgcf-WARP代理模式未安装,脚本即将退出!" && rm -f netfilx4.sh && exit 1 33 | 34 | check(){ 35 | NetfilxStatus=$(curl -4 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.39" -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/81215567" 2>&1) 36 | if [[ $NetfilxStatus == "200" ]]; then 37 | success 38 | fi 39 | if [[ $NetfilxStatus =~ "403"|"404" ]]; then 40 | failed 41 | fi 42 | if [[ -z $NetfilxStatus ]] || [[ $NetfilxStatus == "000" ]]; then 43 | retry 44 | fi 45 | } 46 | 47 | retry(){ 48 | wg-quick down wgcf >/dev/null 2>&1 49 | wg-quick up wgcf >/dev/null 2>&1 50 | check 51 | } 52 | 53 | success(){ 54 | WgcfWARPIP=$(curl -s4m8 https://ip.gs -k) 55 | green "当前Wgcf-WARP的IP:$WgcfWARPIP 已解锁Netfilx" 56 | yellow "等待1小时后,脚本将会自动重新检查Netfilx解锁状态" 57 | sleep 1h 58 | check 59 | } 60 | 61 | failed(){ 62 | WgcfWARPIP=$(curl -s4m8 https://ip.gs -k) 63 | red "当前Wgcf-WARP的IP:$WgcfWARPIP 未解锁Netfilx,脚本将在15秒后重新测试Netfilx解锁情况" 64 | sleep 15 65 | wg-quick down wgcf >/dev/null 2>&1 66 | wg-quick up wgcf >/dev/null 2>&1 67 | check 68 | } 69 | 70 | check 71 | -------------------------------------------------------------------------------- /wgcf-warp/netfilx6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | green() { 7 | echo -e "\033[32m\033[01m$1\033[0m" 8 | } 9 | yellow() { 10 | echo -e "\033[33m\033[01m$1\033[0m" 11 | } 12 | 13 | # 判断系统及定义系统安装依赖方式 14 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 15 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 16 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 17 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 18 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 19 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 20 | 21 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 22 | 23 | for i in "${CMD[@]}"; do 24 | SYS="$i" && [[ -n $SYS ]] && break 25 | done 26 | 27 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 28 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 29 | done 30 | 31 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 32 | [[ -z $(type -P wg-quick) ]] && red "Wgcf-WARP代理模式未安装,脚本即将退出!" && rm -f netfilx4.sh && exit 1 33 | 34 | check(){ 35 | NetfilxStatus=$(curl -6 --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.39" -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/81215567" 2>&1) 36 | if [[ $NetfilxStatus == "200" ]]; then 37 | success 38 | fi 39 | if [[ $NetfilxStatus =~ "403"|"404" ]]; then 40 | failed 41 | fi 42 | if [[ -z $NetfilxStatus ]] || [[ $NetfilxStatus == "000" ]]; then 43 | retry 44 | fi 45 | } 46 | 47 | retry(){ 48 | wg-quick down wgcf >/dev/null 2>&1 49 | wg-quick up wgcf >/dev/null 2>&1 50 | check 51 | } 52 | 53 | success(){ 54 | WgcfWARPIP=$(curl -s6m8 https://ip.gs -k) 55 | green "当前Wgcf-WARP的IP:$WgcfWARPIP 已解锁Netfilx" 56 | yellow "等待1小时后,脚本将会自动重新检查Netfilx解锁状态" 57 | sleep 1h 58 | check 59 | } 60 | 61 | failed(){ 62 | WgcfWARPIP=$(curl -s6m8 https://ip.gs -k) 63 | red "当前Wgcf-WARP的IP:$WgcfWARPIP 未解锁Netfilx,脚本将在15秒后重新测试Netfilx解锁情况" 64 | sleep 15 65 | wg-quick down wgcf >/dev/null 2>&1 66 | wg-quick up wgcf >/dev/null 2>&1 67 | check 68 | } 69 | 70 | check 71 | -------------------------------------------------------------------------------- /wgcf-warp/switchwarp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 34 | [[ -z $(type -P wg-quick) ]] && red "未安装Wgcf-WARP,脚本即将退出" && rm -f switch.sh && exit 1 35 | 36 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 37 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 38 | 39 | if [[ $WgcfWARP4Status =~ on|plus ]] || [[ $WgcfWARP6Status =~ on|plus ]]; then 40 | wg-quick down wgcf >/dev/null 2>&1 41 | systemctl disable wg-quick@wgcf >/dev/null 2>&1 42 | green "Wgcf-WARP关闭成功!" 43 | exit 1 44 | fi 45 | 46 | if [[ $WgcfWARP4Status == off ]] || [[ $WgcfWARP6Status == off ]]; then 47 | wg-quick up wgcf >/dev/null 2>&1 48 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 49 | green "Wgcf-WARP启动成功!" 50 | exit 1 51 | fi 52 | -------------------------------------------------------------------------------- /wgcf-warp/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 34 | [[ -z $(type -P wg-quick) ]] && red "Wgcf-WARP未安装,脚本即将退出" && rm -f uninstall.sh && exit 1 35 | 36 | uninstall(){ 37 | wg-quick down wgcf 2>/dev/null 38 | systemctl disable wg-quick@wgcf 2>/dev/null 39 | ${PACKAGE_UNINSTALL[int]} wireguard-tools wireguard-dkms 2>/dev/null 40 | [[ -z $(type -P wireproxy) ]] && rm -f /usr/local/bin/wgcf 41 | rm -f /etc/wireguard/wgcf.conf 42 | rm -f /etc/wireguard/wgcf-account.toml 43 | rm -f /usr/bin/wireguard-go 44 | if [[ -e /etc/gai.conf ]]; then 45 | sed -i '/^precedence[ ]*::ffff:0:0\/96[ ]*100/d' /etc/gai.conf 46 | fi 47 | green "Wgcf-WARP 已彻底卸载成功!" 48 | rm -f uninstall.sh 49 | } 50 | 51 | uninstall 52 | -------------------------------------------------------------------------------- /wgcf-warp/warp46.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warp46.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == "openvz" ]]; then 59 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 60 | else 61 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 62 | exit 1 63 | fi 64 | fi 65 | } 66 | 67 | checkCentOS8(){ 68 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 69 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 70 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 71 | if [[ $comfirmCentOSStream == "y" ]]; then 72 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 73 | sleep 1 74 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 75 | yum clean all && yum makecache 76 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 77 | else 78 | red "已取消升级过程,脚本即将退出!" 79 | exit 1 80 | fi 81 | fi 82 | } 83 | 84 | install_wireguard_centos(){ 85 | ${PACKAGE_INSTALL[int]} epel-release 86 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 87 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 88 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 89 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 90 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 91 | ${PACKAGE_INSTALL[int]} wireguard-dkms 92 | fi 93 | fi 94 | } 95 | 96 | install_wireguard_debian(){ 97 | ${PACKAGE_INSTALL[int]} lsb-release 98 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 99 | ${PACKAGE_UPDATE[int]} 100 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 101 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 102 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 103 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 104 | ${PACKAGE_INSTALL[int]} --no-install-recommends install wireguard-dkms 105 | fi 106 | fi 107 | } 108 | 109 | install_wireguard_ubuntu(){ 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 111 | } 112 | 113 | install_wireguard(){ 114 | ${PACKAGE_UPDATE[int]} 115 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 116 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 117 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 118 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 119 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 120 | if [[ $vpsvirt =~ lxc|openvz ]]; then 121 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go -O /usr/bin/wireguard-go 122 | chmod +x /usr/bin/wireguard-go 123 | fi 124 | if [[ $vpsvirt == zvm ]]; then 125 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go-s390x -O /usr/bin/wireguard-go 126 | chmod +x /usr/bin/wireguard-go 127 | fi 128 | } 129 | 130 | install_wgcf(){ 131 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 132 | chmod +x /usr/local/bin/wgcf 133 | } 134 | 135 | register_wgcf(){ 136 | rm -f wgcf-account.toml 137 | until [[ -a wgcf-account.toml ]]; do 138 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 139 | yes | wgcf register 140 | sleep 5 141 | done 142 | chmod +x wgcf-account.toml 143 | } 144 | 145 | generate_wgcf_config(){ 146 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 147 | read -p "按键许可证密钥(26个字符):" WPPlusKey 148 | if [[ -n $WPPlusKey ]]; then 149 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 150 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 151 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 152 | if [[ -n $WPPlusName ]]; then 153 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 154 | else 155 | wgcf update 156 | fi 157 | fi 158 | wgcf generate 159 | chmod +x wgcf-profile.conf 160 | sed -i '/0\.\0\/0/d' wgcf-profile.conf 161 | sed -i 's/engage.cloudflareclient.com/162.159.193.10/g' wgcf-profile.conf 162 | sed -i 's/1.1.1.1/1.1.1.1,8.8.8.8,8.8.4.4,2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844/g' wgcf-profile.conf 163 | } 164 | 165 | get_best_mtu(){ 166 | v66=`curl -s6m8 https://ip.gs -k` 167 | v44=`curl -s4m8 https://ip.gs -k` 168 | MTUy=1500 169 | MTUc=10 170 | if [[ -n ${v66} && -z ${v44} ]]; then 171 | ping='ping6' 172 | IP1='2606:4700:4700::1001' 173 | IP2='2001:4860:4860::8888' 174 | else 175 | ping='ping' 176 | IP1='1.1.1.1' 177 | IP2='8.8.8.8' 178 | fi 179 | while true; do 180 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 181 | MTUc=1 182 | MTUy=$((${MTUy} + ${MTUc})) 183 | else 184 | MTUy=$((${MTUy} - ${MTUc})) 185 | if [[ ${MTUc} = 1 ]]; then 186 | break 187 | fi 188 | fi 189 | if [[ ${MTUy} -le 1360 ]]; then 190 | MTUy='1360' 191 | break 192 | fi 193 | done 194 | MTU=$((${MTUy} - 80)) 195 | green "MTU最佳值=$MTU 已设置完毕" 196 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 197 | } 198 | 199 | cpto_wireguard(){ 200 | if [[ ! -d "/etc/wireguard" ]]; then 201 | mkdir /etc/wireguard 202 | fi 203 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 204 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 205 | } 206 | 207 | start_wgcf(){ 208 | yellow "正在启动 Wgcf-WARP" 209 | wg-quick up wgcf >/dev/null 2>&1 210 | WgcfWARPStatus=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 211 | until [[ $WgcfWARPStatus =~ "on"|"plus" ]]; do 212 | red "无法启动Wgcf-WARP,正在尝试重启" 213 | wg-quick down wgcf >/dev/null 2>&1 214 | wg-quick up wgcf >/dev/null 2>&1 215 | WgcfWARPStatus=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 216 | sleep 8 217 | done 218 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 219 | WgcfIPv6=$(curl -s6m8 https://ip.gs -k) 220 | green "Wgcf-WARP 已启动成功" 221 | yellow "Wgcf-WARP的IPv6 IP为:$WgcfIPv6" 222 | rm -f warp46.sh 223 | } 224 | 225 | install(){ 226 | install_wireguard 227 | [[ -z $(type -P wgcf) ]] && install_wgcf 228 | register_wgcf 229 | generate_wgcf_config 230 | get_best_mtu 231 | cpto_wireguard 232 | start_wgcf 233 | } 234 | 235 | check_tun 236 | checkCentOS8 237 | install 238 | -------------------------------------------------------------------------------- /wgcf-warp/warp4d.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warp4d.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == "openvz" ]]; then 59 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 60 | else 61 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 62 | exit 1 63 | fi 64 | fi 65 | } 66 | 67 | checkCentOS8(){ 68 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 69 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 70 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 71 | if [[ $comfirmCentOSStream == "y" ]]; then 72 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 73 | sleep 1 74 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 75 | yum clean all && yum makecache 76 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 77 | else 78 | red "已取消升级过程,脚本即将退出!" 79 | exit 1 80 | fi 81 | fi 82 | } 83 | 84 | install_wireguard_centos(){ 85 | ${PACKAGE_INSTALL[int]} epel-release 86 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 87 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 88 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 89 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 90 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 91 | ${PACKAGE_INSTALL[int]} wireguard-dkms 92 | fi 93 | fi 94 | } 95 | 96 | install_wireguard_debian(){ 97 | ${PACKAGE_INSTALL[int]} lsb-release 98 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 99 | ${PACKAGE_UPDATE[int]} 100 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 101 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 102 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 103 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 104 | ${PACKAGE_INSTALL[int]} --no-install-recommends wireguard-dkms 105 | fi 106 | fi 107 | } 108 | 109 | install_wireguard_ubuntu(){ 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 111 | } 112 | 113 | install_wireguard(){ 114 | ${PACKAGE_UPDATE[int]} 115 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 116 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 117 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 118 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 119 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 120 | if [[ $vpsvirt =~ lxc|openvz ]]; then 121 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go -O /usr/bin/wireguard-go 122 | chmod +x /usr/bin/wireguard-go 123 | fi 124 | if [[ $vpsvirt == zvm ]]; then 125 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go-s390x -O /usr/bin/wireguard-go 126 | chmod +x /usr/bin/wireguard-go 127 | fi 128 | } 129 | 130 | install_wgcf(){ 131 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 132 | chmod +x /usr/local/bin/wgcf 133 | } 134 | 135 | register_wgcf(){ 136 | rm -f wgcf-account.toml 137 | until [[ -a wgcf-account.toml ]]; do 138 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 139 | yes | wgcf register 140 | sleep 5 141 | done 142 | chmod +x wgcf-account.toml 143 | } 144 | 145 | generate_wgcf_config(){ 146 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 147 | read -p "按键许可证密钥(26个字符):" WPPlusKey 148 | if [[ -n $WPPlusKey ]]; then 149 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 150 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 151 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 152 | if [[ -n $WPPlusName ]]; then 153 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 154 | else 155 | wgcf update 156 | fi 157 | fi 158 | wgcf generate 159 | chmod +x wgcf-profile.conf 160 | sed -i "7 s/^/PostUp = ip -4 rule add from $(ip route get 1.1.1.1 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 161 | sed -i "8 s/^/PostDown = ip -4 rule delete from $(ip route get 1.1.1.1 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 162 | sed -i 's/engage.cloudflareclient.com/162.159.193.10/g' wgcf-profile.conf 163 | sed -i 's/1.1.1.1/1.1.1.1,8.8.8.8,8.8.4.4,2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844/g' wgcf-profile.conf 164 | } 165 | 166 | get_best_mtu(){ 167 | v66=`curl -s6m8 https://ip.gs -k` 168 | v44=`curl -s4m8 https://ip.gs -k` 169 | MTUy=1500 170 | MTUc=10 171 | if [[ -n ${v66} && -z ${v44} ]]; then 172 | ping='ping6' 173 | IP1='2606:4700:4700::1001' 174 | IP2='2001:4860:4860::8888' 175 | else 176 | ping='ping' 177 | IP1='1.1.1.1' 178 | IP2='8.8.8.8' 179 | fi 180 | while true; do 181 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 182 | MTUc=1 183 | MTUy=$((${MTUy} + ${MTUc})) 184 | else 185 | MTUy=$((${MTUy} - ${MTUc})) 186 | if [[ ${MTUc} = 1 ]]; then 187 | break 188 | fi 189 | fi 190 | if [[ ${MTUy} -le 1360 ]]; then 191 | MTUy='1360' 192 | break 193 | fi 194 | done 195 | MTU=$((${MTUy} - 80)) 196 | green "MTU最佳值=$MTU 已设置完毕" 197 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 198 | } 199 | 200 | cpto_wireguard(){ 201 | if [[ ! -d "/etc/wireguard" ]]; then 202 | mkdir /etc/wireguard 203 | fi 204 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 205 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 206 | } 207 | 208 | start_wgcf(){ 209 | yellow "正在启动 Wgcf-WARP" 210 | wg-quick up wgcf >/dev/null 2>&1 211 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 212 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 213 | until [[ $WgcfWARP4Status =~ on|plus ]] && [[ $WgcfWARP6Status =~ on|plus ]]; do 214 | red "无法启动Wgcf-WARP,正在尝试重启" 215 | wg-quick down wgcf >/dev/null 2>&1 216 | wg-quick up wgcf >/dev/null 2>&1 217 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 218 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 219 | sleep 8 220 | done 221 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 222 | WgcfIPv4=$(curl -s4m8 https://ip.gs -k) 223 | WgcfIPv6=$(curl -s6m8 https://ip.gs -k) 224 | green "Wgcf-WARP 已启动成功" 225 | yellow "Wgcf-WARP的IPv4 IP为:$WgcfIPv4" 226 | yellow "Wgcf-WARP的IPv6 IP为:$WgcfIPv6" 227 | rm -f warp4d.sh 228 | } 229 | 230 | install(){ 231 | install_wireguard 232 | [[ -z $(type -P wgcf) ]] && install_wgcf 233 | register_wgcf 234 | generate_wgcf_config 235 | get_best_mtu 236 | cpto_wireguard 237 | start_wgcf 238 | } 239 | 240 | check_tun 241 | checkCentOS8 242 | install 243 | -------------------------------------------------------------------------------- /wgcf-warp/warp64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warp64.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == "openvz" ]]; then 59 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 60 | else 61 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 62 | exit 1 63 | fi 64 | fi 65 | } 66 | 67 | checkCentOS8(){ 68 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 69 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 70 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 71 | if [[ $comfirmCentOSStream == "y" ]]; then 72 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 73 | sleep 1 74 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 75 | yum clean all && yum makecache 76 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 77 | else 78 | red "已取消升级过程,脚本即将退出!" 79 | exit 1 80 | fi 81 | fi 82 | } 83 | 84 | install_wireguard_centos(){ 85 | ${PACKAGE_INSTALL[int]} epel-release 86 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 87 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 88 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 89 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 90 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 91 | ${PACKAGE_INSTALL[int]} wireguard-dkms 92 | fi 93 | fi 94 | } 95 | 96 | install_wireguard_debian(){ 97 | ${PACKAGE_INSTALL[int]} lsb-release 98 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 99 | ${PACKAGE_UPDATE[int]} 100 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 101 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 102 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 103 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 104 | ${PACKAGE_INSTALL[int]} --no-install-recommends wireguard-dkms 105 | fi 106 | fi 107 | } 108 | 109 | install_wireguard_ubuntu(){ 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 111 | } 112 | 113 | install_wireguard(){ 114 | ${PACKAGE_UPDATE[int]} 115 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 116 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 117 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 118 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 119 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 120 | if [[ $vpsvirt =~ lxc|openvz ]]; then 121 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go -O /usr/bin/wireguard-go 122 | chmod +x /usr/bin/wireguard-go 123 | fi 124 | if [[ $vpsvirt == zvm ]]; then 125 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go-s390x -O /usr/bin/wireguard-go 126 | chmod +x /usr/bin/wireguard-go 127 | fi 128 | } 129 | 130 | install_wgcf(){ 131 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 132 | chmod +x /usr/local/bin/wgcf 133 | } 134 | 135 | register_wgcf(){ 136 | rm -f wgcf-account.toml 137 | until [[ -a wgcf-account.toml ]]; do 138 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 139 | yes | wgcf register 140 | sleep 5 141 | done 142 | chmod +x wgcf-account.toml 143 | } 144 | 145 | generate_wgcf_config(){ 146 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 147 | read -p "按键许可证密钥(26个字符):" WPPlusKey 148 | if [[ -n $WPPlusKey ]]; then 149 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 150 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 151 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 152 | if [[ -n $WPPlusName ]]; then 153 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 154 | else 155 | wgcf update 156 | fi 157 | fi 158 | wgcf generate 159 | chmod +x wgcf-profile.conf 160 | sed -i '/\:\:\/0/d' wgcf-profile.conf 161 | sed -i 's/engage.cloudflareclient.com/[2606:4700:d0::a29f:c001]/g' wgcf-profile.conf 162 | sed -i 's/1.1.1.1/2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844,1.1.1.1,8.8.8.8,8.8.4.4/g' wgcf-profile.conf 163 | } 164 | 165 | get_best_mtu(){ 166 | v66=`curl -s6m8 https://ip.gs -k` 167 | v44=`curl -s4m8 https://ip.gs -k` 168 | MTUy=1500 169 | MTUc=10 170 | if [[ -n ${v66} && -z ${v44} ]]; then 171 | ping='ping6' 172 | IP1='2606:4700:4700::1001' 173 | IP2='2001:4860:4860::8888' 174 | else 175 | ping='ping' 176 | IP1='1.1.1.1' 177 | IP2='8.8.8.8' 178 | fi 179 | while true; do 180 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 181 | MTUc=1 182 | MTUy=$((${MTUy} + ${MTUc})) 183 | else 184 | MTUy=$((${MTUy} - ${MTUc})) 185 | if [[ ${MTUc} = 1 ]]; then 186 | break 187 | fi 188 | fi 189 | if [[ ${MTUy} -le 1360 ]]; then 190 | MTUy='1360' 191 | break 192 | fi 193 | done 194 | MTU=$((${MTUy} - 80)) 195 | green "MTU最佳值=$MTU 已设置完毕" 196 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 197 | } 198 | 199 | cpto_wireguard(){ 200 | if [[ ! -d "/etc/wireguard" ]]; then 201 | mkdir /etc/wireguard 202 | fi 203 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 204 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 205 | } 206 | 207 | start_wgcf(){ 208 | yellow "正在启动 Wgcf-WARP" 209 | wg-quick up wgcf >/dev/null 2>&1 210 | WgcfWARPStatus=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 211 | until [[ $WgcfWARPStatus =~ on|plus ]]; do 212 | red "无法启动Wgcf-WARP,正在尝试重启" 213 | wg-quick down wgcf >/dev/null 2>&1 214 | wg-quick up wgcf >/dev/null 2>&1 215 | WgcfWARPStatus=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 216 | sleep 8 217 | done 218 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 219 | WgcfIPv4=$(curl -s4m8 https://ip.gs -k) 220 | green "Wgcf-WARP 已启动成功" 221 | yellow "Wgcf-WARP的IPv4 IP为:$WgcfIPv4" 222 | rm -f warp64.sh 223 | } 224 | 225 | install(){ 226 | install_wireguard 227 | [[ -z $(type -P wgcf) ]] && install_wgcf 228 | register_wgcf 229 | generate_wgcf_config 230 | get_best_mtu 231 | cpto_wireguard 232 | start_wgcf 233 | } 234 | 235 | check_tun 236 | checkCentOS8 237 | install 238 | -------------------------------------------------------------------------------- /wgcf-warp/warp6d.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warp6d.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == "openvz" ]]; then 59 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 60 | else 61 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 62 | exit 1 63 | fi 64 | fi 65 | } 66 | 67 | checkCentOS8(){ 68 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 69 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 70 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 71 | if [[ $comfirmCentOSStream == "y" ]]; then 72 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 73 | sleep 1 74 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 75 | yum clean all && yum makecache 76 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 77 | else 78 | red "已取消升级过程,脚本即将退出!" 79 | exit 1 80 | fi 81 | fi 82 | } 83 | 84 | install_wireguard_centos(){ 85 | ${PACKAGE_INSTALL[int]} epel-release 86 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 87 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 88 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 89 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 90 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 91 | ${PACKAGE_INSTALL[int]} wireguard-dkms 92 | fi 93 | fi 94 | } 95 | 96 | install_wireguard_debian(){ 97 | ${PACKAGE_INSTALL[int]} lsb-release 98 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 99 | ${PACKAGE_UPDATE[int]} 100 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 101 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 102 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 103 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 104 | ${PACKAGE_INSTALL[int]} --no-install-recommends wireguard-dkms 105 | fi 106 | fi 107 | } 108 | 109 | install_wireguard_ubuntu(){ 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 111 | } 112 | 113 | install_wireguard(){ 114 | ${PACKAGE_UPDATE[int]} 115 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 116 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 117 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 118 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 119 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 120 | if [[ $vpsvirt =~ lxc|openvz ]]; then 121 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go -O /usr/bin/wireguard-go 122 | chmod +x /usr/bin/wireguard-go 123 | fi 124 | if [[ $vpsvirt == zvm ]]; then 125 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go-s390x -O /usr/bin/wireguard-go 126 | chmod +x /usr/bin/wireguard-go 127 | fi 128 | } 129 | 130 | install_wgcf(){ 131 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 132 | chmod +x /usr/local/bin/wgcf 133 | } 134 | 135 | register_wgcf(){ 136 | rm -f wgcf-account.toml 137 | until [[ -a wgcf-account.toml ]]; do 138 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 139 | yes | wgcf register 140 | sleep 5 141 | done 142 | chmod +x wgcf-account.toml 143 | } 144 | 145 | generate_wgcf_config(){ 146 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 147 | read -p "按键许可证密钥(26个字符):" WPPlusKey 148 | if [[ -n $WPPlusKey ]]; then 149 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 150 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 151 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 152 | if [[ -n $WPPlusName ]]; then 153 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 154 | else 155 | wgcf update 156 | fi 157 | fi 158 | wgcf generate 159 | chmod +x wgcf-profile.conf 160 | sed -i "7 s/^/PostUp = ip -6 rule add from $(ip route get 2606:4700:4700::1001 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 161 | sed -i "8 s/^/PostDown = ip -6 rule delete from $(ip route get 2606:4700:4700::1001 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 162 | sed -i 's/engage.cloudflareclient.com/[2606:4700:d0::a29f:c001]/g' wgcf-profile.conf 163 | sed -i 's/1.1.1.1/2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844,1.1.1.1,8.8.8.8,8.8.4.4/g' wgcf-profile.conf 164 | } 165 | 166 | get_best_mtu(){ 167 | v66=`curl -s6m8 https://ip.gs -k` 168 | v44=`curl -s4m8 https://ip.gs -k` 169 | MTUy=1500 170 | MTUc=10 171 | if [[ -n ${v66} && -z ${v44} ]]; then 172 | ping='ping6' 173 | IP1='2606:4700:4700::1001' 174 | IP2='2001:4860:4860::8888' 175 | else 176 | ping='ping' 177 | IP1='1.1.1.1' 178 | IP2='8.8.8.8' 179 | fi 180 | while true; do 181 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 182 | MTUc=1 183 | MTUy=$((${MTUy} + ${MTUc})) 184 | else 185 | MTUy=$((${MTUy} - ${MTUc})) 186 | if [[ ${MTUc} = 1 ]]; then 187 | break 188 | fi 189 | fi 190 | if [[ ${MTUy} -le 1360 ]]; then 191 | MTUy='1360' 192 | break 193 | fi 194 | done 195 | MTU=$((${MTUy} - 80)) 196 | green "MTU最佳值=$MTU 已设置完毕" 197 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 198 | } 199 | 200 | cpto_wireguard(){ 201 | if [[ ! -d "/etc/wireguard" ]]; then 202 | mkdir /etc/wireguard 203 | fi 204 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 205 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 206 | } 207 | 208 | start_wgcf(){ 209 | yellow "正在启动 Wgcf-WARP" 210 | wg-quick up wgcf >/dev/null 2>&1 211 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 212 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 213 | until [[ $WgcfWARP4Status =~ on|plus ]] && [[ $WgcfWARP6Status =~ on|plus ]]; do 214 | red "无法启动Wgcf-WARP,正在尝试重启" 215 | wg-quick down wgcf >/dev/null 2>&1 216 | wg-quick up wgcf >/dev/null 2>&1 217 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 218 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 219 | sleep 8 220 | done 221 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 222 | WgcfIPv4=$(curl -s4m8 https://ip.gs -k) 223 | WgcfIPv6=$(curl -s6m8 https://ip.gs -k) 224 | green "Wgcf-WARP 已启动成功" 225 | yellow "Wgcf-WARP的IPv4 IP为:$WgcfIPv4" 226 | yellow "Wgcf-WARP的IPv6 IP为:$WgcfIPv6" 227 | rm -f warp6d.sh 228 | } 229 | 230 | install(){ 231 | install_wireguard 232 | [[ -z $(type -P wgcf) ]] && install_wgcf 233 | register_wgcf 234 | generate_wgcf_config 235 | get_best_mtu 236 | cpto_wireguard 237 | start_wgcf 238 | } 239 | 240 | check_tun 241 | checkCentOS8 242 | install 243 | -------------------------------------------------------------------------------- /wgcf-warp/warpd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wg-quick) ]] && red "Wgcf-WARP已经安装,脚本即将退出" && rm -f warpd.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | check_tun(){ 56 | TUN=$(cat /dev/net/tun 2>&1 | tr '[:upper:]' '[:lower:]') 57 | if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ '处于错误状态' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then 58 | if [[ $vpsvirt == "openvz" ]]; then 59 | wget -N --no-check-certificate https://raw.githubusercontents.com/Misaka-blog/tun-script/master/tun.sh && bash tun.sh 60 | else 61 | red "检测到未开启TUN模块,请到VPS控制面板处开启" 62 | exit 1 63 | fi 64 | fi 65 | } 66 | 67 | checkCentOS8(){ 68 | if [[ -n $(cat /etc/os-release | grep "CentOS Linux 8") ]]; then 69 | yellow "检测到当前VPS系统为CentOS 8,是否升级为CentOS Stream 8以确保软件包正常安装?" 70 | read -p "请输入选项 [y/n]:" comfirmCentOSStream 71 | if [[ $comfirmCentOSStream == "y" ]]; then 72 | yellow "正在为你升级到CentOS Stream 8,大概需要10-30分钟的时间" 73 | sleep 1 74 | sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-* 75 | yum clean all && yum makecache 76 | dnf swap centos-linux-repos centos-stream-repos distro-sync -y 77 | else 78 | red "已取消升级过程,脚本即将退出!" 79 | exit 1 80 | fi 81 | fi 82 | } 83 | 84 | install_wireguard_centos(){ 85 | ${PACKAGE_INSTALL[int]} epel-release 86 | ${PACKAGE_INSTALL[int]} net-tools wireguard-tools iptables 87 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 88 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 89 | vsid=`grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1` 90 | curl -Lo /etc/yum.repos.d/wireguard.repo https://copr.fedorainfracloud.org/coprs/jdoss/wireguard/repo/epel-$vsid/jdoss-wireguard-epel-$vsid.repo 91 | ${PACKAGE_INSTALL[int]} wireguard-dkms 92 | fi 93 | fi 94 | } 95 | 96 | install_wireguard_debian(){ 97 | ${PACKAGE_INSTALL[int]} lsb-release 98 | echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list 99 | ${PACKAGE_UPDATE[int]} 100 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 101 | if [[ $main -lt 5 ]] || [[ $minor -lt 6 ]]; then 102 | if [[ $vpsvirt =~ "kvm"|"xen"|"microsoft" ]]; then 103 | ${PACKAGE_INSTALL[int]} --no-install-recommends linux-headers-$(uname -r) 104 | ${PACKAGE_INSTALL[int]} --no-install-recommends wireguard-dkms 105 | fi 106 | fi 107 | } 108 | 109 | install_wireguard_ubuntu(){ 110 | ${PACKAGE_INSTALL[int]} --no-install-recommends net-tools iproute2 openresolv dnsutils wireguard-tools iptables 111 | } 112 | 113 | install_wireguard(){ 114 | ${PACKAGE_UPDATE[int]} 115 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 116 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 117 | [[ $SYSTEM == CentOS ]] && install_wireguard_centos 118 | [[ $SYSTEM == Debian ]] && install_wireguard_debian 119 | [[ $SYSTEM == Ubuntu ]] && install_wireguard_ubuntu 120 | if [[ $vpsvirt =~ lxc|openvz ]]; then 121 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go -O /usr/bin/wireguard-go 122 | chmod +x /usr/bin/wireguard-go 123 | fi 124 | if [[ $vpsvirt == zvm ]]; then 125 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireguard-go-s390x -O /usr/bin/wireguard-go 126 | chmod +x /usr/bin/wireguard-go 127 | fi 128 | } 129 | 130 | install_wgcf(){ 131 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 132 | chmod +x /usr/local/bin/wgcf 133 | } 134 | 135 | register_wgcf(){ 136 | rm -f wgcf-account.toml 137 | until [[ -a wgcf-account.toml ]]; do 138 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 139 | yes | wgcf register 140 | sleep 5 141 | done 142 | chmod +x wgcf-account.toml 143 | } 144 | 145 | generate_wgcf_config(){ 146 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 147 | read -p "按键许可证密钥(26个字符):" WPPlusKey 148 | if [[ -n $WPPlusKey ]]; then 149 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 150 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 151 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 152 | if [[ -n $WPPlusName ]]; then 153 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 154 | else 155 | wgcf update 156 | fi 157 | fi 158 | wgcf generate 159 | chmod +x wgcf-profile.conf 160 | sed -i "7 s/^/PostUp = ip -4 rule add from $(ip route get 1.1.1.1 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 161 | sed -i "8 s/^/PostDown = ip -4 rule delete from $(ip route get 1.1.1.1 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 162 | sed -i "9 s/^/PostUp = ip -6 rule add from $(ip route get 2606:4700:4700::1001 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 163 | sed -i "10 s/^/PostDown = ip -6 rule delete from $(ip route get 2606:4700:4700::1001 | grep -oP 'src \K\S+') lookup main\n/" wgcf-profile.conf 164 | sed -i 's/1.1.1.1/1.1.1.1,8.8.8.8,8.8.4.4,2606:4700:4700::1001,2606:4700:4700::1111,2001:4860:4860::8888,2001:4860:4860::8844/g' wgcf-profile.conf 165 | } 166 | 167 | get_best_mtu(){ 168 | v66=`curl -s6m8 https://ip.gs -k` 169 | v44=`curl -s4m8 https://ip.gs -k` 170 | MTUy=1500 171 | MTUc=10 172 | if [[ -n ${v66} && -z ${v44} ]]; then 173 | ping='ping6' 174 | IP1='2606:4700:4700::1001' 175 | IP2='2001:4860:4860::8888' 176 | else 177 | ping='ping' 178 | IP1='1.1.1.1' 179 | IP2='8.8.8.8' 180 | fi 181 | while true; do 182 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 183 | MTUc=1 184 | MTUy=$((${MTUy} + ${MTUc})) 185 | else 186 | MTUy=$((${MTUy} - ${MTUc})) 187 | if [[ ${MTUc} = 1 ]]; then 188 | break 189 | fi 190 | fi 191 | if [[ ${MTUy} -le 1360 ]]; then 192 | MTUy='1360' 193 | break 194 | fi 195 | done 196 | MTU=$((${MTUy} - 80)) 197 | green "MTU最佳值=$MTU 已设置完毕" 198 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 199 | } 200 | 201 | cpto_wireguard(){ 202 | if [[ ! -d "/etc/wireguard" ]]; then 203 | mkdir /etc/wireguard 204 | fi 205 | mv -f wgcf-profile.conf /etc/wireguard/wgcf.conf 206 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 207 | } 208 | 209 | start_wgcf(){ 210 | yellow "正在启动 Wgcf-WARP" 211 | wg-quick up wgcf >/dev/null 2>&1 212 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 213 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 214 | until [[ $WgcfWARP4Status =~ on|plus ]] && [[ $WgcfWARP6Status =~ on|plus ]]; do 215 | red "无法启动Wgcf-WARP,正在尝试重启" 216 | wg-quick down wgcf >/dev/null 2>&1 217 | wg-quick up wgcf >/dev/null 2>&1 218 | WgcfWARP4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 219 | WgcfWARP6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2) 220 | sleep 8 221 | done 222 | systemctl enable wg-quick@wgcf >/dev/null 2>&1 223 | WgcfIPv4=$(curl -s4m8 https://ip.gs -k) 224 | WgcfIPv6=$(curl -s6m8 https://ip.gs -k) 225 | green "Wgcf-WARP 已启动成功" 226 | yellow "Wgcf-WARP的IPv4 IP为:$WgcfIPv4" 227 | yellow "Wgcf-WARP的IPv6 IP为:$WgcfIPv6" 228 | rm -f warpd.sh 229 | } 230 | 231 | install(){ 232 | install_wireguard 233 | install_wgcf 234 | register_wgcf 235 | generate_wgcf_config 236 | get_best_mtu 237 | cpto_wireguard 238 | start_wgcf 239 | } 240 | 241 | check_tun 242 | checkCentOS8 243 | install 244 | -------------------------------------------------------------------------------- /wireproxy-warp/README.md: -------------------------------------------------------------------------------- 1 | # Misaka WARP 脚本 - WireProxy-WARP 代理模式 2 | 3 | 使用基于WireGuard的用户代理程序WireProxy,在VPS创建本地Socks5代理 4 | 5 | ## 使用方法 6 | 7 | ### IPv4 Only或原生双栈VPS 8 | 9 | ```shell 10 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/warp4.sh && bash warp4.sh 11 | ``` 12 | 13 | ### IPv6 Only VPS 14 | 15 | ```shell 16 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/warp6.sh && bash warp6.sh 17 | ``` 18 | 19 | ### 修改WireProxy端口 20 | 21 | ```shell 22 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/changeport.sh && bash changeport.sh 23 | ``` 24 | 25 | ### 卸载WireProxy-WARP 代理模式 26 | 27 | ```shell 28 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/uninstall.sh && bash uninstall.sh 29 | ``` 30 | 31 | ### 刷Netfilx IP 32 | 33 | ```shell 34 | wget -N https://raw.githubusercontents.com/Misaka-blog/Misaka-WARP-Script/master/wireproxy-warp/netfilx-wireproxy.sh && bash netfilx-wireproxy.sh 35 | ``` 36 | 37 | 可搭配 [Screen 管理脚本](https://github.com/Misaka-blog/screenManager) 使用最佳 38 | 39 | ## 开关WireProxy WARP 40 | 41 | 启动:`systemctl start wireproxy-warp` 42 | 43 | 关闭:`systemctl stop wireproxy-warp` 44 | 45 | 设置开机自启:`systemctl enable wireproxy-warp` 46 | 47 | 取消开机自启:`systemctl disable wireproxy-warp` 48 | 49 | ## 赞助我们 50 | 51 | ![afdian-MisakaNo.jpg](https://s2.loli.net/2021/12/25/SimocqwhVg89NQJ.jpg) 52 | 53 | ## 交流群 54 | [Telegram](https://t.me/misakanetcn) 55 | 56 | -------------------------------------------------------------------------------- /wireproxy-warp/changeport.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | red() { 3 | echo -e "\033[31m\033[01m$1\033[0m" 4 | } 5 | green() { 6 | echo -e "\033[32m\033[01m$1\033[0m" 7 | } 8 | yellow() { 9 | echo -e "\033[33m\033[01m$1\033[0m" 10 | } 11 | 12 | # 判断系统及定义系统安装依赖方式 13 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 14 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 15 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 16 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 17 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 18 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 19 | 20 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 21 | 22 | for i in "${CMD[@]}"; do 23 | SYS="$i" && [[ -n $SYS ]] && break 24 | done 25 | 26 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 27 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 28 | done 29 | 30 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 31 | [[ -z $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式未安装,脚本即将退出!" && rm -f changeport.sh && exit 1 32 | 33 | changeport(){ 34 | systemctl stop wireproxy-warp 35 | read -p "请输入WARP Cli使用的代理端口(默认40000):" WireProxyPort 36 | [[ -z $WireProxyPort ]] && WireProxyPort=40000 37 | CurrentPort=$(grep BindAddress /etc/wireguard/proxy.conf) 38 | sed -i "s/$CurrentPort/BindAddress = 127.0.0.1:$WireProxyPort/g" /etc/wireguard/proxy.conf 39 | yellow "正在启动WireProxy-WARP代理模式" 40 | systemctl start wireproxy-warp 41 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 42 | until [[ $socks5Status =~ on|plus ]]; do 43 | red "启动WireProxy-WARP代理模式失败,正在尝试重启" 44 | systemctl stop wireproxy-warp 45 | systemctl start wireproxy-warp 46 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 47 | sleep 8 48 | done 49 | systemctl enable wireproxy-warp 50 | green "WireProxy-WARP代理模式已启动成功!" 51 | yellow "本地Socks5代理为: 127.0.0.1:$WireProxyPort" 52 | rm -f changeport.sh 53 | } 54 | 55 | changeport -------------------------------------------------------------------------------- /wireproxy-warp/netfilx-wireproxy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | green() { 7 | echo -e "\033[32m\033[01m$1\033[0m" 8 | } 9 | yellow() { 10 | echo -e "\033[33m\033[01m$1\033[0m" 11 | } 12 | 13 | # 判断系统及定义系统安装依赖方式 14 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 15 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 16 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 17 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 18 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 19 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 20 | 21 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 22 | 23 | for i in "${CMD[@]}"; do 24 | SYS="$i" && [[ -n $SYS ]] && break 25 | done 26 | 27 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 28 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 29 | done 30 | 31 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 32 | [[ -z $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式未安装,脚本即将退出!" && rm -f wireproxy-netfilx.sh && exit 1 33 | 34 | WireProxyPort=$(grep BindAddress /etc/wireguard/proxy.conf 2>/dev/null | sed "s/BindAddress = 127.0.0.1://g") 35 | 36 | check(){ 37 | NetfilxStatus=$(curl -sx socks5h://localhost:$WireProxyPort -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/81215567" 2>&1) 38 | if [[ $NetfilxStatus == "200" ]]; then 39 | success 40 | fi 41 | if [[ $NetfilxStatus =~ "403"|"404" ]]; then 42 | failed 43 | fi 44 | if [[ -z $NetfilxStatus ]] || [[ $NetfilxStatus == "000" ]]; then 45 | retry 46 | fi 47 | } 48 | 49 | retry(){ 50 | systemctl stop wireproxy-warp 51 | systemctl start wireproxy-warp 52 | check 53 | } 54 | 55 | success(){ 56 | WireProxyIP=$(curl -sx socks5h://localhost:$WireProxyPort https://ip.gs -k --connect-timeout 8) 57 | green "当前WireProxy-WARP的IP:$WireProxyIP 已解锁Netfilx" 58 | yellow "等待1小时后,脚本将会自动重新检查Netfilx解锁状态" 59 | sleep 1h 60 | check 61 | } 62 | 63 | failed(){ 64 | WireProxyIP=$(curl -sx socks5h://localhost:$WireProxyPort https://ip.gs -k --connect-timeout 8) 65 | red "当前WireProxy-WARP的IP:$WireProxyIP 未解锁Netfilx,脚本将在15秒后重新测试Netfilx解锁情况" 66 | sleep 15 67 | systemctl stop wireproxy-warp 68 | systemctl start wireproxy-warp 69 | check 70 | } 71 | 72 | check 73 | -------------------------------------------------------------------------------- /wireproxy-warp/uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 34 | [[ -z $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式未安装,脚本即将退出" && rm -f uninstall.sh && exit 1 35 | 36 | uninstall(){ 37 | systemctl stop wireproxy-warp 38 | systemctl disable wireproxy-warp 39 | rm -f /etc/systemd/system/wireproxy-warp.service 40 | rm -f /usr/local/bin/wireproxy 41 | rm -f /etc/wireguard/proxy.conf 42 | if [[ ! -f /etc/wireguard/wgcf.conf ]]; then 43 | rm -f /etc/wireguard/wgcf-account.toml 44 | rm -f /usr/local/bin/wgcf 45 | fi 46 | green "WARP-Cli代理模式已彻底卸载成功!" 47 | rm -f uninstall.sh 48 | } 49 | 50 | uninstall 51 | -------------------------------------------------------------------------------- /wireproxy-warp/warp4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式已经安装,脚本即将退出" && rm -f warp4d.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | install_wgcf(){ 56 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 57 | chmod +x /usr/local/bin/wgcf 58 | } 59 | 60 | register_wgcf(){ 61 | rm -f wgcf-account.toml 62 | until [[ -a wgcf-account.toml ]]; do 63 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 64 | yes | wgcf register 65 | sleep 5 66 | done 67 | chmod +x wgcf-account.toml 68 | } 69 | 70 | generate_wgcf_config(){ 71 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 72 | read -p "按键许可证密钥(26个字符):" WPPlusKey 73 | if [[ -n $WPPlusKey ]]; then 74 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 75 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 76 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 77 | if [[ -n $WPPlusName ]]; then 78 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 79 | else 80 | wgcf update 81 | fi 82 | fi 83 | wgcf generate 84 | chmod +x wgcf-profile.conf 85 | } 86 | 87 | get_best_mtu(){ 88 | v66=`curl -s6m8 https://ip.gs -k` 89 | v44=`curl -s4m8 https://ip.gs -k` 90 | MTUy=1500 91 | MTUc=10 92 | if [[ -n ${v66} && -z ${v44} ]]; then 93 | ping='ping6' 94 | IP1='2606:4700:4700::1001' 95 | IP2='2001:4860:4860::8888' 96 | else 97 | ping='ping' 98 | IP1='1.1.1.1' 99 | IP2='8.8.8.8' 100 | fi 101 | while true; do 102 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 103 | MTUc=1 104 | MTUy=$((${MTUy} + ${MTUc})) 105 | else 106 | MTUy=$((${MTUy} - ${MTUc})) 107 | if [[ ${MTUc} = 1 ]]; then 108 | break 109 | fi 110 | fi 111 | if [[ ${MTUy} -le 1360 ]]; then 112 | MTUy='1360' 113 | break 114 | fi 115 | done 116 | MTU=$((${MTUy} - 80)) 117 | green "MTU最佳值=$MTU 已设置完毕" 118 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 119 | } 120 | 121 | make_wireproxy_file(){ 122 | read -p "请输入将要设置的Socks5端口(默认40000):" WireProxyPort 123 | [[ -z $WireProxyPort ]] && WireProxyPort=40000 124 | WgcfPrivateKey=$(grep PrivateKey wgcf-profile.conf | sed "s/PrivateKey = //g") 125 | WgcfPublicKey=$(grep PublicKey wgcf-profile.conf | sed "s/PublicKey = //g") 126 | 127 | if [[ ! -d "/etc/wireguard" ]]; then 128 | mkdir /etc/wireguard 129 | fi 130 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 131 | 132 | cat < /etc/wireguard/proxy.conf 133 | [Interface] 134 | Address = 172.16.0.2/32 135 | MTU = $MTU 136 | PrivateKey = $WgcfPrivateKey 137 | DNS = 1.1.1.1,8.8.8.8,8.8.4.4 138 | 139 | [Peer] 140 | PublicKey = $WgcfPublicKey 141 | Endpoint = 162.159.193.10:2408 142 | 143 | [Socks5] 144 | BindAddress = 127.0.0.1:$WireProxyPort 145 | EOF 146 | green "WireProxy-WARP代理模式配置文件已生成成功!" 147 | cat <<'TEXT' > /etc/systemd/system/wireproxy-warp.service 148 | [Unit] 149 | Description=CloudFlare WARP based for WireProxy, script by owo.misaka.rest 150 | After=network.target 151 | [Install] 152 | WantedBy=multi-user.target 153 | [Service] 154 | Type=simple 155 | WorkingDirectory=/root 156 | ExecStart=/usr/local/bin/wireproxy -c /etc/wireguard/proxy.conf 157 | Restart=always 158 | TEXT 159 | green "Systemd 系统守护服务设置成功!" 160 | rm -f wgcf-profile.conf 161 | } 162 | 163 | download_wireproxy(){ 164 | if [[ $arch == "amd64" || $arch == "x86_64" ]]; then 165 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-amd64 -O /usr/local/bin/wireproxy 166 | chmod +x /usr/local/bin/wireproxy 167 | fi 168 | if [[ $arch == "armv8" || $arch == "arm64" || $arch == "aarch64" ]]; then 169 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-arm64 -O /usr/local/bin/wireproxy 170 | chmod +x /usr/local/bin/wireproxy 171 | fi 172 | if [[ $arch == "s390x" ]]; then 173 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-s390x -O /usr/local/bin/wireproxy 174 | chmod +x /usr/local/bin/wireproxy 175 | fi 176 | } 177 | 178 | start_wireproxy_warp(){ 179 | yellow "正在启动WireProxy-WARP代理模式" 180 | systemctl start wireproxy-warp 181 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 182 | until [[ $socks5Status =~ on|plus ]]; do 183 | red "启动WireProxy-WARP代理模式失败,正在尝试重启" 184 | systemctl stop wireproxy-warp 185 | systemctl start wireproxy-warp 186 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 187 | sleep 8 188 | done 189 | systemctl enable wireproxy-warp 190 | socks5IP=$(curl -sx socks5h://localhost:$WireProxyPort https://ip.gs -k --connect-timeout 8) 191 | green "WireProxy-WARP代理模式已启动成功!" 192 | yellow "本地Socks5代理为: 127.0.0.1:$WireProxyPort" 193 | yellow "WireProxy-WARP代理模式的IP为:$socks5IP" 194 | rm -f warp4.sh 195 | } 196 | 197 | install(){ 198 | ${PACKAGE_UPDATE[int]} 199 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 200 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 201 | [[ -z $(type -P wgcf) ]] && install_wgcf 202 | register_wgcf 203 | generate_wgcf_config 204 | get_best_mtu 205 | make_wireproxy_file 206 | download_wireproxy 207 | start_wireproxy_warp 208 | } 209 | 210 | install 211 | -------------------------------------------------------------------------------- /wireproxy-warp/warp6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | red() { 4 | echo -e "\033[31m\033[01m$1\033[0m" 5 | } 6 | 7 | green() { 8 | echo -e "\033[32m\033[01m$1\033[0m" 9 | } 10 | 11 | yellow() { 12 | echo -e "\033[33m\033[01m$1\033[0m" 13 | } 14 | 15 | # 判断系统及定义系统安装依赖方式 16 | REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "'amazon linux'") 17 | RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS") 18 | PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update") 19 | PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install") 20 | PACKAGE_REMOVE=("apt -y remove" "apt -y remove" "yum -y remove" "yum -y remove") 21 | PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove") 22 | 23 | CMD=("$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)" "$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)" "$(lsb_release -sd 2>/dev/null)" "$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)" "$(grep . /etc/redhat-release 2>/dev/null)" "$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')") 24 | 25 | for i in "${CMD[@]}"; do 26 | SYS="$i" && [[ -n $SYS ]] && break 27 | done 28 | 29 | for ((int = 0; int < ${#REGEX[@]}; int++)); do 30 | [[ $(echo "$SYS" | tr '[:upper:]' '[:lower:]') =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && [[ -n $SYSTEM ]] && break 31 | done 32 | 33 | [[ $EUID -ne 0 ]] && red "请在root用户下运行脚本" && exit 1 34 | 35 | [[ -z $SYSTEM ]] && red "不支持当前VPS的系统,请使用主流操作系统" && exit 1 36 | [[ -n $(type -P wireproxy) ]] && red "WireProxy-WARP代理模式已经安装,脚本即将退出" && rm -f warp4d.sh && exit 1 37 | 38 | main=`uname -r | awk -F . '{print $1}'` 39 | minor=`uname -r | awk -F . '{print $2}'` 40 | vpsvirt=`systemd-detect-virt` 41 | 42 | archAffix(){ 43 | case "$(uname -m)" in 44 | i686 | i386) echo '386' ;; 45 | x86_64 | amd64 ) echo 'amd64' ;; 46 | armv5tel) echo 'armv5' ;; 47 | armv6l) echo 'armv6' ;; 48 | armv7 | armv7l) echo 'armv7' ;; 49 | armv8 | arm64 | aarch64 ) echo 'arm64' ;; 50 | s390x ) echo 's390x' ;; 51 | * ) red "不支持的CPU架构!" && exit 1 ;; 52 | esac 53 | } 54 | 55 | install_wgcf(){ 56 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wgcf_latest_linux_$(archAffix) -O /usr/local/bin/wgcf 57 | chmod +x /usr/local/bin/wgcf 58 | } 59 | 60 | register_wgcf(){ 61 | rm -f wgcf-account.toml 62 | until [[ -a wgcf-account.toml ]]; do 63 | yellow "正在向CloudFlare WARP申请账号,如提示429 Too Many Requests错误请耐心等待即可" 64 | yes | wgcf register 65 | sleep 5 66 | done 67 | chmod +x wgcf-account.toml 68 | } 69 | 70 | generate_wgcf_config(){ 71 | yellow "使用WARP免费版账户请按回车跳过 \n启用WARP+账户,请复制WARP+的许可证密钥(26个字符)后回车" 72 | read -p "按键许可证密钥(26个字符):" WPPlusKey 73 | if [[ -n $WPPlusKey ]]; then 74 | sed -i "s/license_key.*/license_key = \"$WPPlusKey\"/g" wgcf-account.toml 75 | read -p "请输入自定义设备名,如未输入则使用默认随机设备名:" WPPlusName 76 | green "注册WARP+账户中,如下方显示:400 Bad Request,则使用WARP免费版账户" 77 | if [[ -n $WPPlusName ]]; then 78 | wgcf update --name $(echo $WPPlusName | sed s/[[:space:]]/_/g) 79 | else 80 | wgcf update 81 | fi 82 | fi 83 | wgcf generate 84 | chmod +x wgcf-profile.conf 85 | } 86 | 87 | get_best_mtu(){ 88 | v66=`curl -s6m8 https://ip.gs -k` 89 | v44=`curl -s4m8 https://ip.gs -k` 90 | MTUy=1500 91 | MTUc=10 92 | if [[ -n ${v66} && -z ${v44} ]]; then 93 | ping='ping6' 94 | IP1='2606:4700:4700::1001' 95 | IP2='2001:4860:4860::8888' 96 | else 97 | ping='ping' 98 | IP1='1.1.1.1' 99 | IP2='8.8.8.8' 100 | fi 101 | while true; do 102 | if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then 103 | MTUc=1 104 | MTUy=$((${MTUy} + ${MTUc})) 105 | else 106 | MTUy=$((${MTUy} - ${MTUc})) 107 | if [[ ${MTUc} = 1 ]]; then 108 | break 109 | fi 110 | fi 111 | if [[ ${MTUy} -le 1360 ]]; then 112 | MTUy='1360' 113 | break 114 | fi 115 | done 116 | MTU=$((${MTUy} - 80)) 117 | green "MTU最佳值=$MTU 已设置完毕" 118 | sed -i "s/MTU.*/MTU = $MTU/g" wgcf-profile.conf 119 | } 120 | 121 | make_wireproxy_file(){ 122 | read -p "请输入将要设置的Socks5端口(默认40000):" WireProxyPort 123 | [[ -z $WireProxyPort ]] && WireProxyPort=40000 124 | WgcfPrivateKey=$(grep PrivateKey wgcf-profile.conf | sed "s/PrivateKey = //g") 125 | WgcfPublicKey=$(grep PublicKey wgcf-profile.conf | sed "s/PublicKey = //g") 126 | 127 | if [[ ! -d "/etc/wireguard" ]]; then 128 | mkdir /etc/wireguard 129 | fi 130 | mv -f wgcf-account.toml /etc/wireguard/wgcf-account.toml 131 | 132 | 133 | cat < /etc/wireguard/proxy.conf 134 | [Interface] 135 | Address = 172.16.0.2/32 136 | MTU = $MTU 137 | PrivateKey = $WgcfPrivateKey 138 | DNS = 1.1.1.1,8.8.8.8,8.8.4.4 139 | 140 | [Peer] 141 | PublicKey = $WgcfPublicKey 142 | Endpoint = [2606:4700:d0::a29f:c001]:2408 143 | 144 | [Socks5] 145 | BindAddress = 127.0.0.1:$WireProxyPort 146 | EOF 147 | green "WireProxy-WARP代理模式配置文件已生成成功!" 148 | cat <<'TEXT' > /etc/systemd/system/wireproxy-warp.service 149 | [Unit] 150 | Description=CloudFlare WARP based for WireProxy, script by owo.misaka.rest 151 | After=network.target 152 | [Install] 153 | WantedBy=multi-user.target 154 | [Service] 155 | Type=simple 156 | WorkingDirectory=/root 157 | ExecStart=/usr/local/bin/wireproxy -c /etc/wireguard/proxy.conf 158 | Restart=always 159 | TEXT 160 | green "Systemd 系统守护服务设置成功!" 161 | rm -f wgcf-profile.conf 162 | } 163 | 164 | download_wireproxy(){ 165 | if [[ $arch == "amd64" || $arch == "x86_64" ]]; then 166 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-amd64 -O /usr/local/bin/wireproxy 167 | chmod +x /usr/local/bin/wireproxy 168 | fi 169 | if [[ $arch == "armv8" || $arch == "arm64" || $arch == "aarch64" ]]; then 170 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-arm64 -O /usr/local/bin/wireproxy 171 | chmod +x /usr/local/bin/wireproxy 172 | fi 173 | if [[ $arch == "s390x" ]]; then 174 | wget -N --no-check-certificate https://cdn.jsdelivr.net/gh/Misaka-blog/Misaka-WARP-Script/files/wireproxy-s390x -O /usr/local/bin/wireproxy 175 | chmod +x /usr/local/bin/wireproxy 176 | fi 177 | } 178 | 179 | start_wireproxy_warp(){ 180 | yellow "正在启动WireProxy-WARP代理模式" 181 | systemctl start wireproxy-warp 182 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 183 | until [[ $socks5Status =~ on|plus ]]; do 184 | red "启动WireProxy-WARP代理模式失败,正在尝试重启" 185 | systemctl stop wireproxy-warp 186 | systemctl start wireproxy-warp 187 | socks5Status=$(curl -sx socks5h://localhost:$WireProxyPort https://www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 8 | grep warp | cut -d= -f2) 188 | sleep 8 189 | done 190 | systemctl enable wireproxy-warp 191 | socks5IP=$(curl -sx socks5h://localhost:$WireProxyPort ip.gs -k --connect-timeout 8) 192 | green "WireProxy-WARP代理模式已启动成功!" 193 | yellow "本地Socks5代理为: 127.0.0.1:$WireProxyPort" 194 | yellow "WireProxy-WARP代理模式的IP为:$socks5IP" 195 | rm -f warp6.sh 196 | } 197 | 198 | install(){ 199 | ${PACKAGE_UPDATE[int]} 200 | [[ -z $(type -P curl) ]] && ${PACKAGE_INSTALL[int]} curl 201 | [[ -z $(type -P sudo) ]] && ${PACKAGE_INSTALL[int]} sudo 202 | [[ -z $(type -P wgcf) ]] && install_wgcf 203 | register_wgcf 204 | generate_wgcf_config 205 | get_best_mtu 206 | make_wireproxy_file 207 | download_wireproxy 208 | start_wireproxy_warp 209 | } 210 | 211 | install 212 | --------------------------------------------------------------------------------