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

webtransport: add custom resolver to add SNI #1761

Merged
merged 4 commits into from
Sep 20, 2022

Conversation

MarcoPolo
Copy link
Collaborator

The continuation of #1719 for webtransport. Fixes #1760

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

Mostly nits.

p2p/transport/webtransport/listener.go Outdated Show resolved Hide resolved
}
return true
})
return sni, foundSniComponent
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
return sni, foundSniComponent
return

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I know we can do this, but I'm generally not a fan. Do you feel strongly?

Copy link
Contributor

Choose a reason for hiding this comment

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

No strong feelings. I usually prefer the naked return when using the variables from the function the function signature, but I'm not sure if that's an actual Go convention.

Copy link
Collaborator Author

@MarcoPolo MarcoPolo Sep 19, 2022

Choose a reason for hiding this comment

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

https://dave.cheney.net/practical-go/presentations/gophercon-israel.html#_avoid_naked_returns

And yes, I know the section right before discourages named return values. I think it's better to keep them so I can reference them in the comment so it's clear from the signature. Maybe returning a struct would be better?

This probably isn't worth the bike-shedding.

// foundSniComponent will be true. If there's no SNI component, but there is a
// DNS-like compoent, then that will be returned for the sni and
// foundSniComponent will be false (since we didn't find an actual sni component).
func extractSNI(maddr ma.Multiaddr) (sni string, foundSniComponent bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the bool here? Would an empty string be sufficient? As far as I know, there's no way to distinguish between empty string and unset in the TLS ClientHello: https://github.com/golang/go/blob/d74bf73be052851e83fb59a40f47d49f4b890ca3/src/crypto/tls/handshake_messages.go#L124-L135.

I think the more idiomatic variable name for the bool would be ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did you read the comment? I know this is a bit confusing and I was hoping the comment would explain it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not carefully enough, apparently ;)

p2p/transport/webtransport/transport.go Show resolved Hide resolved
p2p/transport/webtransport/transport.go Outdated Show resolved Hide resolved
p2p/transport/webtransport/transport.go Outdated Show resolved Hide resolved
p2p/transport/webtransport/transport.go Outdated Show resolved Hide resolved
@marten-seemann marten-seemann changed the title Add custom resolver to webtransport to add SNI webtransport: add custom resolver to add SNI Sep 19, 2022
@MarcoPolo MarcoPolo merged commit 0788ccd into master Sep 20, 2022
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.

Add resolver to WebTransport transport
2 participants