Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
106 changes: 99 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,37 @@ jobs:
with:
command: check licenses

test:
libcronet:
needs: lint-audit
uses: ./.github/workflows/libcronet.yml

test:
needs: [lint-audit, libcronet]
name: cargo test (unit + integration)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'pull_request' }}
key: test-ubuntu
- name: Check formatting
run: cargo fmt --check
- name: Lint with clippy
run: cargo clippy --all-targets -- -D warnings
- name: Fetch libcronet
uses: actions/download-artifact@v8
with:
name: libcronet-x86_64-unknown-linux-gnu
path: cronet
- name: Point the loader at it
run: echo "CRONET_LIB=$PWD/cronet/libcronet.so" >> "$GITHUB_ENV"
- name: Run tests
run: cargo test --all-targets

linux-gnu:
needs: [lint-audit, test]
needs: [lint-audit, test, libcronet]
name: Build Linux (GNU)
runs-on: ubuntu-latest
strategy:
Expand All @@ -61,6 +73,7 @@ jobs:
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'pull_request' }}
key: ${{ matrix.target_triple }}
- name: Install base dependencies
run: |
Expand All @@ -71,6 +84,27 @@ jobs:
run: sudo apt-get install -y ${{ matrix.apt_packages }}
- name: Add Rust target
run: rustup target add ${{ matrix.target_triple }}
- name: Fetch libcronet
uses: actions/download-artifact@v8
with:
name: libcronet-${{ matrix.target_triple }}
path: cronet
- name: Link with lld
if: ${{ matrix.target == 'arm64' }}
env: ${{ matrix.custom_env }}
run: |
host=$(rustc -vV | sed -n 's/^host: //p')
bin="$(rustc --print sysroot)/lib/rustlib/$host/bin"
prefix=${CC%-gcc}
mkdir -p "$HOME/lld"
printf '#!/bin/sh\nexec "%s/rust-lld" -flavor gnu "$@"\n' "$bin" > "$HOME/lld/lld-wrapper"
chmod +x "$HOME/lld/lld-wrapper"
ln -sf lld-wrapper "$HOME/lld/ld"
ln -sf lld-wrapper "$HOME/lld/$prefix-ld"
echo "$HOME/lld" >> "$GITHUB_PATH"
echo "RUSTFLAGS=-C link-arg=-B$HOME/lld" >> "$GITHUB_ENV"
- name: Point the build at it
run: echo "CRONET_LIB_DIR=$PWD/cronet" >> "$GITHUB_ENV"
- name: Build
env: ${{ matrix.custom_env }}
run: cargo build --release --target ${{ matrix.target_triple }}
Expand All @@ -79,14 +113,15 @@ jobs:
mkdir -p dist
cp target/${{ matrix.target_triple }}/release/client dist/
cp target/${{ matrix.target_triple }}/release/server dist/
cp cronet/LICENSE dist/CHROMIUM-LICENSE
- name: Upload
uses: actions/upload-artifact@v6
with:
name: httproxy-linux-${{ matrix.target }}
path: dist/

linux-musl:
needs: [lint-audit, test]
needs: [lint-audit, test, libcronet]
name: Build Linux (musl)
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -114,6 +149,7 @@ jobs:
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'pull_request' }}
key: ${{ matrix.target_triple }}
- name: Install base dependencies
run: |
Expand All @@ -126,6 +162,27 @@ jobs:
echo "/opt/${{ matrix.package }}/bin/" >> $GITHUB_PATH
- name: Add Rust target
run: rustup target add ${{ matrix.target_triple }}
- name: Fetch libcronet
uses: actions/download-artifact@v8
with:
name: libcronet-${{ matrix.target_triple }}
path: cronet
- name: Link with lld
if: ${{ matrix.target == 'arm64' }}
env: ${{ matrix.custom_env }}
run: |
host=$(rustc -vV | sed -n 's/^host: //p')
bin="$(rustc --print sysroot)/lib/rustlib/$host/bin"
prefix=${CC%-gcc}
mkdir -p "$HOME/lld"
printf '#!/bin/sh\nexec "%s/rust-lld" -flavor gnu "$@"\n' "$bin" > "$HOME/lld/lld-wrapper"
chmod +x "$HOME/lld/lld-wrapper"
ln -sf lld-wrapper "$HOME/lld/ld"
ln -sf lld-wrapper "$HOME/lld/$prefix-ld"
echo "$HOME/lld" >> "$GITHUB_PATH"
echo "RUSTFLAGS=-C link-arg=-B$HOME/lld" >> "$GITHUB_ENV"
- name: Point the build at it
run: echo "CRONET_LIB_DIR=$PWD/cronet" >> "$GITHUB_ENV"
- name: Build
env: ${{ matrix.custom_env }}
run: cargo build --release --target ${{ matrix.target_triple }}
Expand All @@ -134,14 +191,15 @@ jobs:
mkdir -p dist
cp target/${{ matrix.target_triple }}/release/client dist/
cp target/${{ matrix.target_triple }}/release/server dist/
cp cronet/LICENSE dist/CHROMIUM-LICENSE
- name: Upload
uses: actions/upload-artifact@v6
with:
name: httproxy-linux-${{ matrix.target }}-musl
path: dist/

windows:
needs: [lint-audit, test]
needs: [lint-audit, test, libcronet]
name: Build Windows
runs-on: windows-latest
strategy:
Expand All @@ -156,10 +214,19 @@ jobs:
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'pull_request' }}
key: ${{ matrix.target_triple }}
- name: Install dependencies
run: choco install cmake strawberryperl pkgconfiglite llvm nasm -y
shell: cmd
- name: Fetch libcronet
uses: actions/download-artifact@v8
with:
name: libcronet-${{ matrix.target_triple }}
path: cronet
- name: Point the build at it
shell: bash
run: echo "CRONET_LIB_DIR=$(cygpath -w "$PWD/cronet")" >> "$GITHUB_ENV"
- name: Build
env:
RUSTFLAGS: "-C target-feature=+crt-static"
Expand All @@ -172,14 +239,15 @@ jobs:
New-Item -ItemType Directory -Force -Path dist
Copy-Item "target\${{ matrix.target_triple }}\release\client.exe" -Destination dist\
Copy-Item "target\${{ matrix.target_triple }}\release\server.exe" -Destination dist\
Copy-Item "cronet\LICENSE" -Destination dist\CHROMIUM-LICENSE
- name: Upload
uses: actions/upload-artifact@v6
with:
name: httproxy-windows-${{ matrix.target }}
path: dist/

darwin:
needs: [lint-audit, test]
needs: [lint-audit, test, libcronet]
name: Build Darwin
runs-on: macos-latest
strategy:
Expand All @@ -194,26 +262,35 @@ jobs:
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'pull_request' }}
key: ${{ matrix.target_triple }}
- name: Install dependencies
run: brew install llvm
- name: Add Rust target
run: rustup target add ${{ matrix.target_triple }}
- name: Fetch libcronet
uses: actions/download-artifact@v8
with:
name: libcronet-${{ matrix.target_triple }}
path: cronet
- name: Point the build at it
run: echo "CRONET_LIB_DIR=$PWD/cronet" >> "$GITHUB_ENV"
- name: Build
run: cargo build --release --target ${{ matrix.target_triple }}
- name: Archive
run: |
mkdir -p dist
cp target/${{ matrix.target_triple }}/release/client dist/
cp target/${{ matrix.target_triple }}/release/server dist/
cp cronet/LICENSE dist/CHROMIUM-LICENSE
- name: Upload
uses: actions/upload-artifact@v6
with:
name: httproxy-darwin-${{ matrix.target }}
path: dist/

android:
needs: [lint-audit, test]
needs: [lint-audit, test, libcronet]
name: Build Android
runs-on: ubuntu-latest
strategy:
Expand All @@ -228,11 +305,25 @@ jobs:
- name: Rust Cache
uses: swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'pull_request' }}
key: ${{ matrix.target_triple }}
- name: Install Android Tools
run: cargo install cargo-ndk
- name: Add Rust target
run: rustup target add ${{ matrix.target_triple }}
- name: Fetch libcronet
uses: actions/download-artifact@v8
with:
name: libcronet-${{ matrix.target_triple }}
path: cronet
- name: Select the NDK
run: |
ndk="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-}}"
if [ -n "$ndk" ]; then
echo "ANDROID_NDK_HOME=$ndk" >> "$GITHUB_ENV"
fi
- name: Point the build at it
run: echo "CRONET_LIB_DIR=$PWD/cronet" >> "$GITHUB_ENV"
- name: Build
run: cargo ndk --target ${{ matrix.target_triple }} --platform 28 build --release
- name: Archive
Expand Down Expand Up @@ -262,6 +353,7 @@ jobs:
uses: actions/download-artifact@v8
with:
path: artifacts
pattern: httproxy-*
- name: Final Packaging
run: |
mkdir final_dist
Expand All @@ -272,7 +364,7 @@ jobs:
cd final_dist
sha256sum *.zip > sha256sums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v3
with:
files: |
final_dist/*.zip
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/libcronet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: libcronet

on:
workflow_call:
workflow_dispatch:

jobs:
build:
name: ${{ matrix.triple }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {triple: x86_64-unknown-linux-gnu, os: ubuntu-22.04}
- {triple: aarch64-unknown-linux-gnu, os: ubuntu-22.04}
- {triple: x86_64-unknown-linux-musl, os: ubuntu-22.04}
- {triple: aarch64-unknown-linux-musl, os: ubuntu-22.04}
- {triple: x86_64-linux-android, os: ubuntu-22.04}
- {triple: aarch64-linux-android, os: ubuntu-22.04}
- {triple: x86_64-apple-darwin, os: macos-latest}
- {triple: aarch64-apple-darwin, os: macos-latest}
- {triple: x86_64-pc-windows-msvc, os: windows-2022}
- {triple: aarch64-pc-windows-msvc, os: windows-2022}
steps:
- uses: actions/checkout@v6
- name: Restore the package
id: package
uses: actions/cache@v5
with:
path: cronet/${{ matrix.triple }}
key: cronet-package-${{ matrix.triple }}-${{ hashFiles('naiveproxy.lock', 'scripts/build-libcronet.sh') }}-v1
- name: Cache the toolchain
if: steps.package.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: |
.cronet-build/naiveproxy/src/third_party/llvm-build
.cronet-build/naiveproxy/src/gn
.cronet-build/naiveproxy/src/out/sysroot-build
key: cronet-${{ runner.os }}-${{ hashFiles('naiveproxy.lock') }}-v1
- name: Cache the Android NDK
if: contains(matrix.triple, 'android') && steps.package.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: .cronet-build/naiveproxy/src/third_party/android_toolchain
key: cronet-ndk-${{ hashFiles('naiveproxy.lock') }}-v1
- name: Install ninja
if: steps.package.outputs.cache-hit != 'true'
shell: bash
run: |
case "$RUNNER_OS" in
Linux)
sudo apt-get update
sudo apt-get install -y ninja-build ccache zstd xz-utils
;;
macOS)
brew install ninja ccache
;;
Windows)
choco install ninja -y --no-progress
if ! command -v xz >/dev/null 2>&1; then
curl -fsSL -o xz.zip https://tukaani.org/xz/xz-5.6.4-windows.zip
unzip -q xz.zip -d xz
echo "$PWD/xz/bin_x86-64" >> "$GITHUB_PATH"
fi
;;
esac
- name: Build
if: steps.package.outputs.cache-hit != 'true'
shell: bash
run: sh scripts/build-libcronet.sh ${{ matrix.triple }}
- uses: actions/upload-artifact@v6
with:
name: libcronet-${{ matrix.triple }}
path: cronet/${{ matrix.triple }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
target
/target
/cronet
/.cronet-build
2 changes: 1 addition & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ padding_threshold = 500
| --------------------- | ------- | -------- | ----------- | ----------- |
| `listen` | string | yes | — | Local listen address, e.g. `"127.0.0.1:8080"`. |
| `remote` | string | yes | — | Server URL including the hidden path. |
| `address` | string | no | host of `remote` | Connection address override. TLS SNI and `Host` still use the `remote` domain. |
| `address` | string | no | system DNS | Connection address override. TLS SNI and `Host` still use the `remote` domain. |
| `public_key` | string | yes | — | Server's ML-KEM-768 encapsulation key; required for the tunnel handshake. |
| `proxy_auth` | table | no | — | Local proxy authentication (§2.2). |
| `max_connections` | integer | no | `1024` | Concurrent local connections; excess are refused. |
Expand Down
Loading
Loading