Skip to content

Commit e7e5fac

Browse files
committed
chore: update dependencies and add domain_resolver option with endpoint builder
1 parent 9494707 commit e7e5fac

4 files changed

Lines changed: 36 additions & 26 deletions

File tree

Cargo.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rsipstack"
3-
version = "0.4.11"
3+
version = "0.4.12"
44
edition = "2021"
55
description = "SIP Stack Rust library for building SIP applications"
66
license = "MIT"
@@ -20,27 +20,27 @@ path = "src/bin/bench_ua.rs"
2020

2121
[dependencies]
2222
async-trait = "0.1.89"
23-
futures = "0.3.31"
23+
futures = "0.3.32"
2424
rsip = { version = "0.4.0" }
25-
thiserror = "2.0.17"
25+
thiserror = "2.0.18"
2626
tracing = "0.1.44"
27-
tokio-util = { version = "0.7.17", features = ["full"] }
28-
tracing-subscriber = { version = "0.3.20", features = ["local-time"] }
29-
rand = { version = "0.9.2" }
30-
md-5 = "0.9.1"
31-
sha2 = "0.9.5"
27+
tokio-util = { version = "0.7.18", features = ["full"] }
28+
tracing-subscriber = { version = "0.3.22", features = ["local-time"] }
29+
rand = { version = "0.10.0" }
30+
md-5 = "0.10.6"
31+
sha2 = "0.10.9"
3232
get_if_addrs = "0.5.3"
3333
hickory-resolver = { version = "0.25.2", features = [
3434
"system-config",
3535
"tokio",
3636
], optional = true }
37-
bytes = "1.11.0"
38-
futures-util = "0.3.31"
37+
bytes = "1.11.1"
38+
futures-util = "0.3.32"
3939
tokio-tungstenite = { version = "0.28.0", optional = true }
4040
tokio-rustls = { version = "0.26.4", optional = true }
4141
rustls-pemfile = { version = "2.2.0", optional = true }
42-
rustls = "0.23.35"
43-
clap = { version = "4.5.53", features = ["derive"] }
42+
rustls = "0.23.37"
43+
clap = { version = "4.5.60", features = ["derive"] }
4444
nom = "8.0.0"
4545

4646
[features]
@@ -51,19 +51,19 @@ websocket = ["tokio-tungstenite"]
5151
all-transports = ["rustls", "websocket", "srv_lookup"]
5252

5353
[target.'cfg(target_arch = "wasm32")'.dependencies]
54-
tokio = { version = "1.47.1", features = ["time", "sync", "macros", "io-util"] }
54+
tokio = { version = "1.50.0", features = ["time", "sync", "macros", "io-util"] }
5555

5656
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
57-
tokio = { version = "1.48.0", features = ["full"] }
57+
tokio = { version = "1.50.0", features = ["full"] }
5858

5959
[dev-dependencies]
6060
dotenv = "0.15"
6161
sdp-rs = "0.2.1"
6262
rtp-rs = "0.6.0"
6363
stun-rs = "0.1.11"
6464
axum = { version = "0.8.8", features = ["ws"] }
65-
tower = "0.5.2"
66-
tower-http = { version = "0.6.7", features = ["fs", "cors"] }
65+
tower = "0.5.3"
66+
tower-http = { version = "0.6.8", features = ["fs", "cors"] }
6767
http = "1.4.0"
6868

6969
[[example]]

src/resolver/sip_resolver.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
use hickory_resolver::TokioResolver;
2+
use rand::RngExt;
13
use rsip::{Domain, Port, Transport};
24
use std::net::IpAddr;
35
use std::net::SocketAddr;
46
use std::str::FromStr;
57
use std::sync::Arc;
68

7-
use hickory_resolver::TokioResolver;
8-
use rand::Rng;
9-
109
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1110
pub struct Target {
1211
pub addr: SocketAddr,

src/transaction/endpoint.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::{
88
use crate::{
99
dialog::DialogId,
1010
rsip_ext::destination_from_request,
11-
transport::{SipAddr, TransportEvent, TransportLayer},
11+
transport::{transport_layer::DomainResolver, SipAddr, TransportEvent, TransportLayer},
1212
Error, Result, VERSION,
1313
};
1414
use async_trait::async_trait;
@@ -146,6 +146,7 @@ pub struct EndpointBuilder {
146146
message_inspector: Option<Box<dyn MessageInspector>>,
147147
target_locator: Option<Box<dyn TargetLocator>>,
148148
transport_inspector: Option<Box<dyn TransportEventInspector>>,
149+
domain_resolver: Option<Box<dyn DomainResolver>>,
149150
}
150151

151152
/// SIP Endpoint
@@ -647,12 +648,15 @@ impl EndpointBuilder {
647648
message_inspector: None,
648649
target_locator: None,
649650
transport_inspector: None,
651+
domain_resolver: None,
650652
}
651653
}
654+
652655
pub fn with_option(&mut self, option: EndpointOption) -> &mut Self {
653656
self.option = Some(option);
654657
self
655658
}
659+
656660
pub fn with_user_agent(&mut self, user_agent: &str) -> &mut Self {
657661
self.user_agent = user_agent.to_string();
658662
self
@@ -693,13 +697,20 @@ impl EndpointBuilder {
693697
self
694698
}
695699

700+
pub fn with_domain_resolver(&mut self, resolver: Box<dyn DomainResolver>) -> &mut Self {
701+
self.domain_resolver = Some(resolver);
702+
self
703+
}
704+
696705
pub fn build(&mut self) -> Endpoint {
697706
let cancel_token = self.cancel_token.take().unwrap_or_default();
698-
699-
let transport_layer = self
700-
.transport_layer
701-
.take()
702-
.unwrap_or(TransportLayer::new(cancel_token.child_token()));
707+
let transport_layer = self.transport_layer.take().unwrap_or_else(|| {
708+
if let Some(resolver) = self.domain_resolver.take() {
709+
TransportLayer::new_with_domain_resolver(cancel_token.clone(), resolver)
710+
} else {
711+
TransportLayer::new(cancel_token.clone())
712+
}
713+
});
703714

704715
let allows = self.allows.to_owned();
705716
let user_agent = self.user_agent.to_owned();

src/transaction/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pub fn make_tag() -> rsip::param::Tag {
307307

308308
#[cfg(not(target_family = "wasm"))]
309309
pub fn random_text(count: usize) -> String {
310-
use rand::Rng;
310+
use rand::RngExt;
311311
rand::rng()
312312
.sample_iter(rand::distr::Alphanumeric)
313313
.take(count)

0 commit comments

Comments
 (0)