Documentation
¶
Index ¶
- Constants
- Variables
- func AddHostname(hostname string) (*db.DomainInfo, error)
- func FormatConnResponse(version byte, status byte, bndAddr net.Addr) []byte
- func FormatServerChoice(version byte, auth byte) []byte
- func HandleHttpRequest(inboundConn, outboundConn net.Conn, httpPacketHandler func(packet.Packet)) error
- func InitCaCert() error
- func ListenAndServeSocks5(conf config.Config, packetHandler func(packet.Packet)) (net.Listener, error)
- func ReadLine1(reader *textproto.Reader) (string, string, string, error)
- func SetupPac(conf *config.Config) *http.Server
- type ClientConnRequest
- type ClientGreeting
Constants ¶
View Source
const ( METHOD_NO_AUTH_REQUIRED = 0x00 METHOD_GSSAPI = 0x01 METHOD_USERNAME_PASSWORD = 0x02 // 0x03 to 0x7F are IANA assigned // 0x80 to 0xFE are reserved for private methods METHOD_NO_ACCEPTABLE_METHODS = 0xFF )
View Source
const ( STATUS_SUCCEEDED = 0x00 STATUS_GENERAL_FAILURE = 0x01 STATUS_CONNECTION_NOT_ALLOWED = 0x02 STATUS_NETWORK_UNREACHABLE = 0x03 STATUS_HOST_UNREACHABLE = 0x04 STATUS_CONNECTION_REFUSED = 0x05 STATUS_TTL_EXPIRED = 0x06 STATUS_COMMAND_NOT_SUPPORTED = 0x07 STATUS_ADDRESS_TYPE_NOT_SUPPORTED = 0x08 )
View Source
const ( ADDRESS_TYPE_IPV4 = 0x01 ADDRESS_TYPE_DOMAINNAME = 0x03 ADDRESS_TYPE_IPV6 = 0x04 )
View Source
const ( CMD_CONNECT = 0x01 CMD_BIND = 0x02 CMD_UDP_ASSOCIATE = 0x03 )
View Source
const (
SOCKS_VER_5 = 0x05
)
Variables ¶
View Source
var ( CLIENT_CONFIG = &tls.Config{InsecureSkipVerify: true, MinVersion: tls.VersionTLS10} SERVER_CONFIG = &tls.Config{ MinVersion: tls.VersionTLS10, InsecureSkipVerify: true, GetCertificate: func(chi *tls.ClientHelloInfo) (*tls.Certificate, error) { domainInfo, err := db.GetDomain(chi.ServerName) if err != nil { return nil, err } if domainInfo == nil { if domainInfo, err = AddHostname(chi.ServerName); err != nil { return nil, err } } certificate, err := tls.X509KeyPair(domainInfo.Cert, domainInfo.PrivKey) if err != nil { return nil, err } return &certificate, nil }, } )
Functions ¶
func AddHostname ¶ added in v0.17.0
func AddHostname(hostname string) (*db.DomainInfo, error)
AddHostname creates a certificate for hostname, and adds it to the sqlite db stored in the config dir.
func FormatConnResponse ¶
func FormatServerChoice ¶
func HandleHttpRequest ¶ added in v0.17.0
func HandleHttpRequest(inboundConn, outboundConn net.Conn, httpPacketHandler func(packet.Packet)) error
HandleHttpRequest reads http requests from inboundConn to outboundConn, and then read http responses from outboundConn to inboundConn.
httpPacketHandler is called first on the packet when inboundConn -> outboundConn completes, and again when outboundConn -> inboundConn completes.
func InitCaCert ¶ added in v0.17.0
func InitCaCert() error
func ListenAndServeSocks5 ¶ added in v0.15.0
func ListenAndServeSocks5(conf config.Config, packetHandler func(packet.Packet)) (net.Listener, error)
ListenAndServeSocks5 starts a socks5 proxy which will pass any intercepted packets to packetHandler. If net.Listen fails for the server, an error is returned.
Types ¶
type ClientConnRequest ¶
type ClientConnRequest struct { Ver byte Cmd byte Rsv byte DstIpType byte DstIp string DstPort uint16 }
func ParseClientConnRequest ¶
func ParseClientConnRequest(conn net.Conn) (*ClientConnRequest, byte, error)
type ClientGreeting ¶
func ParseClientGreeting ¶
func ParseClientGreeting(conn net.Conn) (*ClientGreeting, error)
func (*ClientGreeting) CanHandle ¶
func (g *ClientGreeting) CanHandle() bool
Click to show internal directories.
Click to hide internal directories.