src

package
v0.0.0-...-02319c3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignalExit  = 1
	TimeoutExit = 2
)

Flags for exit

View Source
const (
	TCP = "TCP"
	UDP = "UDP"
)

Protocol type

View Source
const (
	FIN = 0x01
	SYN = 0x02
	RST = 0x04
	PSH = 0x08
	ACK = 0x10
	URG = 0x20
	ECE = 0x40
	CWR = 0x80
)

Flags for tcp

Variables

This section is empty.

Functions

This section is empty.

Types

type Buckets

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

Buckets time-consuming interval statistics block

type Conf

type Conf struct {
	InterFile     string // Network interface or offline pcap file
	Outfile       string // Save the capture packet file
	FilterIPs     string // Filtering IPs in packets
	FilterPorts   string // Filtering Ports in packets
	FilterCustom  string // Custom filtering rules
	Protocol      string // Application layer protocol of data packet
	Script        string // Lua script for parsing packets
	SlowThreshold int64  // Threshold for slow requests
	Duration      int64  // Time of continuous data capture
	ShowReply     bool   // Whether to display the content of the reply packet
	SnapLen       int    // Capture the data length of the packet
	ReadTimeout   int64  // Timeout for reading packets from NIC
	Promisc       bool   // Whether to use promisc mode to monitor packets
}

Conf conf

func NewConf

func NewConf() *Conf

NewConf new conf

type Hamburg

type Hamburg struct {
	Sniffer *Sniffer
	Parser  *Parser
	State   *State
	Done    chan int
}

Hamburg main

func NewHamburg

func NewHamburg(c *Conf) (*Hamburg, error)

NewHamburg new hamburg

func (*Hamburg) ParsePackets

func (h *Hamburg) ParsePackets(gop *gopacket.Packet)

ParsePackets parser packets

func (*Hamburg) Run

func (h *Hamburg) Run()

Run run

func (*Hamburg) SavePackets

func (h *Hamburg) SavePackets(p *gopacket.Packet)

SavePackets save packets to local file

func (*Hamburg) Scheduler

func (h *Hamburg) Scheduler()

Scheduler schedule process

func (*Hamburg) SetDirection

func (h *Hamburg) SetDirection(v *p.Packet)

SetDirection set request direction

type Lua

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

Lua lua struct

type Parser

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

Parser parser

func NewParser

func NewParser(c *Conf) (*Parser, error)

NewParser new parser

func (*Parser) GetLayers

func (s *Parser) GetLayers(pkt gopacket.Packet) string

GetLayers layers

func (*Parser) ParseEthernetLayer

func (s *Parser) ParseEthernetLayer(pkt gopacket.Packet) *layers.Ethernet

ParseEthernetLayer ethernet layer

func (*Parser) ParseIPLayer

func (s *Parser) ParseIPLayer(pkt gopacket.Packet) *layers.IPv4

ParseIPLayer ip layer

func (*Parser) ParseTCPLayer

func (s *Parser) ParseTCPLayer(pkt gopacket.Packet) *layers.TCP

ParseTCPLayer tcp layer

func (*Parser) ParseUDPLayer

func (s *Parser) ParseUDPLayer(pkt gopacket.Packet) *layers.UDP

ParseUDPLayer udp layer

func (*Parser) Run

func (s *Parser) Run(v *p.Packet)

Run run parser by protocol

func (*Parser) RunScript

func (s *Parser) RunScript(pkt *p.Packet) error

RunScript run custom script

func (*Parser) UnpackLayers

func (s *Parser) UnpackLayers(gop *gopacket.Packet) *p.Packet

UnpackLayers parse all layers

type Sniffer

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

Sniffer sniffer

func NewSniffer

func NewSniffer(c *Conf) (*Sniffer, error)

NewSniffer new sniffer

func (*Sniffer) GetDuration

func (s *Sniffer) GetDuration() time.Duration

GetDuration get duration

func (*Sniffer) GetStartTime

func (s *Sniffer) GetStartTime() time.Time

GetStartTime set start time

func (*Sniffer) NICDetail

func (s *Sniffer) NICDetail()

NICDetail nic detail

func (*Sniffer) SetStartTime

func (s *Sniffer) SetStartTime()

SetStartTime set start time

type StatPair

type StatPair struct {
	Item  string // item key
	Value string // item value
}

StatPair stats table

type State

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

State status summary

func NewState

func NewState(c *Conf) (*State, error)

NewState new state

func (*State) AddDuration

func (s *State) AddDuration(t time.Duration)

AddDuration incr time-consuming interval count

func (*State) FitSlow

func (s *State) FitSlow(v time.Duration) bool

FitSlow verify that the request is too slow

func (*State) IncrReqRsp

func (s *State) IncrReqRsp(isreq bool)

IncrReqRsp incr request and response

func (*State) ShowStats

func (s *State) ShowStats()

ShowStats show stats

Jump to

Keyboard shortcuts

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