Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Jan 20, 2024
2 parents b42b4dd + 15da22e commit a3b168f
Show file tree
Hide file tree
Showing 29 changed files with 805 additions and 330 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
protocol = "sparse"

[build]
#target = "aarch64-linux-android"
# target = "aarch64-linux-android"
106 changes: 106 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Check

on:
[push, pull_request]

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

build:
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu # arch: x86_64, os: linux
- aarch64-unknown-linux-gnu # arch: aarch64
- armv7-unknown-linux-gnueabihf # arch: armv7
- x86_64-apple-darwin # os: darwin
- aarch64-apple-darwin # os: darwin
- x86_64-pc-windows-msvc # os: windows
- i686-pc-windows-msvc

include:
- target: x86_64-unknown-linux-gnu
host_os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
host_os: ubuntu-latest
- target: armv7-unknown-linux-gnueabihf
host_os: ubuntu-latest
- target: x86_64-apple-darwin
host_os: macos-latest
- target: aarch64-apple-darwin
host_os: macos-latest
- target: x86_64-pc-windows-msvc
host_os: windows-latest
- target: i686-pc-windows-msvc
host_os: windows-latest

runs-on: ${{ matrix.host_os }}

steps:
- uses: actions/checkout@v3

- name: Prepare
shell: bash
run: |
rustup target add ${{ matrix.target }}
- name: Build
shell: bash
run: |
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
sudo .github/workflows/install-cross.sh
cross build --verbose --target ${{ matrix.target }}
else
cargo build --verbose --target ${{ matrix.target }}
fi
- name: Run tests
run: cargo test --verbose --all-features

76 changes: 76 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build Releases
on:
push:
tags:
- "*"
env:
CARGO_TERM_COLOR: always

jobs:
build:
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc

include:
- target: x86_64-unknown-linux-gnu
host_os: ubuntu-latest
- target: x86_64-unknown-linux-musl
host_os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
host_os: ubuntu-latest
- target: armv7-unknown-linux-gnueabihf
host_os: ubuntu-latest
- target: x86_64-apple-darwin
host_os: macos-latest
- target: aarch64-apple-darwin
host_os: macos-latest
- target: x86_64-pc-windows-msvc
host_os: windows-latest
- target: i686-pc-windows-msvc
host_os: windows-latest

runs-on: ${{ matrix.host_os }}
steps:
- uses: actions/checkout@v3

- name: Prepare
shell: bash
run: |
mkdir release
rustup target add ${{ matrix.target }}
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
sudo .github/workflows/install-cross.sh
fi
- name: Build
shell: bash
run: |
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
cross build --all-features --release --target ${{ matrix.target }}
else
cargo build --all-features --release --target ${{ matrix.target }}
fi
cbindgen -c cbindgen.toml -l C -o target/${{ matrix.target }}/release/overtls-api.h
if [[ "${{ matrix.host_os }}" == "windows-latest" ]]; then
powershell Compress-Archive -Path target/${{ matrix.target }}/release/overtls.exe, ./config.json, target/${{ matrix.target }}/release/overtls-api.h, target/${{ matrix.target }}/release/overtls.dll -DestinationPath release/overtls-${{ matrix.target }}.zip
elif [[ "${{ matrix.host_os }}" == "macos-latest" ]]; then
zip -j release/overtls-${{ matrix.target }}.zip target/${{ matrix.target }}/release/overtls ./config.json target/${{ matrix.target }}/release/overtls-api.h target/${{ matrix.target }}/release/libovertls.dylib
elif [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
zip -j release/overtls-${{ matrix.target }}.zip target/${{ matrix.target }}/release/overtls ./config.json target/${{ matrix.target }}/release/overtls-api.h target/${{ matrix.target }}/release/libovertls.so
fi
- name: Upload
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: release/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
examples/
nginx_signing.key
overtls-daemon.sh
project.xcworkspace/
Expand Down
50 changes: 32 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
[package]
name = "overtls"
version = "0.1.7"
version = "0.2.8"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["staticlib", "cdylib", "lib"]

[dependencies]
async-shared-timeout = "0.2"
base64 = "0.21"
bytes = "1.4"
clap = { version = "4.2", features = ["derive"] }
bytes = "1.5"
chrono = "0.4"
clap = { version = "4.4", features = ["derive"] }
ctrlc2 = { version = "3.5", features = ["tokio", "termination"] }
dotenvy = "0.15"
env_logger = "0.10"
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
http = "0.2"
futures-util = { version = "0.3", default-features = false, features = [
"sink",
"std",
] }
http = "1.0"
httparse = "1.8"
lazy_static = "1.4"
log = "0.4"
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "json"] }
rustls = "0.21"
rustls-pemfile = "1.0"
serde = { version = "1.0", features = [ "derive" ] }
log = { version = "0.4", features = ["std"] }
moka = { version = "0.12", features = ["future"] }
reqwest = { version = "0.11", default-features = false, features = [
"rustls-tls",
"json",
] }
rustls = { version = "0.22" }
rustls-pemfile = "2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
socks5-impl = "0.2"
socks5-impl = "0.5"
thiserror = "1.0"
tokio = { version = "1.28", features = [ "full" ] }
tokio-rustls = "0.24"
tokio-tungstenite = { version = "0.19", features = [ "rustls-tls-webpki-roots" ] }
tungstenite = { version = "0.19", features = [ "rustls-tls-webpki-roots" ] }
url = "2.3"
webpki = { package = "rustls-webpki", version = "0.100", features = ["alloc", "std"] }
webpki-roots = "0.23"
tokio = { version = "1.35", features = ["full"] }
tokio-rustls = "0.25"
tokio-tungstenite = { version = "0.21", features = ["rustls-tls-webpki-roots"] }
trust-dns-proto = "0.23"
tungstenite = { version = "0.21", features = ["rustls-tls-webpki-roots"] }
url = "2.5"
webpki = { package = "rustls-webpki", version = "0.102", features = [
"alloc",
"std",
] }
webpki-roots = "0.26"

