Skip to content
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

Merged
merged 39 commits into from
Jan 18, 2024
Merged

QUIC transport + API changes #48

merged 39 commits into from
Jan 18, 2024

Conversation

mempirate
Copy link
Contributor

@mempirate mempirate commented Dec 20, 2023

refactor(transport): extract TCP transport to module

refactor: rework socket interface with generic transport

wip: quic

Closes #44

@mempirate
Copy link
Contributor Author

mempirate commented Dec 20, 2023

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@merklefruit merklefruit added C-feature Category: Feature A-transport Area: Transports labels Dec 26, 2023
@mempirate mempirate marked this pull request as ready for review January 4, 2024 10:24
Copy link
Contributor

@merklefruit merklefruit left a 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>
Copy link
Contributor

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> {
Copy link
Contributor

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

Copy link
Contributor Author

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

Comment on lines +163 to +168
// 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));
}
Copy link
Contributor

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?

Comment on lines 266 to +267
layer_stack: Option<Box<dyn Layer<Io> + Send>>,
should_reconnect: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,

Comment on lines +78 to 85
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,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// the endpoint will be bound to the default address.
/// the endpoint will be bound to the unspecified address.

Comment on lines +220 to +225
fn accept(&mut self) -> crate::Acceptor<'_, Self>
where
Self: Sized + Unpin,
{
Acceptor::new(self)
}
Copy link
Contributor

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)

Suggested change
fn accept(&mut self) -> crate::Acceptor<'_, Self>
where
Self: Sized + Unpin,
{
Acceptor::new(self)
}

Copy link
Contributor Author

mempirate commented Jan 18, 2024

Merge activity

@mempirate mempirate merged commit 60d569b into main Jan 18, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transport Area: Transports C-feature Category: Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: QUIC transport
2 participants