mirror of
https://github.com/irlserver/srtla_send.git
synced 2026-07-04 14:46:45 +00:00
chore: lint
This commit is contained in:
@@ -3,7 +3,7 @@ use std::process::Command;
|
||||
fn main() {
|
||||
// Get git commit hash
|
||||
let git_hash = Command::new("git")
|
||||
.args(&["rev-parse", "--short", "HEAD"])
|
||||
.args(["rev-parse", "--short", "HEAD"])
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|output| {
|
||||
@@ -17,7 +17,7 @@ fn main() {
|
||||
|
||||
// Get git branch
|
||||
let git_branch = Command::new("git")
|
||||
.args(&["rev-parse", "--abbrev-ref", "HEAD"])
|
||||
.args(["rev-parse", "--abbrev-ref", "HEAD"])
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|output| {
|
||||
@@ -31,7 +31,7 @@ fn main() {
|
||||
|
||||
// Check if working directory is dirty
|
||||
let git_dirty = Command::new("git")
|
||||
.args(&["diff", "--quiet"])
|
||||
.args(["diff", "--quiet"])
|
||||
.status()
|
||||
.map(|status| !status.success())
|
||||
.unwrap_or(false);
|
||||
|
||||
+3
-3
@@ -188,7 +188,7 @@ impl SrtlaConnection {
|
||||
let now = now_ms();
|
||||
self.last_keepalive_ms = now;
|
||||
// Only set waiting flag and timestamp when we intend to measure RTT
|
||||
if self.waiting_for_keepalive_response == false
|
||||
if !self.waiting_for_keepalive_response
|
||||
&& (self.last_rtt_measurement_ms == 0
|
||||
|| now.saturating_sub(self.last_rtt_measurement_ms) > 3000)
|
||||
{
|
||||
@@ -554,9 +554,9 @@ impl SrtlaConnection {
|
||||
if tsn > 10_000 {
|
||||
self.window += WINDOW_INCR * 2 * fast_mode_bonus;
|
||||
} else if tsn > 7_000 {
|
||||
self.window += WINDOW_INCR * 1 * fast_mode_bonus;
|
||||
self.window += WINDOW_INCR * fast_mode_bonus;
|
||||
} else if tsn > 5_000 {
|
||||
self.window += WINDOW_INCR * 1 * fast_mode_bonus;
|
||||
self.window += WINDOW_INCR * fast_mode_bonus;
|
||||
} else {
|
||||
self.window += WINDOW_INCR * fast_mode_bonus;
|
||||
}
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ pub fn create_reg2_packet(id: &[u8; SRTLA_ID_LEN]) -> Vec<u8> {
|
||||
pub fn create_keepalive_packet() -> Vec<u8> {
|
||||
let mut pkt = vec![0u8; 10];
|
||||
pkt[0..2].copy_from_slice(&SRTLA_TYPE_KEEPALIVE.to_be_bytes());
|
||||
let ts = chrono::Utc::now().timestamp_millis() as i64 as u64;
|
||||
let ts = chrono::Utc::now().timestamp_millis() as u64;
|
||||
for i in 0..8 {
|
||||
pkt[2 + i] = ((ts >> (56 - i * 8)) & 0xff) as u8;
|
||||
}
|
||||
|
||||
+9
-5
@@ -17,6 +17,12 @@ pub struct SrtlaRegistrationManager {
|
||||
reg1_next_send_at_ms: u64,
|
||||
}
|
||||
|
||||
impl Default for SrtlaRegistrationManager {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl SrtlaRegistrationManager {
|
||||
#[allow(deprecated)]
|
||||
pub fn new() -> Self {
|
||||
@@ -79,12 +85,10 @@ impl SrtlaRegistrationManager {
|
||||
if self.active_connections == 0 {
|
||||
let target_idx = if let Some(idx) = self.reg1_target_idx {
|
||||
Some(idx)
|
||||
} else if !connections.is_empty() {
|
||||
Some(0)
|
||||
} else {
|
||||
if !connections.is_empty() {
|
||||
Some(0)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
None
|
||||
};
|
||||
if let Some(idx) = target_idx {
|
||||
let now = now_ms();
|
||||
|
||||
@@ -10,7 +10,7 @@ mod tests {
|
||||
|
||||
// Test basic score calculation
|
||||
let initial_score = conn.get_score();
|
||||
let expected_score = (WINDOW_DEF * WINDOW_MULT) / (0 + 1);
|
||||
let expected_score = WINDOW_DEF * WINDOW_MULT;
|
||||
assert_eq!(initial_score, expected_score);
|
||||
|
||||
// Test with in-flight packets
|
||||
@@ -41,7 +41,7 @@ mod tests {
|
||||
|
||||
// Test multiple packets
|
||||
for i in 1..=5 {
|
||||
conn.register_packet(100 + i as i32);
|
||||
conn.register_packet(100 + i);
|
||||
}
|
||||
assert_eq!(conn.in_flight_packets, initial_in_flight + 6);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ mod tests {
|
||||
let mut temp_file = NamedTempFile::new().unwrap();
|
||||
writeln!(temp_file, "192.168.1.1").unwrap();
|
||||
writeln!(temp_file, "192.168.1.2").unwrap();
|
||||
writeln!(temp_file, "").unwrap(); // Empty line
|
||||
writeln!(temp_file).unwrap(); // Empty line
|
||||
writeln!(temp_file, "192.168.1.3").unwrap();
|
||||
writeln!(temp_file, "invalid-ip").unwrap(); // Invalid IP
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@ pub struct DynamicToggles {
|
||||
pub exploration_enabled: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl Default for DynamicToggles {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl DynamicToggles {
|
||||
#[allow(dead_code)]
|
||||
pub fn new() -> Self {
|
||||
|
||||
@@ -15,7 +15,7 @@ async fn test_ip_file_parsing_and_validation() {
|
||||
writeln!(temp_file, "192.168.1.100").unwrap();
|
||||
writeln!(temp_file, "192.168.1.101").unwrap();
|
||||
writeln!(temp_file, "# This is a comment").unwrap();
|
||||
writeln!(temp_file, "").unwrap(); // Empty line
|
||||
writeln!(temp_file).unwrap(); // Empty line
|
||||
writeln!(temp_file, "192.168.1.102").unwrap();
|
||||
writeln!(temp_file, "invalid-ip-address").unwrap(); // Should be ignored
|
||||
writeln!(temp_file, "10.0.0.1").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user