mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-29 16:11:01 +03:00
copilot review: format IPv6 tcp proxy log targets correctly
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -1165,11 +1165,10 @@ fn tcp_proxy_log_target(url: &str) -> String {
|
||||
.ok()
|
||||
.map(|parsed| {
|
||||
let mut redacted = format!("{}://", parsed.scheme());
|
||||
if let Some(host) = parsed.host_str() {
|
||||
redacted.push_str(host);
|
||||
} else {
|
||||
let Some(host) = parsed.host() else {
|
||||
return "<invalid-url>".to_owned();
|
||||
}
|
||||
};
|
||||
redacted.push_str(&host.to_string());
|
||||
if let Some(port) = parsed.port() {
|
||||
redacted.push(':');
|
||||
redacted.push_str(&port.to_string());
|
||||
@@ -2930,6 +2929,14 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tcp_proxy_log_target_brackets_ipv6_host_with_port() {
|
||||
assert_eq!(
|
||||
tcp_proxy_log_target("https://[2001:db8::1]:21114/api/heartbeat?token=secret"),
|
||||
"https://[2001:db8::1]:21114/api/heartbeat"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_http_proxy_response_to_json() {
|
||||
let mut resp = HttpProxyResponse {
|
||||
|
||||
Reference in New Issue
Block a user