Skip to content

Commit 39f5d83

Browse files
committed
agent: don't always send TCP with framing
Some usages of stun don't have any framing applied at all and the decision for framing should be decided by the calling code.
1 parent 2f30a74 commit 39f5d83

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

stun-proto/src/agent.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,7 @@ pub enum StunAgentPollRet<'a> {
350350
}
351351

352352
fn send_data(transport: TransportType, bytes: &[u8], from: SocketAddr, to: SocketAddr) -> Transmit {
353-
match transport {
354-
TransportType::Udp => Transmit::new(bytes, transport, from, to),
355-
TransportType::Tcp => {
356-
let mut data = Vec::with_capacity(bytes.len() + 2);
357-
data.resize(2, 0);
358-
BigEndian::write_u16(&mut data, bytes.len() as u16);
359-
data.extend(bytes);
360-
Transmit::new_owned(data.into_boxed_slice(), transport, from, to)
361-
}
362-
}
353+
Transmit::new(bytes, transport, from, to)
363354
}
364355

365356
/// A buffer object for handling STUN data received over a TCP connection that requires framing as
@@ -1181,7 +1172,7 @@ pub(crate) mod tests {
11811172
assert_eq!(transmit.from, local_addr);
11821173
assert_eq!(transmit.to, remote_addr);
11831174

1184-
let request = Message::from_bytes(&transmit.data[2..]).unwrap();
1175+
let request = Message::from_bytes(&transmit.data).unwrap();
11851176
assert_eq!(request.transaction_id(), transaction_id);
11861177
}
11871178

0 commit comments

Comments
 (0)