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

transports/tcp: only translate tcp addresses #2970

Merged
merged 6 commits into from
Oct 4, 2022

Conversation

elenaf9
Copy link
Contributor

@elenaf9 elenaf9 commented Oct 3, 2022

Description

Return None in in <GenTcpTransport as Transport>::address_translation if the address is not a tcp address.
Relevant if in case of something like OrTransport<TcpTransport, QuicTransport>, where tcp would currently perform the address translation for quic addresses.
Raise by @mxinden for quic in #2289 (comment), so I think the same should also be applied for the tcp transport.

Change checklist

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +1271 to +1273
let tcp_listen_addr = Multiaddr::empty()
.with(Protocol::Ip4(Ipv4Addr::new(127, 0, 0, 1)))
.with(Protocol::Tcp(port));
Copy link
Contributor

Choose a reason for hiding this comment

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

I always find these easier to read if we parse them from a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer using types where possible, avoiding any unwraps that would be needed when parsing from string :)

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Thank you for the fix @elenaf9!

@mxinden mxinden merged commit 4577c5a into libp2p:master Oct 4, 2022
@elenaf9 elenaf9 deleted the tcp/fix-address-translation branch October 4, 2022 19:53
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

Successfully merging this pull request may close these issues.

3 participants