common

package
v0.0.0-...-c6b16a5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeHttp = iota
	TypeUnknown
)
View Source
const (
	KiB = 1024
	MiB = KiB * 1024
	GiB = MiB * 1024

	// TCPBufSize is the size of tcp buffer
	TCPBufSize = 16 << 10

	// UDPBufSize is the size of udp buffer, 2^16 = 65536
	UDPBufSize = 64 << 10
)

Variables

This section is empty.

Functions

func GetBuffer

func GetBuffer(size int) []byte

func GetBufioReader

func GetBufioReader(r io.Reader) *bufio.Reader

func GetPath

func GetPath(fileName string) string

Function that search the specified file in related paths.

func GetWriteBuffer

func GetWriteBuffer() *bytes.Buffer

func HumanFriendlyTraffic

func HumanFriendlyTraffic(bytes uint64) string

func Must

func Must(err error)

func Must2

func Must2(_ interface{}, err error)

func PickPort

func PickPort(network string, host string) int

For testing only

func PutBuffer

func PutBuffer(buf []byte) error

func PutBufioReader

func PutBufioReader(r *bufio.Reader)

func PutWriteBuffer

func PutWriteBuffer(buf *bytes.Buffer)

Types

type Matcher

type Matcher struct {
	NetRanger cidranger.Ranger
	IPMap     map[string]net.IP
	DomainMap map[string]string
}

func NewMather

func NewMather(configFileName string) *Matcher

New a matcher that checks if a cidr or ip or domain is in a predefined list.

func (*Matcher) Check

func (m *Matcher) Check(host string) bool

type SniffConn

type SniffConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewSniffConn

func NewSniffConn(c net.Conn) *SniffConn

func (*SniffConn) Read

func (c *SniffConn) Read(p []byte) (int, error)

func (*SniffConn) Sniff

func (c *SniffConn) Sniff() int

Jump to

Keyboard shortcuts

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