mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-13 18:41:28 +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()
|
.ok()
|
||||||
.map(|parsed| {
|
.map(|parsed| {
|
||||||
let mut redacted = format!("{}://", parsed.scheme());
|
let mut redacted = format!("{}://", parsed.scheme());
|
||||||
if let Some(host) = parsed.host_str() {
|
let Some(host) = parsed.host() else {
|
||||||
redacted.push_str(host);
|
|
||||||
} else {
|
|
||||||
return "<invalid-url>".to_owned();
|
return "<invalid-url>".to_owned();
|
||||||
}
|
};
|
||||||
|
redacted.push_str(&host.to_string());
|
||||||
if let Some(port) = parsed.port() {
|
if let Some(port) = parsed.port() {
|
||||||
redacted.push(':');
|
redacted.push(':');
|
||||||
redacted.push_str(&port.to_string());
|
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]
|
#[test]
|
||||||
fn test_http_proxy_response_to_json() {
|
fn test_http_proxy_response_to_json() {
|
||||||
let mut resp = HttpProxyResponse {
|
let mut resp = HttpProxyResponse {
|
||||||
|
|||||||
Reference in New Issue
Block a user