From 571fd3824bf65f27cd6cb5d36f460fb994a26426 Mon Sep 17 00:00:00 2001 From: Monica Sarbu Date: Thu, 18 Sep 2014 19:02:34 +0200 Subject: [PATCH] Added explicit support for X-Forwarded-For. #60 --- http.go | 13 +++++++++---- log_unix.go | 6 +++--- log_windows.go | 6 +++--- procs.go | 2 +- publish.go | 1 - 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/http.go b/http.go index b35cf9f13053..105ffd620758 100644 --- a/http.go +++ b/http.go @@ -43,6 +43,7 @@ type HttpMessage struct { ContentLength int ContentType string ReasonPhrase string + XForwardedFor string Raw []byte @@ -148,6 +149,8 @@ func httpParseHeader(m *HttpMessage, data []byte) (bool, bool, int) { m.connection = string(bytes.Trim(data[i+1:p], " \t")) } else if bytes.Equal(bytes.ToLower(data[:i]), []byte("transfer-encoding")) { m.transfer_encoding = string(bytes.Trim(data[i+1:p], " \t")) + } else if bytes.Equal(bytes.ToLower(data[:i]), []byte("x-forwarded-for")) { + m.XForwardedFor = string(bytes.Trim(data[i+1:p], " \t")) } return true, true, p + 2 @@ -489,10 +492,12 @@ func receivedHttpRequest(msg *HttpMessage) { trans.Http = bson.M{ "host": msg.Host, "request": bson.M{ - "method": msg.Method, - "uri": msg.RequestUri, - "line": msg.FirstLine, - "line.raw": msg.FirstLine, + "method": msg.Method, + "uri": msg.RequestUri, + "uri.raw": msg.RequestUri, + "line": msg.FirstLine, + "line.raw": msg.FirstLine, + "x-forwarded-for": msg.XForwardedFor, }, } diff --git a/log_unix.go b/log_unix.go index 362cfee4e8f5..f6436ea3ff53 100644 --- a/log_unix.go +++ b/log_unix.go @@ -28,9 +28,9 @@ const ( ) type Logger struct { - toSyslog bool - level syslog.Priority - selectors map[string]bool + toSyslog bool + level syslog.Priority + selectors map[string]bool debug_all_selectors bool logger *log.Logger diff --git a/log_windows.go b/log_windows.go index 937067c3b20a..329d8790d833 100644 --- a/log_windows.go +++ b/log_windows.go @@ -8,9 +8,9 @@ import ( ) type Logger struct { - toSyslog bool - level Priority - selectors map[string]bool + toSyslog bool + level Priority + selectors map[string]bool debug_all_selectors bool logger *log.Logger diff --git a/procs.go b/procs.go index 55214d8f2a7c..9e33d21a50f8 100644 --- a/procs.go +++ b/procs.go @@ -3,10 +3,10 @@ package main import ( "bufio" "bytes" + "io" "io/ioutil" "net" "os" - "io" "path/filepath" "runtime" "strconv" diff --git a/publish.go b/publish.go index 5a331bc6e2e1..5d74834fe6a8 100644 --- a/publish.go +++ b/publish.go @@ -367,7 +367,6 @@ func (publisher *PublisherType) Init(publishDisabled bool) error { INFO("No agent name configured, using hostname '%s'", publisher.name) } - if !publisher.disabled && publisher.TopologyOutput != nil { RefreshTopologyFreq := 10 * time.Second if _Config.Agent.Refresh_topology_freq != 0 {