all: imp chlog; dry; fix races
This commit is contained in:
parent
e4a42bf233
commit
d42d1a7ea4
|
@ -10,10 +10,7 @@ and this project adheres to
|
||||||
|
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Fixed
|
|
||||||
- Web UI HTTP/3 not working [#4986]
|
|
||||||
|
|
||||||
[#4986]: https://github.com/AdguardTeam/AdGuardHome/issues/4986
|
|
||||||
<!--
|
<!--
|
||||||
## [v0.108.0] - TBA (APPROX.)
|
## [v0.108.0] - TBA (APPROX.)
|
||||||
-->
|
-->
|
||||||
|
@ -24,7 +21,13 @@ and this project adheres to
|
||||||
opposed to URL paths ([#3418]). Note that AdGuard Home checks the server name
|
opposed to URL paths ([#3418]). Note that AdGuard Home checks the server name
|
||||||
only if the URL does not contain a ClientID.
|
only if the URL does not contain a ClientID.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Web UI not switching to HTTP/3 ([#4986], [#4993]).
|
||||||
|
|
||||||
[#3418]: https://github.com/AdguardTeam/AdGuardHome/issues/3418
|
[#3418]: https://github.com/AdguardTeam/AdGuardHome/issues/3418
|
||||||
|
[#4986]: https://github.com/AdguardTeam/AdGuardHome/issues/4986
|
||||||
|
[#4993]: https://github.com/AdguardTeam/AdGuardHome/issues/4993
|
||||||
|
|
||||||
[clientid]: https://github.com/AdguardTeam/AdGuardHome/wiki/Clients#clientid
|
[clientid]: https://github.com/AdguardTeam/AdGuardHome/wiki/Clients#clientid
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,14 @@ package aghhttp
|
||||||
const (
|
const (
|
||||||
HdrNameAcceptEncoding = "Accept-Encoding"
|
HdrNameAcceptEncoding = "Accept-Encoding"
|
||||||
HdrNameAccessControlAllowOrigin = "Access-Control-Allow-Origin"
|
HdrNameAccessControlAllowOrigin = "Access-Control-Allow-Origin"
|
||||||
|
HdrNameAltSvc = "Alt-Svc"
|
||||||
HdrNameContentEncoding = "Content-Encoding"
|
HdrNameContentEncoding = "Content-Encoding"
|
||||||
HdrNameContentType = "Content-Type"
|
HdrNameContentType = "Content-Type"
|
||||||
|
HdrNameOrigin = "Origin"
|
||||||
HdrNameServer = "Server"
|
HdrNameServer = "Server"
|
||||||
HdrNameTrailer = "Trailer"
|
HdrNameTrailer = "Trailer"
|
||||||
HdrNameUserAgent = "User-Agent"
|
HdrNameUserAgent = "User-Agent"
|
||||||
|
HdrNameVary = "Vary"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTTP header value constants.
|
// HTTP header value constants.
|
||||||
|
|
|
@ -320,14 +320,26 @@ func handleHTTPSRedirect(w http.ResponseWriter, r *http.Request) (ok bool) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the browser know that server support HTTP/3
|
var serveHTTP3 bool
|
||||||
// max-age is set to default (24 hourd)
|
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
|
// 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 {
|
// TODO(a.garipov): Consider adding a configurable max-age. Currently, the
|
||||||
altSvc := fmt.Sprintf(`h3=":%[1]v";`, config.TLS.PortHTTPS)
|
// default is 24 hours.
|
||||||
w.Header().Set("Alt-Svc", altSvc)
|
if serveHTTP3 {
|
||||||
|
altSvc := fmt.Sprintf(`h3=":%d"`, portHTTPS)
|
||||||
|
respHdr.Set(aghhttp.HdrNameAltSvc, altSvc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.TLS == nil && web.forceHTTPS {
|
if r.TLS == nil && web.forceHTTPS {
|
||||||
|
@ -357,8 +369,8 @@ func handleHTTPSRedirect(w http.ResponseWriter, r *http.Request) (ok bool) {
|
||||||
Host: r.Host,
|
Host: r.Host,
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Access-Control-Allow-Origin", originURL.String())
|
respHdr.Set(aghhttp.HdrNameAccessControlAllowOrigin, originURL.String())
|
||||||
w.Header().Set("Vary", "Origin")
|
respHdr.Set(aghhttp.HdrNameVary, aghhttp.HdrNameOrigin)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue