Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[workspace]
resolver = "2"

members = ["stun-agent",
"stun-agent",
"stun-rs",
"stun-vectors",
]
members = ["stun-agent", "stun-rs", "stun-vectors"]
2 changes: 1 addition & 1 deletion stun-agent/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct TransactionEventHandler {
}

impl TransactionEventHandler {
pub fn init(&mut self) -> TransactionEvents {
pub fn init(&mut self) -> TransactionEvents<'_> {
TransactionEvents {
handler: self,
events: Vec::new(),
Expand Down
13 changes: 1 addition & 12 deletions stun-agent/src/rtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ const BETA: f32 = 0.25; // (1/4)

pub const DEFAULT_GRANULARITY: Duration = Duration::from_millis(1);

// TODO: Remove this hack once duration_abs_diff
// [#117618](https://github.com/rust-lang/rust/issues/117618)
// was not nightly
fn abs_diff(a: Duration, b: Duration) -> Duration {
if a > b {
a - b
} else {
b - a
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RttCalcuator {
rto: Duration,
Expand Down Expand Up @@ -70,7 +59,7 @@ impl RttCalcuator {
);
} else {
// Subsequent RTT measurements
self.rttvar = self.rttvar.mul_f32(1.0 - BETA) + abs_diff(self.srtt, r).mul_f32(BETA);
self.rttvar = self.rttvar.mul_f32(1.0 - BETA) + self.srtt.abs_diff(r).mul_f32(BETA);
self.srtt = self.srtt.mul_f32(1.0 - ALPHA) + r.mul_f32(ALPHA);
self.rto = self.srtt + cmp::max(self.granularity, self.rttvar.mul_f32(K as f32));
trace!(
Expand Down
24 changes: 12 additions & 12 deletions stun-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ license = "MIT/Apache-2.0"
categories = ["network-programming"]
edition = "2021"

[dev-dependencies]
stun-vectors = { path = "../stun-vectors" }
[package.metadata.docs.rs]
all-features = true

[features]
default = []
discovery = []
experiments = []
ice = []
mobility = []
turn = []

[dependencies]
base64 = "0.22.0"
Expand All @@ -33,13 +41,5 @@ precis-profiles = "0.1.12"
quoted-string-parser = "0.1.0"
rand = "0.9.0"

[features]
default = []
experiments = []
ice = []
turn = []
mobility = []
discovery = []

[package.metadata.docs.rs]
all-features = true
[dev-dependencies]
stun-vectors = { path = "../stun-vectors" }
10 changes: 5 additions & 5 deletions stun-rs/src/attributes/turn/requested_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ impl RequestedTrasport {
/// Creates a new attribute.
/// # Arguments:
/// - `protocol`- The protocol specifies the desired protocol. The code points
/// used in this field are taken from those allowed in the Protocol
/// field in the IPv4 header and the Next Header field in the IPv6
/// header [PROTOCOL-NUMBERS](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml).
/// This specification only allows the use of code point 17
/// (User Datagram Protocol).
/// used in this field are taken from those allowed in the Protocol
/// field in the IPv4 header and the Next Header field in the IPv6
/// header [PROTOCOL-NUMBERS](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml).
/// This specification only allows the use of code point 17
/// (User Datagram Protocol).
pub fn new(protocol: ProtocolNumber) -> Self {
Self(protocol)
}
Expand Down
22 changes: 11 additions & 11 deletions stun-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,20 @@
//! # Common features
//! This crate defines next feature flags that can be enabled:
//! * **turn**: Extends support for parsing attributes defined in
//! [`RFC8656`](https://datatracker.ietf.org/doc/html/rfc8656).
//! Traversal Using Relays around NAT (TURN).
//! [`RFC8656`](https://datatracker.ietf.org/doc/html/rfc8656).
//! Traversal Using Relays around NAT (TURN).
//! * **ice**: Extends support for parsing attributes defined in
//! [`RFC8445`](https://datatracker.ietf.org/doc/html/rfc8445).
//! Interactive Connectivity Establishment (ICE).
//! [`RFC8445`](https://datatracker.ietf.org/doc/html/rfc8445).
//! Interactive Connectivity Establishment (ICE).
//! * **mobility**: Extends support for parsing attributes defined in
//! [`RFC8016`](https://datatracker.ietf.org/doc/html/rfc8016).
//! Mobility with Traversal Using Relays around NAT (TURN).
//! [`RFC8016`](https://datatracker.ietf.org/doc/html/rfc8016).
//! Mobility with Traversal Using Relays around NAT (TURN).
//! * **experiments**: This flag can be set to adjust some behavior
//! of the library, such as default padding. When testing protocols,
//! we can use this flag to force the library to keep the data
//! associated with [Unknown](crate::attributes::Unknown) attributes.
//! By default, [Unknown](crate::attributes::Unknown) attributes
//! store no data to save memory consumption.
//! of the library, such as default padding. When testing protocols,
//! we can use this flag to force the library to keep the data
//! associated with [Unknown](crate::attributes::Unknown) attributes.
//! By default, [Unknown](crate::attributes::Unknown) attributes
//! store no data to save memory consumption.

#![deny(missing_docs)]

Expand Down
6 changes: 3 additions & 3 deletions stun-rs/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ impl HMACKey {
/// - `username` - The user name
/// - `realm` - The realm.
/// - `algorithm`- Optional value for the algorithm used to generate the key. If
/// algorithm is None, [`AlgorithmId::MD5`](crate::AlgorithmId::MD5) will be used.
/// The resulting key length is 16 bytes when `MD5` is used, or 32 bytes if
/// SHA-256 algorithm is used.
/// algorithm is None, [`AlgorithmId::MD5`](crate::AlgorithmId::MD5) will be used.
/// The resulting key length is 16 bytes when `MD5` is used, or 32 bytes if
/// SHA-256 algorithm is used.
/// # Returns
/// The new [`HMACKey`] used for long term credential mechanism, or a `StunError` if
/// `username`, `realm` or `password` can not be processed using the opaque string profile.
Expand Down