mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-26 04:46:35 +08:00
fix: 补齐 ATX 控制器缺失接口并完成全项目 clippy -D warnings 修复
This commit is contained in:
@@ -50,7 +50,7 @@ fn decode_header(first_byte: u8, header_bytes: &[u8]) -> (usize, usize) {
|
||||
let head_len = ((first_byte & 0x3) + 1) as usize;
|
||||
|
||||
let mut n = first_byte as usize;
|
||||
if head_len > 1 && header_bytes.len() >= 1 {
|
||||
if head_len > 1 && !header_bytes.is_empty() {
|
||||
n |= (header_bytes[0] as usize) << 8;
|
||||
}
|
||||
if head_len > 2 && header_bytes.len() >= 2 {
|
||||
|
||||
@@ -202,9 +202,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_rendezvous_addr() {
|
||||
let mut config = RustDeskConfig::default();
|
||||
let mut config = RustDeskConfig {
|
||||
rendezvous_server: "example.com".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
config.rendezvous_server = "example.com".to_string();
|
||||
assert_eq!(config.rendezvous_addr(), "example.com:21116");
|
||||
|
||||
config.rendezvous_server = "example.com:21116".to_string();
|
||||
@@ -217,10 +219,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_relay_addr() {
|
||||
let mut config = RustDeskConfig::default();
|
||||
let mut config = RustDeskConfig {
|
||||
rendezvous_server: "example.com".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// Rendezvous server configured, relay defaults to same host
|
||||
config.rendezvous_server = "example.com".to_string();
|
||||
assert_eq!(config.relay_addr(), Some("example.com:21117".to_string()));
|
||||
|
||||
// Explicit relay server
|
||||
@@ -238,10 +242,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_effective_rendezvous_server() {
|
||||
let mut config = RustDeskConfig::default();
|
||||
let mut config = RustDeskConfig {
|
||||
rendezvous_server: "custom.example.com".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
// When user sets a server, use it
|
||||
config.rendezvous_server = "custom.example.com".to_string();
|
||||
assert_eq!(config.effective_rendezvous_server(), "custom.example.com");
|
||||
|
||||
// When empty, returns empty
|
||||
|
||||
@@ -729,7 +729,7 @@ impl Connection {
|
||||
}
|
||||
|
||||
// Check if client sent supported_decoding with a codec preference
|
||||
if let Some(ref supported_decoding) = opt.supported_decoding.as_ref() {
|
||||
if let Some(supported_decoding) = opt.supported_decoding.as_ref() {
|
||||
let prefer = supported_decoding.prefer.value();
|
||||
debug!("Client codec preference: prefer={}", prefer);
|
||||
|
||||
@@ -1352,8 +1352,12 @@ impl Connection {
|
||||
debug!("Mouse event: x={}, y={}, mask={}", me.x, me.y, me.mask);
|
||||
|
||||
// Convert RustDesk mouse event to One-KVM mouse events
|
||||
let mouse_events =
|
||||
convert_mouse_event(me, self.screen_width, self.screen_height, self.relative_mouse_active);
|
||||
let mouse_events = convert_mouse_event(
|
||||
me,
|
||||
self.screen_width,
|
||||
self.screen_height,
|
||||
self.relative_mouse_active,
|
||||
);
|
||||
|
||||
// Send to HID controller if available
|
||||
if let Some(ref hid) = self.hid {
|
||||
@@ -1616,7 +1620,10 @@ async fn run_video_streaming(
|
||||
);
|
||||
}
|
||||
if let Err(e) = video_manager.request_keyframe().await {
|
||||
debug!("Failed to request keyframe for connection {}: {}", conn_id, e);
|
||||
debug!(
|
||||
"Failed to request keyframe for connection {}: {}",
|
||||
conn_id, e
|
||||
);
|
||||
}
|
||||
|
||||
// Inner loop: receives frames from current subscription
|
||||
|
||||
@@ -189,7 +189,7 @@ pub fn hash_password_double(password: &str, salt: &str, challenge: &str) -> Vec<
|
||||
|
||||
// Second hash: SHA256(first_hash + challenge)
|
||||
let mut hasher2 = Sha256::new();
|
||||
hasher2.update(&first_hash);
|
||||
hasher2.update(first_hash);
|
||||
hasher2.update(challenge.as_bytes());
|
||||
hasher2.finalize().to_vec()
|
||||
}
|
||||
|
||||
@@ -127,7 +127,8 @@ impl VideoFrameAdapter {
|
||||
|
||||
// Inject cached SPS/PPS before IDR when missing
|
||||
if is_keyframe && (!has_sps || !has_pps) {
|
||||
if let (Some(ref sps), Some(ref pps)) = (self.h264_sps.as_ref(), self.h264_pps.as_ref()) {
|
||||
if let (Some(sps), Some(pps)) = (self.h264_sps.as_ref(), self.h264_pps.as_ref())
|
||||
{
|
||||
let mut out = Vec::with_capacity(8 + sps.len() + pps.len() + data.len());
|
||||
out.extend_from_slice(&[0, 0, 0, 1]);
|
||||
out.extend_from_slice(sps);
|
||||
|
||||
@@ -36,8 +36,8 @@ use tracing::{debug, error, info, warn};
|
||||
|
||||
use crate::audio::AudioController;
|
||||
use crate::hid::HidController;
|
||||
use crate::video::stream_manager::VideoStreamManager;
|
||||
use crate::utils::bind_tcp_listener;
|
||||
use crate::video::stream_manager::VideoStreamManager;
|
||||
|
||||
use self::config::RustDeskConfig;
|
||||
use self::connection::ConnectionManager;
|
||||
@@ -559,6 +559,7 @@ impl RustDeskService {
|
||||
/// 2. Send RelayResponse with client's socket_addr
|
||||
/// 3. Connect to RELAY server
|
||||
/// 4. Accept connection without waiting for response
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn handle_relay_request(
|
||||
rendezvous_addr: &str,
|
||||
relay_server: &str,
|
||||
|
||||
@@ -559,7 +559,7 @@ impl RendezvousMediator {
|
||||
);
|
||||
|
||||
let msg = make_punch_hole_sent(
|
||||
&ph.socket_addr.to_vec(), // Use peer's socket_addr, not ours
|
||||
&ph.socket_addr, // Use peer's socket_addr, not ours
|
||||
&id,
|
||||
&ph.relay_server,
|
||||
ph.nat_type.enum_value().unwrap_or(NatType::UNKNOWN_NAT),
|
||||
|
||||
Reference in New Issue
Block a user