Documentation ¶
Index ¶
Constants ¶
const ( CommandConnect uint8 = iota + 1 CommandBind CommandAssociate )
const ( AddressTypeIPv4 uint8 = iota + 1 AddressTypeDomainName AddressTypeIPv6 )
const ( DestIPv4Size = 4 + 2 // IPv4 + Port DestIPv6Size = 16 + 2 // IPv6 + Port )
const AuthUserPWVersion = 0x1
const VERSION uint8 = 0x05
Variables ¶
var ( ErrUnimplemented = errors.New("unimplemented") ErrUnsupportedVersion = errors.New("unsupported version") ErrUnsupportedAddressType = errors.New("unsupported address type") ErrUnknownNetwork = errors.New("unknown network") ErrAuthNoneAcceptable = errors.New("auth none acceptable") ErrInvalidHostnameLength = errors.New("invalid hostname length") )
General
var ( ErrReplyGeneralFailure = errors.New("general SOCKS server failure") ErrReplyConnectionNotAllowed = errors.New("connection not allowed by ruleset") ErrReplyNetworkUnreachable = errors.New("network unreachable") ErrReplyHostUnreachable = errors.New("host unreachable") ErrReplyConnectionRefused = errors.New("connection refused") ErrReplyTTLExpired = errors.New("TTL expired") ErrReplyCommandNotSupported = errors.New("command not supported") ErrReplyAddressTypeNotSupported = errors.New("address type not supported") )
Reply
var ( ErrAuthVersion = errors.New("invalid version") ErrAuthUnknown = errors.New("unknown authentication method") )
Auth UserPW
var ErrInvalidBufferSize = errors.New("invalid buffer size")
var ErrMethodsLimit = errors.New("reached the limit of methods")
Functions ¶
This section is empty.
Types ¶
type AuthGSSAPI ¶
type AuthGSSAPI struct { }
AuthGSSAPI is the GSSAPI authentication method. Currently unimplemented
type AuthHandler ¶
type AuthHandler func(authMethod AuthMethod, authData any) bool
AuthHandler used to determine if the authentication is valid or not
type AuthMethod ¶
type AuthMethod uint8
AuthMethod ...
X'03' to X'7F' IANA ASSIGNED X'80' to X'FE' RESERVED FOR PRIVATE METHODS
const ( MethodAuthNone AuthMethod = iota // no authentication required MethodAuthGSSAPI // GSSAPI MethodAuthUserPW // username/password MethodAuthCHAP // Challenge-Handshake Authentication Protocol MerhodAuthCRAM // Challenge-Response Authentication Method MethodAuthSSL // Secure Sockets Layer MethodAuthNDS // NDS Authentication MethodAuthMAF // Multi-Authentication Framework MethodAuthJSB // JSON Parameter Block MethodAuthNoneAcceptable AuthMethod = 0xFF // no acceptable methods )
type AuthReply ¶
type AuthReply struct { Version uint8 // required, should be the version of the authentication method Status ReplyStatus Validate func(uint8) error }
AuthReply is the reply after SOCKS5 authentication method.
type AuthUserPW ¶
type AuthUserPW struct { Version uint8 // unrequired, only used by Unpack UsernameLength uint8 // unrequired, only used by Unpack Username []byte PasswordLength uint8 // unrequired, only used by Unpack Password []byte }
AuthUserPW is the username/password authentication method.
func (AuthUserPW) Method ¶
func (AuthUserPW) Method() uint8
func (*AuthUserPW) Pack ¶
func (auth *AuthUserPW) Pack(w io.Writer) (err error)
Pack writes the authentication method to the given writer.
func (*AuthUserPW) Unpack ¶
func (auth *AuthUserPW) Unpack(r io.Reader) (err error)
Unpack reads the authentication method from the given reader.
func (AuthUserPW) Ver ¶
func (AuthUserPW) Ver() uint8
type Destination ¶
type HandshakeReply ¶
type HandshakeReply struct { Version uint8 Method AuthMethod }
HandshakeReply is the handshake reply for SOCKS V5.
type HandshakeRequest ¶
type HandshakeRequest struct { Version uint8 // unrequired, only used by Unpack NMethods uint8 // unrequired, only used by Unpack Methods []AuthMethod }
HandshakeRequest is the handshake request for SOCKS V5.
type Reply ¶
type Reply struct { Version uint8 // unrequired, only used by Unpack Status ReplyStatus Reserved uint8 // unrequired, only used by Unpack AddressType uint8 Bind ReplyBind }
Reply is a reply structure for SOCKS V5.
type ReplyStatus ¶
type ReplyStatus uint8
ReplyStatus ...
X'09' to X'FF' unassigned
const ( ReplySuccess ReplyStatus = iota // succeeded ReplyGeneralFailure // general SOCKS server failure ReplyConnectionNotAllowed // connection not allowed by ruleset ReplyNetworkUnreachable // Network unreachable ReplyHostUnreachable // Host unreachable ReplyConnectionRefused // Connection refused ReplyTTLExpired // TTL expired ReplyCommandNotSupported // Command not supported ReplyAddressTypeNotSupported // Address type not supported )
func (ReplyStatus) String ¶
func (i ReplyStatus) String() string
type Request ¶
type Request struct { Version uint8 // unrequired, only used by Unpack Command uint8 // required only by Pack Reserved uint8 // unrequired, only used by Unpack AddressType uint8 // unrequired, only used by Unpack Destination Destination // required only by Pack }
Request is the request for SOCKS V5.
type RequestV5DestDomainName ¶
RequestV5DestDomainName is a domaim name destination.
func (*RequestV5DestDomainName) Kind ¶
func (h *RequestV5DestDomainName) Kind() uint8
Kind returns AddressType
func (*RequestV5DestDomainName) Put ¶
func (h *RequestV5DestDomainName) Put(buf []byte) error
func (*RequestV5DestDomainName) Size ¶
func (h *RequestV5DestDomainName) Size() uint8
Size returns binary length of struct
type RequestV5DestIPv4 ¶
RequestV5DestinationIPv4 is a IPv4 destination.
func (*RequestV5DestIPv4) Size ¶
func (h *RequestV5DestIPv4) Size() uint8
Size returns binary length of struct
type RequestV5DestIPv6 ¶
RequestV5DestinationIPv6 is a IPv6 destination.
func (*RequestV5DestIPv6) Put ¶
func (h *RequestV5DestIPv6) Put(buf []byte) error
func (*RequestV5DestIPv6) Size ¶
func (h *RequestV5DestIPv6) Size() uint8
Size returns binary length of struct