protocols

package
v0.0.0-...-81c6b1d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README

应用层协议处理

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHttpByRequest

func CheckHttpByRequest(data []byte) bool

CheckHttpByRequest check 是否是http请求

func CheckHttpByResponse

func CheckHttpByResponse(data []byte) bool

CheckHttpByResponse check 是否是http响应

func GenerateSessionId

func GenerateSessionId(srcIP, dstIP, srcPort, dstPort, protocol string) string

GenerateSessionId 生成五元祖hash

Types

type Device

type Device struct {
	Name        string
	Type        string
	IPv4        string
	IPv6        string
	MAC         string
	Services    string
	Description string // 服务描述(来自 TXT 记录)
}

func ParseMDNS

func ParseMDNS(data []byte, srcIP, srcMac string) Device

ParseMDNS 解析 mDNS 数据包

type HTTPData

type HTTPData struct {
	Method string `bson:"method"`
	URL    string `bson:"url"`
	Host   string `bson:"host"`
}

type HTTPHandler

type HTTPHandler struct {
}

func (HTTPHandler) HandleData

func (HTTPHandler) HandleData(data []byte, sr StreamReaderInterface) (int, bool)

type ProtocolHandler

type ProtocolHandler interface {
	HandleData(data []byte, reader StreamReaderInterface) (int, bool)
}

type ProtocolType

type ProtocolType string
const (
	HTTP    ProtocolType = "http"
	TLS     ProtocolType = "tls"
	DNS     ProtocolType = "dns"
	UNKNOWN ProtocolType = "unknown"
)

func IdentifyProtocol

func IdentifyProtocol(buffer []byte, srcPort, dstPort string) ProtocolType

IdentifyProtocol 识别协议

type StreamReaderInterface

type StreamReaderInterface interface {
	GetIdentifier([]byte) ProtocolType
	GetIdent() bool
	SetUrls(urls string)
	GetUrls() []string
	LockParent()
	UnLockParent()
	SetHttpInfo(host, userAgent, contentType, upgrade string)
	SetTlsInfo(sni, version, cipherSuite string)
	SetApplicationProtocol(applicationProtocol ProtocolType)
}

StreamReaderInterface 流Reader接口

type TLSHandler

type TLSHandler struct{}

func (TLSHandler) HandleData

func (TLSHandler) HandleData(data []byte, reader StreamReaderInterface) (int, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL