Documentation ¶
Index ¶
- Constants
- Variables
- func CopyBuffer(dst io.Writer, src io.Reader, bufSize int) error
- func DoHttp(req *http.Request) (*http.Response, error)
- func ErrorResponse(message string, statusCode int, w http.ResponseWriter)
- func GetBuffer(size int) []byte
- func GetUrl(req *http.Request) string
- func HealthResponse(message string, w http.ResponseWriter)
- func HttpBasicAuth(auth string, verify func(string, string) bool) bool
- func IsIPv4(address string) bool
- func PutBuffer(b []byte)
- func ReadMethods(r io.Reader) ([]uint8, error)
- func StrEQ(s1, s2 string) bool
- func StrInSlice(str string, slice []string) bool
- func Transport(rw1, rw2 io.ReadWriter) error
- func UnGzip(body []byte) []byte
- func VerifyByHtpasswd(users string) func(string, string) bool
- func VerifyByMap(users map[string]string) func(string, string) bool
- func WriteMethod(method uint8, w io.Writer) error
- func WriteMethods(methods []uint8, w io.Writer) error
- type Addr
- type BufferedConn
- type ListenConfig
- type Reply
- type SOCKS5Request
- type UDPDatagram
- type UDPHeader
- type UserPassRequest
- type UserPassResponse
Constants ¶
const ( AddrIPv4 uint8 = 1 AddrDomain = 3 AddrIPv6 = 4 )
Address types
const ( SOCKS5Version = 5 SOCKS5UserPassVer = 1 )
SOCKS5 Version = 5
const ( MethodNoAuth uint8 = iota MethodGSSAPI MethodUserPass MethodNoAcceptable uint8 = 0xFF )
Methods
const ( SOCKS5CmdConnect uint8 = iota + 1 SOCKS5CmdBind SOCKS5CmdUDP SOCKS5CmdUDPOverTCP )
SOCKS5 Commands
const ( SOCKS5RespSucceeded uint8 = iota SOCKS5RespFailure SOCKS5RespAllowed SOCKS5RespNetUnreachable SOCKS5RespHostUnreachable SOCKS5RespConnRefused SOCKS5RespTTLExpired SOCKS5RespCmdUnsupported SOCKS5RespAddrUnsupported )
SOCKS5 Response codes
Variables ¶
Functions ¶
func ErrorResponse ¶
func ErrorResponse(message string, statusCode int, w http.ResponseWriter)
func HealthResponse ¶
func HealthResponse(message string, w http.ResponseWriter)
HealthResponse wrapper a response with plain message
func ReadMethods ¶
ReadMethods returns methods Method selection
+----+----------+----------+ |VER | NMETHODS | METHODS | +----+----------+----------+ | 1 | 1 | 1 to 255 | +----+----------+----------+
func StrInSlice ¶
StrInSlice return whether str in slice
func VerifyByHtpasswd ¶
VerifyByHtpasswd returns a verifier that verify by a htpasswd file
func VerifyByMap ¶
VerifyByMap returns an verifier that verify by an username-password map
func WriteMethod ¶
WriteMethod send the selected method to the client
Types ¶
type Addr ¶
Addr has following struct
+------+----------+----------+ | Type | ADDR | PORT | +------+----------+----------+ | 1 | Variable | 2 | +------+----------+----------+
func NewAddrFromAddr ¶
NewAddrFromAddr creates an address object
func NewAddrFromPair ¶
NewAddrFromPair creates an address object from host and port pair
type BufferedConn ¶
type ListenConfig ¶
type ListenConfig struct {
net.ListenConfig
}
type Reply ¶
Reply is a SOCKSv5 reply
+----+-----+-------+------+----------+----------+ |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT | +----+-----+-------+------+----------+----------+ | 1 | 1 | X'00' | 1 | Variable | 2 | +----+-----+-------+------+----------+----------+
type SOCKS5Request ¶
SOCKS5Request represent a socks5 request The SOCKSv5 request
+----+-----+-------+------+----------+----------+ |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT | +----+-----+-------+------+----------+----------+ | 1 | 1 | X'00' | 1 | Variable | 2 | +----+-----+-------+------+----------+----------+
func NewSOCKS5Request ¶
func NewSOCKS5Request(cmd uint8, addr *Addr) *SOCKS5Request
NewSOCKS5Request creates an request object
func ReadSOCKS5Request ¶
func ReadSOCKS5Request(r io.Reader) (*SOCKS5Request, error)
ReadSOCKS5Request reads request from the stream
func (*SOCKS5Request) String ¶
func (r *SOCKS5Request) String() string
type UDPDatagram ¶
UDPDatagram represent an UDP request
func NewUDPDatagram ¶
func NewUDPDatagram(header *UDPHeader, data []byte) *UDPDatagram
NewUDPDatagram creates an UDPDatagram
func ReadUDPDatagram ¶
func ReadUDPDatagram(r io.Reader) (*UDPDatagram, error)
ReadUDPDatagram reads an UDPDatagram from the stream
type UDPHeader ¶
UDPHeader is the header of an UDP request
+----+------+------+----------+----------+----------+ |RSV | FRAG | ATYP | DST.ADDR | DST.PORT | DATA | +----+------+------+----------+----------+----------+ | 2 | 1 | 1 | Variable | 2 | Variable | +----+------+------+----------+----------+----------+
func NewUDPHeader ¶
NewUDPHeader creates an UDPHeader
type UserPassRequest ¶
UserPassRequest Username/Password authentication request
+----+------+----------+------+----------+ |VER | ULEN | UNAME | PLEN | PASSWD | +----+------+----------+------+----------+ | 1 | 1 | 1 to 255 | 1 | 1 to 255 | +----+------+----------+------+----------+
func NewUserPassRequest ¶
func NewUserPassRequest(ver byte, u, p string) *UserPassRequest
func ReadUserPassRequest ¶
func ReadUserPassRequest(r io.Reader) (*UserPassRequest, error)
func (*UserPassRequest) String ¶
func (req *UserPassRequest) String() string
type UserPassResponse ¶
UserPassResponse Username/Password authentication response
+----+--------+ |VER | STATUS | +----+--------+ | 1 | 1 | +----+--------+
func NewUserPassResponse ¶
func NewUserPassResponse(ver, status byte) *UserPassResponse
func ReadUserPassResponse ¶
func ReadUserPassResponse(r io.Reader) (*UserPassResponse, error)
func (*UserPassResponse) String ¶
func (res *UserPassResponse) String() string