瀏覽代碼

write overridden host into request packet for log captures

Tobias Begalke 6 年之前
父節點
當前提交
36399ac68b
共有 1 個文件被更改,包括 6 次插入2 次删除
  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{