Skip to content

Commit a3b168f

Browse files
committed
merge upstream
2 parents b42b4dd + 15da22e commit a3b168f

29 files changed

+805
-330
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
protocol = "sparse"
33

44
[build]
5-
#target = "aarch64-linux-android"
5+
# target = "aarch64-linux-android"

.github/workflows/check.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Check
2+
3+
on:
4+
[push, pull_request]
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
9+
jobs:
10+
check:
11+
name: Check
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions-rs/toolchain@v1
16+
with:
17+
profile: minimal
18+
toolchain: stable
19+
override: true
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: check
23+
24+
fmt:
25+
name: Rustfmt
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: actions-rs/toolchain@v1
30+
with:
31+
profile: minimal
32+
toolchain: stable
33+
override: true
34+
- run: rustup component add rustfmt
35+
- uses: actions-rs/cargo@v1
36+
with:
37+
command: fmt
38+
args: --all -- --check
39+
40+
clippy:
41+
name: Clippy
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v2
45+
- uses: actions-rs/toolchain@v1
46+
with:
47+
profile: minimal
48+
toolchain: stable
49+
override: true
50+
- run: rustup component add clippy
51+
- uses: actions-rs/cargo@v1
52+
with:
53+
command: clippy
54+
args: -- -D warnings
55+
56+
build:
57+
strategy:
58+
matrix:
59+
target:
60+
- x86_64-unknown-linux-gnu # arch: x86_64, os: linux
61+
- aarch64-unknown-linux-gnu # arch: aarch64
62+
- armv7-unknown-linux-gnueabihf # arch: armv7
63+
- x86_64-apple-darwin # os: darwin
64+
- aarch64-apple-darwin # os: darwin
65+
- x86_64-pc-windows-msvc # os: windows
66+
- i686-pc-windows-msvc
67+
68+
include:
69+
- target: x86_64-unknown-linux-gnu
70+
host_os: ubuntu-latest
71+
- target: aarch64-unknown-linux-gnu
72+
host_os: ubuntu-latest
73+
- target: armv7-unknown-linux-gnueabihf
74+
host_os: ubuntu-latest
75+
- target: x86_64-apple-darwin
76+
host_os: macos-latest
77+
- target: aarch64-apple-darwin
78+
host_os: macos-latest
79+
- target: x86_64-pc-windows-msvc
80+
host_os: windows-latest
81+
- target: i686-pc-windows-msvc
82+
host_os: windows-latest
83+
84+
runs-on: ${{ matrix.host_os }}
85+
86+
steps:
87+
- uses: actions/checkout@v3
88+
89+
- name: Prepare
90+
shell: bash
91+
run: |
92+
rustup target add ${{ matrix.target }}
93+
94+
- name: Build
95+
shell: bash
96+
run: |
97+
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
98+
sudo .github/workflows/install-cross.sh
99+
cross build --verbose --target ${{ matrix.target }}
100+
else
101+
cargo build --verbose --target ${{ matrix.target }}
102+
fi
103+
104+
- name: Run tests
105+
run: cargo test --verbose --all-features
106+

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build Releases
2+
on:
3+
push:
4+
tags:
5+
- "*"
6+
env:
7+
CARGO_TERM_COLOR: always
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
target:
14+
- x86_64-unknown-linux-gnu
15+
- x86_64-unknown-linux-musl
16+
- aarch64-unknown-linux-gnu
17+
- armv7-unknown-linux-gnueabihf
18+
- x86_64-apple-darwin
19+
- aarch64-apple-darwin
20+
- x86_64-pc-windows-msvc
21+
- i686-pc-windows-msvc
22+
23+
include:
24+
- target: x86_64-unknown-linux-gnu
25+
host_os: ubuntu-latest
26+
- target: x86_64-unknown-linux-musl
27+
host_os: ubuntu-latest
28+
- target: aarch64-unknown-linux-gnu
29+
host_os: ubuntu-latest
30+
- target: armv7-unknown-linux-gnueabihf
31+
host_os: ubuntu-latest
32+
- target: x86_64-apple-darwin
33+
host_os: macos-latest
34+
- target: aarch64-apple-darwin
35+
host_os: macos-latest
36+
- target: x86_64-pc-windows-msvc
37+
host_os: windows-latest
38+
- target: i686-pc-windows-msvc
39+
host_os: windows-latest
40+
41+
runs-on: ${{ matrix.host_os }}
42+
steps:
43+
- uses: actions/checkout@v3
44+
45+
- name: Prepare
46+
shell: bash
47+
run: |
48+
mkdir release
49+
rustup target add ${{ matrix.target }}
50+
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
51+
sudo .github/workflows/install-cross.sh
52+
fi
53+
54+
- name: Build
55+
shell: bash
56+
run: |
57+
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
58+
cross build --all-features --release --target ${{ matrix.target }}
59+
else
60+
cargo build --all-features --release --target ${{ matrix.target }}
61+
fi
62+
cbindgen -c cbindgen.toml -l C -o target/${{ matrix.target }}/release/overtls-api.h
63+
if [[ "${{ matrix.host_os }}" == "windows-latest" ]]; then
64+
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
65+
elif [[ "${{ matrix.host_os }}" == "macos-latest" ]]; then
66+
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
67+
elif [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
68+
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
69+
fi
70+
71+
- name: Upload
72+
uses: softprops/action-gh-release@v1
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
with:
76+
files: release/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
examples/
12
nginx_signing.key
23
overtls-daemon.sh
34
project.xcworkspace/

Cargo.toml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
11
[package]
22
name = "overtls"
3-
version = "0.1.7"
3+
version = "0.2.8"
44
edition = "2021"
55
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
66

77
[lib]
88
crate-type = ["staticlib", "cdylib", "lib"]
99

1010
[dependencies]
11+
async-shared-timeout = "0.2"
1112
base64 = "0.21"
12-
bytes = "1.4"
13-
clap = { version = "4.2", features = ["derive"] }
13+
bytes = "1.5"
14+
chrono = "0.4"
15+
clap = { version = "4.4", features = ["derive"] }
16+
ctrlc2 = { version = "3.5", features = ["tokio", "termination"] }
1417
dotenvy = "0.15"
1518
env_logger = "0.10"
16-
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
17-
http = "0.2"
19+
futures-util = { version = "0.3", default-features = false, features = [
20+
"sink",
21+
"std",
22+
] }
23+
http = "1.0"
1824
httparse = "1.8"
1925
lazy_static = "1.4"
20-
log = "0.4"
21-
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "json"] }
22-
rustls = "0.21"
23-
rustls-pemfile = "1.0"
24-
serde = { version = "1.0", features = [ "derive" ] }
26+
log = { version = "0.4", features = ["std"] }
27+
moka = { version = "0.12", features = ["future"] }
28+
reqwest = { version = "0.11", default-features = false, features = [
29+
"rustls-tls",
30+
"json",
31+
] }
32+
rustls = { version = "0.22" }
33+
rustls-pemfile = "2.0"
34+
serde = { version = "1.0", features = ["derive"] }
2535
serde_json = "1.0"
26-
socks5-impl = "0.2"
36+
socks5-impl = "0.5"
2737
thiserror = "1.0"
28-
tokio = { version = "1.28", features = [ "full" ] }
29-
tokio-rustls = "0.24"
30-
tokio-tungstenite = { version = "0.19", features = [ "rustls-tls-webpki-roots" ] }
31-
tungstenite = { version = "0.19", features = [ "rustls-tls-webpki-roots" ] }
32-
url = "2.3"
33-
webpki = { package = "rustls-webpki", version = "0.100", features = ["alloc", "std"] }
34-
webpki-roots = "0.23"
38+
tokio = { version = "1.35", features = ["full"] }
39+
tokio-rustls = "0.25"
40+
tokio-tungstenite = { version = "0.21", features = ["rustls-tls-webpki-roots"] }
41+
trust-dns-proto = "0.23"
42+
tungstenite = { version = "0.21", features = ["rustls-tls-webpki-roots"] }
43+
url = "2.5"
44+
webpki = { package = "rustls-webpki", version = "0.102", features = [
45+
"alloc",
46+
"std",
47+
] }
48+
webpki-roots = "0.26"
3549

3650
[target.'cfg(target_family="unix")'.dependencies]
3751
daemonize = "0.5"

apple/readme.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Building iOS framework
2+
3+
### Install **Rust** build tools
4+
- Install Xcode Command Line Tools: `xcode-select --install`
5+
- Install Rust programming language: `curl https://sh.rustup.rs -sSf | sh`
6+
- Install iOS target support: `rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios`
7+
- Install `cbindgen` tool: `cargo install cbindgen`
8+
9+
### Building iOS framework
10+
Due to an unknown reason at present, compiling Rust code from Xcode fails, so you have to manually compile it.
11+
Please run the following command in zsh (or bash):
12+
```bash
13+
cd overtls
14+
15+
cargo build --release --target aarch64-apple-ios
16+
cargo build --release --target x86_64-apple-ios
17+
lipo -create target/aarch64-apple-ios/release/libovertls.a target/x86_64-apple-ios/release/libovertls.a -output target/libovertls.a
18+
cbindgen --config cbindgen.toml -l C -o target/overtls-ios.h
19+
```

cbindgen.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[export]
2-
include = ["over_tls_client_run", "over_tls_client_stop"]
2+
include = ["over_tls_client_run", "over_tls_client_stop", "overtls_set_log_callback"]
33
exclude = ["Java_com_github_shadowsocks_bg_OverTlsWrapper_runClient", "Java_com_github_shadowsocks_bg_OverTlsWrapper_stopClient"]

