|
@@ -186,10 +186,6 @@ func processPacket(packet gopacket.Packet) {
|
|
|
ipSrc = ip.SrcIP.String()
|
|
|
ipDst = ip.DstIP.String()
|
|
|
hasIPv4 = true
|
|
|
- if config.Trace {
|
|
|
- log.Printf("IPv4 packet %s -> %s\n", ipSrc, ipDst)
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// IPv6
|
|
@@ -198,9 +194,6 @@ func processPacket(packet gopacket.Packet) {
|
|
|
ip := ipLayer.(*layers.IPv6)
|
|
|
ipSrc = ip.SrcIP.String()
|
|
|
ipDst = ip.DstIP.String()
|
|
|
- if config.Trace {
|
|
|
- log.Printf("IPv6 packet %s -> %s\n", ipSrc, ipDst)
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -221,6 +214,11 @@ func processPacket(packet gopacket.Packet) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if len(applicationLayer.Payload()) < 50 {
|
|
|
+ log.Println("application layer too small!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
request := data.Request{
|
|
|
IpSrc: ipSrc,
|
|
|
IpDst: ipDst,
|
|
@@ -262,33 +260,25 @@ func processPacket(packet gopacket.Packet) {
|
|
|
}
|
|
|
|
|
|
if config.Trace {
|
|
|
- log.Println("Request for NATS")
|
|
|
- pretty.Println(request)
|
|
|
+ log.Printf("[%s] %s\n", request.Source, request.Url)
|
|
|
}
|
|
|
|
|
|
natsEC.Publish(config.NatsQueue, &request)
|
|
|
}
|
|
|
|
|
|
func processAJP13(request *data.Request, appData []byte) error {
|
|
|
- if config.Trace {
|
|
|
- log.Printf("packet: %v\n", appData)
|
|
|
- }
|
|
|
|
|
|
a, err := ajp13.Parse(appData)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("Failed to parse AJP13 request: %s", err)
|
|
|
}
|
|
|
|
|
|
- if config.Trace {
|
|
|
- log.Println("AJP13")
|
|
|
- pretty.Println(a)
|
|
|
- }
|
|
|
-
|
|
|
request.Url = a.URI
|
|
|
request.Method = a.Method()
|
|
|
request.Host = a.Server
|
|
|
request.Protocol = a.Version
|
|
|
request.Origin = a.RemoteAddr.String()
|
|
|
+ request.Source = a.RemoteAddr.String()
|
|
|
|
|
|
if v, ok := a.Header("Referer"); ok {
|
|
|
request.Referer = v
|
|
@@ -336,7 +326,7 @@ func processAJP13(request *data.Request, appData []byte) error {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if config.Trace {
|
|
|
+ if false && config.Trace {
|
|
|
log.Println("Request")
|
|
|
pretty.Println(request)
|
|
|
}
|