mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 08:50:40 +01:00
auth: bypass ambient proxies by default; UU_USE_PROXY=1 opts in (#52)
A local HTTP/SOCKS proxy that intercepts TLS caused login to fail with "tls handshake eof". Build all cloud API clients with no_proxy() unless UU_USE_PROXY is explicitly truthy, so direct connections are the default and environments that genuinely need a proxy can still enable it.
This commit is contained in:
1 parent
70cb5ad57e
commit
6416f75b7f
5 files changed
+26
-2
No files matched your search
@@ -116,6 +116,7 @@ viewer does not reconnect them automatically.
|
||||
| `UU_FFMPEG_ROOT` | FFmpeg prefix (`bin/ffmpeg`, libs in `lib/x86_64-linux-gnu`) |
|
||||
| `UU_AUDIO=0`, `UU_AUDIO_SOURCE` | disable sound / choose the Pulse source (default `@DEFAULT_MONITOR@`) |
|
||||
| `UU_LOGIN_WINDOW=0` | don't auto-open the login window |
|
||||
| `UU_USE_PROXY=1` | honor HTTP/SOCKS proxy env vars; cloud API clients bypass env proxies by default |
|
||||
| `UU_REMOTE_ASSIST=0`, `UU_ASSIST_ALLOW=1`, `UU_ASSIST_UI=tty`, `UU_ASSIST_DEBUG=1` | disable assistance / allow at start / terminal UI for `assist` / include the server's short error message in assist errors |
|
||||
|
||||
Token has no expiry field; API code 1120 (HTTP 422) means invalid/expired → re-login. The config is re-read
|
||||
|
||||
@@ -288,6 +288,7 @@ Common environment variables:
|
||||
| `UU_ASSIST_ALLOW=1` | Allow remote assistance at start (overrides the saved switch) |
|
||||
| `UU_LOGIN_WINDOW=0` | Do not open the login window automatically when credentials are missing |
|
||||
| `UU_PORT_MAPPING=0` | Disable port mapping (the official host's controlled-side switch) |
|
||||
| `UU_USE_PROXY=1` | Honor HTTP/SOCKS proxy environment variables; by default proxies are ignored and NetEase servers are reached directly |
|
||||
|
||||
Host settings such as "lock after remote session" and "mute host" are stored in
|
||||
`~/.config/uuremote/host_settings.json`.
|
||||
|
||||
@@ -258,6 +258,7 @@ systemctl --user restart uuremote-native.service
|
||||
| `UU_REMOTE_ASSIST=0` | 关闭远程协助(未登录时也不再以访客身份提供协助) |
|
||||
| `UU_ASSIST_ALLOW=1` | 启动时就允许他人远程协助(覆盖窗口里保存的开关状态) |
|
||||
| `UU_PORT_MAPPING=0` | 关闭端口映射(对应官方被控端的开关) |
|
||||
| `UU_USE_PROXY=1` | 使用环境变量里的 HTTP/SOCKS 代理;默认忽略代理、直连网易服务器 |
|
||||
|
||||
「远程结束后自动锁屏」「静音运行」等设置保存在 `~/.config/uuremote/host_settings.json`。
|
||||
|
||||
|
||||
+22
-1
@@ -121,9 +121,24 @@ fn redact_urls(text: &str) -> String {
|
||||
out
|
||||
}
|
||||
|
||||
/// Cloud API clients ignore ambient HTTP/SOCKS proxy settings by default: a local
|
||||
/// proxy that intercepts TLS breaks login and signaling. `UU_USE_PROXY=1` opts back
|
||||
/// into reqwest's standard proxy environment handling.
|
||||
pub fn http_client_builder() -> reqwest::ClientBuilder {
|
||||
let builder = reqwest::Client::builder();
|
||||
if std::env::var("UU_USE_PROXY").ok().as_deref().is_some_and(proxy_requested) {
|
||||
builder
|
||||
} else {
|
||||
builder.no_proxy()
|
||||
}
|
||||
}
|
||||
fn proxy_requested(value: &str) -> bool {
|
||||
matches!(value.trim().to_ascii_lowercase().as_str(), "1" | "true" | "yes" | "on")
|
||||
}
|
||||
|
||||
impl UUAuthClient {
|
||||
pub fn new(creds: Credentials) -> Self {
|
||||
let http = reqwest::Client::builder()
|
||||
let http = http_client_builder()
|
||||
.timeout(std::time::Duration::from_secs(12))
|
||||
.build()
|
||||
.unwrap();
|
||||
@@ -346,4 +361,10 @@ mod guest_tests {
|
||||
let text = super::redact_urls("proxy http://user:[email protected]:3128 failed for (https://api.example/p?token=abc)");
|
||||
assert_eq!(text, "proxy http://proxy.example:3128 failed for (https://api.example/p)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn proxy_opt_in_accepts_only_explicit_truthy_values() {
|
||||
for value in ["1", "true", "TRUE", " yes ", "On"] { assert!(super::proxy_requested(value)); }
|
||||
for value in ["", "0", "false", "no", "off", "2"] { assert!(!super::proxy_requested(value)); }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -93,7 +93,7 @@ pub struct Api {
|
||||
}
|
||||
impl Api {
|
||||
pub fn new(signer: UUAuthClient, base: &str) -> Self {
|
||||
Self { signer, base: base.trim_end_matches('/').into(), http: reqwest::Client::builder().timeout(Duration::from_secs(12)).build().unwrap() }
|
||||
Self { signer, base: base.trim_end_matches('/').into(), http: crate::auth::http_client_builder().timeout(Duration::from_secs(12)).build().unwrap() }
|
||||
}
|
||||
pub async fn join_share(&self, connect_id: &str, connect_code: &str) -> Result<JoinData, Error> {
|
||||
if connect_id.trim().is_empty() || connect_code.trim().is_empty() || connect_id.chars().chain(connect_code.chars()).any(char::is_control) { return Err(Error::InvalidAssist); }
|
||||
|
||||
Reference in new issue
Block a user