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

Can't get local address of AddrStream #2773

Closed
lilyball opened this issue Mar 11, 2022 · 0 comments
Closed

Can't get local address of AddrStream #2773

lilyball opened this issue Mar 11, 2022 · 0 comments
Labels
C-bug Category: bug. Something is wrong. This is bad!

Comments

@lilyball
Copy link

Version
hyper v0.14.17

Description
AddrStream offers a remote_addr() method that returns the remote (peer) address of the connection. But there's no equivalent local_addr() method. TcpStream has such a method, but the only way to get that from AddrStream is AddrStream::to_inner() that consumes the AddrStream entirely (which is to say, there's no as_inner() method to get a reference).

This is really frustrating because I want to log the local IP address on incoming connections (I'm listening on 0.0.0.0 and I want to know which interface the connection is coming in on). So I either need an AddrStream::local_addr() method or I need an AddrStream::as_inner() method1 that I can then use to call TcpStream::local_addr().

Footnotes

  1. Or maybe an <AddrStream as AsRef<TcpStream>> impl.

@lilyball lilyball added the C-bug Category: bug. Something is wrong. This is bad! label Mar 11, 2022
ilyatrefilov added a commit to ilyatrefilov/hyper that referenced this issue Apr 20, 2022
Expose local address of tcp connection in AddrStream for the purpose
mentioned in hyperium#2773.
ilyatrefilov added a commit to ilyatrefilov/hyper that referenced this issue Apr 20, 2022
Expose local address of tcp connection in AddrStream for the purpose
mentioned in hyperium#2773.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug. Something is wrong. This is bad!
Projects
None yet
Development

No branches or pull requests

1 participant