From 03f5442ddc08e727a0b72e00451e197a56a1072c Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:52:11 +0800 Subject: [PATCH] support windows 7 building --- .github/workflows/check.yml | 7 ++- .github/workflows/mips-unknown-linux-gnu.yml | 2 +- .github/workflows/release-win7.yml | 52 ++++++++++++++++++++ .github/workflows/release.yml | 2 +- Cargo.toml | 2 +- src/traffic_status.rs | 11 ++--- 6 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/release-win7.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index c468174..2722d0e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,7 +1,12 @@ name: Check on: - [push, pull_request] + push: + branches: + - '**' + pull_request: + branches: + - '**' env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/mips-unknown-linux-gnu.yml b/.github/workflows/mips-unknown-linux-gnu.yml index 6527043..d2a2fef 100644 --- a/.github/workflows/mips-unknown-linux-gnu.yml +++ b/.github/workflows/mips-unknown-linux-gnu.yml @@ -2,7 +2,7 @@ name: Build mips-unknown-linux-gnu Releases on: push: tags: - - "*" + - "v*.*.*" env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml new file mode 100644 index 0000000..072d73b --- /dev/null +++ b/.github/workflows/release-win7.yml @@ -0,0 +1,52 @@ +name: Build Releases +on: + push: + tags: + - "w*.*.*" +env: + CARGO_TERM_COLOR: always + RUST_VERSION: "1.75" + +jobs: + build: + strategy: + fail-fast: false + matrix: + target: + - x86_64-pc-windows-msvc + - i686-pc-windows-msvc + + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_VERSION }} + targets: ${{ matrix.target }} + + - name: Prepare + shell: bash + run: | + cargo install cbindgen + mkdir release + rustup target add ${{ matrix.target }} + + - name: Build + if: ${{ !cancelled() }} + shell: bash + run: | + cargo build --all-features --release --target ${{ matrix.target }} + cbindgen -c cbindgen.toml -l C --cpp-compat -o ./overtls.h + 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 }}-win7.zip + + - name: Upload + if: ${{ !cancelled() }} + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: release/* + + - name: Abort on error + if: ${{ failure() }} + run: echo "Some of jobs failed" && false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9423a53..63630b8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Build Releases on: push: tags: - - "*" + - "v*.*.*" env: CARGO_TERM_COLOR: always diff --git a/Cargo.toml b/Cargo.toml index e06661b..85070e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ license = "MIT" description = "A simple proxy tunnel, minimalist tool for bypassing the GFW." repository = "https://github.com/ShadowsocksR-Live/overtls" readme = "readme.md" -rust-version = "1.80" [lib] crate-type = ["staticlib", "cdylib", "lib"] @@ -31,6 +30,7 @@ futures-util = { version = "0.3", default-features = false, features = [ hickory-proto = "0.24" http = "1" httparse = "1" +lazy_static = "1" log = { version = "0.4", features = ["std"] } moka = { version = "0.12", default-features = false, features = ["future"] } reqwest = { version = "0.12", default-features = false, features = [ diff --git a/src/traffic_status.rs b/src/traffic_status.rs index 21453ba..68c8374 100644 --- a/src/traffic_status.rs +++ b/src/traffic_status.rs @@ -1,8 +1,5 @@ use crate::error::{Error, Result}; -use std::{ - os::raw::c_void, - sync::{LazyLock, Mutex}, -}; +use std::{os::raw::c_void, sync::Mutex}; /// # Safety /// @@ -47,8 +44,10 @@ unsafe impl Sync for TrafficStatusCallback {} static TRAFFIC_STATUS_CALLBACK: Mutex> = Mutex::new(None); static SEND_INTERVAL_SECS: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(1); -static TRAFFIC_STATUS: LazyLock> = LazyLock::new(|| Mutex::new(TrafficStatus::default())); -static TIME_STAMP: LazyLock> = LazyLock::new(|| Mutex::new(std::time::Instant::now())); +lazy_static::lazy_static! { + static ref TRAFFIC_STATUS: Mutex = Mutex::new(TrafficStatus::default()); + static ref TIME_STAMP: Mutex = Mutex::new(std::time::Instant::now()); +} pub(crate) fn traffic_status_update(delta_tx: usize, delta_rx: usize) -> Result<()> { {