direct

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultShadowsocksNoneUDPNATServer = &ShadowsocksNoneUDPNATServer{}
	DefaultSocks5UDPNATServer          = &Socks5UDPNATServer{}
)

Functions

func NewShadowsocksNoneUDPClient

func NewShadowsocksNoneUDPClient(addrPort netip.AddrPort, mtu, fwmark int) *zerocopy.SimpleUDPClient

func NewSocks5UDPClient

func NewSocks5UDPClient(addrPort netip.AddrPort, mtu, fwmark int) *zerocopy.SimpleUDPClient

NewSocks5UDPClient creates a SOCKS5 UDP client.

Technically, each UDP session should be preceded by a UDP ASSOCIATE request. But most censorship circumvention programs do not require this. So we just skip this little ritual.

func NewUDPClient

func NewUDPClient(mtu, fwmark int, preferIPv6 bool) *zerocopy.SimpleUDPClient

Types

type DirectPacketClientPackUnpacker added in v1.1.0

type DirectPacketClientPackUnpacker struct {
	zerocopy.ZeroHeadroom
	// contains filtered or unexported fields
}

DirectPacketClientPackUnpacker packs and unpacks packets for direct connection.

DirectPacketClientPackUnpacker implements the zerocopy ClientPacker and Unpacker interfaces.

func NewDirectPacketClientPackUnpacker added in v1.1.0

func NewDirectPacketClientPackUnpacker(mtu int, preferIPv6 bool) *DirectPacketClientPackUnpacker

NewDirectPacketClientPackUnpacker creates a zerocopy.ClientPackUnpacker for direct connection.

func (*DirectPacketClientPackUnpacker) PackInPlace added in v1.1.0

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

PackInPlace implements the zerocopy.ClientPacker PackInPlace method.

func (*DirectPacketClientPackUnpacker) UnpackInPlace added in v1.1.0

func (p *DirectPacketClientPackUnpacker) 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 {
	zerocopy.ZeroHeadroom
	// 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) 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) 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 {
	zerocopy.ZeroHeadroom
	// 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(rw zerocopy.DirectReadWriteCloser, targetAddr conn.Addr, payload []byte) (*DirectStreamReadWriter, 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 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, conn tfo.Conn) (dsrw *DirectStreamReadWriter, addr conn.Addr, err error)

NewSocks5StreamServerReadWriter handles a SOCKS5 request from rw and wraps rw into a ReadWriter ready for use. conn must be provided when UDP is enabled.

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) DirectReadCloser

func (rw *DirectStreamReadWriter) DirectReadCloser() io.ReadCloser

DirectReadCloser implements the DirectReadCloser DirectReadCloser method.

func (*DirectStreamReadWriter) DirectWriteCloser

func (rw *DirectStreamReadWriter) DirectWriteCloser() io.WriteCloser

DirectWriteCloser implements the DirectWriteCloser DirectWriteCloser method.

func (*DirectStreamReadWriter) MaxPayloadSizePerWrite

func (rw *DirectStreamReadWriter) MaxPayloadSizePerWrite() int

MaxPayloadSizePerWrite implements the Writer MaxPayloadSizePerWrite method.

func (*DirectStreamReadWriter) MinPayloadBufferSizePerRead

func (rw *DirectStreamReadWriter) MinPayloadBufferSizePerRead() int

MinPayloadBufferSizePerRead implements the Reader MinPayloadBufferSizePerRead 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) WriteZeroCopy

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

WriteZeroCopy implements the Writer WriteZeroCopy method.

type DirectUDPNATServer added in v1.1.0

type DirectUDPNATServer struct {
	zerocopy.ZeroHeadroom
	// 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) NewSession added in v1.1.0

NewSession implements the zerocopy.UDPNATServer NewSession method.

type ShadowsocksNonePacketClientPackUnpacker added in v1.1.0

type ShadowsocksNonePacketClientPackUnpacker struct {
	ShadowsocksNonePacketHeadroom
	// contains filtered or unexported fields
}

ShadowsocksNonePacketClientPackUnpacker implements the zerocopy ClientPacker and Unpacker interfaces.

func NewShadowsocksNonePacketClientPackUnpacker added in v1.1.0

func NewShadowsocksNonePacketClientPackUnpacker(serverAddrPort netip.AddrPort, maxPacketSize int) *ShadowsocksNonePacketClientPackUnpacker

NewShadowsocksNonePacketClientPackUnpacker creates a zerocopy.ClientPackUnpacker for communicating with a Shadowsocks none server.

func (*ShadowsocksNonePacketClientPackUnpacker) PackInPlace added in v1.1.0

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

PackInPlace implements the zerocopy.ClientPacker PackInPlace method.

func (*ShadowsocksNonePacketClientPackUnpacker) UnpackInPlace added in v1.1.0

func (p *ShadowsocksNonePacketClientPackUnpacker) 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 ShadowsocksNonePacketHeadroom added in v1.1.0

type ShadowsocksNonePacketHeadroom struct{}

ShadowsocksNonePacketHeadroom implements the zerocopy Headroom interface.

func (*ShadowsocksNonePacketHeadroom) FrontHeadroom added in v1.1.0

func (p *ShadowsocksNonePacketHeadroom) FrontHeadroom() int

FrontHeadroom implements the zerocopy.Headroom FrontHeadroom method.

func (*ShadowsocksNonePacketHeadroom) RearHeadroom added in v1.1.0

func (p *ShadowsocksNonePacketHeadroom) RearHeadroom() int

RearHeadroom implements the zerocopy.Headroom RearHeadroom method.

type ShadowsocksNonePacketServerPackUnpacker added in v1.1.0

type ShadowsocksNonePacketServerPackUnpacker struct {
	ShadowsocksNonePacketHeadroom
	// contains filtered or unexported fields
}

ShadowsocksNonePacketServerPackUnpacker implements the zerocopy ServerPacker and Unpacker interfaces.

func (*ShadowsocksNonePacketServerPackUnpacker) PackInPlace added in v1.1.0

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

PackInPlace implements the zerocopy.ServerPacker PackInPlace method.

func (*ShadowsocksNonePacketServerPackUnpacker) UnpackInPlace added in v1.1.0

func (p *ShadowsocksNonePacketServerPackUnpacker) 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(address string, dialerTFO bool, dialerFwmark int) *ShadowsocksNoneTCPClient

func (*ShadowsocksNoneTCPClient) Dial

func (c *ShadowsocksNoneTCPClient) Dial(targetAddr conn.Addr, payload []byte) (tfoConn tfo.Conn, rw zerocopy.ReadWriter, err error)

Dial implements the zerocopy.TCPClient Dial method.

func (*ShadowsocksNoneTCPClient) NativeInitialPayload

func (c *ShadowsocksNoneTCPClient) NativeInitialPayload() bool

NativeInitialPayload implements the zerocopy.TCPClient NativeInitialPayload method.

type ShadowsocksNoneTCPServer

type ShadowsocksNoneTCPServer struct{}

ShadowsocksNoneTCPServer implements the zerocopy TCPServer interface.

func NewShadowsocksNoneTCPServer

func NewShadowsocksNoneTCPServer() *ShadowsocksNoneTCPServer

func (*ShadowsocksNoneTCPServer) Accept

func (s *ShadowsocksNoneTCPServer) Accept(conn tfo.Conn) (rw zerocopy.ReadWriter, targetAddr conn.Addr, payload []byte, err error)

Accept implements the zerocopy.TCPServer Accept method.

func (*ShadowsocksNoneTCPServer) DefaultTCPConnCloser

func (s *ShadowsocksNoneTCPServer) DefaultTCPConnCloser() zerocopy.TCPConnCloser

DefaultTCPConnCloser implements the zerocopy.TCPServer DefaultTCPConnCloser method.

func (*ShadowsocksNoneTCPServer) NativeInitialPayload

func (s *ShadowsocksNoneTCPServer) NativeInitialPayload() bool

NativeInitialPayload implements the zerocopy.TCPServer NativeInitialPayload method.

type ShadowsocksNoneUDPNATServer added in v1.1.0

type ShadowsocksNoneUDPNATServer struct {
	ShadowsocksNonePacketHeadroom
}

ShadowsocksNoneUDPNATServer implements the zerocopy UDPNATServer interface.

func (*ShadowsocksNoneUDPNATServer) NewSession added in v1.1.0

NewSession implements the zerocopy.UDPNATServer NewSession method.

type Socks5PacketClientPackUnpacker added in v1.1.0

type Socks5PacketClientPackUnpacker struct {
	Socks5PacketHeadroom
	// contains filtered or unexported fields
}

Socks5PacketClientPackUnpacker implements the zerocopy ClientPacker and Unpacker interfaces.

func NewSocks5PacketClientPackUnpacker added in v1.1.0

func NewSocks5PacketClientPackUnpacker(serverAddrPort netip.AddrPort, maxPacketSize int) *Socks5PacketClientPackUnpacker

NewSocks5PacketClientPackUnpacker creates a zerocopy.ClientPackUnpacker for communicating with a SOCKS5 server.

func (*Socks5PacketClientPackUnpacker) PackInPlace added in v1.1.0

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

PackInPlace implements the zerocopy.ClientPacker PackInPlace method.

func (*Socks5PacketClientPackUnpacker) UnpackInPlace added in v1.1.0

func (p *Socks5PacketClientPackUnpacker) 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 Socks5PacketHeadroom added in v1.1.0

type Socks5PacketHeadroom struct{}

Socks5PacketHeadroom implements the zerocopy Headroom interface.

func (*Socks5PacketHeadroom) FrontHeadroom added in v1.1.0

func (p *Socks5PacketHeadroom) FrontHeadroom() int

FrontHeadroom implements the zerocopy.Headroom FrontHeadroom method.

func (*Socks5PacketHeadroom) RearHeadroom added in v1.1.0

func (p *Socks5PacketHeadroom) RearHeadroom() int

RearHeadroom implements the zerocopy.Headroom RearHeadroom method.

type Socks5PacketServerPackUnpacker added in v1.1.0

type Socks5PacketServerPackUnpacker struct {
	Socks5PacketHeadroom
	// contains filtered or unexported fields
}

Socks5PacketServerPackUnpacker implements the zerocopy ServerPacker and Unpacker interfaces.

func (*Socks5PacketServerPackUnpacker) PackInPlace added in v1.1.0

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

PackInPlace implements the zerocopy.ServerPacker PackInPlace method.

func (*Socks5PacketServerPackUnpacker) UnpackInPlace added in v1.1.0

func (p *Socks5PacketServerPackUnpacker) 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 implements the zerocopy TCPClient interface.

func NewSocks5TCPClient

func NewSocks5TCPClient(address string, dialerTFO bool, dialerFwmark int) *Socks5TCPClient

func (*Socks5TCPClient) Dial

func (c *Socks5TCPClient) Dial(targetAddr conn.Addr, payload []byte) (tfoConn tfo.Conn, rw zerocopy.ReadWriter, err error)

Dial implements the zerocopy.TCPClient Dial method.

func (*Socks5TCPClient) NativeInitialPayload

func (c *Socks5TCPClient) NativeInitialPayload() bool

NativeInitialPayload implements the zerocopy.TCPClient NativeInitialPayload method.

type Socks5TCPServer

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

Socks5TCPServer implements the zerocopy TCPServer interface.

func NewSocks5TCPServer

func NewSocks5TCPServer(enableTCP, enableUDP bool) *Socks5TCPServer

func (*Socks5TCPServer) Accept

func (s *Socks5TCPServer) Accept(conn tfo.Conn) (rw zerocopy.ReadWriter, targetAddr conn.Addr, payload []byte, err error)

Accept implements the zerocopy.TCPServer Accept method.

func (*Socks5TCPServer) DefaultTCPConnCloser

func (s *Socks5TCPServer) DefaultTCPConnCloser() zerocopy.TCPConnCloser

DefaultTCPConnCloser implements the zerocopy.TCPServer DefaultTCPConnCloser method.

func (*Socks5TCPServer) NativeInitialPayload

func (s *Socks5TCPServer) NativeInitialPayload() bool

NativeInitialPayload implements the zerocopy.TCPServer NativeInitialPayload method.

type Socks5UDPNATServer added in v1.1.0

type Socks5UDPNATServer struct {
	Socks5PacketHeadroom
}

Socks5UDPNATServer implements the zerocopy UDPNATServer interface.

func (*Socks5UDPNATServer) NewSession added in v1.1.0

NewSession implements the zerocopy.UDPNATServer NewSession method.

type TCPClient

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

TCPClient implements the zerocopy TCPClient interface.

func NewTCPClient

func NewTCPClient(dialerTFO bool, dialerFwmark int) *TCPClient

func (*TCPClient) Dial

func (c *TCPClient) Dial(targetAddr conn.Addr, payload []byte) (tfoConn tfo.Conn, rw zerocopy.ReadWriter, err error)

Dial implements the zerocopy.TCPClient Dial method.

func (*TCPClient) NativeInitialPayload

func (c *TCPClient) NativeInitialPayload() bool

NativeInitialPayload implements the zerocopy.TCPClient NativeInitialPayload 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(conn tfo.Conn) (rw zerocopy.ReadWriter, targetAddr conn.Addr, payload []byte, err error)

Accept implements the zerocopy.TCPServer Accept method.

func (*TCPServer) DefaultTCPConnCloser

func (s *TCPServer) DefaultTCPConnCloser() zerocopy.TCPConnCloser

DefaultTCPConnCloser implements the zerocopy.TCPServer DefaultTCPConnCloser method.

func (*TCPServer) NativeInitialPayload

func (s *TCPServer) NativeInitialPayload() bool

NativeInitialPayload implements the zerocopy.TCPServer NativeInitialPayload method.

Jump to

Keyboard shortcuts

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