From 0f903b8ee0977ed6feed70bffe4d78a627b6ca25 Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Fri, 4 Oct 2024 20:20:13 +0800 Subject: [PATCH] Bump version 0.2.37 --- .github/workflows/release.yml | 21 +- Cargo.toml | 2 +- install/overtls-install-caddy.sh | 599 +++++++++++++++++++++++++++++++ readme-cn.md | 13 + readme.md | 13 + 5 files changed, 645 insertions(+), 3 deletions(-) create mode 100644 install/overtls-install-caddy.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63630b8..a56bdd0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,9 @@ jobs: - aarch64-apple-darwin - x86_64-pc-windows-msvc - i686-pc-windows-msvc + - aarch64-pc-windows-msvc + - x86_64-win7-windows-msvc + - i686-win7-windows-msvc include: - target: x86_64-unknown-linux-gnu @@ -43,6 +46,12 @@ jobs: host_os: windows-latest - target: i686-pc-windows-msvc host_os: windows-latest + - target: aarch64-pc-windows-msvc + host_os: windows-latest + - target: x86_64-win7-windows-msvc + host_os: windows-latest + - target: i686-win7-windows-msvc + host_os: windows-latest runs-on: ${{ matrix.host_os }} steps: @@ -54,7 +63,6 @@ jobs: run: | cargo install cbindgen mkdir release - rustup target add ${{ matrix.target }} if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then sudo .github/workflows/install-cross.sh fi @@ -63,10 +71,19 @@ jobs: shell: bash run: | if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then + rustup target add ${{ matrix.target }} cross build --all-features --release --target ${{ matrix.target }} else - cargo build --all-features --release --target ${{ matrix.target }} + if [[ "${{ matrix.target }}" == "x86_64-win7-windows-msvc" || "${{ matrix.target }}" == "i686-win7-windows-msvc" ]]; then + rustup toolchain install nightly + rustup component add rust-src --toolchain nightly + cargo +nightly build --release -Z build-std --target ${{ matrix.target }} + else + rustup target add ${{ matrix.target }} + cargo build --all-features --release --target ${{ matrix.target }} + fi fi + cbindgen -c cbindgen.toml -l C --cpp-compat -o ./overtls.h if [[ "${{ matrix.host_os }}" == "windows-latest" ]]; then powershell Compress-Archive -Path target/${{ matrix.target }}/release/overtls-bin.exe, ./config.json, ./overtls.h, target/${{ matrix.target }}/release/overtls.dll -DestinationPath release/overtls-${{ matrix.target }}.zip diff --git a/Cargo.toml b/Cargo.toml index 0b4460d..0d4b2f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "overtls" -version = "0.2.36" +version = "0.2.37" edition = "2021" license = "MIT" description = "A simple proxy tunnel, minimalist tool for bypassing the GFW." diff --git a/install/overtls-install-caddy.sh b/install/overtls-install-caddy.sh new file mode 100644 index 0000000..d3c4665 --- /dev/null +++ b/install/overtls-install-caddy.sh @@ -0,0 +1,599 @@ +#!/bin/bash + +#========================================================== +# System Request: Debian 7+ / Ubuntu 14.04+ +# Author: ssrlive +# Description: overTLS onekey for musl building with Caddy +# Version: 1.0.0 +#========================================================== + +#fonts color +Green="\033[32m" +Red="\033[31m" +Yellow="\033[33m" +GreenBG="\033[42;37m" +RedBG="\033[41;37m" +Font="\033[0m" + +#notification information +Info="${Green}[Info]${Font}" +OK="${Green}[OK]${Font}" +Error="${Red}[Error]${Font}" + +cur_dir=`pwd` + +function get_binary_target() { + local _binary_target="" + local CPU_ARCH=`uname -m` + case ${CPU_ARCH} in + x86_64) + _binary_target="x86_64-unknown-linux-musl" + ;; + aarch64) + _binary_target="aarch64-unknown-linux-musl" + ;; + armv7l) + _binary_target="armv7-unknown-linux-musleabihf" + ;; + *) + echo -e "${Error} ${RedBG} The current CPU architecture ${CPU_ARCH} is not supported. Please contact the author! ${Font}" + exit 1 + ;; + esac + echo ${_binary_target} +} + +cpu_arch_target=$(get_binary_target) + +overtls_install_sh="overtls-install-caddy.sh" +overtls_install_sh_url="https://raw.githubusercontent.com/shadowsocksr-live/overtls/master/install/overtls-install-caddy.sh" + +overtls_bin_url="https://github.com/shadowsocksr-live/overtls/releases/latest/download/overtls-${cpu_arch_target}.zip" +overtls_bin_zip_file="overtls-${cpu_arch_target}.zip" + +daemon_script_url="https://raw.githubusercontent.com/shadowsocksr-live/overtls/master/install/overtls-daemon.sh" +daemon_script_file="overtls-daemon.sh" +service_dir=/lib/systemd/system +service_name=overtls +service_stub=/etc/init.d/${service_name} + +config_file_path="/etc/overtls/config.json" +caddy_conf_file="/etc/caddy/Caddyfile" +site_dir="/fakesite" +site_cert_dir="/fakesite_cert" +target_bin_path="/usr/local/bin/overtls-bin" +bin_name=overtls-bin + +export web_svr_domain="" +export web_svr_local_ip_addr="" +export web_svr_listen_port="443" +export web_svr_reverse_proxy_host="127.0.0.1" +export web_svr_reverse_proxy_port=10000 + +function random_string_gen() { + local PASS="" + local MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" # "~!@#$%^&*()_+=" + local LENGTH=$1 + [ -z $1 ] && LENGTH="16" + while [ "${n:=1}" -le "$LENGTH" ] + do + PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}" + let n+=1 + done + + echo ${PASS} +} + +# Reverse proxy entry point. +export reverse_proxy_location=$(random_string_gen 20) + +function check_root_account() { + if [ `id -u` == 0 ]; then + echo -e "${OK} ${GreenBG} Current account is the root user, enter the installation process ${Font} " + sleep 3 + else + echo -e "${Error} ${RedBG} Current account is not root user, please switch to the root user and re-execute this script ${Font}" + exit 1 + fi +} + +source /etc/os-release + +function script_file_full_path() { + echo $(readlink -f "$0") +} + +function judge() { + if [[ $? -eq 0 ]]; then + echo -e "${OK} ${GreenBG} $1 Completed ${Font}" + sleep 1 + else + echo -e "${Error} ${RedBG} $1 Failed ${Font}" + exit 1 + fi +} + +function disable_web_servers() { + sudo systemctl stop nginx # stop nginx + sudo systemctl disable nginx # disable nginx + + sudo systemctl stop httpd # stop apache2 + sudo systemctl disable httpd # disable apache2 + + sudo systemctl stop apache2 # stop apache2 + sudo systemctl disable apache2 # disable apache2 + + sudo systemctl stop caddy # stop caddy + sudo systemctl disable cadddy # disable caddy +} + +function install_caddy_in_debian() { + if [[ -x /usr/bin/caddy ]]; then + echo -e "${OK} ${GreenBG} Caddy has been installed before this moment ${Font}" + sudo systemctl enable caddy + sudo systemctl start caddy + return 0 + fi + + # Install caddy, see https://caddyserver.com/docs/install#debian-ubuntu-raspbian + sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl + curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg + curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list + sudo apt update + sudo apt install caddy + + sudo systemctl enable caddy + sudo systemctl start caddy + + judge "Caddy installation" +} + +function dependency_install() { + apt install curl wget git lsof bc unzip -y + apt install cron vim curl -y + apt update -y + apt install qrencode zlib1g zlib1g-dev autoconf libtool -y + if [[ "${ID}" == "ubuntu" && `echo "${VERSION_ID}" | cut -d '.' -f1` -ge 20 ]]; then + apt install inetutils-ping -y + fi +} + +function random_listen_port() { + local overtls_port=0 + while true; do + overtls_port=$(shuf -i 9000-19999 -n 1) + expr ${overtls_port} + 1 &>/dev/null + if [ $? -eq 0 ]; then + if [ ${overtls_port} -ge 1 ] && [ ${overtls_port} -le 65535 ] && [ ${overtls_port:0:1} != 0 ]; then + break + fi + fi + done + echo ${overtls_port} +} + +function check_file_exists() { + local file_path="${1}" + + if [[ -z "${file_path}" ]]; then + echo -e "${RedBG} Error: file path given is empty. ${Font}" + exit 1 + fi + + if [ ! -f "${file_path}" ]; then + echo -e "${RedBG} Error: ${file_path} not found. ${Font}" + exit 1 + fi +} + +function domain_check() { + local install="" + echo "请输入 你的网站域名 (形如 mygooodsite.com)" + stty erase '^H' && read -p "Please enter your domain name (for example: mygooodsite.com): " web_svr_domain + local web_svr_ip_addr=`ping ${web_svr_domain} -c 1 | sed '1{s/[^(]*(//;s/).*//;q}' | sed '1{s/[^(]*(//;s/).*//;q}'` + echo -e "${OK} ${GreenBG} 正獲取公網 IP, 請耐心等待... ${Font}" + echo -e "${OK} ${GreenBG} Obtaining public IP information, please wait patiently... ${Font}" + local web_svr_local_ip_v4_addr=`curl -4 ip.sb` + local web_svr_local_ip_v6_addr=`curl -6 ip.sb` + echo -e "DNS resolution IP: ${web_svr_ip_addr}" + echo -e "Local V4 IP: ${web_svr_local_ip_v4_addr}" + echo -e "Local V6 IP: ${web_svr_local_ip_v6_addr}" + sleep 2 + if [[ $(echo ${web_svr_local_ip_v4_addr} | tr a-z A-Z) = $(echo ${web_svr_ip_addr} | tr a-z A-Z) ]]; then + echo -e "${OK} ${GreenBG} The DNS resolution IP matches local V4 IP ${Font}" + web_svr_local_ip_addr=${web_svr_local_ip_v4_addr} + sleep 2 + elif [[ $(echo ${web_svr_local_ip_v6_addr} | tr a-z A-Z) = $(echo ${web_svr_ip_addr} | tr a-z A-Z) ]]; then + echo -e "${OK} ${GreenBG} The DNS resolution IP matches local V6 IP ${Font}" + web_svr_local_ip_addr=${web_svr_local_ip_v6_addr} + sleep 2 + else + echo -e "${Error} ${RedBG} The DNS resolution IP does not match the local IP. Do you want to continue the installation? (y/n) ${Font}" && read install + case ${install} in + [yY][eE][sS]|[yY]) + echo -e "${GreenBG} Continue to install ${Font}" + sleep 2 + ;; + *) + echo -e "${RedBG} Installation terminated ${Font}" + exit 2 + ;; + esac + fi + + local rvs_path=${reverse_proxy_location} + echo "请输入 反向代理入口路径(不带前后斜杠), 默认值 ${rvs_path} " + stty erase '^H' && read -p "Please enter reverse proxy path without slashes (default ${rvs_path}):" rvs_path + [[ -z ${rvs_path} ]] && rvs_path=${reverse_proxy_location} + reverse_proxy_location=${rvs_path} +} + +function input_web_listen_port() { + local port="443" + stty erase '^H' && read -p "Please enter the access port number (default: 443):" port + [[ -z ${port} ]] && port="443" + echo ${port} +} + +function cron_random_restart_overtls_svc() { + local random_hour=$(od -An -N1 -i /dev/urandom | awk '{print $1 % 24}') + local random_minute=$(od -An -N1 -i /dev/urandom | awk '{print $1 % 60}') + + (crontab -l; echo "${random_minute} ${random_hour} * * * systemctl restart overtls") | crontab - +} + +function download_n_install_overtls_server_bin() { + local local_bin_path="${target_bin_path}" + + rm -rf ${overtls_bin_zip_file} + wget ${overtls_bin_url} >/dev/null 2>&1 + if [ $? -ne 0 ]; then echo "wget failed"; exit -1; fi + + rm -rf ${bin_name} + unzip ${overtls_bin_zip_file} ${bin_name} >/dev/null 2>&1 + if [ $? -ne 0 ]; then echo "unzip failed"; exit -1; fi + + chmod +x ${bin_name} + rm -rf ${overtls_bin_zip_file} + + rm -rf ${local_bin_path} + local target_dir="$(dirname "${local_bin_path}")" + mv ${bin_name} ${target_dir} + + echo "${local_bin_path}" +} + +function write_overtls_config_file() { + local local_cfg_file_path="${1}" + local dir_path="$(dirname "${local_cfg_file_path}")" + mkdir -p "${dir_path}" + rm -rf "${local_cfg_file_path}" + + local identity=$(random_string_gen 4) + + cat > ${local_cfg_file_path} < /dev/null 2>&1 + # if [ $? -eq 0 ]; then + # ${service_stub} stop + # fi + + # if [[ "${ID}" == "ubuntu" || "${ID}" == "debian" || "${ID}" == "linuxmint" ]]; then + # update-rc.d -f ${service_name} remove + # elif [[ "${ID}" == "centos" ]]; then + # chkconfig --del ${service_name} + # fi + + sleep 2 + + systemctl stop ${service_name}.service + sleep 2 + + systemctl disable ${service_name}.service + + rm -rf ${config_file_path} + rm -rf ${service_stub} + rm -rf ${target_bin_path} + rm -rf ${service_dir}/${service_name}.service + + systemctl daemon-reload + + echo "${service_name} uninstall success!" +} + +function install_binary_as_systemd_service() { + local role="${1}" + local local_bin_file_path=${2} + local local_cfg_file_path=${3} + + check_install_systemd_svc_params "${role}" "${local_bin_file_path}" "${local_cfg_file_path}" + + if systemctl is-active --quiet ${service_name} ; then + echo "${service_name} is running" + echo -e "${Error} ${RedBG} Do you want to remove ${service_name} really and install a new one? (Y/N) ${Font}" && read action + case ${action} in + [yY][eE][sS]|[yY]) + echo -e "${GreenBG} Continue to install ${Font}" + sleep 2 + ;; + *) + echo -e "${RedBG} Installation terminated ${Font}" + exit 2 + ;; + esac + fi + + do_uninstall_service_action + + create_overtls_systemd_service "${role}" "${local_bin_file_path}" "${local_cfg_file_path}" +} + +# Uninstall overtls +function uninstall_overtls() { + printf "Are you sure uninstall ${service_name}? (y/n)\n" + read -p "(Default: n):" answer + [ -z ${answer} ] && answer="n" + if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then + do_uninstall_service_action + else + echo + echo "uninstall cancelled, nothing to do..." + echo + fi +} + +function random_reverse_proxy_site() { + local urls=( + "https://www.sohu.com" + "https://www.sina.com.cn" + "https://www.baidu.com" + "https://www.bilibili.com" + "https://www.gov.cn" + "https://www.jd.com" + "https://www.taobao.com" + "https://www.qq.com" + "https://www.163.com" + "https://www.douban.com" + "https://www.zhihu.com" + "https://www.toutiao.com" + "http://www.xinhuanet.com" + "https://www.cctv.com" + "https://www.ifeng.com" + "https://www.huanqiu.com" + "https://www.people.com.cn" + "http://www.news.cn" + "https://www.chinanews.com" + "https://chinaplus.cri.cn/" + "https://www.chinadaily.com.cn" + ) + local random_index=$((RANDOM % ${#urls[@]})) + echo ${urls[$random_index]} +} + +function caddy_web_server_config() { + rm -rf ${caddy_conf_file} + + local selected_site=$(random_reverse_proxy_site) + + cat > ${caddy_conf_file} < /dev/null ; then + if ! command -v brew &> /dev/null ; then + echo -e "${Info} ${Yellow} Homebrew not found, please install it first! ${Font}" + exit 1 + fi + brew install qrencode >/dev/null 2>&1 + fi + elif [[ "$(uname)" == "Linux" ]]; then + sudo apt -y install qrencode >/dev/null 2>&1 + fi + print_qrcode "${svc_bin_path}" "${cfg_path}" + ;; + *) + echo "Arguments error! [${action}]" + echo "Usage: `basename $0` [install|uninstall]" + ;; + esac + + exit 0 +} + +main "$@" + diff --git a/readme-cn.md b/readme-cn.md index a63d45b..123d768 100644 --- a/readme-cn.md +++ b/readme-cn.md @@ -75,6 +75,19 @@ chmod +x overtls-install-musl.sh sudo systemctl start overtls ``` +### 使用 Caddy 的安裝腳本 +
+使用 Caddy 的腳本的安裝步驟 + +```bash +sudo apt install -y wget # Debian/Ubuntu +wget https://raw.githubusercontent.com/shadowsocksr-live/overtls/master/install/overtls-install-caddy.sh +bash ./overtls-install-caddy.sh +sudo systemctl start overtls +``` + +
+ ## 用法 ### 服務端 diff --git a/readme.md b/readme.md index 371fe3d..d38468e 100644 --- a/readme.md +++ b/readme.md @@ -93,6 +93,19 @@ chmod +x overtls-install-musl.sh sudo systemctl start overtls ``` +### Installation script with Caddy +
+Steps of installing with Caddy + +```bash +sudo apt install -y wget # Debian/Ubuntu +wget https://raw.githubusercontent.com/shadowsocksr-live/overtls/master/install/overtls-install-caddy.sh +bash ./overtls-install-caddy.sh +sudo systemctl start overtls +``` + +
+ ## Usage ### Server