socks

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package socks is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddrType

type AddrType byte

AddrType 目标地址类型

const (
	IpV4   AddrType = 1
	Ipv6   AddrType = 4
	Domain AddrType = 3
)

type AssociateCommand

type AssociateCommand interface {
	Associate(request *Request, response *Response) error
}

type AuthState

type AuthState byte // 认证结果
const (
	SUCCESS AuthState = 0 // 认证成功
	FIELD   AuthState = 1 // 认证失败
)

type AuthType

type AuthType byte // 认证方法
const (
	NoAuth        AuthType = 0   // 无需认证
	GssAPIAuth    AuthType = 1   // GSS 认证
	UserPassAuth  AuthType = 2   // 账号/密码认证
	IanaAuthStart AuthType = 3   // iana 认证开始标志
	IanaAuthEnd   AuthType = 127 // iana 认证结束标志
	NoAcceptable  AuthType = 255 // 无可用认证方式
)

type Authentication

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

Authentication 身份认证

func NewAuthentication

func NewAuthentication() *Authentication

func (*Authentication) AddAuthenticator

func (a *Authentication) AddAuthenticator(authenticator Authenticator)

AddAuthenticator 添加认证器

func (*Authentication) Auth

func (a *Authentication) Auth(handshake *Handshake) error

Auth 身份认证, 按照客户端的认证方法顺序匹配,一旦匹配到合适的认证方式, 则终止匹配, 然后执行身份验证并返回结果

func (*Authentication) MatchAuthenticator

func (a *Authentication) MatchAuthenticator(authType AuthType) Authenticator

MatchAuthenticator 匹配认证器

func (*Authentication) SetNoAuth

func (a *Authentication) SetNoAuth(noAuth bool)

SetNoAuth 是否允许无认证

type Authenticator

type Authenticator interface {
	AuthMethod() AuthType             // 支持的认证类型
	Challenge(user, pass string) bool // 认证结果
}

Authenticator 认证器接口

type BindCommand

type BindCommand interface {
	Bind(request *Request, response *Response) error
}

type Cmd

type Cmd byte

Cmd 命令类型

const (
	Connect   Cmd = 1
	Bind      Cmd = 2
	Associate Cmd = 3
)

type ConnectCommand

type ConnectCommand interface {
	Connect(request *Request, response *Response) error
}

type Handshake

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

Handshake socks握手对象

func NewHandshake

func NewHandshake(readBuff *codec.ByteBuf) *Handshake

NewHandshake 构造函数

func (*Handshake) AddAuthType

func (h *Handshake) AddAuthType(authType AuthType)

AddAuthType 添加认证类型

func (*Handshake) AuthTypes

func (h *Handshake) AuthTypes() []AuthType

AuthTypes 获取认证类型

func (*Handshake) Decoder

func (h *Handshake) Decoder() error

Decoder 握手解码

type MockAuthenticator

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

MockAuthenticator is a mock of Authenticator interface.

func NewMockAuthenticator

func NewMockAuthenticator(ctrl *gomock.Controller) *MockAuthenticator

NewMockAuthenticator creates a new mock instance.

func (*MockAuthenticator) AuthMethod

func (m *MockAuthenticator) AuthMethod() AuthType

AuthMethod mocks base method.

func (*MockAuthenticator) Challenge

func (m *MockAuthenticator) Challenge(user, pass string) bool

Challenge mocks base method.

func (*MockAuthenticator) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockAuthenticatorMockRecorder

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

MockAuthenticatorMockRecorder is the mock recorder for MockAuthenticator.

func (*MockAuthenticatorMockRecorder) AuthMethod

func (mr *MockAuthenticatorMockRecorder) AuthMethod() *gomock.Call

AuthMethod indicates an expected call of AuthMethod.

func (*MockAuthenticatorMockRecorder) Challenge

func (mr *MockAuthenticatorMockRecorder) Challenge(user, pass any) *gomock.Call

Challenge indicates an expected call of Challenge.

type Process

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

func NewProcess

func NewProcess() *Process

func (*Process) Accept

func (s *Process) Accept(session *event.Session) error

func (*Process) Active

func (s *Process) Active(session *event.Session, _ any) (any, error)

func (*Process) AddAuthenticator

func (s *Process) AddAuthenticator(authenticator Authenticator)

AddAuthenticator 注册认证器

func (*Process) Disconnect

func (s *Process) Disconnect(_ *event.Session) error

func (*Process) RuleCheck

func (s *Process) RuleCheck(request *Request, response *Response) error

func (*Process) SetAssociate

func (s *Process) SetAssociate(associate AssociateCommand)

func (*Process) SetBind

func (s *Process) SetBind(bind BindCommand)

func (*Process) SetConnect

func (s *Process) SetConnect(connect ConnectCommand)

func (*Process) SetNoAuth

func (s *Process) SetNoAuth(noAuth bool)

SetNoAuth 是否允许无认证

type Request

type Request struct {
	Version    Version  // 协议版本
	Cmd        Cmd      // 命令
	TargetType AddrType // 目标地址类型
	DstAddr    []byte   // 目标地址
	DstPort    uint16   // 目标端口
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(handshake *Handshake, session *event.Session) *Request

func (*Request) Buff

func (r *Request) Buff() *codec.ByteBuf

func (*Request) Decoder

func (r *Request) Decoder() error

Decoder 解码器, 从缓冲区读取数据解析协议, RFC1928 https://datatracker.ietf.org/doc/html/rfc1928

func (*Request) Encode

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

Encode 编码器

func (*Request) Session added in v1.4.1

func (r *Request) Session() *event.Session

type ResType

type ResType byte

ResType 应答类型

const (
	SuccessReply         ResType = 0 // 成功
	ServerFailure        ResType = 1 // 服务器异常
	RuleFailure          ResType = 2 // 规则不允许
	NetworkUnreachable   ResType = 3 // 网络无法访问
	HostUnreachable      ResType = 4 // 主机无法访问
	ConnectionRefused    ResType = 5 // 连接被拒绝
	TtlExpired           ResType = 6 // TTL超时
	CommandNotSupported  ResType = 7 // 不支持的命令
	AddrTypeNotSupported ResType = 8 // 不支持的地址类型
)

type Response

type Response struct {
	Version Version // 协议版本
	ResType ResType // 应答类型

	AddType AddrType // 绑定地址类型
	BndAddr []byte   // 绑定地址
	BndPort uint16   // 绑定端口
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(handshake *Handshake, session *event.Session) *Response

func (*Response) Encoder

func (r *Response) Encoder() error

Encoder 编码器, 把Response对象转为为二进制写入缓冲区

func (*Response) Reply

func (r *Response) Reply(resType ResType) error

func (*Response) Session added in v1.4.1

func (r *Response) Session() *event.Session

func (*Response) SetAddrAndPort

func (r *Response) SetAddrAndPort(addr net.Addr) error

SetAddrAndPort 设置ip和端口

func (*Response) SetHandshake

func (r *Response) SetHandshake(handshake *Handshake)

type Version

type Version byte

Version 协议版本

const (
	V4 Version = 4
	V5 Version = 5
)

Jump to

Keyboard shortcuts

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