Documentation ¶
Index ¶
- Constants
- Variables
- type AddrSpec
- type AddrType
- type AddressRewriter
- type AuthContext
- type AuthStatus
- type AuthType
- type Authenticator
- type Command
- type Config
- type CredentialStore
- type DNSResolver
- type NoAuthAuthenticator
- type Request
- type Resolver
- type Server
- type StaticCredentialStore
- type Status
- type UserPassAuthenticator
Constants ¶
const ( NoAuth AuthType = 0x00 NoAcceptable AuthType = 0xFF UserPassAuth AuthType = 0x02 AuthSuccess AuthStatus = 0x00 AuthFailure AuthStatus = 0x01 UserAuthVersion = 0x01 )
const ( Version uint8 = 0x05 CommandConnect Command = 0x01 CommandBind Command = 0x02 CommandAssociate Command = 0x03 StatusRequestGranted Status = 0x00 StatusGeneralFailure Status = 0x01 StatusConnectionNotAllowed Status = 0x02 StatusNetworkUnreachable Status = 0x03 StatusHostUnreachable Status = 0x04 StatusConnectionRefused Status = 0x05 StatusTTLExpired Status = 0x06 StatusCommandNotSupported Status = 0x07 StatusAddressNotSupported Status = 0x08 AddressTypeIPv4 AddrType = 0x01 AddressTypeIPv6 AddrType = 0x04 AddressTypeDomain AddrType = 0x03 )
Variables ¶
var ( ErrFailedToSendReply = errors.New("failed to send reply") ErrUnrecognizedAddrType = errors.New("unrecognized address type") )
var (
ErrAuthFailure = fmt.Errorf("authentication failure")
)
Functions ¶
This section is empty.
Types ¶
type AddrSpec ¶
AddrSpec is a SOCKS5 address specification
type AddressRewriter ¶
type AuthContext ¶
type AuthContext struct { // Method is the provided auth method Method AuthType // Payload provided during negotiation. // Keys depend on the used auth method. // For UserPass-auth contains Username Payload map[string]string }
AuthContext encapsulates authentication state provided during negotiation
type AuthStatus ¶ added in v0.8.0
type AuthStatus uint8
AuthStatus is the status of the authentication process
func (AuthStatus) Uint8 ¶ added in v0.8.0
func (a AuthStatus) Uint8() uint8
type AuthType ¶ added in v0.8.0
type AuthType uint8
AuthType is the type of authentication used by the client to connect to the proxy server (see RFC 1928, Section 2)
type Authenticator ¶
type Authenticator interface { Authenticate(reader io.Reader, writer io.Writer) (*AuthContext, error) GetCode() AuthType }
Authenticator is the interface implemented by types that can handle authentication
type Config ¶
type Config struct { Authentication []Authenticator Credentials CredentialStore Logger *zerolog.Logger DestConnTimeout time.Duration ClientConnTimeout time.Duration Dial func(network, addr string) (net.Conn, error) AfterRequest func(req *Request, conn net.Conn) Resolver Resolver Rewriter AddressRewriter }
type CredentialStore ¶
type DNSResolver ¶
type DNSResolver struct{}
type NoAuthAuthenticator ¶
type NoAuthAuthenticator struct{}
NoAuthAuthenticator is used to handle the "No Authentication" mode
func (*NoAuthAuthenticator) Authenticate ¶
func (a *NoAuthAuthenticator) Authenticate(_ io.Reader, writer io.Writer) (*AuthContext, error)
Authenticate handles the authentication process
func (*NoAuthAuthenticator) GetCode ¶
func (a *NoAuthAuthenticator) GetCode() AuthType
GetCode returns the code of the authenticator
type Request ¶
type Request struct { Version uint8 Command Command AuthContext *AuthContext RemoteAddr *AddrSpec DestAddr *AddrSpec BufferConn io.Reader Latency time.Duration // contains filtered or unexported fields }
Request is a SOCKS5 request message
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ListenAndServe ¶
type StaticCredentialStore ¶ added in v0.8.0
func (StaticCredentialStore) Valid ¶ added in v0.8.0
func (s StaticCredentialStore) Valid(user, password string) bool
type UserPassAuthenticator ¶
type UserPassAuthenticator struct {
Credentials CredentialStore
}
UserPassAuthenticator is used to handle username/password-based authentication
func (*UserPassAuthenticator) Authenticate ¶
func (a *UserPassAuthenticator) Authenticate(reader io.Reader, writer io.Writer) (*AuthContext, error)
Authenticate handles the authentication process
func (*UserPassAuthenticator) GetCode ¶
func (a *UserPassAuthenticator) GetCode() AuthType
GetCode returns the code of the authenticator