Skip to content

Commit 2c74264

Browse files
committed
fix: update version to 0.2.32 and fix missing ack for client invite
1 parent 4ce2336 commit 2c74264

File tree

3 files changed

+50
-50
lines changed

3 files changed

+50
-50
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rsipstack"
3-
version = "0.2.31"
3+
version = "0.2.32"
44
edition = "2021"
55
description = "SIP Stack Rust library for building SIP applications"
66
license = "MIT"

src/dialog/client_dialog.rs

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,23 @@ impl ClientInviteDialog {
453453
match msg {
454454
SipMessage::Request(_) => {}
455455
SipMessage::Response(resp) => {
456+
let branch = match tx
457+
.original
458+
.via_header()?
459+
.params()?
460+
.iter()
461+
.find(|p| matches!(p, rsip::Param::Branch(_)))
462+
{
463+
Some(p) => p.clone(),
464+
None => {
465+
info!(id=%self.id(),"no branch found in via header");
466+
return Err(crate::Error::DialogError(
467+
"no branch found in via header".to_string(),
468+
self.id(),
469+
));
470+
}
471+
};
472+
456473
match resp.status_code {
457474
StatusCode::Trying => {
458475
self.inner.transition(DialogState::Trying(self.id()))?;
@@ -463,6 +480,21 @@ impl ClientInviteDialog {
463480
continue;
464481
}
465482
StatusCode::ProxyAuthenticationRequired | StatusCode::Unauthorized => {
483+
let ack = self.inner.make_request(
484+
rsip::Method::Ack,
485+
resp.cseq_header()?.seq().ok(),
486+
None,
487+
Some(branch),
488+
None,
489+
None,
490+
)?;
491+
match tx.send_ack(ack).await {
492+
Ok(_) => {}
493+
Err(e) => {
494+
warn!("send ack error: {}", e);
495+
}
496+
}
497+
466498
if auth_sent {
467499
final_response = Some(resp.clone());
468500
info!(id=%self.id(),"received {} response after auth sent", resp.status_code);
@@ -500,42 +532,22 @@ impl ClientInviteDialog {
500532
None => {}
501533
}
502534

503-
// only send ACK if response is final (2xx)
504-
if matches!(resp.status_code, StatusCode::OK | StatusCode::Accepted) {
505-
let branch = match tx
506-
.original
507-
.via_header()?
508-
.params()?
509-
.iter()
510-
.find(|p| matches!(p, rsip::Param::Branch(_)))
511-
{
512-
Some(p) => p.clone(),
513-
None => {
514-
info!(id=%self.id(),"no branch found in via header");
515-
return Err(crate::Error::DialogError(
516-
"no branch found in via header".to_string(),
517-
self.id(),
518-
));
519-
}
520-
};
521-
522-
let ack = self.inner.make_request(
523-
rsip::Method::Ack,
524-
resp.cseq_header()?.seq().ok(),
525-
None,
526-
Some(branch),
527-
None,
528-
None,
529-
)?;
535+
let ack = self.inner.make_request(
536+
rsip::Method::Ack,
537+
resp.cseq_header()?.seq().ok(),
538+
None,
539+
Some(branch),
540+
None,
541+
None,
542+
)?;
530543

531-
if let Ok(id) = DialogId::try_from(&ack) {
532-
dialog_id = id;
533-
}
534-
match tx.send_ack(ack).await {
535-
Ok(_) => {}
536-
Err(e) => {
537-
warn!("send ack error: {}", e);
538-
}
544+
if let Ok(id) = DialogId::try_from(&ack) {
545+
dialog_id = id;
546+
}
547+
match tx.send_ack(ack).await {
548+
Ok(_) => {}
549+
Err(e) => {
550+
warn!("send ack error: {}", e);
539551
}
540552
}
541553

src/transaction/transaction.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,7 @@ impl Transaction {
313313
_ => TransactionState::Proceeding,
314314
},
315315
_ => match self.transaction_type {
316-
TransactionType::ServerInvite => {
317-
if response.status_code.kind() == rsip::StatusCodeKind::Successful {
318-
TransactionState::Completed
319-
} else {
320-
TransactionState::Terminated
321-
}
322-
}
316+
TransactionType::ServerInvite => TransactionState::Completed,
323317
_ => TransactionState::Terminated,
324318
},
325319
};
@@ -551,13 +545,7 @@ impl Transaction {
551545
}
552546
_ => {
553547
if self.transaction_type == TransactionType::ClientInvite {
554-
if self.original.method == rsip::Method::Invite
555-
&& resp.status_code.kind() == rsip::StatusCodeKind::Successful
556-
{
557-
TransactionState::Completed
558-
} else {
559-
TransactionState::Terminated
560-
}
548+
TransactionState::Completed
561549
} else {
562550
TransactionState::Terminated
563551
}

0 commit comments

Comments
 (0)