Skip to content

Commit 79fa281

Browse files
committed
2026-08-27 15:39:29 commit
1 parent 05ea9ca commit 79fa281

18 files changed

Lines changed: 165 additions & 82 deletions

File tree

client_cli/Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client_cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "free-proxy"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
license = "MIT OR Apache-2.0"
55
edition = "2021"
66
authors = ["ZEROLINGG <bcsz8833221@gmail.com>"]

client_tauri/src-tauri/Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client_tauri/src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "free-proxy",
4-
"version": "0.2.3",
4+
"version": "0.2.4",
55
"identifier": "com.zz.freeproxy",
66
"build": {
77
"beforeDevCommand": "pnpm dev",

lib/Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ipnetwork = { version = "0.21.1", optional = true }
6464
dirs = { version = "6", optional = true }
6565
rand = { version = "0.8", optional = true }
6666
machine-uid = { version = "0.6.0", optional = true }
67-
tracing = { version = "0.1", optional = true }
67+
#tracing = { version = "0.1", optional = true }
6868

6969
postcard = { version = "1.1", features = ["alloc"] }
7070

@@ -74,7 +74,7 @@ postcard = { version = "1.1", features = ["alloc"] }
7474
default = ["client"]
7575

7676
# 本地客户端:tokio 运行时 + HTTP 客户端 + MITM TLS
77-
client = ["dep:tokio", "dep:reqwest", "dep:futures-util", "dep:async-stream", "dep:rustls", "dep:tokio-rustls", "dep:rcgen", "dep:moka", "dep:time", "dep:ipnetwork", "dep:reqwest-websocket", "dep:dirs", "dep:rand", "dep:machine-uid", "dep:tracing"]
77+
client = ["dep:tokio", "dep:reqwest", "dep:futures-util", "dep:async-stream", "dep:rustls", "dep:tokio-rustls", "dep:rcgen", "dep:moka", "dep:time", "dep:ipnetwork", "dep:reqwest-websocket", "dep:dirs", "dep:rand", "dep:machine-uid"]
7878

7979
# 服务端 (wasm) 构建:纯逻辑,无 tokio
8080
server = []

lib/src/proxy/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl Proxy {
246246
let (socket, addr) = match listener.accept().await {
247247
Ok(v) => v,
248248
Err(e) => {
249-
tracing::error!("[Client:error] accept error: {e}");
249+
eprintln!("[Client:error] accept error: {e}");
250250
break;
251251
}
252252
};
@@ -255,9 +255,9 @@ impl Proxy {
255255
if let Err(e) = handle_connection(socket, shared).await {
256256
if is_benign_disconnect(&e) {
257257
#[cfg(debug_assertions)]
258-
tracing::debug!("[Client:error] connection {addr}: {e} (benign disconnect)");
258+
eprintln!("[Client:error] connection {addr}: {e} (benign disconnect)");
259259
} else {
260-
tracing::error!("[Client:error] connection {addr}: {:.1024?}...", format!("{e:#?}"));
260+
eprintln!("[Client:error] connection {addr}: {:.1024?}...", format!("{e:#?}"));
261261
}
262262
}
263263
});

lib/src/proxy/relay.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,19 @@ where
200200
// ---------- 请求体范围判定 ----------
201201
let extent = body_extent(&header.headers)?;
202202

203-
tracing::debug!(
204-
"[Client:debug] {:<7} {:<15.30} {:<15.30} {:?}",
205-
header.method,
206-
header
207-
.headers
208-
.iter()
209-
.find(|(k, _)| k.eq_ignore_ascii_case("HOST"))
210-
.map(|(_, v)| v)
211-
.unwrap_or(&"unknown".to_string()),
212-
header.path,
213-
extent
214-
);
203+
// println!(
204+
// "[Client:debug] {:<7} {:<15.30} {:<15.30} {:?} {:.512?}",
205+
// header.method,
206+
// header
207+
// .headers
208+
// .iter()
209+
// .find(|(k, _)| k.eq_ignore_ascii_case("HOST"))
210+
// .map(|(_, v)| v)
211+
// .unwrap_or(&"unknown".to_string()),
212+
// header.path,
213+
// extent,
214+
// format!("{:?}",header.headers)
215+
// );
215216

216217
// ---------- WebSocket 升级请求:转入 WS 隧道,连接不再复用 ----------
217218
if header.is_websocket_upgrade() {
@@ -330,15 +331,15 @@ where
330331
Ok(Ok(Err(e))) => return Err(anyhow::Error::new(e).context("worker request failed")),
331332
Ok(Err(e)) => return Err(anyhow::Error::new(e).context("worker task panicked")),
332333
Err(_) => {
333-
tracing::warn!("proxy: worker response idle timeout");
334+
eprintln!("proxy: worker response idle timeout");
334335
write_502(stream).await?;
335336
return Ok(false);
336337
}
337338
},
338339
};
339340

