fix(proxy-engine): fix inbound route browser ringing and provider-facing SDP advertisement while preventing RTP port exhaustion

This commit is contained in:
2026-04-11 18:40:56 +00:00
parent 21ffc1d017
commit 81441e7853
17 changed files with 208 additions and 469 deletions

View File

@@ -19,11 +19,19 @@ const MAX_EXPIRES: u32 = 300;
#[derive(Debug, Clone)]
pub struct RegisteredDevice {
pub device_id: String,
// These fields are populated at REGISTER time for logging/debugging but are
// not read back — device identity flows via the `device_registered` push
// event, not via struct queries. Kept behind allow(dead_code) because
// removing them would churn handle_register for no runtime benefit.
#[allow(dead_code)]
pub display_name: String,
#[allow(dead_code)]
pub extension: String,
pub contact_addr: SocketAddr,
#[allow(dead_code)]
pub registered_at: Instant,
pub expires_at: Instant,
#[allow(dead_code)]
pub aor: String,
}
@@ -134,11 +142,6 @@ impl Registrar {
Some(entry.contact_addr)
}
/// Check if a source address belongs to a known device.
pub fn is_known_device_address(&self, addr: &str) -> bool {
self.devices.iter().any(|d| d.expected_address == addr)
}
/// Find a registered device by its source IP address.
pub fn find_by_address(&self, addr: &SocketAddr) -> Option<&RegisteredDevice> {
let ip = addr.ip().to_string();
@@ -146,26 +149,4 @@ impl Registrar {
e.contact_addr.ip().to_string() == ip && Instant::now() <= e.expires_at
})
}
/// Get all device statuses for the dashboard.
pub fn get_all_statuses(&self) -> Vec<serde_json::Value> {
let now = Instant::now();
let mut result = Vec::new();
for dc in &self.devices {
let reg = self.registered.get(&dc.id);
let connected = reg.map(|r| now <= r.expires_at).unwrap_or(false);
result.push(serde_json::json!({
"id": dc.id,
"displayName": dc.display_name,
"address": reg.filter(|_| connected).map(|r| r.contact_addr.ip().to_string()),
"port": reg.filter(|_| connected).map(|r| r.contact_addr.port()),
"aor": reg.map(|r| r.aor.as_str()).unwrap_or(""),
"connected": connected,
"isBrowser": false,
}));
}
result
}
}