Use HMAC_SHA1_LEN and MAGIC_COOKIE_BYTES in smoke clients; remove unused import

This commit is contained in:
ghost 2025-09-26 16:23:45 +02:00
parent 8363217c96
commit cd2462915a
2 changed files with 13 additions and 13 deletions

View File

@ -1,6 +1,6 @@
use bytes::BytesMut;
use niom_turn::constants::*;
use niom_turn::stun;
// use niom_turn::stun; // not needed; use specific functions via path when required
use std::net::SocketAddr;
use tokio::net::UdpSocket;
use std::time::Duration;
@ -20,7 +20,7 @@ async fn main() -> anyhow::Result<()> {
let mut buf = BytesMut::new();
buf.extend_from_slice(&METHOD_ALLOCATE.to_be_bytes()); // Allocate Request
buf.extend_from_slice(&0u16.to_be_bytes()); // length placeholder
buf.extend_from_slice(&MAGIC_COOKIE_U32.to_be_bytes());
buf.extend_from_slice(&MAGIC_COOKIE_BYTES);
let trans = [13u8; 12];
buf.extend_from_slice(&trans);
@ -34,7 +34,7 @@ async fn main() -> anyhow::Result<()> {
// MESSAGE-INTEGRITY placeholder
let mi_attr_offset = buf.len();
buf.extend_from_slice(&ATTR_MESSAGE_INTEGRITY.to_be_bytes());
buf.extend_from_slice(&(20u16).to_be_bytes());
buf.extend_from_slice(&((HMAC_SHA1_LEN as u16).to_be_bytes()));
let mi_val_pos = buf.len();
buf.extend_from_slice(&[0u8;20]);
while (buf.len() % 4) != 0 { buf.extend_from_slice(&[0u8]); }

View File

@ -16,7 +16,7 @@ async fn main() -> anyhow::Result<()> {
let mut buf = BytesMut::new();
buf.extend_from_slice(&METHOD_BINDING.to_be_bytes()); // Binding Request
buf.extend_from_slice(&0u16.to_be_bytes()); // length placeholder
buf.extend_from_slice(&MAGIC_COOKIE_U32.to_be_bytes());
buf.extend_from_slice(&MAGIC_COOKIE_BYTES);
let trans = [7u8; 12];
buf.extend_from_slice(&trans);
@ -30,7 +30,7 @@ async fn main() -> anyhow::Result<()> {
// MESSAGE-INTEGRITY placeholder
let mi_attr_offset = buf.len();
buf.extend_from_slice(&ATTR_MESSAGE_INTEGRITY.to_be_bytes());
buf.extend_from_slice(&(20u16).to_be_bytes());
buf.extend_from_slice(&((HMAC_SHA1_LEN as u16).to_be_bytes()));
let mi_val_pos = buf.len();
buf.extend_from_slice(&[0u8;20]);
while (buf.len() % 4) != 0 { buf.extend_from_slice(&[0u8]); }