Documentation ¶
Index ¶
- func SendReply(w io.Writer, rep uint8, bindAddr net.Addr) error
- type AddressRewriter
- type AuthContext
- type Authenticator
- type CredentialStore
- type DNSResolver
- type GPool
- type Logger
- type NameResolver
- type NoAuthAuthenticator
- type Option
- func WithAssociateHandle(h func(ctx context.Context, writer io.Writer, request *Request) error) Option
- func WithAuthMethods(authMethods []Authenticator) Option
- func WithBindHandle(h func(ctx context.Context, writer io.Writer, request *Request) error) Option
- func WithBindIP(ip net.IP) Option
- func WithBufferPool(bufferPool bufferpool.BufPool) Option
- func WithConnectHandle(h func(ctx context.Context, writer io.Writer, request *Request) error) Option
- func WithCredential(cs CredentialStore) Option
- func WithDial(dial func(ctx context.Context, network, addr string) (net.Conn, error)) Option
- func WithGPool(pool GPool) Option
- func WithLogger(l Logger) Option
- func WithResolver(res NameResolver) Option
- func WithRewriter(rew AddressRewriter) Option
- func WithRule(rule RuleSet) Option
- type PermitCommand
- type Request
- type RuleSet
- type Server
- type StaticCredentials
- type Std
- type UserPassAuthenticator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddressRewriter ¶
type AddressRewriter interface {
Rewrite(ctx context.Context, request *Request) (context.Context, *statute.AddrSpec)
}
AddressRewriter is used to rewrite a destination transparently
type AuthContext ¶
type AuthContext struct { // Provided auth method Method uint8 // Payload provided during negotiation. // Keys depend on the used auth method. // For UserPass auth contains username/password Payload map[string]string }
AuthContext A Request encapsulates authentication state provided during negotiation
type Authenticator ¶
type Authenticator interface { Authenticate(reader io.Reader, writer io.Writer, userAddr string) (*AuthContext, error) GetCode() uint8 }
Authenticator provide auth
type CredentialStore ¶
CredentialStore is used to support user/pass authentication optional network addr if you want to limit user network addr,you can refuse it.
type GPool ¶
type GPool interface {
Submit(f func()) error
}
GPool is used to implement custom goroutine pool default use goroutine
type Logger ¶
type Logger interface {
Errorf(format string, arg ...interface{})
}
Logger is used to provide debug logger
type NameResolver ¶
type NameResolver interface {
Resolve(ctx context.Context, name string) (context.Context, net.IP, error)
}
NameResolver is used to implement custom name resolution
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, _ string) (*AuthContext, error)
Authenticate implement interface Authenticator
func (NoAuthAuthenticator) GetCode ¶
func (a NoAuthAuthenticator) GetCode() uint8
GetCode implement interface Authenticator
type Option ¶
type Option func(s *Server)
Option user's option
func WithAssociateHandle ¶
func WithAssociateHandle(h func(ctx context.Context, writer io.Writer, request *Request) error) Option
WithAssociateHandle is used to handle a user's associate command
func WithAuthMethods ¶
func WithAuthMethods(authMethods []Authenticator) Option
WithAuthMethods can be provided to implement custom authentication By default, "auth-less" mode is enabled. For password-based auth use UserPassAuthenticator.
func WithBindHandle ¶
WithBindHandle is used to handle a user's bind command
func WithBufferPool ¶
func WithBufferPool(bufferPool bufferpool.BufPool) Option
WithBufferPool can be provided to implement custom buffer pool By default, buffer pool use size is 32k
func WithConnectHandle ¶
func WithConnectHandle(h func(ctx context.Context, writer io.Writer, request *Request) error) Option
WithConnectHandle is used to handle a user's connect command
func WithCredential ¶
func WithCredential(cs CredentialStore) Option
WithCredential If provided, username/password authentication is enabled, by appending a UserPassAuthenticator to AuthMethods. If not provided, and AUthMethods is nil, then "auth-less" mode is enabled.
func WithLogger ¶
WithLogger can be used to provide a custom log target. Defaults to ioutil.Discard.
func WithResolver ¶
func WithResolver(res NameResolver) Option
WithResolver can be provided to do custom name resolution. Defaults to DNSResolver if not provided.
func WithRewriter ¶
func WithRewriter(rew AddressRewriter) Option
WithRewriter can be used to transparently rewrite addresses. This is invoked before the RuleSet is invoked. Defaults to NoRewrite.
type PermitCommand ¶
PermitCommand is an implementation of the RuleSet which enables filtering supported commands
type Request ¶
type Request struct { statute.Request // AuthContext provided during negotiation AuthContext *AuthContext // LocalAddr of the the network server listen LocalAddr net.Addr // RemoteAddr of the the network that sent the request RemoteAddr net.Addr // DestAddr of the actual destination (might be affected by rewrite) DestAddr *statute.AddrSpec // Reader connect of request Reader io.Reader // RawDestAddr of the desired destination RawDestAddr *statute.AddrSpec }
A Request represents request received by a server
type RuleSet ¶
RuleSet is used to provide custom rules to allow or prohibit actions
func NewPermitAll ¶
func NewPermitAll() RuleSet
NewPermitAll returns a RuleSet which allows all types of connections
func NewPermitConnAndAss ¶
func NewPermitConnAndAss() RuleSet
NewPermitConnAndAss returns a RuleSet which allows Connect and Associate connection
func NewPermitNone ¶
func NewPermitNone() RuleSet
NewPermitNone returns a RuleSet which disallows all types of connections
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is responsible for accepting connections and handling the details of the SOCKS5 protocol
func (*Server) ListenAndServe ¶
ListenAndServe is used to create a listener and serve on it
func (*Server) Proxy ¶
Proxy is used to suffle data from src to destination, and sends errors down a dedicated channel
type StaticCredentials ¶
StaticCredentials enables using a map directly as a credential store
func (StaticCredentials) Valid ¶
func (s StaticCredentials) Valid(user, password, _ string) bool
Valid implement interface CredentialStore
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, userAddr string) (*AuthContext, error)
Authenticate implement interface Authenticator
func (UserPassAuthenticator) GetCode ¶
func (a UserPassAuthenticator) GetCode() uint8
GetCode implement interface Authenticator