direct

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ShadowsocksNonePacketClientMessageHeadroom = zerocopy.Headroom{
	Front: socks5.MaxAddrLen,
	Rear:  0,
}

ShadowsocksNonePacketClientMessageHeadroom is the headroom required by a Shadowsocks none client message.

View Source
var ShadowsocksNonePacketServerMessageHeadroom = zerocopy.Headroom{
	Front: socks5.IPv6AddrLen,
	Rear:  0,
}

ShadowsocksNonePacketServerMessageHeadroom is the headroom required by a Shadowsocks none server message.

View Source
var Socks5PacketClientMessageHeadroom = zerocopy.Headroom{
	Front: 3 + socks5.MaxAddrLen,
	Rear:  0,
}

Socks5PacketClientMessageHeadroom is the headroom required by a SOCKS5 client message.

View Source
var Socks5PacketServerMessageHeadroom = zerocopy.Headroom{
	Front: 3 + socks5.IPv6AddrLen,
	Rear:  0,
}

Socks5PacketServerMessageHeadroom is the headroom required by a SOCKS5 server message.

Functions

func NewTCPTransparentServer added in v1.4.0

func NewTCPTransparentServer() (zerocopy.TCPServer, error)

Types

type DirectPacketClientPacker added in v1.8.0

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

DirectPacketClientPacker packs packets for direct connection.

DirectPacketClientPacker implements the zerocopy ClientPacker interface.

func NewDirectPacketClientPacker added in v1.8.0

func NewDirectPacketClientPacker(network string, mtu int) *DirectPacketClientPacker

NewDirectPacketClientPacker creates a packet packer for direct connection.

func (DirectPacketClientPacker) ClientPackerInfo added in v1.8.0

ClientPackerInfo implements the zerocopy.ClientPacker ClientPackerInfo method.

func (*DirectPacketClientPacker) PackInPlace added in v1.8.0

func (p *DirectPacketClientPacker) PackInPlace(ctx context.Context, b []byte, targetAddr conn.Addr, payloadStart, payloadLen int) (destAddrPort netip.AddrPort, packetStart, packetLen int, err error)

PackInPlace implements the zerocopy.ClientPacker PackInPlace method.

type DirectPacketClientUnpacker added in v1.8.0

type DirectPacketClientUnpacker struct{}

DirectPacketClientUnpacker unpacks packets from direct connection.

DirectPacketClientUnpacker implements the zerocopy ClientUnpacker interface.

func (DirectPacketClientUnpacker) ClientUnpackerInfo added in v1.8.0

ClientUnpackerInfo implements the zerocopy.ClientUnpacker ClientUnpackerInfo method.

func (DirectPacketClientUnpacker) UnpackInPlace added in v1.8.0

func (DirectPacketClientUnpacker) UnpackInPlace(b []byte, packetSourceAddrPort netip.AddrPort, packetStart, packetLen int) (payloadSourceAddr netip.AddrPort, payloadStart, payloadLen int, err error)

UnpackInPlace implements the zerocopy.ClientUnpacker UnpackInPlace method.

type DirectPacketServerPackUnpacker added in v1.1.0

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

func NewDirectPacketServerPackUnpacker added in v1.1.0

func NewDirectPacketServerPackUnpacker(targetAddr conn.Addr, targetAddrOnly bool) *DirectPacketServerPackUnpacker

NewDirectPacketServerPackUnpacker creates a zerocopy.ServerPackUnpacker that forwards packets to the specified target address.

func (*DirectPacketServerPackUnpacker) NewPacker added in v1.8.0

NewPacker implements the zerocopy.ServerUnpacker NewPacker method.

func (*DirectPacketServerPackUnpacker) PackInPlace added in v1.1.0

func (p *DirectPacketServerPackUnpacker) PackInPlace(b []byte, sourceAddrPort netip.AddrPort, payloadStart, payloadLen, maxPacketLen int) (packetStart, packetLen int, err error)

PackInPlace implements the zerocopy.ServerPacker PackInPlace method.

func (DirectPacketServerPackUnpacker) ServerPackerInfo added in v1.6.0

ServerPackerInfo implements the zerocopy.ServerPacker ServerPackerInfo method.

func (DirectPacketServerPackUnpacker) ServerUnpackerInfo added in v1.6.0

ServerUnpackerInfo implements the zerocopy.ServerUnpacker ServerUnpackerInfo method.

