Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
ibigbug committed Sep 23, 2024
1 parent 819a7af commit a078e31
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 90 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:
PACKAGE: "clash"
REGISTRY: "ghcr.io"
IMAGE_NAME: "clash-rs"
RUST_LOG: "clash=TRACE"


# Arm builder https://github.blog/changelog/2024-09-03-github-actions-arm64-linux-and-windows-runners-are-now-generally-available/
Expand Down Expand Up @@ -229,26 +230,15 @@ jobs:
command: clippy
args: --all --target ${{ matrix.target }} ${{ matrix.extra-args }} -- -D warnings

- name: Cargo test (docker test on linux)
- name: Cargo test (no arm windows)
uses: clechasseur/rs-cargo@v2
if: startsWith(matrix.os, 'ubuntu')
if: ${{ matrix.target != 'aarch64-pc-windows-msvc' }}
with:
use-cross: ${{ matrix.cross }}
command: test
args: --all --target ${{ matrix.target }} ${{ matrix.extra-args }}
env:
CROSS_CONTAINER_OPTS: "--network host"
CLASH_DOCKER_TEST: "true"
RUSTFLAGS: ${{ matrix.rustflags || '--cfg tokio_unstable' }}

- name: Cargo test (no docker test on windows-non-arm and macos)
uses: clechasseur/rs-cargo@v2
if: ${{ !startsWith(matrix.os, 'ubuntu') && matrix.target != 'aarch64-pc-windows-msvc' }}
with:
use-cross: ${{ matrix.cross }}
command: test
args: --all --target ${{ matrix.target }} ${{ matrix.extra-args }}
env:
RUSTFLAGS: ${{ matrix.rustflags || '--cfg tokio_unstable' }}

