utils

package
v0.0.0-...-f80152d Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddrTypeIPv4   = 1
	AddrTypeDomain = 3
	AddrTypeIPv6   = 4
)
View Source
const MaxAddrLen = 1 + 1 + 255 + 2

Variables

View Source
var ErrInvalidAddrLen = errors.New("invalid address length")
View Source
var ErrInvalidAddrType = errors.New("invalid address type")

Functions

func ResolveTCPAddr

func ResolveTCPAddr(addr Addr) (*net.TCPAddr, error)

func ResolveUDPAddr

func ResolveUDPAddr(addr Addr) (*net.UDPAddr, error)

Types

type Addr

type Addr []byte

func ParseAddr

func ParseAddr(addr []byte) (Addr, error)

func ReadAddr

func ReadAddr(conn net.Conn) (Addr, error)

func ReadAddrBuffer

func ReadAddrBuffer(conn net.Conn, addr []byte) (Addr, error)

func ResolveAddr

func ResolveAddr(addr net.Addr) (Addr, error)

func ResolveAddrBuffer

func ResolveAddrBuffer(addr net.Addr, b []byte) (Addr, error)

func (Addr) Network

func (addr Addr) Network() string

func (Addr) String

func (addr Addr) String() string

type AppFilter

type AppFilter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

AppFilter represents an application filter

func NewAppFilter

func NewAppFilter() *AppFilter

NewAppFilter creates a new application filter

func (*AppFilter) Add

func (f *AppFilter) Add(pid uint32)

Add adds a process ID to the filter

func (*AppFilter) Lookup

func (f *AppFilter) Lookup(pid uint32) bool

Lookup checks if a process ID exists in the filter

func (*AppFilter) Remove

func (f *AppFilter) Remove(pid uint32)

Remove removes a process ID from the filter

type Buffer

type Buffer []byte

func (Buffer) ReadFrom

func (b Buffer) ReadFrom(r io.Reader) (n int64, err error)

type Conn

type Conn struct{}

func (Conn) Close

func (c Conn) Close() error

func (Conn) LocalAddr

func (c Conn) LocalAddr() net.Addr

func (Conn) RemoteAddr

func (c Conn) RemoteAddr() net.Addr

func (Conn) SetDeadline

func (c Conn) SetDeadline(t time.Time) error

func (Conn) SetReadDeadline

func (c Conn) SetReadDeadline(t time.Time) error

func (Conn) SetWriteDeadline

func (c Conn) SetWriteDeadline(t time.Time) error

type Dialer

type Dialer struct {
	net.Dialer

	Config *tls.Config
	// contains filtered or unexported fields
}

func (*Dialer) Dial

func (d *Dialer) Dial(network, addr string) (net.Conn, error)

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

func (*Dialer) DialTLS

func (d *Dialer) DialTLS(network, addr string) (net.Conn, error)

func (*Dialer) DialTLSContext

func (d *Dialer) DialTLSContext(ctx context.Context, network, addr string) (net.Conn, error)

type DomainTree

type DomainTree struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewDomainTree

func NewDomainTree(sep string) *DomainTree

func (*DomainTree) Load

func (t *DomainTree) Load(k string) interface{}

func (*DomainTree) Reset

func (t *DomainTree) Reset()

func (*DomainTree) Store

func (t *DomainTree) Store(k string, v interface{})

func (*DomainTree) UnsafeLoad

func (t *DomainTree) UnsafeLoad(k string) interface{}

func (*DomainTree) UnsafeReset

func (t *DomainTree) UnsafeReset()

func (*DomainTree) UnsafeStore

func (t *DomainTree) UnsafeStore(k string, v interface{})

type HTTPSResolverGet

type HTTPSResolverGet struct {
	Dialer  Dialer
	BaseUrl string
	Timeout time.Duration
	http.Client
}

func (*HTTPSResolverGet) DialContext

func (r *HTTPSResolverGet) DialContext(ctx context.Context, network, address string) (net.Conn, error)

func (*HTTPSResolverGet) Resolve

func (r *HTTPSResolverGet) Resolve(b []byte, n int) (int, error)

