mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-10-23 16:50:32 +00:00
fix(websocket): throttle the invalid websocket-port warning
check_ws runs on every rendezvous reconnect, online query and relay connect, so an invalid websocket-port logged a warning each time. Keep one line a minute with a count of the rest. Also import the key with the other config keys instead of in the function body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
34846eef9f
commit
b3bf7b76e2
1 file changed
+9
-3
+9
-3
@@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
config::{
|
||||
keys::OPTION_RELAY_SERVER, use_ws, Config, Socks5Server, RELAY_PORT, RENDEZVOUS_PORT,
|
||||
keys::{OPTION_RELAY_SERVER, OPTION_WEBSOCKET_PORT},
|
||||
use_ws, Config, Socks5Server, RELAY_PORT, RENDEZVOUS_PORT,
|
||||
},
|
||||
protobuf::Message,
|
||||
socket_client::split_host_port,
|
||||
@@ -535,7 +536,6 @@ pub fn check_ws(endpoint: &str) -> String {
|
||||
/// when it cannot listen on the scheme's default port. Any other host, such as a peer's server or
|
||||
/// a relay on another machine, keeps the default port. IP endpoints never get here.
|
||||
fn websocket_port(host: &str, own_servers: &[&str]) -> Option<u16> {
|
||||
use crate::config::keys::OPTION_WEBSOCKET_PORT;
|
||||
let port = Config::get_option(OPTION_WEBSOCKET_PORT);
|
||||
if port.is_empty() {
|
||||
return None;
|
||||
@@ -552,7 +552,13 @@ fn websocket_port(host: &str, own_servers: &[&str]) -> Option<u16> {
|
||||
match port.parse::<u16>() {
|
||||
Ok(port) if port > 0 => Some(port),
|
||||
_ => {
|
||||
log::warn!("Ignoring invalid {}: {}", OPTION_WEBSOCKET_PORT, port);
|
||||
crate::throttled_log!(
|
||||
Duration::from_secs(60),
|
||||
warn,
|
||||
"Ignoring invalid {}: {}",
|
||||
OPTION_WEBSOCKET_PORT,
|
||||
port
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user