socks

package
v0.0.0-...-88b4fc5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdConnect      = 0x01
	CmdBind         = 0x02
	CmdUdpASSOCIATE = 0x03

	AtypIPV4   = 0x01
	AtypDomain = 0x03
	AtypIPV6   = 0x04
)
View Source
const (
	MethodNoAuth = 0x00
)
View Source
const (
	VersionSocks5 = 0x05
)

Variables

View Source
var (
	ErrVersionFailed  = errors.New("socks5 version err")
	ErrMessageInvalid = errors.New("socks5 message invalid")
	ErrNotSupportCmd  = errors.New("not support cmd")
)

Functions

func DefaultParseFunc

func DefaultParseFunc(dataStream <-chan []byte) error

func SendSocks5Reply

func SendSocks5Reply(conn net.Conn) error

Types

type DefaultParser

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

func (*DefaultParser) Close

func (p *DefaultParser) Close() error

func (*DefaultParser) Read

func (p *DefaultParser) Read(input []byte) (n int, err error)

func (*DefaultParser) Write

func (p *DefaultParser) Write(input []byte) (int, error)

type HandshakeHandler

type HandshakeHandler struct{}

func NewHandshakeHandler

func NewHandshakeHandler() *HandshakeHandler

func (*HandshakeHandler) Handle

func (h *HandshakeHandler) Handle(conn net.Conn) (RelayInfo, error)

type InitMsgHandler

type InitMsgHandler struct{}

func NewInitMsgHandler

func NewInitMsgHandler() *InitMsgHandler

func (*InitMsgHandler) Handle

func (p *InitMsgHandler) Handle(conn net.Conn) error

type Parser

type Parser interface {
	Write(input []byte) (int, error)
	Read(input []byte) (int, error)
	Close() error
}

func NewParser

func NewParser(localIP, remoteIP string, rwc io.ReadWriteCloser) Parser

type RelayInfo

type RelayInfo struct {
	SrcConn net.Conn
	Cmd     byte
	Addr    string
}

type RelayServer

type RelayServer interface {
	Relay() error
}

func NewRelayServer

func NewRelayServer(info RelayInfo) RelayServer

type Socks5AuthReply

type Socks5AuthReply struct {
	// +----+--------+
	// |VER | METHOD |
	// +----+--------+
	// | 1  |   1    |
	// +----+--------+
	Ver    byte
	Method byte
}

func (*Socks5AuthReply) Encode

func (r *Socks5AuthReply) Encode() []byte

type Socks5Init

type Socks5Init struct {
	// |VER | NMETHODS | METHODS  |
	// +----+----------+----------+
	// | 1  |    1     | 1 to 255 |
	// +----+----------+----------+
	Ver      int
	NMethods int
	Methods  []byte
}

func (*Socks5Init) Decode

func (s *Socks5Init) Decode(conn net.Conn) error

type Socks5Proxy

type Socks5Proxy struct {
	Host         string
	Port         string
	FileHostPort string
	// contains filtered or unexported fields
}

func NewSocks5Proxy

func NewSocks5Proxy(c *Socks5ProxyConfig) *Socks5Proxy

func (*Socks5Proxy) Start

func (p *Socks5Proxy) Start() error

func (*Socks5Proxy) Stop

func (p *Socks5Proxy) Stop() error

type Socks5ProxyConfig

type Socks5ProxyConfig struct {
	Host         string
	Port         string
	FileHostPort string
}

type Socks5Reply

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

func NewSocksReply

func NewSocksReply() *Socks5Reply

func (*Socks5Reply) Bytes

func (r *Socks5Reply) Bytes() []byte

type Socks5Request

type Socks5Request struct {
	// +----+-----+-------+------+----------+----------+
	// |VER | CMD |  RSV  | ATYP | DST.ADDR | DST.PORT |
	// +----+-----+-------+------+----------+----------+
	// | 1  |  1  | X'00' |  1   | Variable |    2     |
	// +----+-----+-------+------+----------+----------+
	Ver  byte
	Cmd  byte
	Rsv  byte
	Atyp byte
	Addr string
	Port uint16
}

func (*Socks5Request) Decode

func (req *Socks5Request) Decode(conn net.Conn) error

type TcpRelayServer

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

func (*TcpRelayServer) Relay

func (s *TcpRelayServer) Relay() error

type UdpRelayServer

type UdpRelayServer struct{}

func (*UdpRelayServer) Relay

func (s *UdpRelayServer) Relay() error

Jump to

Keyboard shortcuts

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