mirror of
https://github.com/syncthing/syncthing.git
synced 2025-12-23 14:08:06 -05:00
chore: remove GUI "debugging" toggle, debug HTTP metrics (#10235)
This removes the `debugging` bool under GUI configuration, and two no longer relevant development endpoints: `httpmetrics` (which I can't imagine anyone using for anything -- if we need such metrics today, the right place is the Prometheus exported metrics) and the `peerCompletion` endpoint (previously used by integration tests). The debugging bool initially enabled just those two endpoints, which are not for end users. Then we added profiling and support bundles, which are very useful indeed for end users to access, and they were hidden behind the same debug flag. I don't see any reason for keeping that flag now that these methods are more generally useful. https://github.com/syncthing/docs/pull/949
This commit is contained in:
@@ -108,7 +108,7 @@
|
||||
<li><a href="" ng-click="about.show()"><span class="fa fa-fw fa-heart"></span> <span translate>About</span></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li ng-if="authenticated || config.gui.debugging" class="dropdown action-menu">
|
||||
<li ng-if="authenticated" class="dropdown action-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
||||
<span class="fa fa-cog"></span>
|
||||
<span class="hidden-xs" translate>Actions</span>
|
||||
@@ -116,14 +116,13 @@
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li ng-if="authenticated"><a href="" ng-click="showSettings()"><span class="fa fa-fw fa-cog"></span> <span translate>Settings</span></a></li>
|
||||
<li ng-if="authenticated"><a href="" ng-click="showDeviceIdentification(thisDevice())"><span class="fa fa-fw fa-qrcode"></span> <span translate>Show ID</span></a></li>
|
||||
<li ng-if="authenticated"><a href="" ng-click="advanced()"><span class="fa fa-fw fa-cogs"></span> <span translate>Advanced</span></a></li>
|
||||
|
||||
<li ng-if="authenticated" class="divider" aria-hidden="true"></li>
|
||||
<li ng-if="authenticated"><a href="" ng-click="advanced()"><span class="fa fa-fw fa-cogs"></span> <span translate>Advanced</span></a></li>
|
||||
<li ng-if="authenticated"><a href="" ng-click="logging.show()"><span class="fa fa-fw fa-wrench"></span> <span translate>Logs</span></a></li>
|
||||
|
||||
<li class="divider" aria-hidden="true" ng-if="config.gui.debugging"></li>
|
||||
<li><a href="/rest/debug/support" target="_blank" ng-if="config.gui.debugging"><span class="fa fa-fw fa-user-md"></span> <span translate>Support Bundle</span></a></li>
|
||||
<li ng-if="authenticated"><a href="" ng-click="showDeviceIdentification(thisDevice())"><span class="fa fa-fw fa-qrcode"></span> <span translate>Show ID</span></a></li>
|
||||
<li ng-if="authenticated"><a href="" ng-click="logging.show()"><span class="fa fa-fw fa-wrench"></span> <span translate>Logs</span></a></li>
|
||||
<li ng-if="authenticated"><a href="/rest/debug/support" target="_blank"><span class="fa fa-fw fa-user-md"></span> <span translate>Support Bundle</span></a></li>
|
||||
|
||||
<li ng-if="authenticated" class="divider" aria-hidden="true"></li>
|
||||
<li ng-if="authenticated && isAuthEnabled()"><a href="" ng-click="logout()"><span class="far fa-fw fa-sign-out"></span> <span translate>Log Out</span></a></li>
|
||||
|
||||
@@ -36,7 +36,6 @@ import (
|
||||
"github.com/calmh/incontainer"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/rcrowley/go-metrics"
|
||||
"github.com/thejerf/suture/v4"
|
||||
"github.com/vitrun/qart/qr"
|
||||
"golang.org/x/text/runes"
|
||||
@@ -336,16 +335,14 @@ func (s *service) Serve(ctx context.Context) error {
|
||||
|
||||
// Debug endpoints, not for general use
|
||||
debugMux := http.NewServeMux()
|
||||
debugMux.HandleFunc("/rest/debug/peerCompletion", s.getPeerCompletion)
|
||||
debugMux.HandleFunc("/rest/debug/httpmetrics", s.getSystemHTTPMetrics)
|
||||
debugMux.HandleFunc("/rest/debug/cpuprof", s.getCPUProf) // duration
|
||||
debugMux.HandleFunc("/rest/debug/heapprof", s.getHeapProf)
|
||||
debugMux.HandleFunc("/rest/debug/support", s.getSupportBundle)
|
||||
debugMux.HandleFunc("/rest/debug/file", s.getDebugFile)
|
||||
restMux.Handler(http.MethodGet, "/rest/debug/*method", s.whenDebugging(debugMux))
|
||||
restMux.Handler(http.MethodGet, "/rest/debug/*method", debugMux)
|
||||
|
||||
// A handler that disables caching
|
||||
noCacheRestMux := noCacheMiddleware(metricsMiddleware(restMux))
|
||||
noCacheRestMux := noCacheMiddleware(restMux)
|
||||
|
||||
// The main routing handler
|
||||
mux := http.NewServeMux()
|
||||
@@ -489,9 +486,6 @@ func (*service) VerifyConfiguration(_, to config.Configuration) error {
|
||||
}
|
||||
|
||||
func (s *service) CommitConfiguration(from, to config.Configuration) bool {
|
||||
// No action required when this changes, so mask the fact that it changed at all.
|
||||
from.GUI.Debugging = to.GUI.Debugging
|
||||
|
||||
if to.GUI == from.GUI {
|
||||
// No GUI changes, we're done here.
|
||||
return true
|
||||
@@ -594,15 +588,6 @@ func corsMiddleware(next http.Handler, allowFrameLoading bool) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
func metricsMiddleware(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
t := metrics.GetOrRegisterTimer(r.URL.Path, nil)
|
||||
t0 := time.Now()
|
||||
h.ServeHTTP(w, r)
|
||||
t.UpdateSince(t0)
|
||||
})
|
||||
}
|
||||
|
||||
func redirectToHTTPSMiddleware(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.TLS == nil {
|
||||
@@ -644,17 +629,6 @@ func localhostMiddleware(h http.Handler) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *service) whenDebugging(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if s.cfg.GUI().Debugging {
|
||||
h.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
http.Error(w, "Debugging disabled", http.StatusForbidden)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *service) getPendingDevices(w http.ResponseWriter, _ *http.Request) {
|
||||
devices, err := s.model.PendingDevices()
|
||||
if err != nil {
|
||||
@@ -1284,26 +1258,6 @@ func (s *service) getSupportBundle(w http.ResponseWriter, r *http.Request) {
|
||||
io.Copy(w, &zipFilesBuffer)
|
||||
}
|
||||
|
||||
func (*service) getSystemHTTPMetrics(w http.ResponseWriter, _ *http.Request) {
|
||||
stats := make(map[string]interface{})
|
||||
metrics.Each(func(name string, intf interface{}) {
|
||||
if m, ok := intf.(*metrics.StandardTimer); ok {
|
||||
pct := m.Percentiles([]float64{0.50, 0.95, 0.99})
|
||||
for i := range pct {
|
||||
pct[i] /= 1e6 // ns to ms
|
||||
}
|
||||
stats[name] = map[string]interface{}{
|
||||
"count": m.Count(),
|
||||
"sumMs": m.Sum() / 1e6, // ns to ms
|
||||
"ratesPerS": []float64{m.Rate1(), m.Rate5(), m.Rate15()},
|
||||
"percentilesMs": pct,
|
||||
}
|
||||
}
|
||||
})
|
||||
bs, _ := json.MarshalIndent(stats, "", " ")
|
||||
w.Write(bs)
|
||||
}
|
||||
|
||||
func (s *service) getSystemDiscovery(w http.ResponseWriter, _ *http.Request) {
|
||||
devices := make(map[string]discover.CacheEntry)
|
||||
|
||||
@@ -1628,35 +1582,6 @@ func (*service) getQR(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(code.PNG())
|
||||
}
|
||||
|
||||
func (s *service) getPeerCompletion(w http.ResponseWriter, _ *http.Request) {
|
||||
tot := map[string]float64{}
|
||||
count := map[string]float64{}
|
||||
|
||||
for _, folder := range s.cfg.Folders() {
|
||||
for _, device := range folder.DeviceIDs() {
|
||||
deviceStr := device.String()
|
||||
if s.model.ConnectedTo(device) {
|
||||
comp, err := s.model.Completion(device, folder.ID)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
tot[deviceStr] += comp.CompletionPct
|
||||
} else {
|
||||
tot[deviceStr] = 0
|
||||
}
|
||||
count[deviceStr]++
|
||||
}
|
||||
}
|
||||
|
||||
comp := map[string]int{}
|
||||
for device := range tot {
|
||||
comp[device] = int(tot[device] / count[device])
|
||||
}
|
||||
|
||||
sendJSON(w, comp)
|
||||
}
|
||||
|
||||
func (s *service) getFolderVersions(w http.ResponseWriter, r *http.Request) {
|
||||
qs := r.URL.Query()
|
||||
versions, err := s.model.GetFolderVersions(qs.Get("folder"))
|
||||
|
||||
@@ -30,7 +30,6 @@ type GUIConfiguration struct {
|
||||
APIKey string `json:"apiKey" xml:"apikey,omitempty"`
|
||||
InsecureAdminAccess bool `json:"insecureAdminAccess" xml:"insecureAdminAccess,omitempty"`
|
||||
Theme string `json:"theme" xml:"theme" default:"default"`
|
||||
Debugging bool `json:"debugging" xml:"debugging,attr"`
|
||||
InsecureSkipHostCheck bool `json:"insecureSkipHostcheck" xml:"insecureSkipHostcheck,omitempty"`
|
||||
InsecureAllowFrameLoading bool `json:"insecureAllowFrameLoading" xml:"insecureAllowFrameLoading,omitempty"`
|
||||
SendBasicAuthPrompt bool `json:"sendBasicAuthPrompt" xml:"sendBasicAuthPrompt,attr"`
|
||||
|
||||
@@ -308,9 +308,6 @@ func (s *Service) reportData(ctx context.Context, urVersion int, preview bool) (
|
||||
if guiCfg.InsecureAdminAccess {
|
||||
report.GUIStats.InsecureAdminAccess++
|
||||
}
|
||||
if guiCfg.Debugging {
|
||||
report.GUIStats.Debugging++
|
||||
}
|
||||
if guiCfg.InsecureSkipHostCheck {
|
||||
report.GUIStats.InsecureSkipHostCheck++
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<remoteGUIPort>0</remoteGUIPort>
|
||||
<numConnections>3</numConnections>
|
||||
</device>
|
||||
<gui enabled="true" tls="false" debugging="true" sendBasicAuthPrompt="false">
|
||||
<gui enabled="true" tls="false" sendBasicAuthPrompt="false">
|
||||
<address>127.0.0.1:8081</address>
|
||||
<user>testuser</user>
|
||||
<password>$2a$10$7tKL5uvLDGn5s2VLPM2yWOK/II45az0mTel8hxAUJDRQN1Tk2QYwu</password>
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<remoteGUIPort>0</remoteGUIPort>
|
||||
<numConnections>3</numConnections>
|
||||
</device>
|
||||
<gui enabled="true" tls="false" debugging="true" sendBasicAuthPrompt="false">
|
||||
<gui enabled="true" tls="false" sendBasicAuthPrompt="false">
|
||||
<address>127.0.0.1:8082</address>
|
||||
<metricsWithoutAuth>false</metricsWithoutAuth>
|
||||
<apikey>abc123</apikey>
|
||||
|
||||
Reference in New Issue
Block a user