Skip to content

Commit 3c3b6af

Browse files
committed
feat: timer from 32 -> 64 s
1 parent 290e519 commit 3c3b6af

5 files changed

Lines changed: 24 additions & 17 deletions

File tree

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rsipstack"
3-
version = "0.2.27"
3+
version = "0.2.28"
44
edition = "2021"
55
description = "SIP Stack Rust library for building SIP applications"
66
license = "MIT"
@@ -31,19 +31,19 @@ wasm-bindgen = "0.2.84"
3131
# code size when deploying.
3232
console_error_panic_hook = { version = "0.1.7", optional = true }
3333
wasm-bindgen-futures = "0.4.45"
34-
tokio-util = { version = "0.7.15", features = ["full"] }
34+
tokio-util = { version = "0.7.16", features = ["full"] }
3535
tracing-subscriber = { version = "0.3.19", features = ["local-time"] }
36-
rand = { version = "0.9.1" }
36+
rand = { version = "0.9.2" }
3737
get_if_addrs = "0.5.3"
3838
rsip-dns = { version = "0.1.4", features = ["trust-dns"] }
3939
bytes = "1.10.1"
4040
futures-util = "0.3.30"
4141
tokio-tungstenite = { version = "0.27.0", optional = true }
4242
tokio-rustls = { version = "0.26.2", optional = true }
4343
rustls-pemfile = { version = "2.2.0", optional = true }
44-
webpki-roots = { version = "1.0.0", optional = true }
45-
rustls = "0.23.28"
46-
clap = { version = "4.5.37", features = ["derive"] }
44+
webpki-roots = { version = "1.0.2", optional = true }
45+
rustls = "0.23.31"
46+
clap = { version = "4.5.43", features = ["derive"] }
4747
http = "1.3.1"
4848

4949
[features]
@@ -53,8 +53,8 @@ websocket = ["tokio-tungstenite"]
5353
all-transports = ["rustls", "websocket"]
5454

5555
[target.'cfg(target_arch = "wasm32")'.dependencies]
56-
tokio = { version = "1.44.2", features = ["time", "sync", "macros", "io-util"] }
57-
getrandom = { version = "0.3.2" }
56+
tokio = { version = "1.47.1", features = ["time", "sync", "macros", "io-util"] }
57+
getrandom = { version = "0.3.3" }
5858

5959
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
6060
tokio = { version = "1.44.2", features = ["full"] }
@@ -65,10 +65,10 @@ dotenv = "0.15"
6565
sdp-rs = "0.2.1"
6666
rtp-rs = "0.6.0"
6767
stun-rs = "0.1.11"
68-
openai-api-rs = "6.0.3"
68+
openai-api-rs = "6.0.8"
6969
base64 = "0.22.1"
7070
serde = "1.0.219"
71-
serde_json = "1.0.140"
71+
serde_json = "1.0.142"
7272
dasp = { version = "0.11", features = ["all"] }
7373
axum = { version = "0.8.4", features = ["ws"] }
7474
tower = "0.5.2"

examples/client/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ struct Args {
7171

7272
#[arg(long)]
7373
call: Option<String>,
74+
75+
#[arg(long)]
76+
reject: bool,
7477
}
7578

7679
async fn handle_user_input(cancel_token: CancellationToken) -> Result<()> {
@@ -229,7 +232,7 @@ async fn main() -> rsipstack::Result<()> {
229232
r = process_registration(endpoint.inner.clone(), sip_server, credential.clone(), token.clone()) => {
230233
info!("register loop finished {:?}", r);
231234
}
232-
r = process_incoming_request(dialog_layer.clone(), incoming, state_sender.clone(), contact.clone()) => {
235+
r = process_incoming_request(dialog_layer.clone(), incoming, state_sender.clone(), contact.clone(), args.reject) => {
233236
info!("serve loop finished {:?}", r);
234237
}
235238
r = process_dialog(dialog_layer.clone(), state_receiver, opt.clone()) => {
@@ -295,6 +298,7 @@ async fn process_incoming_request(
295298
mut incoming: TransactionReceiver,
296299
state_sender: DialogStateSender,
297300
contact: rsip::Uri,
301+
reject: bool,
298302
) -> Result<()> {
299303
while let Some(mut tx) = incoming.recv().await {
300304
info!("Received transaction: {:?}", tx.key);
@@ -320,6 +324,11 @@ async fn process_incoming_request(
320324
// out dialog, new server dialog
321325
match tx.original.method {
322326
rsip::Method::Invite | rsip::Method::Ack => {
327+
if reject && tx.original.method == rsip::Method::Invite {
328+
info!("Rejecting incoming call: {}", tx.original);
329+
tx.reply(rsip::StatusCode::BusyHere).await?;
330+
continue;
331+
}
323332
let mut dialog = match dialog_layer.get_or_create_server_invite(
324333
&tx,
325334
state_sender.clone(),

examples/proxy.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,15 +596,11 @@ impl fmt::Display for ClientAddr {
596596
async fn serve_index() -> impl IntoResponse {
597597
Html(include_str!("../assets/index.html"))
598598
}
599-
async fn serve_sip_js() -> impl IntoResponse {
600-
Html(include_str!("../assets/sip-0.17.1.js"))
601-
}
602599

603600
fn create_http_app(state: AppState) -> Router {
604601
Router::new()
605602
.route("/", get(serve_index))
606603
.route("/ws", get(websocket_handler))
607-
.route("/sip-0.17.1.js", get(serve_sip_js))
608604
.with_state(state)
609605
.layer(ServiceBuilder::new().layer(CorsLayer::permissive()))
610606
}

src/transaction/endpoint.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct EndpointOption {
2828
pub t1: Duration,
2929
pub t4: Duration,
3030
pub t1x64: Duration,
31+
pub timerb: Duration,
3132
pub ignore_out_of_dialog_option: bool,
3233
pub callid_suffix: Option<String>,
3334
}
@@ -38,6 +39,7 @@ impl Default for EndpointOption {
3839
t1: Duration::from_millis(500),
3940
t4: Duration::from_secs(4),
4041
t1x64: Duration::from_millis(64 * 500),
42+
timerb: Duration::from_secs(64),
4143
ignore_out_of_dialog_option: true,
4244
callid_suffix: None,
4345
}

src/transaction/transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ impl Transaction {
673673
.take()
674674
.map(|id| self.endpoint_inner.timers.cancel(id));
675675
self.timer_b.replace(self.endpoint_inner.timers.timeout(
676-
self.endpoint_inner.option.t1x64,
676+
self.endpoint_inner.option.timerb,
677677
TransactionTimer::TimerB(self.key.clone()),
678678
));
679679
}
@@ -683,7 +683,7 @@ impl Transaction {
683683
.map(|id| self.endpoint_inner.timers.cancel(id));
684684
// start Timer B
685685
let timer_b = self.endpoint_inner.timers.timeout(
686-
self.endpoint_inner.option.t1x64,
686+
self.endpoint_inner.option.timerb,
687687
TransactionTimer::TimerB(self.key.clone()),
688688
);
689689
self.timer_b.replace(timer_b);

0 commit comments

Comments
 (0)