340341
if !resp.status().is_success() {
341-
tracing::error!(
342+
eprintln!(
342343
"worker request error: {}, body: {:.1024}...",
343344
resp.status(),
344345
resp.text().await.unwrap_or_default()
@@ -386,7 +387,7 @@ where
386387
let chunk = match chunk {
387388
Ok(c) => c,
388389
Err(_) => {
389-
tracing::debug!("[Client:debug] frame idle timeout (no data for {:?})", FRAME_IDLE_TIMEOUT);
390+
eprintln!("[Client:debug] frame idle timeout (no data for {:?})", FRAME_IDLE_TIMEOUT);
390391
if !wrote {
391392
write_502(stream).await?;
392393
}
@@ -397,11 +398,11 @@ where
397398
let bytes = match chunk {
398399
Some(Ok(b)) => b,
399400
Some(Err(e)) => {
400-
tracing::warn!("[Client:debug] frame read error: {e}");
401+
eprintln!("[Client:debug] frame read error: {e}");
401402
return Ok(false);
402403
}
403404
None => {
404-
tracing::warn!("[Client:debug] stream ended without EOS (truncated)");
405+
eprintln!("[Client:debug] stream ended without EOS (truncated)");
405406
if !wrote {
406407
write_502(stream).await?;
407408
}
@@ -432,7 +433,7 @@ where
432433
return Ok(true);
433434
}
434435
Err(e) => {
435-
tracing::warn!("[Client:debug] frame protocol error: {e}");
436+
eprintln!("[Client:debug] frame protocol error: {e}");
436437
if !wrote {
437438
write_502(stream).await?;
438439
}

lib/src/proxy/tls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl TlsManager {
7373
Err(e) => {
7474
// 解密失败(设备 uid 变化)或文件损坏:自动重建 CA。
7575
// CA 证书随之变化,用户需重新导入 ca.crt.pem 到系统信任区。
76-
tracing::warn!("CA key load failed ({e:#}); regenerating CA");
76+
eprintln!("CA key load failed ({e:#}); regenerating CA");
7777
remove_ca_files(&cert_path, &key_path, ca_dir);
7878
let (cert, key, cert_pem) =
7979
generate_and_persist_ca(&cert_path, &key_path, key_secret)?;

lib/src/proxy/ws.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ where
9191
{
9292
Ok(u) => u,
9393
Err(e) => {
94-
tracing::error!("ws: tunnel handshake failed: {e:#}");
94+
eprintln!("ws: tunnel handshake failed: {e:#}");
9595
let _ = stream
9696
.write_all(b"HTTP/1.1 502 Bad Gateway\r\nContent-Length: 0\r\n\r\n")
9797
.await;
@@ -101,7 +101,7 @@ where
101101
let mut ws = match upgraded.into_websocket().await {
102102
Ok(w) => w,
103103
Err(e) => {
104-
tracing::error!("ws: tunnel upgrade failed: {e:#}");
104+
eprintln!("ws: tunnel upgrade failed: {e:#}");
105105
let _ = stream
106106
.write_all(b"HTTP/1.1 502 Bad Gateway\r\nContent-Length: 0\r\n\r\n")
107107
.await;
@@ -244,7 +244,7 @@ where
244244
}
245245
// 服务端明确抛出的内部错误
246246
WsTunnelMsg::Error(err_msg) => {
247-
tracing::warn!("ws: received explicit error from worker: {err_msg}");
247+
eprintln!("ws: received explicit error from worker: {err_msg}");
248248
let mut w = wr_download.lock().await;
249249

250250
if has_upgraded {
@@ -271,7 +271,7 @@ where
271271
}
272272
Ok(_) => {}
273273
Err(e) => {
274-
tracing::error!("proxy ws: tunnel read error: {e}");
274+
eprintln!("proxy ws: tunnel read error: {e}");
275275
return Err(e).context("ws tunnel read failed");
276276
}
277277
}
@@ -284,12 +284,12 @@ where
284284
tokio::select! {
285285
res = upload => {
286286
if let Err(e) = res {
287-
tracing::warn!("ws tunnel upload terminated with error: {e:#}");
287+
eprintln!("ws tunnel upload terminated with error: {e:#}");
288288
}
289289
}
290290
res = download => {
291291
if let Err(e) = res {
292-
tracing::warn!("ws tunnel download terminated with error: {e:#}");
292+
eprintln!("ws tunnel download terminated with error: {e:#}");
293293
}
294294
}
295295
}

0 commit comments

Comments
 (0)