Documentation
¶
Overview ¶
Package socks5 provides a convenient way to implement a socks5 server with flexible backends.
Index ¶
Constants ¶
View Source
const ( NOAUTH byte = iota GSSAPI UAP )
Method
View Source
const ( CONNECT byte BIND ASSOCIATE )
CMD
View Source
const ( IPV4T byte DOMAIN IPV6T )
Address Type
View Source
const ( SUCC byte = iota FAIL // general SOCKS server failure FORBID // connection not allowed by ruleset NUNREACH // Network unreachable HUNREACH // Host unreachable REFUSE // Connection refused EXPIRE // TTL expired NSUPPORT // Command not supported ANSUP // Address type not supported NOACCEPT byte = 255 )
Replies
View Source
const RSV byte = 0
RSV Reserved
View Source
const VERSION = 5
VERSION -> socks5
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request illustrate a valid socks5 request.
type SOpts ¶ added in v0.2.0
type SOpts struct {
// AllowUDP determines whether the server will accept
// ASSOCIATE CMD or not.
AllowUDP bool
// RewriteBND is only available when AllowUDP is true,
// and the server is behind a NAT network, with all
// its UDP ports forwarded, and serving ASSOCIATE CMD
// from clients who are not in the same intranet as the
// server.
// In this situation, you will want to rewrite BND.ADDR
// in server's reply message in order to make clients
// able to send UDP packet to BND.ADDR:BND.PORT.
//
// There is another situation, that you do not specify
// Addr, in this case, "net" will listen [::] by default,
// result in ASSOCIATE response be:
// byte: {5 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 r1 r0}
// (Means the client should send its udp packet to ipv6
// address [::]:(a random port equals {r1*256+r0}))
// Clients will consider this kind of response as invalid,
// so you'd better appoint RewriteBND mannually to avoid this.
RewriteBND net.IP
// Timeout forces the client to finish tasks in a certain time.
// For a connection, Timeout = max{Auth + Send CMD + req.Accept()},
// and after the (*Request).Accpet(), it will be canceled for
// this connection.
Timeout time.Duration
// ErrChan is the channel to get errors or info from the server.
// Set it to nil to ignore all errors and info.
ErrChan chan error
}
SOpts illustrates options to a server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a socks5 server.
func (*Server) Accept ¶
Accept returns a valid request. If the server is stopped, it will return nil.
func (*Server) GetAuth ¶ added in v0.2.0
func (s *Server) GetAuth(method byte) (a auth.Authenticator)
GetAuth gets an authenticator from the server of given Method. If given Method has no Authenticator, it will return nil.
func (*Server) SetAuth ¶ added in v0.2.0
func (s *Server) SetAuth(a auth.Authenticator)
SetAuth sets an authenticator to the server. It will overwrite exsited Authenticator which has the same Method.
Click to show internal directories.
Click to hide internal directories.