Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(arm): support windows arm #595

Merged
merged 4 commits into from
Sep 19, 2024
Merged
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
19 changes: 16 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
IMAGE_NAME: "clash-rs"


# Arm builder https://github.blog/changelog/2024-09-03-github-actions-arm64-linux-and-windows-runners-are-now-generally-available/
jobs:
compile:
name: ${{ matrix.release-name || matrix.target || 'Unknown' }}
Expand Down Expand Up @@ -114,6 +115,11 @@ jobs:
cross: false
postfix: ".exe"
extra-args: "--all-features"
- os: windows-latest
target: aarch64-pc-windows-msvc
cross: false
postfix: ".exe"
extra-args: --features "shadowsocks tuic"
# Windows static-crt
- os: windows-latest
target: x86_64-pc-windows-msvc
Expand All @@ -129,6 +135,13 @@ jobs:
postfix: ".exe"
extra-args: "--all-features"
rustflags: "-Ctarget-feature=+crt-static --cfg tokio_unstable"
- os: windows-latest
target: aarch64-pc-windows-msvc
release-name: aarch64-pc-windows-msvc-static-crt
cross: false
postfix: ".exe"
extra-args: --features "shadowsocks tuic"
rustflags: "-Ctarget-feature=+crt-static --cfg tokio_unstable"
# MacOSX
- os: macos-12
target: x86_64-apple-darwin
Expand Down Expand Up @@ -195,7 +208,7 @@ jobs:
env:
RUSTFLAGS: ${{ matrix.rustflags || '--cfg tokio_unstable' }}

- name: Cargo test
- name: Cargo test (docker test on linux)
uses: clechasseur/rs-cargo@v2
if: startsWith(matrix.os, 'ubuntu')
with:
Expand All @@ -206,9 +219,9 @@ jobs:
CROSS_CONTAINER_OPTS: "--network host"
RUSTFLAGS: ${{ matrix.rustflags || '--cfg tokio_unstable' }}

- name: Cargo test (no docker test)
- name: Cargo test (no docker test on windows-non-arm and macos)
uses: clechasseur/rs-cargo@v2
if: ${{ !startsWith(matrix.os, 'ubuntu') }}
if: ${{ !startsWith(matrix.os, 'ubuntu') && matrix.target != 'aarch64-pc-windows-msvc' }}
with:
use-cross: ${{ matrix.cross }}
command: test
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions clash_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ shadowsocks = ["dep:shadowsocks"]
tuic = ["dep:tuic", "dep:tuic-quinn", "dep:quinn", "dep:register-count"]
tracing = []
bench = ["dep:criterion"]
onion = ["arti-client/onion-service-client"]
onion = ["dep:arti-client", "dep:tor-rtcompat", "arti-client/onion-service-client"]

[dependencies]
# Async
Expand Down Expand Up @@ -117,8 +117,8 @@ maxminddb = "0.24"
public-suffix = "0.1"
murmur3 = "0.5"

arti-client = { version = "0.22", default-features = false, features = ["tokio", "rustls", "static-sqlite"] }
tor-rtcompat = { version = "0.22", default-features = false }
arti-client = { version = "0.22", optional = true, default-features = false, features = ["tokio", "rustls", "static-sqlite"] }
tor-rtcompat = { version = "0.22", optional = true, default-features = false }

# tuic
tuic = { tag = "v1.2.0", optional = true, git = "https://github.com/Itsusinn/tuic.git" }
Expand Down
5 changes: 4 additions & 1 deletion clash_lib/src/app/outbound/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
OutboundProxyProviderDef, PROXY_DIRECT, PROXY_GLOBAL, PROXY_REJECT,
},
proxy::{
fallback, loadbalance, selector, socks, tor, trojan,
fallback, loadbalance, selector, socks, trojan,
utils::{DirectConnector, ProxyConnector},
vmess, wg, OutboundType,
},
Expand All @@ -44,6 +44,8 @@ use super::utils::proxy_groups_dag_sort;

#[cfg(feature = "shadowsocks")]
use crate::proxy::shadowsocks;
#[cfg(feature = "onion")]
use crate::proxy::tor;
#[cfg(feature = "tuic")]
use crate::proxy::tuic;

Expand Down Expand Up @@ -275,6 +277,7 @@ impl OutboundManager {
});
}

#[cfg(feature = "onion")]
OutboundProxyProtocol::Tor(tor) => {
handlers.insert(tor.name.clone(), {
let h: tor::Handler = tor.try_into()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ use crate::{
},
common::errors::map_io_error,
config::internal::proxy::OutboundProxyProtocol,
proxy::{direct, reject, socks, tor, trojan, vmess, wg, AnyOutboundHandler},
proxy::{direct, reject, socks, trojan, vmess, wg, AnyOutboundHandler},
Error,
};

#[cfg(feature = "shadowsocks")]
use crate::proxy::shadowsocks;
#[cfg(feature = "onion")]
use crate::proxy::tor;
#[cfg(feature = "tuic")]
use crate::proxy::tuic;

Expand Down Expand Up @@ -139,6 +141,7 @@ impl ProxySetProvider {
let h: wg::Handler = wg.try_into()?;
Ok(Arc::new(h) as _)
}
#[cfg(feature = "onion")]
OutboundProxyProtocol::Tor(tor) => {
let h: tor::Handler = tor.try_into()?;
Ok(Arc::new(h) as _)
Expand Down
3 changes: 3 additions & 0 deletions clash_lib/src/config/internal/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub enum OutboundProxyProtocol {
Vmess(OutboundVmess),
#[serde(rename = "wireguard")]
Wireguard(OutboundWireguard),
#[cfg(feature = "onion")]
#[serde(rename = "tor")]
Tor(OutboundTor),
#[cfg(feature = "tuic")]
Expand All @@ -82,6 +83,7 @@ impl OutboundProxyProtocol {
OutboundProxyProtocol::Wireguard(wireguard) => {
&wireguard.common_opts.name
}
#[cfg(feature = "onion")]
OutboundProxyProtocol::Tor(tor) => &tor.name,
#[cfg(feature = "tuic")]
OutboundProxyProtocol::Tuic(tuic) => &tuic.common_opts.name,
Expand Down Expand Up @@ -116,6 +118,7 @@ impl Display for OutboundProxyProtocol {
OutboundProxyProtocol::Trojan(_) => write!(f, "Trojan"),
OutboundProxyProtocol::Vmess(_) => write!(f, "Vmess"),
OutboundProxyProtocol::Wireguard(_) => write!(f, "Wireguard"),
#[cfg(feature = "onion")]
OutboundProxyProtocol::Tor(_) => write!(f, "Tor"),
#[cfg(feature = "tuic")]
OutboundProxyProtocol::Tuic(_) => write!(f, "Tuic"),
Expand Down
1 change: 1 addition & 0 deletions clash_lib/src/proxy/converters/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg(feature = "shadowsocks")]
pub mod shadowsocks;
pub mod socks5;
#[cfg(feature = "onion")]
pub mod tor;
pub mod trojan;
#[cfg(feature = "tuic")]
Expand Down
1 change: 1 addition & 0 deletions clash_lib/src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub mod converters;
#[cfg(feature = "shadowsocks")]
pub mod shadowsocks;
pub mod socks;
#[cfg(feature = "onion")]
pub mod tor;
pub mod trojan;
#[cfg(feature = "tuic")]
Expand Down