func (*DirectPacketServerPackUnpacker) UnpackInPlace added in v1.1.0

func (p *DirectPacketServerPackUnpacker) UnpackInPlace(b []byte, sourceAddrPort netip.AddrPort, packetStart, packetLen int) (targetAddr conn.Addr, payloadStart, payloadLen int, err error)

UnpackInPlace implements the zerocopy.ServerUnpacker UnpackInPlace method.

type DirectStreamReadWriter

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

DirectStreamReadWriter implements the zerocopy ReadWriter interface and reads/writes everything directly from/to the wrapped io.ReadWriter.

func NewDirectStreamReadWriter

func NewDirectStreamReadWriter(rw zerocopy.DirectReadWriteCloser) *DirectStreamReadWriter

NewDirectStreamReadWriter returns a ReadWriter that passes all reads and writes directly to the underlying stream.

func NewShadowsocksNoneStreamClientReadWriter

func NewShadowsocksNoneStreamClientReadWriter(ctx context.Context, rwo zerocopy.DirectReadWriteCloserOpener, targetAddr conn.Addr, payload []byte) (*DirectStreamReadWriter, zerocopy.DirectReadWriteCloser, error)

NewShadowsocksNoneStreamClientReadWriter creates a ReadWriter that acts as a Shadowsocks none method client.

func NewShadowsocksNoneStreamServerReadWriter

func NewShadowsocksNoneStreamServerReadWriter(rw zerocopy.DirectReadWriteCloser) (*DirectStreamReadWriter, conn.Addr, error)

NewShadowsocksNoneStreamServerReadWriter creates a ReadWriter that acts as a Shadowsocks none method server.

func NewSocks5AuthStreamClientReadWriter added in v1.12.0

func NewSocks5AuthStreamClientReadWriter(rw zerocopy.DirectReadWriteCloser, authMsg []byte, targetAddr conn.Addr) (*DirectStreamReadWriter, error)

NewSocks5AuthStreamClientReadWriter is like NewSocks5StreamClientReadWriter, but uses username/password authentication.

func NewSocks5AuthStreamServerReadWriter added in v1.12.0

func NewSocks5AuthStreamServerReadWriter(rw zerocopy.DirectReadWriteCloser, userInfoByUsername map[string]socks5.UserInfo, enableTCP, enableUDP bool) (dsrw *DirectStreamReadWriter, addr conn.Addr, username string, err error)

NewSocks5AuthStreamServerReadWriter is like NewSocks5StreamServerReadWriter, but uses username/password authentication.

func NewSocks5StreamClientReadWriter

func NewSocks5StreamClientReadWriter(rw zerocopy.DirectReadWriteCloser, targetAddr conn.Addr) (*DirectStreamReadWriter, error)

NewSocks5StreamClientReadWriter writes a SOCKS5 CONNECT request to rw and wraps rw into a ReadWriter ready for use.

func NewSocks5StreamServerReadWriter

func NewSocks5StreamServerReadWriter(rw zerocopy.DirectReadWriteCloser, enableTCP, enableUDP bool) (dsrw *DirectStreamReadWriter, addr conn.Addr, err error)

NewSocks5StreamServerReadWriter handles a SOCKS5 request from rw and wraps rw into a ReadWriter ready for use.

When UDP is enabled, rw must be a *net.TCPConn.

func (*DirectStreamReadWriter) Close

func (rw *DirectStreamReadWriter) Close() error

Close implements the ReadWriter Close method.

func (*DirectStreamReadWriter) CloseRead

func (rw *DirectStreamReadWriter) CloseRead() error

CloseRead implements the ReadWriter CloseRead method.

func (*DirectStreamReadWriter) CloseWrite

func (rw *DirectStreamReadWriter) CloseWrite() error

CloseWrite implements the ReadWriter CloseWrite method.

func (*DirectStreamReadWriter) DirectReader added in v1.5.1

func (rw *DirectStreamReadWriter) DirectReader() io.Reader

DirectReader implements the DirectReader DirectReader method.

func (*DirectStreamReadWriter) DirectWriter added in v1.5.1

func (rw *DirectStreamReadWriter) DirectWriter() io.Writer

DirectWriter implements the DirectWriter DirectWriter method.

func (*DirectStreamReadWriter) ReadZeroCopy

