1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dns_udp.go 1.07 KB
一键复制 编辑 原始数据 按行查看 历史
McStork 提交于 2016-01-05 13:41 . Address @urso review of DNS over TCP
package dns
import (
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/packetbeat/procs"
"github.com/elastic/beats/packetbeat/protos"
)
func (dns *Dns) ParseUdp(pkt *protos.Packet) {
defer logp.Recover("Dns ParseUdp")
logp.Debug("dns", "Parsing packet addressed with %s of length %d.",
pkt.Tuple.String(), len(pkt.Payload))
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.
logp.Debug("dns", "%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: len(pkt.Payload),
}
if dnsMsg.Data.QR == Query {
dns.receivedDnsRequest(&dnsTuple, dnsMsg)
} else /* Response */ {
dns.receivedDnsResponse(&dnsTuple, dnsMsg)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v1.2.1

搜索帮助