config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"method": "none",
44
"password": "password",
55
"tunnel_path": "/secret-tunnel-path/",
6-
76
"server_settings": {
87
"disable_tls": false,
98
"manage_clients": {
@@ -19,14 +18,15 @@
1918
"listen_host": "0.0.0.0",
2019
"listen_port": 443
2120
},
22-
2321
"client_settings": {
2422
"disable_tls": false,
2523
"client_id": "33959370-71e0-401d-9746-cda471fc5926",
2624
"server_host": "123.45.67.89",
2725
"server_port": 443,
2826
"server_domain": "example.com",
2927
"cafile": "",
28+
"listen_user": "",
29+
"listen_password": "",
3030
"listen_host": "127.0.0.1",
3131
"listen_port": 1080
3232
}

install/overtls-install.sh

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,44 @@ function install_binary_as_systemd_service() {
711711
create_overtls_systemd_service "${role}" "${local_bin_file_path}" "${local_cfg_file_path}"
712712
}
713713

714+
function macos_install_binary_as_service() {
715+
local role="${1}"
716+
local local_bin_file_path=${2}
717+
local local_cfg_file_path=${3}
718+
local svc_daemon_file_path="~/Library/LaunchAgents/${service_name}.plist"
719+
720+
cat > ${svc_daemon_file_path} <<EOF
721+
<?xml version="1.0" encoding="UTF-8"?>
722+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
723+
<plist version="1.0">
724+
<dict>
725+
<key>Label</key>
726+
<string>${service_name}</string>
727+
<key>RunAtLoad</key>
728+
<true/>
729+
<key>KeepAlive</key>
730+
<false/>
731+
<key>StartInterval</key>
732+
<integer>3</integer>
733+
<key>ProgramArguments</key>
734+
<array>
735+
<string>${local_bin_file_path}</string>
736+
<string>-r</string>
737+
<string>${role}</string>
738+
<string>-c</string>
739+
<string>${local_cfg_file_path}</string>
740+
<string>-d</string>
741+
</array>
742+
<key>WorkingDirectory</key>
743+
<string>/usr/local</string>
744+
</dict>
745+
</plist>
746+
EOF
747+
748+
launchctl load ${svc_daemon_file_path}
749+
launchctl start ${service_name}
750+
}
751+
714752
# Uninstall overtls
715753
function uninstall_overtls() {
716754
printf "Are you sure uninstall ${service_name}? (y/n)\n"
@@ -825,18 +863,35 @@ function main() {
825863
uninstall_overtls
826864
;;
827865
service)
828-
check_root_account
829866
local role="${2}"
830867
local customer_binary_path="$3"
831868
local customer_cfg_file_path="$4"
832869
check_install_systemd_svc_params "${role}" "${customer_binary_path}" "${customer_cfg_file_path}"
833-
install_binary_as_systemd_service "${role}" "${customer_binary_path}" "${customer_cfg_file_path}"
870+
if [[ "$(uname)" == "Linux" ]]; then
871+
check_root_account
872+
install_binary_as_systemd_service "${role}" "${customer_binary_path}" "${customer_cfg_file_path}"
873+
elif [[ "$(uname)" == "Darwin" ]]; then
874+
macos_install_binary_as_service "${role}" "${customer_binary_path}" "${customer_cfg_file_path}"
875+
else
876+
echo -e "${RedBG} Unsupported operating system! ${Font}"
877+
exit 1
878+
fi
834879
;;
835880
qrcode)
836881
local svc_bin_path="${2}"
837882
local cfg_path="${3}"
838-
check_system
839-
sudo ${INSTALL_CMD} -y install qrencode >/dev/null 2>&1
883+
if [[ "$(uname)" == "Darwin" ]]; then
884+
if ! command -v qrencode &> /dev/null ; then
885+
if ! command -v brew &> /dev/null ; then
886+
echo -e "${Info} ${Yellow} Homebrew not found, please install it first! ${Font}"
887+
exit 1
888+
fi
889+
brew install qrencode >/dev/null 2>&1
890+
fi
891+
elif [[ "$(uname)" == "Linux" ]]; then
892+
check_system
893+
sudo ${INSTALL_CMD} -y install qrencode >/dev/null 2>&1
894+
fi
840895
print_qrcode "${svc_bin_path}" "${cfg_path}"
841896
;;
842897
*)

0 commit comments

Comments
 (0)