mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-18 08:29:36 +00:00
35 lines
710 B
Go
35 lines
710 B
Go
package http
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/up9inc/mizu/tap/api"
|
|
)
|
|
|
|
const userAgent = "user-agent"
|
|
|
|
func IsIgnoredUserAgent(item *api.OutputChannelItem, options *api.TrafficFilteringOptions) bool {
|
|
if item.Protocol.Name != "http" {
|
|
return false
|
|
}
|
|
|
|
request := item.Pair.Request.Payload.(HTTPPayload).Data.(*http.Request)
|
|
|
|
for headerKey, headerValues := range request.Header {
|
|
if strings.ToLower(headerKey) == userAgent {
|
|
for _, userAgent := range options.IgnoredUserAgents {
|
|
for _, headerValue := range headerValues {
|
|
if strings.Contains(strings.ToLower(headerValue), strings.ToLower(userAgent)) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|