fix ipv6 udp and wisp-mux 2.0.2

This commit is contained in:
Toshit Chawda 2024-03-21 18:21:56 -07:00
parent 7583a9c3fd
commit 595af12cb7
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
5 changed files with 7 additions and 6 deletions

2
Cargo.lock generated
View file

@ -2421,7 +2421,7 @@ checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
[[package]] [[package]]
name = "wisp-mux" name = "wisp-mux"
version = "2.0.1" version = "2.0.2"
dependencies = [ dependencies = [
"async_io_stream", "async_io_stream",
"bytes", "bytes",

View file

@ -184,7 +184,8 @@ async fn handle_mux(packet: ConnectPacket, mut stream: MuxStream) -> Result<bool
.map_err(|x| WispError::Other(Box::new(x)))?; .map_err(|x| WispError::Other(Box::new(x)))?;
} }
StreamType::Udp => { StreamType::Udp => {
let udp_socket = UdpSocket::bind("0.0.0.0:0") let uri = lookup_host(uri).await.map_err(|x| WispError::Other(Box::new(x)))?.next().ok_or(WispError::InvalidUri)?;
let udp_socket = UdpSocket::bind(if uri.is_ipv4() { "0.0.0.0:0" } else { "[::]:0" })
.await .await
.map_err(|x| WispError::Other(Box::new(x)))?; .map_err(|x| WispError::Other(Box::new(x)))?;
udp_socket udp_socket

View file

@ -1,6 +1,6 @@
[package] [package]
name = "wisp-mux" name = "wisp-mux"
version = "2.0.1" version = "2.0.2"
license = "LGPL-3.0-only" license = "LGPL-3.0-only"
description = "A library for easily creating Wisp servers and clients." description = "A library for easily creating Wisp servers and clients."
homepage = "https://github.com/MercuryWorkshop/epoxy-tls/tree/multiplexed/wisp" homepage = "https://github.com/MercuryWorkshop/epoxy-tls/tree/multiplexed/wisp"

View file

@ -8,7 +8,7 @@ impl From<OpCode> for crate::ws::OpCode {
fn from(opcode: OpCode) -> Self { fn from(opcode: OpCode) -> Self {
use OpCode::*; use OpCode::*;
match opcode { match opcode {
Continuation => unreachable!(), Continuation => unreachable!("continuation should never be recieved when using a fragmentcollector"),
Text => Self::Text, Text => Self::Text,
Binary => Self::Binary, Binary => Self::Binary,
Close => Self::Close, Close => Self::Close,

View file

@ -255,7 +255,7 @@ impl<W: ws::WebSocketWrite> ServerMuxInner<W> {
} }
} }
} }
Continue(_) => unreachable!(), Continue(_) => break Err(WispError::InvalidPacketType),
Close(_) => { Close(_) => {
if let Some(mut stream) = if let Some(mut stream) =
self.stream_map.lock().await.remove(&packet.stream_id) self.stream_map.lock().await.remove(&packet.stream_id)
@ -421,7 +421,7 @@ impl<W: ws::WebSocketWrite> ClientMuxInner<W> {
use PacketType::*; use PacketType::*;
match packet.packet_type { match packet.packet_type {
Connect(_) => unreachable!(), Connect(_) => break Err(WispError::InvalidPacketType),
Data(data) => { Data(data) => {
if let Some(stream) = self.stream_map.lock().await.get(&packet.stream_id) { if let Some(stream) = self.stream_map.lock().await.get(&packet.stream_id) {
let _ = stream.stream.unbounded_send(data); let _ = stream.stream.unbounded_send(data);