update: 升级 rust 依赖

This commit is contained in:
mofeng-git
2026-07-16 22:59:22 +08:00
parent 8036c164b4
commit aca847e76c
15 changed files with 69 additions and 46 deletions

View File

@@ -220,7 +220,7 @@ fn run_capture(
let stream = match sample_format {
SampleFormat::F32 => build_stream::<f32>(
&device,
&stream_config,
stream_config,
input_channels,
input_rate,
tx.clone(),
@@ -229,7 +229,7 @@ fn run_capture(
),
SampleFormat::I16 => build_stream::<i16>(
&device,
&stream_config,
stream_config,
input_channels,
input_rate,
tx.clone(),
@@ -238,7 +238,7 @@ fn run_capture(
),
SampleFormat::U16 => build_stream::<u16>(
&device,
&stream_config,
stream_config,
input_channels,
input_rate,
tx.clone(),
@@ -361,7 +361,7 @@ fn select_input_config(
fn build_stream<T>(
device: &cpal::Device,
config: &StreamConfig,
config: StreamConfig,
input_channels: u32,
input_rate: u32,
tx: mpsc::SyncSender<Vec<i16>>,

View File

@@ -130,11 +130,11 @@ fn device_labels(device: &cpal::Device) -> DeviceLabels {
let formatted = desc.to_string();
let display = desc
.extended()
.first()
.cloned()
.next()
.map(str::to_owned)
.unwrap_or_else(|| formatted.clone());
let mut parts = vec![formatted, desc.name().to_string(), display.clone()];
parts.extend(desc.extended().iter().cloned());
parts.extend(desc.extended().map(str::to_owned));
DeviceLabels {
display,

View File

@@ -1,5 +1,5 @@
use bytes::Bytes;
use rand::Rng;
use rand::RngExt;
use rtp::packet::Packet;
use rtp::packetizer::Payloader;
use rtsp_types as rtsp;

View File

@@ -1,4 +1,4 @@
use rand::Rng;
use rand::RngExt;
use rtsp_types as rtsp;
use std::collections::HashMap;
use std::fmt;

View File

@@ -130,14 +130,14 @@ impl RustDeskConfig {
}
pub fn generate_device_id() -> String {
use rand::Rng;
use rand::RngExt;
let mut rng = rand::rng();
let id: u32 = rng.random_range(100_000_000..999_999_999);
id.to_string()
}
pub fn generate_random_password() -> String {
use rand::Rng;
use rand::RngExt;
const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let mut rng = rand::rng();
(0..8)

View File

@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::fmt::Write as _;
use std::path::{Path, PathBuf};
use std::sync::Arc;
@@ -552,7 +553,12 @@ async fn compute_file_sha256(path: &Path) -> Result<String> {
hasher.update(&buffer[..bytes_read]);
}
Ok(format!("{:x}", hasher.finalize()))
let digest = hasher.finalize();
let mut checksum = String::with_capacity(digest.len() * 2);
for byte in digest {
write!(&mut checksum, "{byte:02x}").expect("writing to a String cannot fail");
}
Ok(checksum)
}
fn normalize_sha256(input: &str) -> Option<String> {
@@ -578,3 +584,20 @@ fn current_target_triple() -> Result<String> {
};
Ok(triple.to_string())
}
#[cfg(test)]
mod tests {
use super::compute_file_sha256;
#[tokio::test]
async fn file_sha256_is_lowercase_hex() {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("payload");
tokio::fs::write(&path, b"one-kvm").await.unwrap();
assert_eq!(
compute_file_sha256(&path).await.unwrap(),
"f62202e0a47f1ebb56427006019524c680f15d769d70479b9dbc35f550e86e5e"
);
}
}

View File

@@ -1,7 +1,7 @@
use std::net::SocketAddr;
use bytes::{Bytes, BytesMut};
use des::cipher::{BlockEncrypt, KeyInit};
use des::cipher::{Block, BlockCipherEncrypt, KeyInit};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::sync::broadcast;
@@ -703,7 +703,10 @@ fn encrypt_vnc_challenge(challenge: &[u8; 16], password: &str) -> Result<[u8; 16
.map_err(|_| AppError::BadRequest("Invalid VNC DES key".to_string()))?;
let mut out = *challenge;
for chunk in out.chunks_exact_mut(8) {
cipher.encrypt_block(chunk.into());
let block: &mut Block<des::Des> = chunk
.try_into()
.expect("VNC challenge chunks are exactly one DES block");
cipher.encrypt_block(block);
}
Ok(out)
}