socks

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientHandshake

func ClientHandshake(request *protocol.RequestHeader, reader io.Reader, writer io.Writer, delayAuthWrite bool) (*net.Destination, error)

func ClientHandshake4

func ClientHandshake4(request *protocol.RequestHeader, reader io.Reader, writer io.Writer) error

func DecodeUDPPacket

func DecodeUDPPacket(packet *buf.Buffer) (*protocol.RequestHeader, error)

func EncodeUDPPacket

func EncodeUDPPacket(request *protocol.RequestHeader, data []byte) (*buf.Buffer, error)

func EncodeUDPPacketFromAddress

func EncodeUDPPacketFromAddress(address net.Destination, data []byte) (*buf.Buffer, error)

func ReadUntilNull

func ReadUntilNull(reader io.Reader) (string, error)

ReadUntilNull reads content from given reader, until a null (0x00) byte.

func ReadUsernamePassword

func ReadUsernamePassword(reader io.Reader) (string, string, error)

ReadUsernamePassword reads Socks 5 username/password message from the given reader. +----+------+----------+------+----------+ |VER | ULEN | UNAME | PLEN | PASSWD | +----+------+----------+------+----------+ | 1 | 1 | 1 to 255 | 1 | 1 to 255 | +----+------+----------+------+----------+

Types

type Client

type Client struct {
	ClientSettings
}

func NewClient

func NewClient(settings *ClientSettings) *Client

config won'e be nil, but may be zero-value

func (*Client) HandleFlow

func (c *Client) HandleFlow(ctx context.Context, dst net.Destination, rw buf.ReaderWriter) error

func (*Client) HandlePacketConn

func (c *Client) HandlePacketConn(ctx context.Context, dst net.Destination, pc udp.PacketReaderWriter) error

func (*Client) ListenPacket

func (c *Client) ListenPacket(ctx context.Context, dst net.Destination) (udp.UdpConn, error)

func (*Client) ProxyDial

func (c *Client) ProxyDial(ctx context.Context, dst net.Destination,
	initialData buf.MultiBuffer) (i.FlowConn, error)

type ClientSettings

type ClientSettings struct {
	ServerDest     net.Destination
	User, Secret   string
	Policy         i.TimeoutSetting
	DelayAuthWrite bool
	DNS            i.IPResolver
	Dialer         i.Dialer
}

type Server

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

Server is a SOCKS 5 proxy server

func NewServer

func NewServer(config *SocksServerConfig) *Server

NewServer creates a new Server object.

func (*Server) AddUser

func (s *Server) AddUser(user i.User)

func (*Server) FallbackProcess

func (s *Server) FallbackProcess(ctx context.Context, conn net.Conn) (bool, buf.MultiBuffer, error)

func (*Server) HasAccount

func (c *Server) HasAccount(username, password string) bool

func (*Server) Network

func (s *Server) Network() []nethelper.Network

func (*Server) Process

func (s *Server) Process(ctx context.Context, conn net.Conn) error

func (*Server) RemoveUser

func (s *Server) RemoveUser(id string)

type ServerSession

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

func (*ServerSession) Handshake

func (s *ServerSession) Handshake(reader io.Reader, writer io.Writer) (*protocol.RequestHeader, error)

Handshake performs a Socks4/4a/5 handshake.

type SocksServerConfig

type SocksServerConfig struct {
	Address    nethelper.Address
	UdpEnabled bool
	AuthType   pc.AuthType
	Policy     i.TimeoutSetting
	Handler    i.Handler
}

type UDPConn

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

func (*UDPConn) Close

func (c *UDPConn) Close() error

func (*UDPConn) CloseWrite

func (c *UDPConn) CloseWrite() error

func (*UDPConn) ReadPacket

func (c *UDPConn) ReadPacket() (*udp.Packet, error)

func (*UDPConn) WritePacket

func (c *UDPConn) WritePacket(p *udp.Packet) error

type UDPReader

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

func NewUDPReader

func NewUDPReader(reader io.Reader) *UDPReader

func (*UDPReader) Read

func (r *UDPReader) Read(p []byte) (int, error)

func (*UDPReader) ReadMultiBuffer

func (r *UDPReader) ReadMultiBuffer() (buf.MultiBuffer, error)

func (*UDPReader) ReadPacket

func (r *UDPReader) ReadPacket() (*udp.Packet, error)

type UDPWriter

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

func NewUDPWriter

func NewUDPWriter(request *protocol.RequestHeader, writer io.Writer) *UDPWriter

func (*UDPWriter) Write

func (w *UDPWriter) Write(b []byte) (int, error)

Write implements io.Writer.

func (*UDPWriter) WriteTo

func (w *UDPWriter) WriteTo(payload []byte, addr gonet.Addr) (n int, err error)

type User

type User struct {
	Name   string
	Secret string
}

Jump to

Keyboard shortcuts

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