Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rustalk-cli/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub enum ModuleActionType {

/// Parse a console command from input string
pub fn parse_command(input: &str) -> Result<ConsoleCommand> {
let parts: Vec<&str> = input.trim().split_whitespace().collect();
let parts: Vec<&str> = input.split_whitespace().collect();

if parts.is_empty() {
anyhow::bail!("Empty command");
Expand Down
1 change: 1 addition & 0 deletions rustalk-cloud/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl CloudApi {
}

/// Build the API router
#[allow(clippy::too_many_arguments)]
fn router(
webui_path: Option<String>,
acme_state: AcmeState,
Expand Down
2 changes: 1 addition & 1 deletion rustalk-cloud/src/handlers/call_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub async fn list_rates() -> (StatusCode, Json<Value>) {
}

/// Import rates from JSON or CSV
pub async fn import_rates(Json(request): Json<RateImportRequest>) -> (StatusCode, Json<Value>) {
pub async fn import_rates(Json(_request): Json<RateImportRequest>) -> (StatusCode, Json<Value>) {
// Placeholder - would parse and save to database
let response = RateImportResponse {
success: true,
Expand Down
2 changes: 1 addition & 1 deletion rustalk-cloud/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub async fn get_config() -> (StatusCode, Json<Value>) {
}

/// Update configuration
pub async fn update_config(Json(payload): Json<Value>) -> (StatusCode, Json<Value>) {
pub async fn update_config(Json(_payload): Json<Value>) -> (StatusCode, Json<Value>) {
// Placeholder - would update database
(
StatusCode::OK,
Expand Down
4 changes: 2 additions & 2 deletions rustalk-cloud/src/handlers/voicemail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub async fn get_mwi_status(

/// Mark a message as read
pub async fn mark_message_read(
Path((mailbox_id, message_id)): Path<(String, String)>,
Path((_mailbox_id, message_id)): Path<(String, String)>,
State(state): State<VoicemailState>,
) -> (StatusCode, Json<Value>) {
let mut manager = state.write().await;
Expand All @@ -160,7 +160,7 @@ pub async fn mark_message_read(

/// Delete a voicemail message
pub async fn delete_message(
Path((mailbox_id, message_id)): Path<(String, String)>,
Path((_mailbox_id, message_id)): Path<(String, String)>,
State(state): State<VoicemailState>,
) -> (StatusCode, Json<Value>) {
let mut manager = state.write().await;
Expand Down
2 changes: 1 addition & 1 deletion rustalk-core/src/acme/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use std::time::Duration;
use tokio::time::sleep;
use tracing::{debug, info, warn};
use tracing::{debug, info};

use super::storage::CertificateStorage;
use super::validation::{ChallengeType, ChallengeValidator};
Expand Down
14 changes: 1 addition & 13 deletions rustalk-core/src/acme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ pub use client::{AcmeClient, AcmeConfig};
pub use storage::{CertificateInfo, CertificateStorage};
pub use validation::{ChallengeType, ValidationResult};

use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

/// Certificate status information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Default)]
pub struct CertificateStatus {
/// Whether a valid certificate exists
pub exists: bool,
Expand Down Expand Up @@ -54,14 +53,3 @@ pub struct CertificateOperationResult {
pub certificate: Option<CertificateInfo>,
}

impl Default for CertificateStatus {
fn default() -> Self {
Self {
exists: false,
domains: Vec::new(),
expires_at: None,
days_until_expiry: None,
needs_renewal: false,
}
}
}
8 changes: 4 additions & 4 deletions rustalk-core/src/acme/storage.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Certificate storage and management

use anyhow::{Context, Result};
use rustls_pemfile::{certs, pkcs8_private_keys};
use anyhow::Result;
use rustls_pemfile::certs;
use serde::{Deserialize, Serialize};
use std::io::BufReader;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use tokio::fs;
use tracing::{info, warn};
use tracing::info;

/// Information about a stored certificate
#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
2 changes: 2 additions & 0 deletions rustalk-core/src/acme/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct ValidationResult {
/// Challenge validator
pub struct ChallengeValidator {
challenge_type: ChallengeType,
#[allow(dead_code)]
http_port: u16,
tokens: Arc<RwLock<std::collections::HashMap<String, String>>>,
}
Expand Down Expand Up @@ -147,6 +148,7 @@ impl ChallengeValidator {
}

/// Get the key authorization for a token (for HTTP server)
#[allow(dead_code)]
pub async fn get_key_authorization(&self, token: &str) -> Option<String> {
let tokens = self.tokens.read().await;
tokens.get(token).cloned()
Expand Down
1 change: 1 addition & 0 deletions rustalk-core/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl AuthManager {
}

/// Calculate the digest response value
#[allow(clippy::too_many_arguments)]
fn calculate_response(
&self,
username: &str,
Expand Down
2 changes: 1 addition & 1 deletion rustalk-core/src/b2bua/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl B2BUA {
.ok_or_else(|| anyhow::anyhow!("No Call-ID in response"))?;

let sessions = self.sessions.read().await;
if let Some(session) = sessions.values().find(|s| s.call_id() == call_id) {
if let Some(_session) = sessions.values().find(|s| s.call_id() == call_id) {
// Forward response to the other leg
debug!("Forwarding response to other leg");
// In a real implementation, we would modify headers and forward
Expand Down
26 changes: 13 additions & 13 deletions rustalk-core/src/media/sdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,35 @@ impl SdpSession {

Ok(session)
}
}

/// Serialize to SDP string
pub fn to_string(&self) -> String {
let mut sdp = String::new();

sdp.push_str(&format!("v={}\r\n", self.version));
sdp.push_str(&format!("o={}\r\n", self.origin));
sdp.push_str(&format!("s={}\r\n", self.session_name));
impl std::fmt::Display for SdpSession {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "v={}\r\n", self.version)?;
write!(f, "o={}\r\n", self.origin)?;
write!(f, "s={}\r\n", self.session_name)?;

if let Some(conn) = &self.connection {
sdp.push_str(&format!("c={}\r\n", conn));
write!(f, "c={}\r\n", conn)?;
}

sdp.push_str("t=0 0\r\n");
write!(f, "t=0 0\r\n")?;

for media in &self.media {
let formats = media
.formats
.iter()
.map(|f| f.to_string())
.map(|fmt| fmt.to_string())
.collect::<Vec<_>>()
.join(" ");
sdp.push_str(&format!(
write!(
f,
"m={} {} {} {}\r\n",
media.media_type, media.port, media.protocol, formats
));
)?;
}

sdp
Ok(())
}
}

Expand Down
1 change: 0 additions & 1 deletion rustalk-core/src/sip/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use super::{Header, Method, StatusCode, Uri};
use bytes::Bytes;
use std::collections::HashMap;

/// SIP Message - either a Request or Response
#[derive(Debug, Clone)]
Expand Down
43 changes: 24 additions & 19 deletions rustalk-core/src/sip/method.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! SIP Methods

use std::fmt;
use std::str::FromStr;

/// SIP Method types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -51,29 +52,33 @@ impl Method {
Method::Message => "MESSAGE",
}
}

pub fn from_str(s: &str) -> Option<Self> {
match s {
"INVITE" => Some(Method::Invite),
"ACK" => Some(Method::Ack),
"BYE" => Some(Method::Bye),
"CANCEL" => Some(Method::Cancel),
"REGISTER" => Some(Method::Register),
"OPTIONS" => Some(Method::Options),
"INFO" => Some(Method::Info),
"PRACK" => Some(Method::Prack),
"SUBSCRIBE" => Some(Method::Subscribe),
"NOTIFY" => Some(Method::Notify),
"UPDATE" => Some(Method::Update),
"REFER" => Some(Method::Refer),
"MESSAGE" => Some(Method::Message),
_ => None,
}
}
}

impl fmt::Display for Method {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.as_str())
}
}

impl FromStr for Method {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"INVITE" => Ok(Method::Invite),
"ACK" => Ok(Method::Ack),
"BYE" => Ok(Method::Bye),
"CANCEL" => Ok(Method::Cancel),
"REGISTER" => Ok(Method::Register),
"OPTIONS" => Ok(Method::Options),
"INFO" => Ok(Method::Info),
"PRACK" => Ok(Method::Prack),
"SUBSCRIBE" => Ok(Method::Subscribe),
"NOTIFY" => Ok(Method::Notify),
"UPDATE" => Ok(Method::Update),
"REFER" => Ok(Method::Refer),
"MESSAGE" => Ok(Method::Message),
_ => Err(format!("Unknown SIP method: {}", s)),
}
}
}
4 changes: 2 additions & 2 deletions rustalk-core/src/sip/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use super::{Header, Message, Method, Request, Response, StatusCode, Uri};
use bytes::Bytes;
use nom::{
branch::alt,
bytes::complete::{tag, take_until, take_while, take_while1},
bytes::complete::{tag, take_until, take_while1},
character::complete::{char, digit1, line_ending, space1},
combinator::{map, map_res, opt},
multi::many0,
sequence::{delimited, preceded, separated_pair, terminated, tuple},
sequence::{preceded, separated_pair, terminated, tuple},
IResult,
};

Expand Down
4 changes: 1 addition & 3 deletions rustalk-core/src/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ use crate::sip::Message;
use anyhow::Result;
use std::net::SocketAddr;
use std::sync::Arc;
use tokio::net::UdpSocket;
use tokio::sync::mpsc;
use tracing::{debug, error, info};

pub mod tls;
pub mod udp;
Expand Down Expand Up @@ -49,6 +46,7 @@ pub trait Transport: Send + Sync {

/// Transport layer manager
pub struct TransportLayer {
#[allow(dead_code)]
config: TransportConfig,
transport: Arc<dyn Transport>,
}
Expand Down
4 changes: 2 additions & 2 deletions rustalk-core/src/transport/tls.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
//! TLS/mTLS Transport implementation for secure SIP (SIPS)

use super::{Transport, TransportConfig};
use crate::sip::{parser::parse_message, Message};
use crate::sip::Message;
use anyhow::Result;
use rustls::{ClientConfig, ServerConfig};
use rustls_pemfile::{certs, pkcs8_private_keys};
use std::fs::File;
use std::io::BufReader;
use std::net::SocketAddr;
use std::sync::Arc;
use tokio::net::TcpListener;
use tracing::{debug, info};

pub struct TlsTransport {
local_addr: SocketAddr,
#[allow(dead_code)]
server_config: Arc<ServerConfig>,
}

Expand Down
2 changes: 1 addition & 1 deletion rustalk-core/src/transport/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::net::SocketAddr;
use std::sync::Arc;
use tokio::net::UdpSocket;
use tokio::sync::Mutex;
use tracing::{debug, error};
use tracing::debug;

pub struct UdpTransport {
socket: Arc<Mutex<UdpSocket>>,
Expand Down