utils

package
v0.0.0-...-ca67efc Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: GPL-2.0, GPL-3.0, LGPL-3.0 Imports: 8 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 IPv4Addr

func IPv4Addr(i uint32) net.IP

func IPv4Mask

func IPv4Mask(i uint32) net.IPMask

func IPv6Addr

func IPv6Addr(a, b, c, d uint32) net.IP

func IPv6Mask

func IPv6Mask(a, b, c, d uint32) net.IPMask

func Mask4

func Mask4(ones int) uint32

func Mask6

func Mask6(ones int) [4]uint32

func PutAddr

func PutAddr(addr Addr)

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 GetAddr

func GetAddr() Addr

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 Element

type Element struct {
	N uint32
	R map[uint32]struct{}
	C int
}

type Element6

type Element6 struct {
	N [4]uint32
	R map[[4]uint32]struct{}
	C int
}

type IPFilter

type IPFilter struct {
	sync.RWMutex

	E  []*Element
	E6 []*Element6
	// contains filtered or unexported fields
}

func NewIPFilter

func NewIPFilter() *IPFilter

func (*IPFilter) Add

func (f *IPFilter) Add(s string) error

func (*IPFilter) AddCIDR

func (f *IPFilter) AddCIDR(ip net.IP, mask net.IPMask) error

func (*IPFilter) AddIP

func (f *IPFilter) AddIP(ip net.IP) error

func (*IPFilter) Lookup

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

func (*IPFilter) Reset

func (f *IPFilter) Reset()

func (*IPFilter) SetMode

func (f *IPFilter) SetMode(mode bool)

func (*IPFilter) Sort

func (f *IPFilter) Sort()

func (*IPFilter) String

func (f *IPFilter) String() string

func (*IPFilter) UnsafeAdd

func (f *IPFilter) UnsafeAdd(s string) error

func (*IPFilter) UnsafeReset

func (f *IPFilter) UnsafeReset()

func (*IPFilter) UnsafeSetMode

func (f *IPFilter) UnsafeSetMode(mode bool)

func (*IPFilter) UnsafeSort

func (f *IPFilter) UnsafeSort()

type PacketConn

type PacketConn interface {
	LocalAddr() net.Addr
	WriteFrom([]byte, net.Addr) (int, error)
	WriteTo([]byte, *net.UDPAddr) error
	ReadTo([]byte) (int, net.Addr, error)
	io.Closer
}

type Tree

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

func NewTree

func NewTree(sep string) *Tree

func (*Tree) Load

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

func (*Tree) Reset

func (t *Tree) Reset()

func (*Tree) Store

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

func (*Tree) UnsafeLoad

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

func (*Tree) UnsafeReset

func (t *Tree) UnsafeReset()

func (*Tree) UnsafeStore

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

Jump to

Keyboard shortcuts

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