type HTTPSResolverPost

type HTTPSResolverPost struct {
	Dialer  Dialer
	BaseUrl string
	Timeout time.Duration
	http.Client
}

func (*HTTPSResolverPost) DialContext

func (r *HTTPSResolverPost) DialContext(ctx context.Context, network, address string) (net.Conn, error)

func (*HTTPSResolverPost) Resolve

func (r *HTTPSResolverPost) Resolve(b []byte, n int) (int, error)

type IPFilter

type IPFilter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

IPFilter represents an IP filter

func NewIPFilter

func NewIPFilter() *IPFilter

NewIPFilter creates a new IP filter

func (*IPFilter) Add

func (f *IPFilter) Add(ip net.IP)

Add adds an IP address to the filter

func (*IPFilter) Lookup

func (f *IPFilter) Lookup(ip net.IP) bool

Lookup checks if an IP address exists in the filter

type IPTree

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

IPTree is a simple IP tree implementation for IP lookup

func NewIPTree

func NewIPTree() *IPTree

NewIPTree creates a new IP tree

func (*IPTree) Insert

func (t *IPTree) Insert(ip []byte)

Insert inserts an IP address into the tree

func (*IPTree) Lookup

func (t *IPTree) Lookup(ip []byte) bool

Lookup checks if an IP address exists in the tree

type PacketConnGet

type PacketConnGet struct {
	Conn
	// contains filtered or unexported fields
}

func (*PacketConnGet) Read

func (c *PacketConnGet) Read(b []byte) (int, error)

func (*PacketConnGet) ReadFrom

func (c *PacketConnGet) ReadFrom(b []byte) (int, net.Addr, error)

func (*PacketConnGet) Write

func (c *PacketConnGet) Write(b []byte) (int, error)

func (*PacketConnGet) WriteTo

func (c *PacketConnGet) WriteTo(b []byte, addr net.Addr) (int, error)

type PacketConnPost

type PacketConnPost struct {
	Conn
	// contains filtered or unexported fields
}

func (*PacketConnPost) Read

func (c *PacketConnPost) Read(b []byte) (int, error)

func (*PacketConnPost) ReadFrom

func (c *PacketConnPost) ReadFrom(b []byte) (int, net.Addr, error)

func (*PacketConnPost) Write

func (c *PacketConnPost) Write(b []byte) (int, error)

func (*PacketConnPost) WriteTo

func (c *PacketConnPost) WriteTo(b []byte, addr net.Addr) (int, error)

type Resolver

type Resolver interface {
	Resolve([]byte, int) (int, error)
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

func NewResolver

func NewResolver(s string) (Resolver, error)

type TCPResolver

type TCPResolver struct {
	Dialer  net.Dialer
	Addr    string
	Timeout time.Duration
}

func (*TCPResolver) DialContext

func (r *TCPResolver) DialContext(ctx context.Context, network, address string) (net.Conn, error)

func (*TCPResolver) Resolve

func (r *TCPResolver) Resolve(b []byte, n int) (l int, err error)

type TLSResolver

type TLSResolver struct {
	Dialer  net.Dialer
	Conf    *tls.Config
	Addr    string
	Timeout time.Duration
}

func (*TLSResolver) DialContext

func (r *TLSResolver) DialContext(ctx context.Context, network, address string) (net.Conn, error)

func (*TLSResolver) Resolve

func (r *TLSResolver) Resolve(b []byte, n int) (l int, err error)

type UDPResolver

type UDPResolver struct {
	Dialer  net.Dialer
	Addr    string
	Timeout time.Duration
}

func (*UDPResolver) DialContext

func (r *UDPResolver) DialContext(ctx context.Context, network, address string) (net.Conn, error)

func (*UDPResolver) Resolve

func (r *UDPResolver) Resolve(b []byte, n int) (int, error)

Directories

Path Synopsis
Package iptree implements radix tree data structure for IPv4 and IPv6 networks.
Package iptree implements radix tree data structure for IPv4 and IPv6 networks.

Jump to

Keyboard shortcuts

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