- name: Cargo build
Expand Down Expand Up @@ -306,7 +296,9 @@ jobs:
# Deleted latest tag and push it
git tag -d latest || true
git push origin :refs/tags/latest || true
# Deleted all drafts
# Create local tag
git tag latest
# Delete all drafts
gh release list | grep Draft | awk '{print $1 " \t"}' | while read -r line; do gh release delete -y "$line"; done
env:
GH_TOKEN: ${{ github.token }}
Expand Down
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pre-build = [

[build.env]
volumes = ["/var/run/docker.sock=/var/run/docker.sock"] # Docker in docker
passthrough = ["CLASH_GIT_REF", "CLASH_GIT_SHA", "RUSTFLAGS", "CLASH_DOCKER_TEST"]
passthrough = ["CLASH_GIT_REF", "CLASH_GIT_SHA", "RUSTFLAGS", "RUST_LOG"]

[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main"
Expand Down
3 changes: 2 additions & 1 deletion clash_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ mockall = "0.13.0"
tokio-test = "0.4.4"
axum-macros = "0.4.0"
bollard = "0.17"
serial_test = "3.1.1"
serial_test = "3.1"
env_logger = "0.11"

[build-dependencies]
prost-build = "0.13"
Expand Down
6 changes: 0 additions & 6 deletions clash_lib/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
fn main() -> std::io::Result<()> {
println!("cargo::rustc-check-cfg=cfg(docker_test)");
println!("cargo:rerun-if-env-changed=CLASH_DOCKER_TEST");
if let Some("1" | "true") = option_env!("CLASH_DOCKER_TEST") {
println!("cargo::rustc-cfg=docker_test");
}

println!("cargo:rerun-if-changed=src/common/geodata/geodata.proto");
prost_build::compile_protos(
&["src/common/geodata/geodata.proto"],
Expand Down
10 changes: 9 additions & 1 deletion clash_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,15 @@ async fn start_async(opts: Options) -> Result<(), Error> {
#[cfg(test)]
mod tests {
use crate::{shutdown, start, Config, Options};
use std::{thread, time::Duration};
use std::{sync::Once, thread, time::Duration};

static INIT: Once = Once::new();

pub fn initialize() {
INIT.call_once(|| {
env_logger::init();
});
}

#[test]
fn start_and_stop() {
Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl OutboundHandler for Handler {
}

#[cfg(feature = "shadowsocks")]
#[cfg(all(test, docker_test))]
#[cfg(all(test))]

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-musleabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / i686-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 202 in clash_lib/src/proxy/relay/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition
mod tests {

use tokio::sync::RwLock;
Expand Down
7 changes: 5 additions & 2 deletions clash_lib/src/proxy/shadowsocks/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,16 @@ where

let mut buf = ReadBuf::new(buf);

let rv = ready!(inner.poll_recv_from(cx, &mut buf));
let rv = ready!(inner.poll_recv(cx, &mut buf));
debug!("recv udp packet from remote ss server: {:?}", rv);

match rv {
Ok((n, src, ..)) => Poll::Ready(Some(UdpPacket {
data: buf.filled()[..n].to_vec(),
src_addr: src.into(),
src_addr: match src {
shadowsocks::relay::Address::SocketAddress(a) => a.into(),
_ => SocksAddr::any_ipv4(),
},
dst_addr: SocksAddr::any_ipv4(),
})),
Err(_) => Poll::Ready(None),
Expand Down
18 changes: 9 additions & 9 deletions clash_lib/src/proxy/shadowsocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,18 @@ impl OutboundHandler for Handler {
}
}

#[cfg(all(test, docker_test))]
#[cfg(all(test))]

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-musleabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / i686-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 291 in clash_lib/src/proxy/shadowsocks/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition
mod tests {

use super::super::utils::test_utils::{
consts::*, docker_runner::DockerTestRunner,
};
use crate::proxy::utils::test_utils::{
docker_runner::{DockerTestRunnerBuilder, MultiDockerTestRunner},
run_test_suites_and_cleanup, Suite,
use crate::{
proxy::utils::test_utils::{
docker_runner::{DockerTestRunnerBuilder, MultiDockerTestRunner},
run_test_suites_and_cleanup, Suite,
},
tests::initialize,
};

use super::*;
Expand All @@ -317,8 +320,8 @@ mod tests {

#[tokio::test]
#[serial_test::serial]
async fn test_ss() -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt().try_init();
async fn test_ss_plain() -> anyhow::Result<()> {
initialize();
let opts = HandlerOptions {
name: "test-ss".to_owned(),
common_opts: Default::default(),
Expand Down Expand Up @@ -466,9 +469,6 @@ mod tests {
#[serial_test::serial]
async fn test_ss_obfs_tls() -> anyhow::Result<()> {
if cfg!(target_arch = "x86_64") {
let _ = tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.try_init();
test_ss_obfs_inner(SimpleOBFSMode::Tls).await
} else {
eprintln!("test_ss_obfs_tls is ignored on non-x86_64 platform");
Expand Down
4 changes: 1 addition & 3 deletions clash_lib/src/proxy/socks/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl OutboundHandler for Handler {
}
}

#[cfg(all(test, docker_test))]
#[cfg(all(test))]

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-musleabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / i686-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 279 in clash_lib/src/proxy/socks/outbound/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition
mod tests {

use std::sync::Arc;
Expand Down Expand Up @@ -326,7 +326,6 @@ mod tests {
#[tokio::test]
#[serial_test::serial]
async fn test_socks5_no_auth() -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt().try_init();
let opts = HandlerOptions {
name: "test-socks5-no-auth".to_owned(),
common_opts: Default::default(),
Expand All @@ -352,7 +351,6 @@ mod tests {
async fn test_socks5_auth() -> anyhow::Result<()> {
use crate::proxy::DialWithConnector;

let _ = tracing_subscriber::fmt().try_init();
let opts = HandlerOptions {
name: "test-socks5-no-auth".to_owned(),
common_opts: Default::default(),
Expand Down
6 changes: 1 addition & 5 deletions clash_lib/src/proxy/trojan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl OutboundHandler for Handler {
}
}

#[cfg(all(test, docker_test))]
#[cfg(all(test))]

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-musleabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / i686-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 257 in clash_lib/src/proxy/trojan/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition
mod tests {

use std::collections::HashMap;
Expand Down Expand Up @@ -288,10 +288,6 @@ mod tests {
#[tokio::test]
#[serial_test::serial]
async fn test_trojan_ws() -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt()
// any additional configuration of the subscriber you might want here..
.try_init();

let span = tracing::info_span!("test_trojan_ws");
let _enter = span.enter();

Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
};

#[cfg(all(test, docker_test))]
#[cfg(all(test))]

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-musleabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / i686-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 6 in clash_lib/src/proxy/utils/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition
pub mod test_utils;

mod platform;
Expand Down
38 changes: 0 additions & 38 deletions clash_lib/src/proxy/utils/socket_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,41 +148,3 @@ pub async fn new_udp_socket(

UdpSocket::from_std(socket.into())
}

#[cfg(test)]
mod tests {
use std::{net::IpAddr, time::Duration};

use tokio::{net::TcpSocket, time::timeout};

#[tokio::test]
#[ignore = "not a real test"]
async fn test_connect_tcp() {
let mut futs = vec![];

for i in 0..100 {
futs.push(tokio::spawn(async move {
let now = std::time::Instant::now();
let socket = socket2::Socket::new(
socket2::Domain::IPV4,
socket2::Type::DGRAM,
None,
)
.unwrap();

timeout(
Duration::from_secs(10),
TcpSocket::from_std_stream(socket.into())
.connect(("1.1.1.1".parse::<IpAddr>().unwrap(), 443).into()),
)
.await
.unwrap()
.unwrap();

println!("fut {} took {:?}", i, now.elapsed().as_millis());
}));
}

futures::future::join_all(futs).await;
}
}
18 changes: 16 additions & 2 deletions clash_lib/src/proxy/utils/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ pub async fn ping_pong_test(
// server(127.0.0.1:port)

let sess = Session {
destination: ("127.0.0.1".to_owned(), port)
destination: (
if cfg!(target_os = "linux") {
"127.0.0.1".to_owned()
} else {
"host.docker.internal".to_owned()
},
port,
)
.try_into()
.unwrap_or_else(|_| panic!("")),
..Default::default()
Expand Down Expand Up @@ -144,7 +151,14 @@ pub async fn ping_pong_udp_test(
let src = ("127.0.0.1".to_owned(), 10005)
.try_into()
.unwrap_or_else(|_| panic!(""));
let dst: SocksAddr = ("127.0.0.1".to_owned(), port)
let dst: SocksAddr = (
if cfg!(target_os = "linux") {
"127.0.0.1".to_owned()
} else {
"host.docker.internal".to_owned()
},
port,
)
.try_into()
.unwrap_or_else(|_| panic!(""));

Expand Down
6 changes: 1 addition & 5 deletions clash_lib/src/proxy/vmess/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl OutboundHandler for Handler {
}
}

#[cfg(all(test, docker_test))]
#[cfg(all(test))]

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-musleabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / i686-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 289 in clash_lib/src/proxy/vmess/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition
mod tests {
use crate::proxy::utils::test_utils::{
config_helper::test_config_base_dir,
Expand Down Expand Up @@ -317,10 +317,6 @@ mod tests {
#[tokio::test]
#[serial_test::serial]
async fn test_vmess_ws() -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt()
// any additional configuration of the subscriber you might want here..
.try_init();

let span = tracing::info_span!("test_vmess_ws");
let _enter = span.enter();

Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/wg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl OutboundHandler for Handler {
}
}

#[cfg(all(test, docker_test))]
#[cfg(all(test))]

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / i686-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-musl

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-musleabihf

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-unknown-linux-gnu-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / armv7-unknown-linux-gnueabi-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / i686-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-pc-windows-msvc-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / x86_64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition

Check failure on line 320 in clash_lib/src/proxy/wg/mod.rs

View workflow job for this annotation

GitHub Actions / aarch64-apple-darwin-static-crt

unneeded sub `cfg` when there is only one condition
mod tests {

use crate::proxy::utils::{
Expand Down

0 comments on commit a078e31

Please sign in to comment.