net

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFiltered = errors.New("packet has been filtered")

Functions

func CmpNet

func CmpNet(a, b net.IPNet) int

func CmpUDPAddr

func CmpUDPAddr(a, b *net.UDPAddr) int

func ContainsNet

func ContainsNet(outer, inner *net.IPNet) bool

func FindNextPortToListen

func FindNextPortToListen(network string, start, end int) (int, error)

func FindRandomPortToListen

func FindRandomPortToListen(network string, min, max int) (int, error)

func NewPacketPipeConn

func NewPacketPipeConn(l1 net.Addr, l2 net.Addr, depth int) (*PacketPipeConn, *PacketPipeConn)

func NewSplitConn

func NewSplitConn(recv ReceivePacketConn, send SendPacketConn) net.PacketConn

func OffsetIP

func OffsetIP(ip net.IP, off int) net.IP

Types

type FilteredConn

type FilteredConn struct {
	net.PacketConn
	// contains filtered or unexported fields
}

FilteredConn wraps a net.PacketConn

func NewFilteredConn

func NewFilteredConn(c net.PacketConn, logger *log.Logger) *FilteredConn

func (*FilteredConn) AddPacketReadHandler

func (c *FilteredConn) AddPacketReadHandler(h PacketHandler)

func (*FilteredConn) AddPacketReadHandlerConn

func (c *FilteredConn) AddPacketReadHandlerConn(h PacketHandler) net.PacketConn

func (*FilteredConn) ReadFrom

func (c *FilteredConn) ReadFrom(buf []byte) (int, net.Addr, error)

func (*FilteredConn) RemovePacketReadHandler

func (c *FilteredConn) RemovePacketReadHandler(h PacketHandler)

type PacketHandler

type PacketHandler interface {
	OnPacketRead([]byte, net.Addr) (bool, error)
}

PacketHandler is a handler interface

type PacketHandlerConn

type PacketHandlerConn struct {
	PacketHandler
	// contains filtered or unexported fields
}

PacketHandlerConn implements a PacketHandler which forwards filtered reads to a pipe connection

func (*PacketHandlerConn) OnPacketRead

func (ph *PacketHandlerConn) OnPacketRead(buf []byte, rAddr net.Addr) (abort bool, err error)

type PacketPipe

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

func NewPacketPipe

func NewPacketPipe(lAddr net.Addr, depth int) *PacketPipe

func (*PacketPipe) Close

func (p *PacketPipe) Close() error

func (*PacketPipe) LocalAddr

func (p *PacketPipe) LocalAddr() net.Addr

func (*PacketPipe) ReadFrom

func (p *PacketPipe) ReadFrom(buf []byte) (int, net.Addr, error)

func (*PacketPipe) SetReadDeadline

func (p *PacketPipe) SetReadDeadline(t time.Time) error

func (*PacketPipe) SetWriteDeadline

func (p *PacketPipe) SetWriteDeadline(t time.Time) error

func (*PacketPipe) WriteFrom

func (p *PacketPipe) WriteFrom(buf []byte, addr net.Addr) (int, error)

type PacketPipeConn

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

func (*PacketPipeConn) Close

func (c *PacketPipeConn) Close() error

func (*PacketPipeConn) LocalAddr

func (c *PacketPipeConn) LocalAddr() net.Addr

func (*PacketPipeConn) ReadFrom

func (c *PacketPipeConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*PacketPipeConn) SetDeadline

func (c *PacketPipeConn) SetDeadline(t time.Time) error

func (*PacketPipeConn) SetReadDeadline

func (c *PacketPipeConn) SetReadDeadline(t time.Time) error

func (*PacketPipeConn) SetWriteDeadline

func (c *PacketPipeConn) SetWriteDeadline(t time.Time) error

func (*PacketPipeConn) WriteTo

func (c *PacketPipeConn) WriteTo(p []byte, _ net.Addr) (n int, err error)

type ReceivePacketConn

type ReceivePacketConn interface {
	ReadFrom(p []byte) (n int, addr net.Addr, err error)
	Close() error
	LocalAddr() net.Addr
	SetReadDeadline(t time.Time) error
}

type STUNPacketHandler

type STUNPacketHandler struct {
	Logger *log.Logger
}

func (*STUNPacketHandler) OnPacketRead

func (ph *STUNPacketHandler) OnPacketRead(buf []byte, rAddr net.Addr) (bool, error)

type SendPacketConn

type SendPacketConn interface {
	WriteTo(p []byte, addr net.Addr) (n int, err error)
	Close() error
	SetWriteDeadline(t time.Time) error
}

type SplitConn

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

func (*SplitConn) Close

func (c *SplitConn) Close() error

func (*SplitConn) LocalAddr

func (c *SplitConn) LocalAddr() net.Addr

func (*SplitConn) ReadFrom

func (c *SplitConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*SplitConn) SetDeadline

func (c *SplitConn) SetDeadline(t time.Time) error

func (*SplitConn) SetReadDeadline

func (c *SplitConn) SetReadDeadline(t time.Time) error

func (*SplitConn) SetWriteDeadline

func (c *SplitConn) SetWriteDeadline(t time.Time) error

func (*SplitConn) WriteTo

func (c *SplitConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

Jump to

Keyboard shortcuts

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