network

package
v0.0.0-...-775528f Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NetworkIP     = "ip"
	NetworkTCP    = "tcp"
	NetworkUDP    = "udp"
	NetworkICMPv4 = "icmpv4"
	NetworkICMPv6 = "icmpv6"
)
View Source
const DefaultFallbackDelay = 300 * time.Millisecond
View Source
const DefaultHeadroom = 1024

Variables

View Source
var ErrUnknownNetwork = E.New("unknown network")

Functions

func CalculateFrontHeadroom

func CalculateFrontHeadroom(writer any) int

func CalculateMTU

func CalculateMTU(reader any, writer any) int

func CalculateRearHeadroom

func CalculateRearHeadroom(writer any) int

func CastPacketReader

func CastPacketReader[T PacketReader](reader PacketReader) (T, bool)

func CastPacketWriter

func CastPacketWriter[T PacketWriter](writer PacketWriter) (T, bool)

func CastReader

func CastReader[T io.Reader](reader io.Reader) (T, bool)

func CastWriter

func CastWriter[T io.Writer](writer io.Writer) (T, bool)

func DialParallel

func DialParallel(ctx context.Context, dialer Dialer, network string, destination M.Socksaddr, destinationAddresses []netip.Addr, preferIPv6 bool, fallbackDelay time.Duration) (net.Conn, error)

func DialSerial

func DialSerial(ctx context.Context, dialer Dialer, network string, destination M.Socksaddr, destinationAddresses []netip.Addr) (net.Conn, error)

func HandshakeFailure

func HandshakeFailure(conn any, err error) error

func IsPublicAddr

func IsPublicAddr(addr netip.Addr) bool

func IsUnsafeWriter

func IsUnsafeWriter(writer any) bool

func IsVirtual

func IsVirtual(addr netip.Addr) bool

func ListenSerial

func ListenSerial(ctx context.Context, dialer Dialer, destination M.Socksaddr, destinationAddresses []netip.Addr) (net.PacketConn, netip.Addr, error)

func LocalAddrs

func LocalAddrs() ([]netip.Addr, error)

func LocalPublicAddrs

func LocalPublicAddrs() ([]netip.Addr, error)

func NetworkName

func NetworkName(network string) string

func UnwrapCountPacketReader

func UnwrapCountPacketReader(reader PacketReader, countFunc []CountFunc) (PacketReader, []CountFunc)

func UnwrapCountPacketWriter

func UnwrapCountPacketWriter(writer PacketWriter, countFunc []CountFunc) (PacketWriter, []CountFunc)

func UnwrapReader

func UnwrapReader(reader io.Reader) io.Reader

func UnwrapWriter

func UnwrapWriter(writer io.Writer) io.Writer

Types

type AbstractConn

type AbstractConn interface {
	Close() error
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

type BindPacketConn

type BindPacketConn interface {
	NetPacketConn
	net.Conn
}

type CachedPacketReader

type CachedPacketReader interface {
	ReadCachedPacket() *PacketBuffer
}

type CachedReader

type CachedReader interface {
	ReadCached() *buf.Buffer
}

type CountFunc

type CountFunc func(n int64)

func UnwrapCountReader

func UnwrapCountReader(reader io.Reader, countFunc []CountFunc) (io.Reader, []CountFunc)

func UnwrapCountWriter

func UnwrapCountWriter(writer io.Writer, countFunc []CountFunc) (io.Writer, []CountFunc)

type DefaultDialer

type DefaultDialer struct {
	net.Dialer
	net.ListenConfig
}

func (*DefaultDialer) DialContext

func (d *DefaultDialer) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error)

func (*DefaultDialer) DialParallel

func (d *DefaultDialer) DialParallel(ctx context.Context, network string, destination M.Socksaddr, destinationAddresses []netip.Addr) (net.Conn, error)

func (*DefaultDialer) ListenPacket

func (d *DefaultDialer) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error)

type Dialer

type Dialer interface {
	DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error)
	ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error)
}

type EarlyConn

type EarlyConn interface {
	NeedHandshake() bool
}

type ExtendedConn

type ExtendedConn interface {
	ExtendedReader
	ExtendedWriter
	net.Conn
}

type ExtendedReader

type ExtendedReader interface {
	io.Reader
	ReadBuffer(buffer *buf.Buffer) error
}

type ExtendedWriter

type ExtendedWriter interface {
	io.Writer
	WriteBuffer(buffer *buf.Buffer) error
}

type FrontHeadroom

type FrontHeadroom interface {
	FrontHeadroom() int
}

type HandshakeConn

type HandshakeConn interface {
	HandshakeFailure(err error) error
}

type LazyHeadroom

type LazyHeadroom interface {
	LazyHeadroom() bool
}

type NetPacketConn

type NetPacketConn interface {
	PacketConn
	NetPacketReader
	NetPacketWriter
}

