mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
app/vmselect: show X-Forwarded-For contents on /api/v1/status/active_queries page
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/659
This commit is contained in:
@@ -481,13 +481,19 @@ var (
|
||||
requestsTotal = metrics.NewCounter(`vm_http_requests_all_total`)
|
||||
)
|
||||
|
||||
// Errorf writes formatted error message to w and to logger.
|
||||
func Errorf(w http.ResponseWriter, r *http.Request, format string, args ...interface{}) {
|
||||
errStr := fmt.Sprintf(format, args...)
|
||||
// GetQuotedRemoteAddr returns quoted remote address.
|
||||
func GetQuotedRemoteAddr(r *http.Request) string {
|
||||
remoteAddr := strconv.Quote(r.RemoteAddr) // quote remoteAddr and X-Forwarded-For, since they may contain untrusted input
|
||||
if addr := r.Header.Get("X-Forwarded-For"); addr != "" {
|
||||
remoteAddr += ", X-Forwarded-For: " + strconv.Quote(addr)
|
||||
}
|
||||
return remoteAddr
|
||||
}
|
||||
|
||||
// Errorf writes formatted error message to w and to logger.
|
||||
func Errorf(w http.ResponseWriter, r *http.Request, format string, args ...interface{}) {
|
||||
errStr := fmt.Sprintf(format, args...)
|
||||
remoteAddr := GetQuotedRemoteAddr(r)
|
||||
errStr = fmt.Sprintf("remoteAddr: %s; %s", remoteAddr, errStr)
|
||||
logger.WarnfSkipframes(1, "%s", errStr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user