-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow use of custom port value in Alt-Svc header. #3272
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
http3/server.go
Outdated
@@ -530,7 +548,8 @@ func ListenAndServe(addr, certFile, keyFile string, handler http.Handler) error | |||
} | |||
|
|||
quicServer := &Server{ | |||
Server: httpServer, | |||
Server: httpServer, | |||
customAltSvcPort: customAltSvcPort, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another possible way to do this would be to just set Server.port
to customAltSvcPort
here, and then SetQuicHeaders
would find port
is always having a non-zero value. Open to suggestions of what you think is the best way to do this. :)
http3/server.go
Outdated
// customAltSvcPort is used to override the default port value in the Alt-Svc response header. | ||
// This is useful when a Layer 4 firewall is redirecting UDP traffic and clients must use | ||
// a port different from the port the QUIC server itself is listening on. | ||
func ListenAndServeWithCustomAltSvcPort(addr, certFile, keyFile string, handler http.Handler, customAltSvcPort uint32) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need an extra function here. Users who need to change the port should just initialize an http3.Server.
.
example/main.go
Outdated
err = http3.ListenAndServeWithCustomAltSvcPort(bCap, certFile, keyFile, handler, uint32(*customAltSvcPort)) | ||
} else { | ||
err = http3.ListenAndServe(bCap, certFile, keyFile, handler) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is important enough to warrant complicating the example.
http3/server.go
Outdated
@@ -92,7 +92,8 @@ type Server struct { | |||
// See https://www.ietf.org/archive/id/draft-schinazi-masque-h3-datagram-02.html. | |||
EnableDatagrams bool | |||
|
|||
port uint32 // used atomically | |||
port uint32 // used atomically | |||
customAltSvcPort uint32 // custom port used for Alt-Svc response header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be fine just to export port
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good now. Can we have a test case please?
Codecov Report
@@ Coverage Diff @@
## master #3272 +/- ##
==========================================
+ Coverage 85.48% 85.69% +0.21%
==========================================
Files 132 132
Lines 9799 9775 -24
==========================================
Hits 8376 8376
+ Misses 1048 1024 -24
Partials 375 375
Continue to review full report at Codecov.
|
I disabled the |
Thank you @marten-seemann :) |
Fixes #3262