Update trafficlog.go

Update logger to include browser UserAgent string in log lines. This will allow Crowdsec to filter for known bad useragents.
This commit is contained in:
Raithmir 2025-03-21 16:59:22 +00:00 committed by GitHub
parent 7dff4f83b4
commit f2b4c47805
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,6 +27,6 @@ func (l *Logger) LogHTTPRequest(r *http.Request, reqclass string, statusCode int
requestURI := r.RequestURI
statusCodeString := strconv.Itoa(statusCode)
//fmt.Println("[" + time.Now().Format("2006-01-02 15:04:05.000000") + "] [router:" + reqclass + "] [client " + clientIP + "] " + r.Method + " " + requestURI + " " + statusCodeString)
l.logger.Println("[" + time.Now().Format("2006-01-02 15:04:05.000000") + "] [router:" + reqclass + "] [origin:" + r.URL.Hostname() + "] [client " + clientIP + "] [useragent " + r.UserAgent() + "] " + r.Method + " " + requestURI + " " + statusCodeString)
l.logger.Println("[" + time.Now().Format("2006-01-02 15:04:05.000000") + "] [router:" + reqclass + "] [origin:" + r.URL.Hostname() + "] [client: " + clientIP + "] [useragent: " + r.UserAgent() + "] " + r.Method + " " + requestURI + " " + statusCodeString)
}()
}