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

ProxyProtocolAcceptorFuture impl compatibility issue #20

Open
ii64 opened this issue Nov 23, 2024 · 4 comments
Open

ProxyProtocolAcceptorFuture impl compatibility issue #20

ii64 opened this issue Nov 23, 2024 · 4 comments

Comments

@ii64
Copy link

ii64 commented Nov 23, 2024

I'd like to use ProxyProtocolAcceptor to wrap a tokio TcpListener but it seems that this is not supported yet?
hyper-server = { version = "0.6.0", features = ["proxy-protocol"] }

   Compiling hyper-server v0.6.0
error[E0308]: mismatched types
   --> /home/ii64/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-server-0.6.0/src/proxy_protocol/mod.rs:333:13
    |
332 |         ProxyProtocolAcceptorFuture::new(
    |         -------------------------------- arguments to this function are incorrect
333 |             timeout(self.parsing_timeout, future),
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `dyn futures_util::Future`, found future
    |
    = note: expected struct `tokio::time::Timeout<Pin<Box<dyn futures_util::Future<Output = Result<(I, Option<std::net::SocketAddr>), std::io::Error>> + Send>>>`
               found struct `tokio::time::Timeout<Pin<Box<impl futures_util::Future<Output = Result<(I, Option<std::net::SocketAddr>), std::io::Error>>>>>`
    = help: you can box the `impl futures_util::Future<Output = Result<(I, Option<std::net::SocketAddr>), std::io::Error>>` to coerce it to `Box<dyn futures_util::Future<Output = Result<(I, Option<std::net::SocketAddr>), std::io::Error>> + Send>`, but you'll have to change the expected type as well
note: associated function defined here
   --> /home/ii64/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hyper-server-0.6.0/src/proxy_protocol/future.rs:40:19
    |
40  |     pub(crate) fn new(future: Timeout<F>, acceptor: A, service: S) -> Self {
    |                   ^^^ ------------------

For more information about this error, try `rustc --explain E0308`.
error: could not compile `hyper-server` (lib) due to 1 previous error
@ii64
Copy link
Author

ii64 commented Nov 23, 2024

This fixed the issue:

    fn accept(&self, stream: I, service: S) -> Self::Future {
        let future = Box::pin(read_proxy_header(stream));
        
        ProxyProtocolAcceptorFuture::new(
            timeout(self.parsing_timeout, future.boxed()),
            self.inner.clone(),
            service,
        )
    }

@ii64
Copy link
Author

ii64 commented Nov 23, 2024

Also I noticed that this proxy protocol feature removed from 0.7.0. I do wonder why it is removed.

@0xAlcibiades
Copy link
Member

It's likely going to come back in, was just re-working the entire server stack to be more modular.

@0xAlcibiades
Copy link
Member

@ii64 if you wanted to PR proxy protocol support back in that'd be great under the feature flag proxy-protocol, if not, will likely approach some time before the 0.7.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants