-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QUIC transport + API changes #48
Conversation
Current dependencies on/for this PR: This stack of pull requests is managed by Graphite. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful
/// A joinset of authentication tasks. | ||
pub(super) auth_tasks: JoinSet<Result<AuthResult<T::Io>, PubError>>, | ||
/// The receiver end of the message broadcast channel. The sender half is stored by [`PubSocket`](super::PubSocket). | ||
pub(super) from_socket_bcast: broadcast::Receiver<PubMessage>, | ||
} | ||
|
||
impl<T: ServerTransport> Future for PubDriver<T> { | ||
impl<T> Future for PubDriver<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this impl is a lot cleaner, love it 🚀
// Take the transport here, so we can move it into the backend task | ||
let mut transport = self.transport.take().unwrap(); | ||
|
||
pub async fn bind(&mut self, addr: SocketAddr) -> Result<(), PubError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: what do you think of following the tokio convention of using the generic ToSocketAddrs
trait?
It's the one used in TcpStream::connect:
pub async fn connect<A: ToSocketAddrs>(addr: A) -> io::Result<TcpStream> {
let addrs = to_socket_addrs(addr).await?;
let mut last_err = None;
for addr in addrs {
match TcpStream::connect_addr(addr).await {
Ok(stream) => return Ok(stream),
Err(e) => last_err = Some(e),
}
}
// ...
the cool thing is that it automatically resolves dns names which is something we need to do manually right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was also thinking about this, will make issue w.r.t. QoL improvements
// Some transport implementations (e.g. Quinn) can't dial an unspecified IP address, so replace | ||
// it with localhost. | ||
if endpoint.ip().is_unspecified() { | ||
// TODO: support IPv6 | ||
endpoint.set_ip(IpAddr::V4(Ipv4Addr::LOCALHOST)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this work in a real network environment?
layer_stack: Option<Box<dyn Layer<Io> + Send>>, | ||
should_reconnect: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
layer_stack: Option<Box<dyn Layer<Io> + Send>>, | |
should_reconnect: bool, | |
layer_stack: Option<Box<dyn Layer<Io> + Send>>, | |
/// If the session should be reconnected upon an unexpected disconnection | |
should_reconnect: bool, |
match Pin::new(&mut *self.get_mut().inner).poll_accept(cx) { | ||
Poll::Ready(mut accept) => match accept.poll_unpin(cx) { | ||
Poll::Ready(Ok(output)) => Poll::Ready(Ok(output)), | ||
Poll::Ready(Err(e)) => Poll::Ready(Err(e)), | ||
Poll::Pending => Poll::Pending, | ||
}, | ||
Poll::Pending => Poll::Pending, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
match Pin::new(&mut *self.get_mut().inner).poll_accept(cx) { | |
Poll::Ready(mut accept) => match accept.poll_unpin(cx) { | |
Poll::Ready(Ok(output)) => Poll::Ready(Ok(output)), | |
Poll::Ready(Err(e)) => Poll::Ready(Err(e)), | |
Poll::Pending => Poll::Pending, | |
}, | |
Poll::Pending => Poll::Pending, | |
} | |
match Pin::new(&mut *self.get_mut().inner).poll_accept(cx) { | |
Poll::Ready(mut accept) => accept.poll_unpin(cx), | |
Poll::Pending => Poll::Pending, | |
} |
} | ||
|
||
/// Creates a new [`quinn::Endpoint`] with the given configuration and a Tokio runtime. If no `addr` is given, | ||
/// the endpoint will be bound to the default address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// the endpoint will be bound to the default address. | |
/// the endpoint will be bound to the unspecified address. |
fn accept(&mut self) -> crate::Acceptor<'_, Self> | ||
where | ||
Self: Sized + Unpin, | ||
{ | ||
Acceptor::new(self) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default impl can be omitted (at your preference)
fn accept(&mut self) -> crate::Acceptor<'_, Self> | |
where | |
Self: Sized + Unpin, | |
{ | |
Acceptor::new(self) | |
} |
Merge activity
|
refactor(transport): extract TCP transport to module
refactor: rework socket interface with generic transport
wip: quic
Closes #44