- Uses certificate and key files provided by admin in config - Let's Encrypt integration planned, but not even close to working - Initial HTTP3 Support added
This commit is contained in:
parent
68d7a5e8c3
commit
9151bfb3be
6 changed files with 250 additions and 42 deletions
40
web/public/middleware/httpUpgrade.go
Normal file
40
web/public/middleware/httpUpgrade.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package webmiddleware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/config"
|
||||
)
|
||||
|
||||
func AddUpgradeHeader(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.ProtoMajor {
|
||||
case 1:
|
||||
// Always offer upgrade to http2
|
||||
headerText := fmt.Sprintf(
|
||||
"h2=\":%d\"; ma=3600",
|
||||
config.GlobalConfig.General.GetFinalPublicPort(),
|
||||
)
|
||||
// Offer upgrade to http3 if enabled
|
||||
if config.GlobalConfig.Experimental.Http3Support && config.GlobalConfig.SSL.HandleSSL {
|
||||
headerText = fmt.Sprintf(
|
||||
"h3=\":%d\"; ma=3600, %s",
|
||||
config.GlobalConfig.General.GetFinalPublicPort(),
|
||||
headerText,
|
||||
)
|
||||
}
|
||||
w.Header().Add("Alt-Svc", headerText)
|
||||
case 2:
|
||||
// Offer upgrade to http3 if enabled
|
||||
if config.GlobalConfig.Experimental.Http3Support && config.GlobalConfig.SSL.HandleSSL {
|
||||
headerText := fmt.Sprintf(
|
||||
"h3=\":%d\"; ma=3600",
|
||||
config.GlobalConfig.General.GetFinalPublicPort(),
|
||||
)
|
||||
w.Header().Add("Alt-Svc", headerText)
|
||||
}
|
||||
}
|
||||
h.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue