1 Star 0 Fork 0

gaokens / godpi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dns.go 803 Bytes
一键复制 编辑 原始数据 按行查看 历史
gaokens 提交于 2020-02-03 21:58 . chage mod name
package classifiers
import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"gitee.com/tingkle/godpi/types"
)
// DNSClassifier struct
type DNSClassifier struct{}
// HeuristicClassify for DNSClassifier
func (classifier DNSClassifier) HeuristicClassify(flow *types.Flow) bool {
return checkFlowLayer(flow, layers.LayerTypeUDP, func(layer gopacket.Layer) (detected bool) {
layerParser := gopacket.DecodingLayerParser{}
dns := layers.DNS{}
err := dns.DecodeFromBytes(layer.LayerPayload(), &layerParser)
// attempt to decode layer as DNS packet using gopacket and return
// whether it was successful
detected = err == nil
return
})
}
// GetProtocol returns the corresponding protocol
func (classifier DNSClassifier) GetProtocol() types.Protocol {
return types.DNS
}
1
https://gitee.com/tingkle/godpi.git
git@gitee.com:tingkle/godpi.git
tingkle
godpi
godpi
3e1ec68ffa6e

搜索帮助