Skip to content

Commit

Permalink
remove socket_addrs to SocketAddr repeatation
Browse files Browse the repository at this point in the history
  • Loading branch information
radioactiveAHM committed Sep 20, 2024
1 parent 908731f commit 006256f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/doh3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ async fn client_noise(addr: SocketAddr, target: SocketAddr, noise: Noise)->quinn
}

pub async fn http3(server_name: String, socket_addrs: &str, udp_socket_addrs: &str, quic_conf_file: crate::config::Quic, noise: Noise) {
let socketddrs = SocketAddr::from_str(socket_addrs).unwrap();

let qaddress = {
if SocketAddr::from_str(socket_addrs).unwrap().is_ipv4() {
if socketddrs.is_ipv4() {
SocketAddr::from_str("0.0.0.0:0").unwrap()
}else if SocketAddr::from_str(socket_addrs).unwrap().is_ipv6() {
}else if socketddrs.is_ipv6() {
SocketAddr::from_str("[::]:0").unwrap()
} else {
panic!()
Expand All @@ -58,7 +60,7 @@ pub async fn http3(server_name: String, socket_addrs: &str, udp_socket_addrs: &s
// UDP socket as endpoint for quic
let mut endpoint = {
if noise.enable {
client_noise(qaddress, SocketAddr::from_str(socket_addrs).unwrap(), noise).await
client_noise(qaddress, socketddrs, noise).await
}else {
quinn::Endpoint::client(qaddress).unwrap()
}
Expand All @@ -70,7 +72,7 @@ pub async fn http3(server_name: String, socket_addrs: &str, udp_socket_addrs: &s
loop {
println!("QUIC Connecting");
// Connect to dns server
let connecting = endpoint.connect(SocketAddr::from_str(socket_addrs).unwrap(), server_name.as_str()).unwrap();
let connecting = endpoint.connect(socketddrs, server_name.as_str()).unwrap();

let conn = {
let connecting = connecting.into_0rtt();
Expand Down

0 comments on commit 006256f

Please sign in to comment.