Documentation
¶
Overview ¶
Package socks is a generated GoMock package.
Index ¶
- type AddrType
- type AssociateCommand
- type AuthState
- type AuthType
- type Authentication
- type Authenticator
- type BindCommand
- type Cmd
- type ConnectCommand
- type Handshake
- type Interceptor
- type MockAuthenticator
- type MockAuthenticatorMockRecorder
- type Process
- func (s *Process) Accept(session *event.Session) error
- func (s *Process) Active(session *event.Session, _ any) (any, error)
- func (s *Process) AddAuthenticator(authenticator Authenticator)
- func (s *Process) AddInterceptor(interceptor Interceptor)
- func (s *Process) RuleCheck(request *Request) error
- func (s *Process) SetAssociate(associate AssociateCommand)
- func (s *Process) SetBind(bind BindCommand)
- func (s *Process) SetConnect(connect ConnectCommand)
- func (s *Process) SetNoAuth(noAuth bool)
- type Request
- type ResType
- type Response
- type UdpRelay
- func (u *UdpRelay) Buf() *codec.ByteBuf
- func (u *UdpRelay) Decode() error
- func (u *UdpRelay) DecodeBuff(buffer *codec.ByteBuf) error
- func (u *UdpRelay) Encode() error
- func (u *UdpRelay) GetDstAddr() *net.UDPAddr
- func (u *UdpRelay) GetDstAddrString() string
- func (u *UdpRelay) Payload() ([]byte, error)
- func (u *UdpRelay) Serialize() ([]byte, error)
- func (u *UdpRelay) SetAddr(addr *net.UDPAddr)
- func (u *UdpRelay) SetPayload(payload []byte)
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssociateCommand ¶
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 ConnectCommand ¶
type Handshake ¶
type Handshake struct {
// contains filtered or unexported fields
}
Handshake socks握手对象
func (*Handshake) AddAuthType ¶
AddAuthType 添加认证类型
type Interceptor ¶ added in v1.6.1
Interceptor socks拦截器接口
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 ¶
func (m *MockAuthenticator) EXPECT() *MockAuthenticatorMockRecorder
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.
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
func NewProcess ¶
func NewProcess() *Process
func (*Process) AddAuthenticator ¶
func (s *Process) AddAuthenticator(authenticator Authenticator)
AddAuthenticator 注册认证器
func (*Process) AddInterceptor ¶ added in v1.6.1
func (s *Process) AddInterceptor(interceptor Interceptor)
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)
type Request ¶
type Request struct {
Version Version // 协议版本
Cmd Cmd // 命令
DstAddrType AddrType // 目标地址类型
DstAddr []byte // 目标地址
DstPort uint16 // 目标端口
// contains filtered or unexported fields
}
func (*Request) Decoder ¶
Decoder 解码器, 从缓冲区读取数据解析协议, RFC1928 https://datatracker.ietf.org/doc/html/rfc1928
func (*Request) GetDstAddr ¶ added in v1.6.1
func (*Request) GetDstAddrString ¶ added in v1.6.2
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 (*Response) SetAddrAndPort ¶
SetAddrAndPort 设置ip和端口
func (*Response) SetHandshake ¶
type UdpRelay ¶ added in v1.6.1
type UdpRelay struct {
AddType AddrType // 绑定地址类型
DstAddr []byte // 目标地址
DstPort uint16 // 目标端口
// contains filtered or unexported fields
}
UdpRelay UDP中继对象
func NewUdpRelay ¶ added in v1.6.1
func (*UdpRelay) DecodeBuff ¶ added in v1.6.1
DecodeBuff 解码, 从指定缓冲区解析
func (*UdpRelay) GetDstAddr ¶ added in v1.6.1
func (*UdpRelay) GetDstAddrString ¶ added in v1.6.2
func (*UdpRelay) SetPayload ¶ added in v1.6.1
SetPayload 设置载荷