func (rw *DirectStreamReadWriter) ReadZeroCopy(b []byte, payloadBufStart, payloadBufLen int) (payloadLen int, err error)

ReadZeroCopy implements the Reader ReadZeroCopy method.

func (*DirectStreamReadWriter) ReaderInfo added in v1.6.0

func (rw *DirectStreamReadWriter) ReaderInfo() zerocopy.ReaderInfo

ReaderInfo implements the Reader ReaderInfo method.

func (*DirectStreamReadWriter) WriteZeroCopy

func (rw *DirectStreamReadWriter) WriteZeroCopy(b []byte, payloadStart, payloadLen int) (payloadWritten int, err error)

WriteZeroCopy implements the Writer WriteZeroCopy method.

func (*DirectStreamReadWriter) WriterInfo added in v1.6.0

func (rw *DirectStreamReadWriter) WriterInfo() zerocopy.WriterInfo

WriterInfo implements the Writer WriterInfo method.

type DirectUDPClient added in v1.8.0

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

DirectUDPClient implements the zerocopy UDPClient interface.

func NewDirectUDPClient added in v1.8.0

func NewDirectUDPClient(name, network string, mtu int, listenConfig conn.ListenConfig) *DirectUDPClient

NewDirectUDPClient creates a new UDP client that sends packets directly.

func (*DirectUDPClient) Info added in v1.8.0

Info implements the zerocopy.UDPClient Info method.

func (*DirectUDPClient) NewSession added in v1.8.0

NewSession implements the zerocopy.UDPClient NewSession method.

type DirectUDPNATServer added in v1.1.0

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

DirectUDPNATServer implements the zerocopy UDPNATServer interface.

func NewDirectUDPNATServer added in v1.1.0

func NewDirectUDPNATServer(targetAddr conn.Addr, targetAddrOnly bool) *DirectUDPNATServer

func (*DirectUDPNATServer) Info added in v1.6.0

Info implements the zerocopy.UDPNATServer Info method.

func (*DirectUDPNATServer) NewUnpacker added in v1.8.0

func (s *DirectUDPNATServer) NewUnpacker() (zerocopy.ServerUnpacker, error)

NewUnpacker implements the zerocopy.UDPNATServer NewUnpacker method.

type ShadowsocksNonePacketClientPacker added in v1.4.0

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

ShadowsocksNonePacketClientPacker implements the zerocopy ClientPacker interface.

func NewShadowsocksNonePacketClientPacker added in v1.4.0

func NewShadowsocksNonePacketClientPacker(serverAddrPort netip.AddrPort, maxPacketSize int) *ShadowsocksNonePacketClientPacker

NewShadowsocksNonePacketClientPacker creates a Shadowsocks none packet client packer.

func (ShadowsocksNonePacketClientPacker) ClientPackerInfo added in v1.6.0

ClientPackerInfo implements the zerocopy.ClientPacker ClientPackerInfo method.

func (*ShadowsocksNonePacketClientPacker) PackInPlace added in v1.4.0

func (p *ShadowsocksNonePacketClientPacker) PackInPlace(ctx context.Context, b []byte, targetAddr conn.Addr, payloadStart, payloadLen int) (destAddrPort netip.AddrPort, packetStart, packetLen int, err error)

PackInPlace implements the zerocopy.ClientPacker PackInPlace method.

type ShadowsocksNonePacketClientUnpacker added in v1.4.0

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

ShadowsocksNonePacketClientUnpacker implements the zerocopy ClientUnpacker interface.

func NewShadowsocksNonePacketClientUnpacker added in v1.4.0

func NewShadowsocksNonePacketClientUnpacker(serverAddrPort netip.AddrPort) *ShadowsocksNonePacketClientUnpacker

NewShadowsocksNonePacketClientUnpacker creates a Shadowsocks none packet client unpacker.

func (ShadowsocksNonePacketClientUnpacker) ClientUnpackerInfo added in v1.6.0

ClientUnpackerInfo implements the zerocopy.ClientUnpacker ClientUnpackerInfo method.

func (*ShadowsocksNonePacketClientUnpacker) UnpackInPlace added in v1.4.0

func (p *ShadowsocksNonePacketClientUnpacker) UnpackInPlace(b []byte, packetSourceAddrPort netip.AddrPort, packetStart, packetLen int) (payloadSourceAddrPort netip.AddrPort, payloadStart, payloadLen int, err error)

