1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dns_udp.go 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
Steffen Siering 提交于 2016-11-14 14:50 . More Packetbeat cleanups (#2972)
package dns
import (
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/packetbeat/procs"
"github.com/elastic/beats/packetbeat/protos"
)
// Only EDNS packets should have their size beyond this value
const maxDNSPacketSize = (1 << 9) // 512 (bytes)
func (dns *dnsPlugin) ParseUDP(pkt *protos.Packet) {
defer logp.Recover("Dns ParseUdp")
packetSize := len(pkt.Payload)
debugf("Parsing packet addressed with %s of length %d.",
pkt.Tuple.String(), packetSize)
dnsPkt, err := decodeDNSData(transportUDP, pkt.Payload)
if err != nil {
// This means that malformed requests or responses are being sent or
// that someone is attempting to the DNS port for non-DNS traffic. Both
// are issues that a monitoring system should report.
debugf("%s", err.Error())
return
}
dnsTuple := dnsTupleFromIPPort(&pkt.Tuple, transportUDP, dnsPkt.Id)
dnsMsg := &dnsMessage{
ts: pkt.Ts,
tuple: pkt.Tuple,
cmdlineTuple: procs.ProcWatcher.FindProcessesTuple(&pkt.Tuple),
data: dnsPkt,
length: packetSize,
}
if dnsMsg.data.Response {
dns.receivedDNSResponse(&dnsTuple, dnsMsg)
} else /* Query */ {
dns.receivedDNSRequest(&dnsTuple, dnsMsg)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v5.6.15

搜索帮助