utils

package
v0.0.0-...-3aa2dc7 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: GPL-3.0 Imports: 16 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 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
	Tree *iptree.Tree
}

func NewIPFilter

func NewIPFilter() *IPFilter

func (*IPFilter) Add

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

func (*IPFilter) Lookup

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

func (*IPFilter) Reset

func (f *IPFilter) Reset()

func (*IPFilter) UnsafeAdd

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

func (*IPFilter) UnsafeReset

func (f *IPFilter) UnsafeReset()

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