mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-24 11:41:19 +08:00
caddyhttp: Split up logged remote address into IP and port (#4403)
This commit is contained in:
8
admin.go
8
admin.go
@ -659,11 +659,17 @@ type adminHandler struct {
|
||||
// ServeHTTP is the external entry point for API requests.
|
||||
// It will only be called once per request.
|
||||
func (h adminHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
ip, port, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err != nil {
|
||||
ip = r.RemoteAddr
|
||||
port = ""
|
||||
}
|
||||
log := Log().Named("admin.api").With(
|
||||
zap.String("method", r.Method),
|
||||
zap.String("host", r.Host),
|
||||
zap.String("uri", r.RequestURI),
|
||||
zap.String("remote_addr", r.RemoteAddr),
|
||||
zap.String("remote_ip", ip),
|
||||
zap.String("remote_port", port),
|
||||
zap.Reflect("headers", r.Header),
|
||||
)
|
||||
if r.TLS != nil {
|
||||
|
Reference in New Issue
Block a user