1 Star 0 Fork 0

gaokens / godpi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
rpc.go 913 Bytes
一键复制 编辑 原始数据 按行查看 历史
gaokens 提交于 2020-02-03 21:58 . chage mod name
package classifiers
import (
"bytes"
"encoding/binary"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"gitee.com/tingkle/godpi/types"
)
// RPCClassifier struct
type RPCClassifier struct{}
// HeuristicClassify for RPCClassifier
func (classifier RPCClassifier) HeuristicClassify(flow *types.Flow) bool {
return checkFirstPayload(flow.GetPackets(), layers.LayerTypeTCP,
func(payload []byte, packetsRest []gopacket.Packet) bool {
if len(payload) < 24 {
return false
}
// check first bytes for version 5.0 bind request
firstBytes := []byte{5, 0, 11, 3, 16, 0, 0, 0}
// check if lengths match
frameLen := int(binary.LittleEndian.Uint16(payload[8:10]))
return bytes.HasPrefix(payload, firstBytes) && len(payload) == frameLen
})
}
// GetProtocol returns the corresponding protocol
func (classifier RPCClassifier) GetProtocol() types.Protocol {
return types.RPC
}
1
https://gitee.com/tingkle/godpi.git
git@gitee.com:tingkle/godpi.git
tingkle
godpi
godpi
3e1ec68ffa6e

搜索帮助