[target.'cfg(target_family="unix")'.dependencies]
daemonize = "0.5"
Expand Down
19 changes: 19 additions & 0 deletions apple/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Building iOS framework

### Install **Rust** build tools
- Install Xcode Command Line Tools: `xcode-select --install`
- Install Rust programming language: `curl https://sh.rustup.rs -sSf | sh`
- Install iOS target support: `rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios`
- Install `cbindgen` tool: `cargo install cbindgen`

### Building iOS framework
Due to an unknown reason at present, compiling Rust code from Xcode fails, so you have to manually compile it.
Please run the following command in zsh (or bash):
```bash
cd overtls

cargo build --release --target aarch64-apple-ios
cargo build --release --target x86_64-apple-ios
lipo -create target/aarch64-apple-ios/release/libovertls.a target/x86_64-apple-ios/release/libovertls.a -output target/libovertls.a
cbindgen --config cbindgen.toml -l C -o target/overtls-ios.h
```
2 changes: 1 addition & 1 deletion cbindgen.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[export]
include = ["over_tls_client_run", "over_tls_client_stop"]
include = ["over_tls_client_run", "over_tls_client_stop", "overtls_set_log_callback"]
exclude = ["Java_com_github_shadowsocks_bg_OverTlsWrapper_runClient", "Java_com_github_shadowsocks_bg_OverTlsWrapper_stopClient"]
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"method": "none",
"password": "password",
"tunnel_path": "/secret-tunnel-path/",

"server_settings": {
"disable_tls": false,
"manage_clients": {
Expand All @@ -19,14 +18,15 @@
"listen_host": "0.0.0.0",
"listen_port": 443
},

"client_settings": {
"disable_tls": false,
"client_id": "33959370-71e0-401d-9746-cda471fc5926",
"server_host": "123.45.67.89",
"server_port": 443,
"server_domain": "example.com",
"cafile": "",
"listen_user": "",
"listen_password": "",
"listen_host": "127.0.0.1",
"listen_port": 1080
}
Expand Down
63 changes: 59 additions & 4 deletions install/overtls-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,44 @@ function install_binary_as_systemd_service() {
create_overtls_systemd_service "${role}" "${local_bin_file_path}" "${local_cfg_file_path}"
}

function macos_install_binary_as_service() {
local role="${1}"
local local_bin_file_path=${2}
local local_cfg_file_path=${3}
local svc_daemon_file_path="~/Library/LaunchAgents/${service_name}.plist"

cat > ${svc_daemon_file_path} <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>${service_name}</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>StartInterval</key>
<integer>3</integer>
<key>ProgramArguments</key>
<array>
<string>${local_bin_file_path}</string>
<string>-r</string>
<string>${role}</string>
<string>-c</string>
<string>${local_cfg_file_path}</string>
<string>-d</string>
</array>
<key>WorkingDirectory</key>
<string>/usr/local</string>
</dict>
</plist>
EOF

launchctl load ${svc_daemon_file_path}
launchctl start ${service_name}
}

# Uninstall overtls
function uninstall_overtls() {
printf "Are you sure uninstall ${service_name}? (y/n)\n"
Expand Down Expand Up @@ -825,18 +863,35 @@ function main() {
uninstall_overtls
;;
service)
check_root_account
local role="${2}"
local customer_binary_path="$3"
local customer_cfg_file_path="$4"
check_install_systemd_svc_params "${role}" "${customer_binary_path}" "${customer_cfg_file_path}"
install_binary_as_systemd_service "${role}" "${customer_binary_path}" "${customer_cfg_file_path}"
if [[ "$(uname)" == "Linux" ]]; then
check_root_account
install_binary_as_systemd_service "${role}" "${customer_binary_path}" "${customer_cfg_file_path}"
elif [[ "$(uname)" == "Darwin" ]]; then
macos_install_binary_as_service "${role}" "${customer_binary_path}" "${customer_cfg_file_path}"
else
echo -e "${RedBG} Unsupported operating system! ${Font}"
exit 1
fi
;;
qrcode)
local svc_bin_path="${2}"
local cfg_path="${3}"
check_system
sudo ${INSTALL_CMD} -y install qrencode >/dev/null 2>&1
if [[ "$(uname)" == "Darwin" ]]; then
if ! command -v qrencode &> /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
check_system
sudo ${INSTALL_CMD} -y install qrencode >/dev/null 2>&1
fi
print_qrcode "${svc_bin_path}" "${cfg_path}"
;;
*)
Expand Down
Loading

0 comments on commit a3b168f

Please sign in to comment.