mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-14 18:51:34 +03:00
Pull request: home: add a patch against the global pprof handlers
Merge in DNS/adguard-home from 2336-pprof to master Closes #2336. Squashed commit of the following: commit 855e133b17da4274bef7dec5c3b7db73486d97db Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Nov 19 14:49:22 2020 +0300 home: add a patch against the global pprof handlers
This commit is contained in:
parent
b1c71a1284
commit
62a8fe0b73
36
CHANGELOG.md
36
CHANGELOG.md
@ -9,24 +9,46 @@ and this project adheres to
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [v0.104.3] - 2020-11-19
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The accidentally exposed profiler HTTP API ([#2336]).
|
||||||
|
|
||||||
|
[#2336]: https://github.com/AdguardTeam/AdGuardHome/issues/2336
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [v0.104.2] - 2020-11-19
|
## [v0.104.2] - 2020-11-19
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- This changelog :-) (#2294).
|
- This changelog :-) ([#2294]).
|
||||||
- `HACKING.md`, a guide for developers.
|
- `HACKING.md`, a guide for developers.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Improved tests output (#2273).
|
- Improved tests output ([#2273]).
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Query logs from file not loading after the ones buffered in memory (#2325).
|
- Query logs from file not loading after the ones buffered in memory ([#2325]).
|
||||||
- Unnecessary errors in query logs when switching between log files (#2324).
|
- Unnecessary errors in query logs when switching between log files ([#2324]).
|
||||||
- `404 Not Found` errors on the DHCP settings page on *Windows*. The page now
|
- `404 Not Found` errors on the DHCP settings page on *Windows*. The page now
|
||||||
correctly shows that DHCP is not currently available on that OS (#2295).
|
correctly shows that DHCP is not currently available on that OS ([#2295]).
|
||||||
- Infinite loop in `/dhcp/find_active_dhcp` (#2301).
|
- Infinite loop in `/dhcp/find_active_dhcp` ([#2301]).
|
||||||
|
|
||||||
[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.104.2...HEAD
|
[#2273]: https://github.com/AdguardTeam/AdGuardHome/issues/2273
|
||||||
|
[#2294]: https://github.com/AdguardTeam/AdGuardHome/issues/2294
|
||||||
|
[#2295]: https://github.com/AdguardTeam/AdGuardHome/issues/2295
|
||||||
|
[#2301]: https://github.com/AdguardTeam/AdGuardHome/issues/2301
|
||||||
|
[#2324]: https://github.com/AdguardTeam/AdGuardHome/issues/2324
|
||||||
|
[#2325]: https://github.com/AdguardTeam/AdGuardHome/issues/2325
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.104.3...HEAD
|
||||||
|
[v0.104.3]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.104.2...v0.104.3
|
||||||
[v0.104.2]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.104.1...v0.104.2
|
[v0.104.2]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.104.1...v0.104.2
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/util"
|
"github.com/AdguardTeam/AdGuardHome/internal/util"
|
||||||
@ -141,6 +142,7 @@ func (web *Web) Start() {
|
|||||||
web.httpServer = &http.Server{
|
web.httpServer = &http.Server{
|
||||||
ErrorLog: web.errLogger,
|
ErrorLog: web.errLogger,
|
||||||
Addr: address,
|
Addr: address,
|
||||||
|
Handler: filterPPROF(http.DefaultServeMux),
|
||||||
}
|
}
|
||||||
err := web.httpServer.ListenAndServe()
|
err := web.httpServer.ListenAndServe()
|
||||||
if err != http.ErrServerClosed {
|
if err != http.ErrServerClosed {
|
||||||
@ -151,6 +153,22 @@ func (web *Web) Start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(a.garipov): We currently have to use this, because everything registers
|
||||||
|
// its HTTP handlers in http.DefaultServeMux. In the future, refactor our HTTP
|
||||||
|
// API initialization process and stop using the gosh darn http.DefaultServeMux
|
||||||
|
// for anything at all. Gosh darn global variables.
|
||||||
|
func filterPPROF(h http.Handler) (filtered http.Handler) {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if strings.HasPrefix(r.URL.Path, "/debug/pprof") {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
h.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Close - stop HTTP server, possibly waiting for all active connections to be closed
|
// Close - stop HTTP server, possibly waiting for all active connections to be closed
|
||||||
func (web *Web) Close() {
|
func (web *Web) Close() {
|
||||||
log.Info("Stopping HTTP server...")
|
log.Info("Stopping HTTP server...")
|
||||||
|
Loading…
Reference in New Issue
Block a user