Skip to content

Commit 24f0f5f

Browse files
committed
feat: update version to 0.2.26 and enhance EndpointOption with callid_suffix
1 parent 1a63cbb commit 24f0f5f

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rsipstack"
3-
version = "0.2.25"
3+
version = "0.2.26"
44
edition = "2021"
55
description = "SIP Stack Rust library for building SIP applications"
66
license = "MIT"
@@ -33,7 +33,6 @@ console_error_panic_hook = { version = "0.1.7", optional = true }
3333
wasm-bindgen-futures = "0.4.45"
3434
tokio-util = { version = "0.7.15", features = ["full"] }
3535
tracing-subscriber = { version = "0.3.19", features = ["local-time"] }
36-
uuid = { version = "1.16.0", features = ["v4"] }
3736
rand = { version = "0.9.1" }
3837
get_if_addrs = "0.5.3"
3938
rsip-dns = { version = "0.1.4", features = ["trust-dns"] }
@@ -56,7 +55,6 @@ all-transports = ["rustls", "websocket"]
5655
[target.'cfg(target_arch = "wasm32")'.dependencies]
5756
tokio = { version = "1.44.2", features = ["time", "sync", "macros", "io-util"] }
5857
getrandom = { version = "0.3.2" }
59-
uuid = { version = "1.16.0" }
6058

6159
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
6260
tokio = { version = "1.44.2", features = ["full"] }

src/transaction/endpoint.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ use tokio::{
2323
use tokio_util::sync::CancellationToken;
2424
use tracing::{debug, info, trace, warn};
2525

26+
#[derive(Debug, Clone)]
2627
pub struct EndpointOption {
2728
pub t1: Duration,
2829
pub t4: Duration,
2930
pub t1x64: Duration,
3031
pub ignore_out_of_dialog_option: bool,
32+
pub callid_suffix: Option<String>,
3133
}
3234

3335
impl Default for EndpointOption {
@@ -37,6 +39,7 @@ impl Default for EndpointOption {
3739
t4: Duration::from_secs(4),
3840
t1x64: Duration::from_millis(64 * 500),
3941
ignore_out_of_dialog_option: true,
42+
callid_suffix: None,
4043
}
4144
}
4245
}
@@ -111,6 +114,7 @@ pub struct EndpointBuilder {
111114
transport_layer: Option<TransportLayer>,
112115
cancel_token: Option<CancellationToken>,
113116
timer_interval: Option<Duration>,
117+
option: Option<EndpointOption>,
114118
}
115119

116120
/// SIP Endpoint
@@ -175,6 +179,7 @@ impl EndpointInner {
175179
cancel_token: CancellationToken,
176180
timer_interval: Option<Duration>,
177181
allows: Vec<rsip::Method>,
182+
option: Option<EndpointOption>,
178183
) -> Arc<Self> {
179184
Arc::new(EndpointInner {
180185
allows: Mutex::new(Some(allows)),
@@ -186,7 +191,7 @@ impl EndpointInner {
186191
timer_interval: timer_interval.unwrap_or(Duration::from_millis(20)),
187192
cancel_token,
188193
incoming_sender: Mutex::new(None),
189-
option: EndpointOption::default(),
194+
option: option.unwrap_or_default(),
190195
})
191196
}
192197

@@ -434,9 +439,13 @@ impl EndpointBuilder {
434439
transport_layer: None,
435440
cancel_token: None,
436441
timer_interval: None,
442+
option: None,
437443
}
438444
}
439-
445+
pub fn with_option(&mut self, option: EndpointOption) -> &mut Self {
446+
self.option = Some(option);
447+
self
448+
}
440449
pub fn with_user_agent(&mut self, user_agent: &str) -> &mut Self {
441450
self.user_agent = user_agent.to_string();
442451
self
@@ -471,13 +480,15 @@ impl EndpointBuilder {
471480
let allows = self.allows.to_owned();
472481
let user_agent = self.user_agent.to_owned();
473482
let timer_interval = self.timer_interval.to_owned();
483+
let option = self.option.to_owned();
474484

475485
let core = EndpointInner::new(
476486
user_agent,
477487
transport_layer,
478488
cancel_token,
479489
timer_interval,
480490
allows,
491+
option,
481492
);
482493

483494
Endpoint { inner: core }

src/transaction/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl EndpointInner {
9393
) -> rsip::Request {
9494
let headers = vec![
9595
Header::Via(via.into()),
96-
Header::CallId(make_call_id(None)),
96+
Header::CallId(make_call_id(self.option.callid_suffix.as_deref())),
9797
Header::From(from.into()),
9898
Header::To(to.into()),
9999
Header::CSeq(rsip::typed::CSeq { seq, method }.into()),

src/transaction/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use key::TransactionKey;
33
use std::time::Duration;
44
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
55
use transaction::Transaction;
6-
use uuid::Uuid;
76

87
pub mod endpoint;
98
pub mod key;
@@ -18,7 +17,7 @@ mod tests;
1817
pub const TO_TAG_LEN: usize = 8;
1918
pub const BRANCH_LEN: usize = 12;
2019
pub const CNONCE_LEN: usize = 8;
21-
20+
pub const CALL_ID_LEN: usize = 22;
2221
pub struct IncomingRequest {
2322
pub request: rsip::Request,
2423
pub connection: SipConnection,
@@ -272,7 +271,12 @@ pub fn make_via_branch() -> rsip::Param {
272271
}
273272

274273
pub fn make_call_id(domain: Option<&str>) -> rsip::headers::CallId {
275-
format!("{}@{}", Uuid::new_v4(), domain.unwrap_or("restsend.com")).into()
274+
format!(
275+
"{}@{}",
276+
random_text(CALL_ID_LEN),
277+
domain.unwrap_or("restsend.com")
278+
)
279+
.into()
276280
}
277281

278282
pub fn make_tag() -> rsip::param::Tag {

0 commit comments

Comments
 (0)