Pull request: home: inc req size for some apis
Merge in DNS/adguard-home from 2666-req-body-lim to master
Updates #2666.
Squashed commit of the following:
commit a525974aee54831963e3f95c8186d44f1752e9c7
Merge: 947703f3 44168292
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Thu Feb 11 13:48:06 2021 +0300
Merge branch 'master' into 2666-req-body-lim
commit 947703f36e1ee0ab08f938850f76824b7899d7e1
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Thu Feb 11 13:28:54 2021 +0300
home: inc req size for some apis
This commit is contained in:
parent
44168292d5
commit
f016ae172c
|
@ -17,13 +17,20 @@ and this project adheres to
|
|||
## [v0.105.1] - 2021-02-24
|
||||
-->
|
||||
|
||||
### Changed
|
||||
|
||||
- Increase the HTTP API request body size limit for the `/control/access/set`
|
||||
API ([#2666]).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Set the request body size limit for HTTPS reqeusts as well.
|
||||
- Incorrect version tag in the Docker release ([#2663]).
|
||||
- DNSCrypt queries weren't marked as such in logs ([#2662]).
|
||||
|
||||
[#2662]: https://github.com/AdguardTeam/AdGuardHome/issues/2662
|
||||
[#2663]: https://github.com/AdguardTeam/AdGuardHome/issues/2663
|
||||
[#2666]: https://github.com/AdguardTeam/AdGuardHome/issues/2666
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,17 @@ const RequestBodySizeLimit = 64 * 1024
|
|||
func limitRequestBody(h http.Handler) (limited http.Handler) {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var err error
|
||||
r.Body, err = aghio.LimitReadCloser(r.Body, RequestBodySizeLimit)
|
||||
|
||||
var bodySizeLimit int64 = RequestBodySizeLimit
|
||||
if u := r.URL; u.Path == "/control/access/set" {
|
||||
// An exception for a poorly designed API. Remove once
|
||||
// the new, better API is up.
|
||||
//
|
||||
// See https://github.com/AdguardTeam/AdGuardHome/issues/2666.
|
||||
bodySizeLimit *= 4
|
||||
}
|
||||
|
||||
r.Body, err = aghio.LimitReadCloser(r.Body, bodySizeLimit)
|
||||
if err != nil {
|
||||
log.Error("limitRequestBody: %s", err)
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ func (web *Web) tlsServerLoop() {
|
|||
RootCAs: Context.tlsRoots,
|
||||
CipherSuites: Context.tlsCiphers,
|
||||
},
|
||||
Handler: Context.mux,
|
||||
Handler: withMiddlewares(Context.mux, limitRequestBody),
|
||||
ReadTimeout: web.conf.ReadTimeout,
|
||||
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
|
||||
WriteTimeout: web.conf.WriteTimeout,
|
||||
|
|
Loading…
Reference in New Issue