|
@@ -265,6 +265,9 @@ func nginxLogCapture(logfile, format string) {
|
|
|
reqRegexp := regexp.MustCompile(`^([A-Z]+)\s+(.+?)\s+(HTTP/\d+\.\d+)$`)
|
|
|
|
|
|
for line := range t.Lines {
|
|
|
+ var remote string
|
|
|
+ var err error
|
|
|
+
|
|
|
l := line.Text
|
|
|
|
|
|
logEntry, err := p.ParseString(l)
|
|
@@ -277,20 +280,15 @@ func nginxLogCapture(logfile, format string) {
|
|
|
pretty.Println(logEntry)
|
|
|
}
|
|
|
|
|
|
- remote, err := logEntry.Field("remote_addr")
|
|
|
+ remote, err = logEntry.Field("remote_addr")
|
|
|
if err != nil {
|
|
|
log.Println(err)
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- if config.UseXForwardedAsSource {
|
|
|
- xff, err := logEntry.Field("http_x_forwarded_for")
|
|
|
- if err != nil && xff != "" {
|
|
|
- ips := strings.Split(xff, ",")
|
|
|
- if len(ips) > 0 {
|
|
|
- remote = strings.TrimSpace(ips[0])
|
|
|
- }
|
|
|
- }
|
|
|
+ xff, err := logEntry.Field("http_x_forwarded_for")
|
|
|
+ if err != nil && xff != "" {
|
|
|
+ remote = xff
|
|
|
}
|
|
|
|
|
|
if remote == "" {
|