packet

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Req  *http.Request
	Resp *http.Response
}

type EventFunc

type EventFunc func(req *http.Request, resp *http.Response)

type HTTPEvent

type HTTPEvent struct {
	Type      string
	Start     time.Time
	End       time.Time
	StreamSeq uint
}

HTTPEvent is HTTP request or response

type HTTPHeaderItem

type HTTPHeaderItem struct {
	Name  string
	Value string
}

HTTPHeaderItem is HTTP header key-value pair

type HTTPRequestEvent

type HTTPRequestEvent struct {
	HTTPEvent
	ClientAddr string
	ServerAddr string
	Method     string
	URI        string
	Version    string
	Headers    []HTTPHeaderItem
	Body       []byte
}

HTTPRequestEvent is HTTP request

type HTTPResponseEvent

type HTTPResponseEvent struct {
	HTTPEvent
	ClientAddr string
	ServerAddr string
	Version    string
	Code       uint
	Reason     string
	Headers    []HTTPHeaderItem
	Body       []byte
}

HTTPResponseEvent is HTTP response

type HTTPStreamFactory

type HTTPStreamFactory struct {
	// contains filtered or unexported fields
}

HTTPStreamFactory implements StreamFactory interface for tcpassembly

func NewHTTPStreamFactory

func NewHTTPStreamFactory(out chan<- interface{}) HTTPStreamFactory

NewHTTPStreamFactory create a NewHTTPStreamFactory.

func (HTTPStreamFactory) New

func (f HTTPStreamFactory) New(netFlow, tcpFlow gopacket.Flow) (ret tcpassembly.Stream)

New creates a HTTPStreamFactory.

func (*HTTPStreamFactory) RunningStreamCount

func (f *HTTPStreamFactory) RunningStreamCount() int32

RunningStreamCount 当前流计数.

func (HTTPStreamFactory) Wait

func (f HTTPStreamFactory) Wait()

Wait 等待所有流完成.

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

func NewPacketHandle

func NewPacketHandle(ctx context.Context, cardName string, eventCh chan interface{}) *Handle

func (*Handle) EventHandle

func (slf *Handle) EventHandle()

EventHandle 设置goroutine进行消息处理.

func (*Handle) Listen

func (slf *Handle) Listen() error

Listen 监听网卡.

func (*Handle) SetBpf

func (slf *Handle) SetBpf(bpf string) *Handle

SetBpf 设置过滤器规则.

func (*Handle) SetEventHandle

func (slf *Handle) SetEventHandle(goroutineNum int, handle EventFunc) *Handle

SetEventHandle 设置多协程事件处理.

func (*Handle) SetFlushTime

func (slf *Handle) SetFlushTime(timer time.Duration) *Handle

SetFlushTime 设置清理缓存时间, 清除收到的最后一个数据包时间加上此时间之前的所有的数据包.

func (*Handle) SetPromisc

func (slf *Handle) SetPromisc(promise bool) *Handle

SetPromisc 设置混杂模式.

type StreamDataBlock

type StreamDataBlock struct {
	Bytes []byte
	Seen  time.Time
}

StreamDataBlock is copied from tcpassembly.Reassembly

func NewStreamDataBlock

func NewStreamDataBlock(bytes []byte, seen time.Time) *StreamDataBlock

NewStreamDataBlock create a new StreamDataBlock.

type StreamReader

type StreamReader struct {
	// contains filtered or unexported fields
}

StreamReader read data from tcp stream

func NewStreamReader

func NewStreamReader() *StreamReader

NewStreamReader create a new StreamReader.

func (*StreamReader) Next

func (s *StreamReader) Next(n int) ([]byte, error)

Next 往后获取指定长度的数据.

func (*StreamReader) ReadUntil

func (s *StreamReader) ReadUntil(delim []byte) ([]byte, error)

ReadUntil 读取到指定分隔符.

Jump to

Keyboard shortcuts

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