From 63961624b68377f73d3b568d9f4f4651ceb0015d Mon Sep 17 00:00:00 2001 From: AB Date: Sat, 29 Nov 2025 01:47:15 +0200 Subject: [PATCH] Bump libs. added CI --- .github/workflows/ci.yml | 44 +++++++++++ .github/workflows/release.yml | 134 ++++++++++++++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 8 +- src/xray_runner.rs | 20 ----- 5 files changed, 184 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b0ea3dd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: CI + +on: + push: + branches: [main, master, develop] + pull_request: + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + test: + name: Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - run: cargo test --locked + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all-targets --all-features -- -D warnings + + fmt: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - run: cargo fmt --all -- --check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cff3252 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,134 @@ +name: Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: write + +jobs: + build: + name: Build ${{ matrix.target }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + use_cross: false + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + use_cross: false + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + use_cross: true + - os: macos-latest + target: x86_64-apple-darwin + use_cross: false + - os: macos-latest + target: aarch64-apple-darwin + use_cross: false + - os: windows-latest + target: x86_64-pc-windows-msvc + use_cross: false + + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Install musl tools + if: matrix.target == 'x86_64-unknown-linux-musl' + run: sudo apt-get update && sudo apt-get install -y musl-tools + + - name: Install cross + if: matrix.use_cross + run: cargo install cross --git https://github.com/cross-rs/cross + + - uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + + - name: Build + run: | + if [ "${{ matrix.use_cross }}" == "true" ]; then + cross build --release --locked --target ${{ matrix.target }} + else + cargo build --release --locked --target ${{ matrix.target }} + fi + shell: bash + + - name: Get binary name + id: binary + run: | + name=$(grep '^name = ' Cargo.toml | head -1 | cut -d'"' -f2) + if [ "${{ runner.os }}" == "Windows" ]; then + echo "name=${name}.exe" >> $GITHUB_OUTPUT + else + echo "name=${name}" >> $GITHUB_OUTPUT + fi + shell: bash + + - name: Strip binary + if: runner.os != 'Windows' + run: strip target/${{ matrix.target }}/release/${{ steps.binary.outputs.name }} + + - name: Package + id: package + run: | + name=$(grep '^name = ' Cargo.toml | head -1 | cut -d'"' -f2) + target="${{ matrix.target }}" + binary="${{ steps.binary.outputs.name }}" + + cd target/${target}/release + + if [ "${{ runner.os }}" == "Windows" ]; then + archive="${name}-${target}.zip" + 7z a ../../../${archive} ${binary} + echo "archive=${archive}" >> $GITHUB_OUTPUT + else + archive="${name}-${target}.tar.gz" + tar czf ../../../${archive} ${binary} + echo "archive=${archive}" >> $GITHUB_OUTPUT + fi + shell: bash + + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.target }} + path: ${{ steps.package.outputs.archive }} + + release: + name: Release + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Generate changelog + run: | + if [ -n "$(git tag --sort=-creatordate | head -n 2 | tail -n 1)" ]; then + prev_tag=$(git tag --sort=-creatordate | head -n 2 | tail -n 1) + git log ${prev_tag}..HEAD --pretty=format:"- %s" > CHANGELOG.md + else + echo "Initial release" > CHANGELOG.md + fi + + - uses: softprops/action-gh-release@v2 + with: + body_path: CHANGELOG.md + files: artifacts/**/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index 418bac1..dfb1c7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -609,7 +609,7 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "v2parser" -version = "0.3.1" +version = "0.4.0" dependencies = [ "base64", "clap", diff --git a/Cargo.toml b/Cargo.toml index 340146d..7a722e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "v2parser" -version = "0.3.1" -edition = "2021" +version = "0.4.0" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,7 +15,9 @@ serde = { version = "1.0.189", features = ["derive"] } serde_json = "1.0.107" urlencoding = "2" tokio = { version = "1.0", features = ["full"] } +tempfile = "3" + +[target.'cfg(unix)'.dependencies] signal-hook = "0.3" signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] } -tempfile = "3" futures = "0.3" diff --git a/src/xray_runner.rs b/src/xray_runner.rs index 46bd095..552ceb9 100644 --- a/src/xray_runner.rs +++ b/src/xray_runner.rs @@ -64,26 +64,6 @@ impl XrayRunner { Ok(()) } - - pub fn is_running(&mut self) -> bool { - if let Some(process) = &mut self.process { - match process.try_wait() { - Ok(Some(_)) => { - // Process has exited - self.process = None; - false - } - Ok(None) => true, // Process is still running - Err(_) => { - // Error checking status, assume not running - self.process = None; - false - } - } - } else { - false - } - } } impl Drop for XrayRunner {