type NetPacketReader

type NetPacketReader interface {
	PacketReader
	ReadFrom(p []byte) (n int, addr net.Addr, err error)
}

type NetPacketWriter

type NetPacketWriter interface {
	PacketWriter
	WriteTo(p []byte, addr net.Addr) (n int, err error)
}

type PacketBuffer

type PacketBuffer struct {
	Buffer      *buf.Buffer
	Destination M.Socksaddr
}

type PacketConn

type PacketConn interface {
	PacketReader
	PacketWriter

	Close() error
	LocalAddr() net.Addr
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
}

type PacketReadCounter

type PacketReadCounter interface {
	PacketReader
	UnwrapPacketReader() (PacketReader, []CountFunc)
}

type PacketReadWaitCreator

type PacketReadWaitCreator interface {
	CreateReadWaiter() (PacketReadWaiter, bool)
}

type PacketReadWaiter

type PacketReadWaiter interface {
	InitializeReadWaiter(newBuffer func() *buf.Buffer)
	WaitReadPacket() (destination M.Socksaddr, err error)
}

type PacketReader

type PacketReader interface {
	ReadPacket(buffer *buf.Buffer) (destination M.Socksaddr, err error)
}

func UnwrapPacketReader

func UnwrapPacketReader(reader PacketReader) PacketReader

type PacketWriteCounter

type PacketWriteCounter interface {
	PacketWriter
	UnwrapPacketWriter() (PacketWriter, []CountFunc)
}

type PacketWriter

type PacketWriter interface {
	WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error
}

func UnwrapPacketWriter

func UnwrapPacketWriter(writer PacketWriter) PacketWriter

type ParallelDialer

type ParallelDialer interface {
	Dialer
	DialParallel(ctx context.Context, network string, destination M.Socksaddr, destinationAddresses []netip.Addr) (net.Conn, error)
}
var SystemDialer ParallelDialer = &DefaultDialer{}

type PayloadDialer

type PayloadDialer interface {
	DialPayloadContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error)
}

type ReadCounter

type ReadCounter interface {
	io.Reader
	UnwrapReader() (io.Reader, []CountFunc)
}

type ReadWaitCreator

type ReadWaitCreator interface {
	CreateReadWaiter() (ReadWaiter, bool)
}

type ReadWaiter

type ReadWaiter interface {
	InitializeReadWaiter(newBuffer func() *buf.Buffer)
	WaitReadBuffer() error
}

type ReaderWithMTU

type ReaderWithMTU interface {
	ReaderMTU() int
}

type ReaderWithUpstream

type ReaderWithUpstream interface {
	ReaderReplaceable() bool
}

type RearHeadroom

type RearHeadroom interface {
	RearHeadroom() int
}

type TCPConnectionHandler

type TCPConnectionHandler interface {
	NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error
}

type ThreadSafePacketReader

type ThreadSafePacketReader interface {
	ReadPacketThreadSafe() (buffer *buf.Buffer, addr M.Socksaddr, err error)
}

func IsSafePacketReader

func IsSafePacketReader(reader any) ThreadSafePacketReader

type ThreadSafeReader

type ThreadSafeReader interface {
	ReadBufferThreadSafe() (buffer *buf.Buffer, err error)
}

func IsSafeReader

func IsSafeReader(reader any) ThreadSafeReader

type ThreadUnsafeWriter

type ThreadUnsafeWriter interface {
	WriteIsThreadUnsafe()
}

type TimeoutPacketReader

type TimeoutPacketReader interface {
	PacketReader
	SetReadDeadline(t time.Time) error
}

type UDPConnectionHandler

type UDPConnectionHandler interface {
	NewPacketConnection(ctx context.Context, conn PacketConn, metadata M.Metadata) error
}

type UDPHandler

type UDPHandler interface {
	NewPacket(ctx context.Context, conn PacketConn, buffer *buf.Buffer, metadata M.Metadata) error
}

type VectorisedPacketWriter

type VectorisedPacketWriter interface {
	WriteVectorisedPacket(buffers []*buf.Buffer, destination M.Socksaddr) error
}

type VectorisedWriter

type VectorisedWriter interface {
	WriteVectorised(buffers []*buf.Buffer) error
}

type WithUpstreamReader

type WithUpstreamReader interface {
	UpstreamReader() any
}

type WithUpstreamWriter

type WithUpstreamWriter interface {
	UpstreamWriter() any
}

type WriteCounter

type WriteCounter interface {
	io.Writer
	UnwrapWriter() (io.Writer, []CountFunc)
}

type WriterWithMTU

type WriterWithMTU interface {
	WriterMTU() int
}

type WriterWithUpstream

type WriterWithUpstream interface {
	WriterReplaceable() bool
}

Jump to

Keyboard shortcuts

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