Skip to content

Commit

Permalink
Added explicit support for X-Forwarded-For. #60
Browse files Browse the repository at this point in the history
  • Loading branch information
monicasarbu committed Sep 18, 2014
1 parent 6b75989 commit 571fd38
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
13 changes: 9 additions & 4 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type HttpMessage struct {
ContentLength int
ContentType string
ReasonPhrase string
XForwardedFor string

Raw []byte

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
},
}

Expand Down
6 changes: 3 additions & 3 deletions log_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions log_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion procs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package main
import (
"bufio"
"bytes"
"io"
"io/ioutil"
"net"
"os"
"io"
"path/filepath"
"runtime"
"strconv"
Expand Down
1 change: 0 additions & 1 deletion publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 571fd38

Please sign in to comment.