Explorar o código

write overridden host into request packet for log captures

Tobias Begalke %!s(int64=6) %!d(string=hai) anos
pai
achega
36399ac68b
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      main.go

+ 6 - 2
main.go

@@ -312,7 +312,7 @@ func nginxLogCapture(logfile, format string) {
 			CreatedAt: timeStamp.Unix(),
 			Url:       reqData[2],
 			Method:    reqData[1],
-			Host:      "[not available]",
+			Host:      host,
 			Protocol:  reqData[3],
 		}
 
@@ -381,7 +381,11 @@ func apacheLogCapture(logfile string) {
 			vhostAndPort := strings.Split(logEntry.VirtualHost, ":")
 			virtualHost = vhostAndPort[0]
 		} else {
-			vhost = "[not available]"
+			if config.HostName != "" {
+				vhost = config.HostName
+			} else {
+				vhost = "[not available]"
+			}
 		}
 
 		request := data.Request{