socks5

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoAuth = uint8(0)

	UserPassAuth = uint8(2)
)
View Source
const (
	ConnectCommand   = uint8(1)
	BindCommand      = uint8(2)
	AssociateCommand = uint8(3)
)
View Source
const (
	Socks5Version = uint8(5)
)

Variables

View Source
var (
	UserAuthFailed  = fmt.Errorf("user authentication failed")
	NoSupportedAuth = fmt.Errorf("no supported authentication mechanism")
)

Functions

This section is empty.

Types

type AddrSpec

type AddrSpec struct {
	FQDN string
	IP   net.IP
	Port int
}

func (*AddrSpec) Address

func (a *AddrSpec) Address() string

func (*AddrSpec) String

func (a *AddrSpec) String() string

type AddressRewriter

type AddressRewriter interface {
	Rewrite(ctx context.Context, request *Request) (context.Context, *AddrSpec)
}

type AuthContext

type AuthContext struct {
	Method  uint8
	Payload map[string]string
}

type Authenticator

type Authenticator interface {
	Authenticate(reader io.Reader, writer io.Writer) (*AuthContext, error)
	GetCode() uint8
}

type Config

type Config struct {
	AuthMethods []Authenticator
	Credentials CredentialStore
	Resolver    NameResolver
	Rules       RuleSet
	Rewriter    AddressRewriter
	BindIP      net.IP
	Dial        func(ctx context.Context, network, addr string) (net.Conn, error)
}

type CredentialStore

type CredentialStore interface {
	Valid(user, password string) bool
}

type DNSResolver

type DNSResolver struct{}

func (DNSResolver) Resolve

func (d DNSResolver) Resolve(ctx context.Context, name string) (context.Context, net.IP, error)

type NameResolver

type NameResolver interface {
	Resolve(ctx context.Context, name string) (context.Context, net.IP, error)
}

type NoAuthAuthenticator

type NoAuthAuthenticator struct{}

func (NoAuthAuthenticator) Authenticate

func (a NoAuthAuthenticator) Authenticate(_ io.Reader, writer io.Writer) (*AuthContext, error)

func (NoAuthAuthenticator) GetCode

func (a NoAuthAuthenticator) GetCode() uint8

type PermitCommand

type PermitCommand struct {
	EnableConnect   bool
	EnableBind      bool
	EnableAssociate bool
}

func (*PermitCommand) Allow

func (p *PermitCommand) Allow(ctx context.Context, req *Request) (context.Context, bool)

type Request

type Request struct {
	Version     uint8
	Command     uint8
	AuthContext *AuthContext
	RemoteAddr  *AddrSpec
	DestAddr    *AddrSpec
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(bufConn io.Reader) (*Request, error)

type RuleSet

type RuleSet interface {
	Allow(ctx context.Context, req *Request) (context.Context, bool)
}

func PermitAll

func PermitAll() RuleSet

func PermitNone

func PermitNone() RuleSet

type Server

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

func New

func New(conf *Config) (*Server, error)

func (*Server) Handler

func (s *Server) Handler(conn net.Conn, bufConn *bufio.Reader) error

type StaticCredentials

type StaticCredentials map[string]string

func (StaticCredentials) Valid

func (s StaticCredentials) Valid(user, password string) bool

type UserPassAuthenticator

type UserPassAuthenticator struct {
	Credentials CredentialStore
}

func (UserPassAuthenticator) Authenticate

func (a UserPassAuthenticator) Authenticate(reader io.Reader, writer io.Writer) (*AuthContext, error)

func (UserPassAuthenticator) GetCode

func (a UserPassAuthenticator) GetCode() uint8

Jump to

Keyboard shortcuts

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