Skip to content

Commit 136eedb

Browse files
committed
fix: update version to 0.2.63, modify transaction timers
1 parent 3379600 commit 136eedb

File tree

5 files changed

+57
-32
lines changed

5 files changed

+57
-32
lines changed

Cargo.toml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rsipstack"
3-
version = "0.2.62"
3+
version = "0.2.63"
44
edition = "2021"
55
description = "SIP Stack Rust library for building SIP applications"
66
license = "MIT"
@@ -25,13 +25,6 @@ log = "0.4.28"
2525
rsip = { version = "0.4.0" }
2626
thiserror = "2.0.16"
2727
tracing = "0.1.41"
28-
wasm-bindgen = "0.2.101"
29-
# The `console_error_panic_hook` crate provides better debugging of panics by
30-
# logging them with `console.error`. This is great for development, but requires
31-
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
32-
# code size when deploying.
33-
console_error_panic_hook = { version = "0.1.7", optional = true }
34-
wasm-bindgen-futures = "0.4.51"
3528
tokio-util = { version = "0.7.16", features = ["full"] }
3629
tracing-subscriber = { version = "0.3.20", features = ["local-time"] }
3730
rand = { version = "0.9.2" }
@@ -48,7 +41,7 @@ clap = { version = "4.5.47", features = ["derive"] }
4841
http = "1.3.1"
4942

5043
[features]
51-
default = ["console_error_panic_hook", "rustls", "websocket"]
44+
default = ["rustls", "websocket"]
5245
rustls = ["tokio-rustls", "rustls-pemfile", "webpki-roots"]
5346
websocket = ["tokio-tungstenite"]
5447
all-transports = ["rustls", "websocket"]
@@ -68,8 +61,8 @@ rtp-rs = "0.6.0"
6861
stun-rs = "0.1.11"
6962
openai-api-rs = "6.0.11"
7063
base64 = "0.22.1"
71-
serde = "1.0.219"
72-
serde_json = "1.0.143"
64+
serde = "1.0.226"
65+
serde_json = "1.0.145"
7366
dasp = { version = "0.11", features = ["all"] }
7467
axum = { version = "0.8.4", features = ["ws"] }
7568
tower = "0.5.2"

src/dialog/dialog.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,27 @@ impl DialogInner {
325325
headers.push(Header::CallId(
326326
self.id.lock().unwrap().call_id.clone().into(),
327327
));
328-
headers.push(self.from.clone().into());
329-
headers.push(self.to.lock().unwrap().clone().into());
328+
329+
let to = self
330+
.to
331+
.lock()
332+
.unwrap()
333+
.clone()
334+
.untyped()
335+
.value()
336+
.to_string();
337+
338+
let from = self.from.clone().untyped().value().to_string();
339+
match self.role {
340+
TransactionRole::Client => {
341+
headers.push(Header::From(from.into()));
342+
headers.push(Header::To(to.into()));
343+
}
344+
TransactionRole::Server => {
345+
headers.push(Header::From(to.into()));
346+
headers.push(Header::To(from.into()));
347+
}
348+
}
330349
headers.push(Header::CSeq(cseq_header.into()));
331350
headers.push(Header::UserAgent(
332351
self.endpoint_inner.user_agent.clone().into(),

src/transaction/endpoint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct EndpointOption {
3232
pub t1: Duration,
3333
pub t4: Duration,
3434
pub t1x64: Duration,
35-
pub timerb: Duration,
35+
pub timerc: Duration,
3636
pub ignore_out_of_dialog_option: bool,
3737
pub callid_suffix: Option<String>,
3838
pub dialog_keepalive_duration: Option<Duration>,
@@ -44,7 +44,7 @@ impl Default for EndpointOption {
4444
t1: Duration::from_millis(500),
4545
t4: Duration::from_secs(4),
4646
t1x64: Duration::from_millis(64 * 500),
47-
timerb: Duration::from_secs(64),
47+
timerc: Duration::from_secs(180),
4848
ignore_out_of_dialog_option: true,
4949
callid_suffix: None,
5050
dialog_keepalive_duration: Some(Duration::from_secs(60)),

src/transaction/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ impl std::fmt::Display for TransactionType {
249249
pub enum TransactionTimer {
250250
TimerA(TransactionKey, Duration),
251251
TimerB(TransactionKey),
252+
TimerC(TransactionKey),
252253
TimerD(TransactionKey),
253254
TimerK(TransactionKey),
254255
TimerG(TransactionKey, Duration),
@@ -260,6 +261,7 @@ impl TransactionTimer {
260261
match self {
261262
TransactionTimer::TimerA(key, _) => key,
262263
TransactionTimer::TimerB(key) => key,
264+
TransactionTimer::TimerC(key) => key,
263265
TransactionTimer::TimerD(key) => key,
264266
TransactionTimer::TimerG(key, _) => key,
265267
TransactionTimer::TimerK(key) => key,
@@ -275,6 +277,7 @@ impl std::fmt::Display for TransactionTimer {
275277
write!(f, "TimerA: {} {}", key, duration.as_millis())
276278
}
277279
TransactionTimer::TimerB(key) => write!(f, "TimerB: {}", key),
280+
TransactionTimer::TimerC(key) => write!(f, "TimerC: {}", key),
278281
TransactionTimer::TimerD(key) => write!(f, "TimerD: {}", key),
279282
TransactionTimer::TimerG(key, duration) => {
280283
write!(f, "TimerG: {} {}", key, duration.as_millis())

src/transaction/transaction.rs

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{Error, Result};
88
use rsip::headers::ContentLength;
99
use rsip::message::HasHeaders;
1010
use rsip::prelude::HeadersExt;
11-
use rsip::{Header, Method, Request, Response, SipMessage, StatusCode};
11+
use rsip::{Header, Method, Request, Response, SipMessage, StatusCode, StatusCodeKind};
1212
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
1313
use tracing::{debug, info, trace};
1414

@@ -161,6 +161,7 @@ pub struct Transaction {
161161
pub tu_sender: TransactionEventSender,
162162
pub timer_a: Option<u64>,
163163
pub timer_b: Option<u64>,
164+
pub timer_c: Option<u64>,
164165
pub timer_d: Option<u64>,
165166
pub timer_k: Option<u64>, // server invite only
166167
pub timer_g: Option<u64>, // server invite only
@@ -197,6 +198,7 @@ impl Transaction {
197198
last_ack: None,
198199
timer_a: None,
199200
timer_b: None,
201+
timer_c: None,
200202
timer_d: None,
201203
timer_k: None,
202204
timer_g: None,
@@ -414,7 +416,7 @@ impl Transaction {
414416
}
415417
}
416418

417-
async fn send_ack(&mut self, connection: Option<SipConnection>) -> Result<()> {
419+
pub async fn send_ack(&mut self, connection: Option<SipConnection>) -> Result<()> {
418420
if self.transaction_type != TransactionType::ClientInvite {
419421
return Err(Error::TransactionError(
420422
"send_ack is only valid for client invite transactions".to_string(),
@@ -595,7 +597,7 @@ impl Transaction {
595597
_ => {}
596598
}
597599
let new_state = match resp.status_code.kind() {
598-
rsip::StatusCodeKind::Provisional => {
600+
StatusCodeKind::Provisional => {
599601
if resp.status_code == rsip::StatusCode::Trying {
600602
TransactionState::Trying
601603
} else {
@@ -651,25 +653,26 @@ impl Transaction {
651653
.timeout(duration, TransactionTimer::TimerA(key, duration));
652654
self.timer_a.replace(timer_a);
653655
} else if let TransactionTimer::TimerB(_) = timer {
654-
// Inform TU about timeout
655656
let timeout_response = self.endpoint_inner.make_response(
656657
&self.original,
657658
rsip::StatusCode::RequestTimeout,
658659
None,
659660
);
660661
self.inform_tu_response(timeout_response)?;
662+
self.transition(TransactionState::Terminated)?;
661663
}
662664
}
663665
}
664666
TransactionState::Proceeding => {
665-
if let TransactionTimer::TimerB(_) = timer {
667+
if let TransactionTimer::TimerC(_) = timer {
666668
// Inform TU about timeout
667669
let timeout_response = self.endpoint_inner.make_response(
668670
&self.original,
669671
rsip::StatusCode::RequestTimeout,
670672
None,
671673
);
672674
self.inform_tu_response(timeout_response)?;
675+
self.transition(TransactionState::Terminated)?;
673676
}
674677
}
675678
TransactionState::Completed => {
@@ -738,7 +741,7 @@ impl Transaction {
738741
self.timer_a.replace(timer_a);
739742
}
740743
self.timer_b.replace(self.endpoint_inner.timers.timeout(
741-
self.endpoint_inner.option.timerb,
744+
self.endpoint_inner.option.t1x64,
742745
TransactionTimer::TimerB(self.key.clone()),
743746
));
744747
}
@@ -747,17 +750,18 @@ impl Transaction {
747750
self.timer_a
748751
.take()
749752
.map(|id| self.endpoint_inner.timers.cancel(id));
750-
751-
if matches!(
752-
self.transaction_type,
753-
TransactionType::ClientInvite | TransactionType::ClientNonInvite
754-
) && self.timer_b.is_none()
755-
{
756-
let timer_b = self.endpoint_inner.timers.timeout(
757-
self.endpoint_inner.option.timerb,
758-
TransactionTimer::TimerB(self.key.clone()),
759-
);
760-
self.timer_b.replace(timer_b);
753+
if matches!(self.transaction_type, TransactionType::ClientInvite) {
754+
self.timer_b
755+
.take()
756+
.map(|id| self.endpoint_inner.timers.cancel(id));
757+
if self.timer_c.is_none() {
758+
// start Timer C for client invite only
759+
let timer_c = self.endpoint_inner.timers.timeout(
760+
self.endpoint_inner.option.timerc,
761+
TransactionTimer::TimerC(self.key.clone()),
762+
);
763+
self.timer_c.replace(timer_c);
764+
}
761765
}
762766
}
763767
TransactionState::Completed => {
@@ -767,6 +771,9 @@ impl Transaction {
767771
self.timer_b
768772
.take()
769773
.map(|id| self.endpoint_inner.timers.cancel(id));
774+
self.timer_c
775+
.take()
776+
.map(|id| self.endpoint_inner.timers.cancel(id));
770777

771778
if self.transaction_type == TransactionType::ServerInvite {
772779
// start Timer G for server invite only
@@ -839,6 +846,9 @@ impl Transaction {
839846
self.timer_b
840847
.take()
841848
.map(|id| self.endpoint_inner.timers.cancel(id));
849+
self.timer_c
850+
.take()
851+
.map(|id| self.endpoint_inner.timers.cancel(id));
842852
self.timer_d
843853
.take()
844854
.map(|id| self.endpoint_inner.timers.cancel(id));

0 commit comments

Comments
 (0)