Skip to content

Commit

Permalink
Don't use DNS in server::Builder::listen
Browse files Browse the repository at this point in the history
DNS doesn't make sense when specifying a local address.
  • Loading branch information
Ralith authored and stammw committed Apr 2, 2020
1 parent 3a71f05 commit 2e49daa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion quinn-h3/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl Context {
PORTS.lock().unwrap().next().unwrap(),
);
let mut server = self.server_config.clone();
server.listen(addr).unwrap();
server.listen(addr);
debug!("server bind");
let handle = thread::spawn(move || {
let my_span = span!(Level::TRACE, "server");
Expand Down
15 changes: 5 additions & 10 deletions quinn-h3/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{
future::Future,
io, mem,
net::{SocketAddr, ToSocketAddrs},
mem,
net::SocketAddr,
pin::Pin,
task::{Context, Poll},
};
Expand Down Expand Up @@ -58,14 +58,9 @@ impl Builder {
}
}

pub fn listen<S: ToSocketAddrs>(&mut self, socket: S) -> Result<&mut Self, io::Error> {
self.listen = Some(
socket
.to_socket_addrs()?
.next()
.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "no socket found"))?,
);
Ok(self)
pub fn listen(&mut self, addr: SocketAddr) -> &mut Self {
self.listen = Some(addr);
self
}

pub fn certificate(
Expand Down
4 changes: 1 addition & 3 deletions quinn-h3/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ impl Helper {
let Certs { chain, key, cert } = CERTS.clone();
let mut server = server::Builder::default();
server.certificate(chain, key).expect("server certs");
server
.listen(SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), port))
.unwrap();
server.listen(SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), port));

let mut client = client::Builder::default();
client.add_certificate_authority(cert.clone()).unwrap();
Expand Down

0 comments on commit 2e49daa

Please sign in to comment.