mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-10 01:30:07 +03:00
all: imp chlog; dry; fix races
This commit is contained in:
parent
e4a42bf233
commit
d42d1a7ea4
3 changed files with 30 additions and 12 deletions
internal/home
|
@ -320,14 +320,26 @@ func handleHTTPSRedirect(w http.ResponseWriter, r *http.Request) (ok bool) {
|
|||
return false
|
||||
}
|
||||
|
||||
// Let the browser know that server support HTTP/3
|
||||
// max-age is set to default (24 hourd)
|
||||
var serveHTTP3 bool
|
||||
var portHTTPS int
|
||||
func() {
|
||||
config.RLock()
|
||||
defer config.RUnlock()
|
||||
|
||||
serveHTTP3, portHTTPS = config.DNS.ServeHTTP3, config.TLS.PortHTTPS
|
||||
}()
|
||||
|
||||
respHdr := w.Header()
|
||||
|
||||
// Let the browser know that server supports HTTP/3.
|
||||
//
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Alt-Svc
|
||||
// TODO: take max-age from config and set
|
||||
if config.DNS.ServeHTTP3 {
|
||||
altSvc := fmt.Sprintf(`h3=":%[1]v";`, config.TLS.PortHTTPS)
|
||||
w.Header().Set("Alt-Svc", altSvc)
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Alt-Svc.
|
||||
//
|
||||
// TODO(a.garipov): Consider adding a configurable max-age. Currently, the
|
||||
// default is 24 hours.
|
||||
if serveHTTP3 {
|
||||
altSvc := fmt.Sprintf(`h3=":%d"`, portHTTPS)
|
||||
respHdr.Set(aghhttp.HdrNameAltSvc, altSvc)
|
||||
}
|
||||
|
||||
if r.TLS == nil && web.forceHTTPS {
|
||||
|
@ -357,8 +369,8 @@ func handleHTTPSRedirect(w http.ResponseWriter, r *http.Request) (ok bool) {
|
|||
Host: r.Host,
|
||||
}
|
||||
|
||||
w.Header().Set("Access-Control-Allow-Origin", originURL.String())
|
||||
w.Header().Set("Vary", "Origin")
|
||||
respHdr.Set(aghhttp.HdrNameAccessControlAllowOrigin, originURL.String())
|
||||
respHdr.Set(aghhttp.HdrNameVary, aghhttp.HdrNameOrigin)
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue