Documentation
¶
Index ¶
- Variables
- func AddrToNetAddr(network string, a Addr) (net.Addr, error)
- func Auth(conn io.ReadWriter, author Authenticator) error
- func ReadExactFrom(conn io.Reader, n byte) ([]byte, error)
- func ReplyTo(conn io.Writer, message []byte) error
- func UDPAddrIsAllZero(addr Addr) bool
- type Addr
- type AddressType
- type Authenticator
- type Command
- type Config
- type Datagram
- type DomainNameAddr
- type EmptyAddr
- type Filed
- type IPv4Addr
- type IPv6Addr
- type Relayer
- type Request
- type Response
- type RuleSet
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAuthFormat = errors.New("auth: invalid format") ErrAuthNoAcceptableMethods = errors.New("auth: no acceptable methods") ErrAuthMethodFormat = errors.New("auth: invalid method format") )
View Source
var ( ErrRequestFormat = errors.New("request: invalid format") ErrRequestCommand = errors.New("request: command not support") )
View Source
var (
ErrDatagramFormat = errors.New("UDP Associate Datagram format error")
)
View Source
var ( // ErrSocksVersion is returned when the SOCKS version requested by the client is not 5. ErrSocksVersion = errors.New("version not support") )
Functions ¶
func Auth ¶
func Auth(conn io.ReadWriter, author Authenticator) error
func UDPAddrIsAllZero ¶
Types ¶
type Addr ¶
type Addr interface {
Type() AddressType
String() string
Packet() []byte
}
func AddrMarshal ¶
func AddrUnmarshal ¶
type AddressType ¶
type AddressType byte
const ( IPv4 AddressType = 0x01 DomainName AddressType = 0x03 IPv6 AddressType = 0x04 )
type Authenticator ¶
type Authenticator map[byte]func(io.ReadWriter) error
func (Authenticator) SupportGSSAPI ¶
func (a Authenticator) SupportGSSAPI()
func (Authenticator) SupportNoAuth ¶
func (a Authenticator) SupportNoAuth()
func (Authenticator) SupportUsernamePassword ¶
func (a Authenticator) SupportUsernamePassword(hasUser func(name, password string) bool)
type Config ¶
type Config struct {
// Authenticator specifies the authentication methods supported by the server.
// If not set, no authentication is required by default.
Authenticator Authenticator
// RuleSet defines the rules for allowing or denying SOCKS commands.
// If not set, only the CONNECT command is allowed by default.
RuleSet RuleSet
// Logger specifies the logger to use.
// If nil, a default text logger that writes to stdout will be used.
Logger *slog.Logger
// DialTimeout is the timeout for establishing a connection to the destination.
// Defaults to 10 seconds if not set.
DialTimeout time.Duration
// ActivityTimeout is the timeout for inactivity on a connection.
// Connections with no activity for this duration will be closed.
// Defaults to 30 seconds if not set.
ActivityTimeout time.Duration
}
Config configures a SOCKS5 server.
type DomainNameAddr ¶
type DomainNameAddr struct {
// contains filtered or unexported fields
}
DomainNameAddr 表示域名與埠
func (*DomainNameAddr) Packet ¶
func (a *DomainNameAddr) Packet() []byte
func (*DomainNameAddr) String ¶
func (a *DomainNameAddr) String() string
String returns the domain name and port, for example: www.example.com:443
func (*DomainNameAddr) Type ¶
func (a *DomainNameAddr) Type() AddressType
type EmptyAddr ¶
type EmptyAddr struct{}
EmptyAddr indicates an empty address, used to return an error Response
func (*EmptyAddr) Type ¶
func (e *EmptyAddr) Type() AddressType
type IPv4Addr ¶
type IPv4Addr struct {
// contains filtered or unexported fields
}
IPv4Addr represents IPv4 address and port
func (*IPv4Addr) Type ¶
func (a *IPv4Addr) Type() AddressType
type IPv6Addr ¶
type IPv6Addr struct {
// contains filtered or unexported fields
}
IPv6Addr 表示 IPv6 地址與埠
func (*IPv6Addr) Type ¶
func (a *IPv6Addr) Type() AddressType
type Relayer ¶
type Relayer struct {
// contains filtered or unexported fields
}
func NewRelayer ¶
func (*Relayer) PacketDatagram ¶
type Response ¶
func NewResponse ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a SOCKS5 proxy server.
func NewServer ¶
NewServer creates a new SOCKS5 Server with the given configuration. It provides sensible defaults for any unset options.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the TCP network address and then calls Serve to handle requests. If the address is empty, it defaults to the SOCKS5 standard port 1080.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.