UnpackInPlace implements the zerocopy.ClientUnpacker UnpackInPlace method.

type ShadowsocksNonePacketServerPacker added in v1.4.0

type ShadowsocksNonePacketServerPacker struct{}

ShadowsocksNonePacketServerPacker implements the zerocopy ServerPacker interface.

func (ShadowsocksNonePacketServerPacker) PackInPlace added in v1.4.0

func (ShadowsocksNonePacketServerPacker) PackInPlace(b []byte, sourceAddrPort netip.AddrPort, payloadStart, payloadLen, maxPacketLen int) (packetStart, packetLen int, err error)

PackInPlace implements the zerocopy.ServerPacker PackInPlace method.

func (ShadowsocksNonePacketServerPacker) ServerPackerInfo added in v1.6.0

ServerPackerInfo implements the zerocopy.ServerPacker ServerPackerInfo method.

type ShadowsocksNonePacketServerUnpacker added in v1.4.0

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

ShadowsocksNonePacketServerUnpacker implements the zerocopy Unpacker interface.

func (ShadowsocksNonePacketServerUnpacker) NewPacker added in v1.8.0

NewPacker implements the zerocopy.ServerUnpacker NewPacker method.

func (ShadowsocksNonePacketServerUnpacker) ServerUnpackerInfo added in v1.6.0

ServerUnpackerInfo implements the zerocopy.ServerUnpacker ServerUnpackerInfo method.

func (*ShadowsocksNonePacketServerUnpacker) UnpackInPlace added in v1.4.0

func (p *ShadowsocksNonePacketServerUnpacker) UnpackInPlace(b []byte, sourceAddrPort netip.AddrPort, packetStart, packetLen int) (targetAddr conn.Addr, payloadStart, payloadLen int, err error)

UnpackInPlace implements the zerocopy.ServerUnpacker UnpackInPlace method.

type ShadowsocksNoneTCPClient

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

ShadowsocksNoneTCPClient implements the zerocopy TCPClient interface.

func NewShadowsocksNoneTCPClient

func NewShadowsocksNoneTCPClient(name, network, address string, dialer conn.Dialer) *ShadowsocksNoneTCPClient

func (*ShadowsocksNoneTCPClient) Dial

func (c *ShadowsocksNoneTCPClient) Dial(ctx context.Context, targetAddr conn.Addr, payload []byte) (rawRW zerocopy.DirectReadWriteCloser, rw zerocopy.ReadWriter, err error)

Dial implements the zerocopy.TCPClient Dial method.

func (*ShadowsocksNoneTCPClient) Info added in v1.6.0

Info implements the zerocopy.TCPClient Info method.

type ShadowsocksNoneTCPServer

type ShadowsocksNoneTCPServer struct{}

ShadowsocksNoneTCPServer implements the zerocopy TCPServer interface.

func NewShadowsocksNoneTCPServer

func NewShadowsocksNoneTCPServer() ShadowsocksNoneTCPServer

func (ShadowsocksNoneTCPServer) Accept

func (ShadowsocksNoneTCPServer) Accept(rawRW zerocopy.DirectReadWriteCloser) (rw zerocopy.ReadWriter, targetAddr conn.Addr, payload []byte, username string, err error)

Accept implements the zerocopy.TCPServer Accept method.

func (ShadowsocksNoneTCPServer) Info added in v1.6.0

Info implements the zerocopy.TCPServer Info method.

type ShadowsocksNoneUDPClient added in v1.8.0

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

ShadowsocksNoneUDPClient implements the zerocopy UDPClient interface.

func NewShadowsocksNoneUDPClient

func NewShadowsocksNoneUDPClient(name, network string, addr conn.Addr, mtu int, listenConfig conn.ListenConfig) *ShadowsocksNoneUDPClient

NewShadowsocksNoneUDPClient creates a new Shadowsocks none UDP client.

func (*ShadowsocksNoneUDPClient) Info added in v1.8.0

Info implements the zerocopy.UDPClient Info method.

func (*ShadowsocksNoneUDPClient) NewSession added in v1.8.0

NewSession implements the zerocopy.UDPClient NewSession method.

type ShadowsocksNoneUDPNATServer added in v1.1.0

type ShadowsocksNoneUDPNATServer struct{}

ShadowsocksNoneUDPNATServer implements the zerocopy UDPNATServer interface.

func (ShadowsocksNoneUDPNATServer) Info added in v1.6.0

Info implements the zerocopy.UDPNATServer Info method.

func (ShadowsocksNoneUDPNATServer) NewUnpacker added in v1.8.0

NewUnpacker implements the zerocopy.UDPNATServer NewUnpacker method.

type Socks5AuthTCPClient added in v1.12.0

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

Socks5AuthTCPClient is like Socks5TCPClient, but uses username/password authentication.

Socks5AuthTCPClient implements zerocopy.TCPClient.

func (*Socks5AuthTCPClient) Dial added in v1.12.0

func (c *Socks5AuthTCPClient) Dial(ctx context.Context, targetAddr conn.Addr, payload []byte) (rawRW zerocopy.DirectReadWriteCloser, rw zerocopy.ReadWriter, err error)

Dial implements zerocopy.TCPClient.Dial.

func (*Socks5AuthTCPClient) Info added in v1.12.0

Info implements zerocopy.TCPClient.Info.

type Socks5AuthTCPServer added in v1.12.0

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

Socks5AuthTCPServer is like Socks5TCPServer, but uses username/password authentication.

Socks5AuthTCPServer implements zerocopy.TCPServer.

func (*Socks5AuthTCPServer) Accept added in v1.12.0

func (s *Socks5AuthTCPServer) Accept(rawRW zerocopy.DirectReadWriteCloser) (rw zerocopy.ReadWriter, targetAddr conn.Addr, payload []byte, username string, err error)

Accept implements zerocopy.TCPServer.Accept.

func (*Socks5AuthTCPServer) Info added in v1.12.0

Info implements zerocopy.TCPServer.Info.

type Socks5AuthUDPClient added in v1.12.0

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

Socks5AuthUDPClient is like Socks5UDPClient, but uses username/password authentication.

Socks5AuthUDPClient implements zerocopy.UDPClient.

func (*Socks5AuthUDPClient) Info added in v1.12.0

Info implements zerocopy.UDPClient.Info.

func (*Socks5AuthUDPClient) NewSession added in v1.12.0

NewSession implements zerocopy.UDPClient.NewSession.

type Socks5PacketClientPacker added in v1.4.0

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

Socks5PacketClientPacker implements the zerocopy ClientPacker interface.

func NewSocks5PacketClientPacker added in v1.4.0

func NewSocks5PacketClientPacker(serverAddrPort netip.AddrPort, maxPacketSize int) *Socks5PacketClientPacker

NewSocks5PacketClientPacker creates a SOCKS5 packet client packer.

func (Socks5PacketClientPacker) ClientPackerInfo added in v1.6.0

ClientPackerInfo implements the zerocopy.ClientPacker ClientPackerInfo method.

func (*Socks5PacketClientPacker) PackInPlace added in v1.4.0

func (p *Socks5PacketClientPacker) PackInPlace(ctx context.Context, b []byte, targetAddr conn.Addr, payloadStart, payloadLen int) (destAddrPort netip.AddrPort, packetStart, packetLen int, err error)

PackInPlace implements the zerocopy.ClientPacker PackInPlace method.

type Socks5PacketClientUnpacker added in v1.4.0

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

Socks5PacketClientUnpacker implements the zerocopy Unpacker interface.

func NewSocks5PacketClientUnpacker added in v1.4.0

func NewSocks5PacketClientUnpacker(serverAddrPort netip.AddrPort) *Socks5PacketClientUnpacker

NewSocks5PacketClientUnpacker creates a SOCKS5 packet client unpacker.

func (Socks5PacketClientUnpacker) ClientUnpackerInfo added in v1.6.0

ClientUnpackerInfo implements the zerocopy.ClientUnpacker ClientUnpackerInfo method.

func (*Socks5PacketClientUnpacker) UnpackInPlace added in v1.4.0

func (p *Socks5PacketClientUnpacker) UnpackInPlace(b []byte, packetSourceAddrPort netip.AddrPort, packetStart, packetLen int) (payloadSourceAddrPort netip.AddrPort, payloadStart, payloadLen int, err error)

UnpackInPlace implements the zerocopy.ClientUnpacker UnpackInPlace method.

type Socks5PacketServerPacker added in v1.4.0

type Socks5PacketServerPacker struct{}

Socks5PacketServerPacker implements the zerocopy ServerPacker interface.

func (Socks5PacketServerPacker) PackInPlace added in v1.4.0

func (Socks5PacketServerPacker) PackInPlace(b []byte, sourceAddrPort netip.AddrPort, payloadStart, payloadLen, maxPacketLen int) (packetStart, packetLen int, err error)

PackInPlace implements the zerocopy.ServerPacker PackInPlace method.

func (Socks5PacketServerPacker) ServerPackerInfo added in v1.6.0

ServerPackerInfo implements the zerocopy.ServerPacker ServerPackerInfo method.

type Socks5PacketServerUnpacker added in v1.4.0

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

Socks5PacketServerUnpacker implements the zerocopy Unpacker interface.

func (Socks5PacketServerUnpacker) NewPacker added in v1.8.0

NewPacker implements the zerocopy.ServerUnpacker NewPacker method.

func (Socks5PacketServerUnpacker) ServerUnpackerInfo added in v1.6.0

ServerUnpackerInfo implements the zerocopy.ServerUnpacker ServerUnpackerInfo method.

func (*Socks5PacketServerUnpacker) UnpackInPlace added in v1.4.0

func (p *Socks5PacketServerUnpacker) UnpackInPlace(b []byte, sourceAddrPort netip.AddrPort, packetStart, packetLen int) (targetAddr conn.Addr, payloadStart, payloadLen int, err error)

UnpackInPlace implements the zerocopy.ServerUnpacker UnpackInPlace method.

type Socks5TCPClient

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

Socks5TCPClient is an unauthenticated SOCKS5 TCP client.

Socks5TCPClient implements zerocopy.TCPClient.

func NewSocks5TCPClient

func NewSocks5TCPClient(name, network, address string, dialer conn.Dialer) *Socks5TCPClient

func (*Socks5TCPClient) Dial

func (c *Socks5TCPClient) Dial(ctx context.Context, targetAddr conn.Addr, payload []byte) (rawRW zerocopy.DirectReadWriteCloser, rw zerocopy.ReadWriter, err error)

Dial implements zerocopy.TCPClient.Dial.

func (*Socks5TCPClient) Info added in v1.6.0

Info implements zerocopy.TCPClient.Info.

type Socks5TCPClientConfig added in v1.12.0

type Socks5TCPClientConfig struct {
	// Name is the name of the client.
	Name string

	// Network controls the address family when resolving the address.
	//
	// - "tcp": System default, likely dual-stack.
	// - "tcp4": Resolve to IPv4 addresses.
	// - "tcp6": Resolve to IPv6 addresses.
	Network string

	// Address is the address of the remote proxy server.
	Address string

	// Dialer is the dialer used to establish connections.
	Dialer conn.Dialer

	// AuthMsg is the serialized username/password authentication message.
	AuthMsg []byte
}

Socks5TCPClientConfig contains configuration options for a SOCKS5 TCP client.

func (*Socks5TCPClientConfig) NewClient added in v1.12.0

func (c *Socks5TCPClientConfig) NewClient() zerocopy.TCPClient

NewClient creates a new SOCKS5 TCP client.

type Socks5TCPServer

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

Socks5TCPServer is an unauthenticated SOCKS5 TCP server.

Socks5TCPServer implements zerocopy.TCPServer.

func (*Socks5TCPServer) Accept

func (s *Socks5TCPServer) Accept(rawRW zerocopy.DirectReadWriteCloser) (rw zerocopy.ReadWriter, targetAddr conn.Addr, payload []byte, username string, err error)

Accept implements zerocopy.TCPServer.Accept.

func (*Socks5TCPServer) Info added in v1.6.0

Info implements zerocopy.TCPServer.Info.

type Socks5TCPServerConfig added in v1.12.0

type Socks5TCPServerConfig struct {
	// Users is a list of users allowed to connect to the server.
	// It is ignored if none of the authentication methods are enabled.
	Users []socks5.UserInfo

	// EnableUserPassAuth controls whether to enable username/password authentication.
	EnableUserPassAuth bool

	// EnableTCP controls whether to accept CONNECT requests.
	EnableTCP bool

	// EnableUDP controls whether to accept UDP ASSOCIATE requests.
	EnableUDP bool
}

Socks5TCPServerConfig contains configuration options for a SOCKS5 TCP server.

func (*Socks5TCPServerConfig) NewServer added in v1.12.0

func (c *Socks5TCPServerConfig) NewServer() (zerocopy.TCPServer, error)

NewServer creates a new SOCKS5 TCP server.

type Socks5UDPClient added in v1.8.0

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

Socks5UDPClient is a SOCKS5 UDP client.

Socks5UDPClient implements zerocopy.UDPClient.

func (*Socks5UDPClient) Info added in v1.8.0

Info implements zerocopy.UDPClient.Info.

func (*Socks5UDPClient) NewSession added in v1.8.0

NewSession implements zerocopy.UDPClient.NewSession.

type Socks5UDPClientConfig added in v1.12.0

type Socks5UDPClientConfig struct {
	// Logger is the logger used for logging.
	Logger *zap.Logger

	// Name is the name of the SOCKS5 client.
	Name string

	// Network controls the address family when resolving the server's TCP address.
	//
	// - "tcp": System default, likely dual-stack.
	// - "tcp4": Resolve to IPv4 addresses.
	// - "tcp6": Resolve to IPv6 addresses.
	NetworkTCP string

	// NetworkIP controls the address family when resolving the server's UDP bound address.
	//
	// - "ip": System default, likely dual-stack.
	// - "ip4": Resolve to IPv4 addresses.
	// - "ip6": Resolve to IPv6 addresses.
	NetworkIP string

	// Address is the SOCKS5 server's TCP address.
	Address string

	// Dialer is the dialer used to establish TCP connections.
	Dialer conn.Dialer

	// MTU is the MTU of the client's designated network path.
	MTU int

	// ListenConfig is the [conn.ListenConfig] for opening client sockets.
	ListenConfig conn.ListenConfig

	// AuthMsg is the serialized username/password authentication message.
	AuthMsg []byte
}

Socks5UDPClientConfig contains configuration options for a SOCKS5 UDP client.

func (*Socks5UDPClientConfig) NewClient added in v1.12.0

func (c *Socks5UDPClientConfig) NewClient() zerocopy.UDPClient

NewClient creates a new SOCKS5 UDP client.

type Socks5UDPNATServer added in v1.1.0

type Socks5UDPNATServer struct{}

Socks5UDPNATServer implements the zerocopy UDPNATServer interface.

func (Socks5UDPNATServer) Info added in v1.6.0

Info implements the zerocopy.UDPNATServer Info method.

func (Socks5UDPNATServer) NewUnpacker added in v1.8.0

NewUnpacker implements the zerocopy.UDPNATServer NewUnpacker method.

type TCPClient

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

TCPClient implements the zerocopy TCPClient interface.

func NewTCPClient

func NewTCPClient(name, network string, dialer conn.Dialer) *TCPClient

func (*TCPClient) Dial

func (c *TCPClient) Dial(ctx context.Context, targetAddr conn.Addr, payload []byte) (rawRW zerocopy.DirectReadWriteCloser, rw zerocopy.ReadWriter, err error)

Dial implements the zerocopy.TCPClient Dial method.

func (*TCPClient) Info added in v1.6.0

func (c *TCPClient) Info() zerocopy.TCPClientInfo

Info implements the zerocopy.TCPClient Info method.

type TCPServer

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

TCPServer is the client-side tunnel server.

TCPServer implements the zerocopy TCPServer interface.

func NewTCPServer

func NewTCPServer(targetAddr conn.Addr) *TCPServer

func (*TCPServer) Accept

func (s *TCPServer) Accept(rawRW zerocopy.DirectReadWriteCloser) (rw zerocopy.ReadWriter, targetAddr conn.Addr, payload []byte, username string, err error)

Accept implements the zerocopy.TCPServer Accept method.

func (*TCPServer) Info added in v1.6.0

func (s *TCPServer) Info() zerocopy.TCPServerInfo

Info implements the zerocopy.TCPServer Info method.

type TCPTransparentServer added in v1.4.0

type TCPTransparentServer struct{}

TCPTransparentServer is a transparent proxy server.

TCPTransparentServer implements the zerocopy TCPServer interface.

func (TCPTransparentServer) Accept added in v1.4.0

func (TCPTransparentServer) Accept(rawRW zerocopy.DirectReadWriteCloser) (rw zerocopy.ReadWriter, targetAddr conn.Addr, payload []byte, username string, err error)

Accept implements the zerocopy.TCPServer Accept method.

func (TCPTransparentServer) Info added in v1.6.0

Info implements the zerocopy.TCPServer Info method.

Jump to

Keyboard shortcuts

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