Documentation ¶
Index ¶
- Constants
- Variables
- func Base32Decode(text string) []byte
- func Base32Encode(buf []byte) string
- func DecryptHost(c *GCipher, text string, mark byte) string
- func EncryptHost(c *GCipher, text string, mark byte) string
- func SafeAddHeader(req *http.Request, k, v string)
- func SafeGetHeader(req *http.Request, k string) string
- func StartServer(addr string, config *ServerConfig)
- func TryDecryptHost(c *GCipher, text string) (h string, m byte)
- type ClientConfig
- type GCipher
- func (gc *GCipher) Bridge(target, source net.Conn, key []byte, options *IOConfig)
- func (gc *GCipher) Decrypt(buf []byte) []byte
- func (gc *GCipher) DecryptString(text string) string
- func (gc *GCipher) Encrypt(buf []byte) []byte
- func (gc *GCipher) EncryptString(text string) string
- func (gc *GCipher) GenerateIV(s, s2 byte) []byte
- func (gc *GCipher) GetCipherStream(key []byte) *InplaceCTR
- func (gc *GCipher) New() (err error)
- func (gc *GCipher) NewRand() *rand.Rand
- func (gc *GCipher) RandomIV() (string, []byte)
- func (gc *GCipher) ReverseIV(key string) []byte
- func (gc *GCipher) WrapIO(dst io.Writer, src io.Reader, key []byte, options *IOConfig) *IOCopyCipher
- type IOConfig
- type IOCopyCipher
- type IOReaderCipher
- type InplaceCTR
- type OneBytePool
- type ProxyClient
- type ProxyUpstream
- type ServerConfig
- type TokenBucket
- type UserConfig
Constants ¶
View Source
const ( IV_LENGTH = 16 SSL_RECORD_MAX = 18 * 1024 // 18kb STREAM_BUFFER_SIZE = 512 )
View Source
const ( SOCKS5_VERSION = byte(0x05) SOCKS_TYPE_IPv4 = 1 SOCKS_TYPE_Dm = 3 SOCKS_TYPE_IPv6 = 4 DO_HTTP = 0 DO_SOCKS5 = 1 HOST_HTTP_CONNECT = byte(0x00) HOST_HTTP_FORWARD = byte(0x01) HOST_SOCKS_CONNECT = byte(0x02) HOST_IPV6 = byte(0x04) AUTH_HEADER = "X-Authorization" CANNOT_READ_BUF = "socks server: cannot read buffer: " NOT_SOCKS5 = "invalid socks version (socks5 only)" UDP_TIMEOUT = 30 TCP_TIMEOUT = 60 )
View Source
const (
UOT_HEADER = byte(0x07)
)
Variables ¶
View Source
var ( OK_HTTP = []byte("HTTP/1.0 200 OK\r\n\r\n") // version, granted = 0, 0, ipv4, 0, 0, 0, 0, (port) 0, 0 OK_SOCKS = []byte{SOCKS5_VERSION, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01} // RSV | FRAG | ATYP | DST.ADDR | DST.PORT | UDP_REQUEST_HEADER = []byte{0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} UDP_REQUEST_HEADER6 = []byte{0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} DUMMY_FIELDS = []string{"Accept-Language", "User-Agent", "Referer", "Cache-Control", "Accept-Encoding", "Connection"} )
Functions ¶
func StartServer ¶
func StartServer(addr string, config *ServerConfig)
Types ¶
type ClientConfig ¶
type GCipher ¶
func (*GCipher) Bridge ¶
func (*GCipher) GetCipherStream ¶
func (gc *GCipher) GetCipherStream(key []byte) *InplaceCTR
type IOConfig ¶
type IOConfig struct {
Bucket *TokenBucket
}
type IOCopyCipher ¶
type IOCopyCipher struct { Dst io.Writer Src io.Reader Key []byte Throttling *TokenBucket Partial bool Cipher *GCipher }
func (*IOCopyCipher) DoCopy ¶
func (cc *IOCopyCipher) DoCopy() (written int64, err error)
type IOReaderCipher ¶
type IOReaderCipher struct { Src io.Reader Key []byte Cipher *GCipher // contains filtered or unexported fields }
func (*IOReaderCipher) Init ¶
func (rc *IOReaderCipher) Init() *IOReaderCipher
func (*IOReaderCipher) Read ¶
func (rc *IOReaderCipher) Read(p []byte) (n int, err error)
type InplaceCTR ¶
type InplaceCTR struct {
// contains filtered or unexported fields
}
func (*InplaceCTR) XorBuffer ¶
func (x *InplaceCTR) XorBuffer(buf []byte)
From src/crypto/cipher/ctr.go
type OneBytePool ¶
type OneBytePool chan []byte
func NewOneBytePool ¶
func NewOneBytePool(s int) *OneBytePool
func (*OneBytePool) Free ¶
func (p *OneBytePool) Free(buf []byte)
func (*OneBytePool) Get ¶
func (p *OneBytePool) Get() []byte
type ProxyClient ¶
type ProxyClient struct { *ClientConfig DNSCache *lru.Cache Nickname string Localaddr string Listener *listenerWrapper // contains filtered or unexported fields }
func NewClient ¶
func NewClient(localaddr string, config *ClientConfig) *ProxyClient
func (*ProxyClient) PleaseUnlockMe ¶
func (proxy *ProxyClient) PleaseUnlockMe()
func (*ProxyClient) ServeHTTP ¶
func (proxy *ProxyClient) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*ProxyClient) Start ¶
func (proxy *ProxyClient) Start() error
func (*ProxyClient) UpdateKey ¶
func (proxy *ProxyClient) UpdateKey(newKey string)
type ProxyUpstream ¶
type ProxyUpstream struct { *ServerConfig // contains filtered or unexported fields }
func (*ProxyUpstream) ServeHTTP ¶
func (proxy *ProxyUpstream) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*ProxyUpstream) Write ¶
func (proxy *ProxyUpstream) Write(w http.ResponseWriter, r *http.Request, p []byte, code int) (n int, err error)
type ServerConfig ¶
type TokenBucket ¶
type TokenBucket struct { Speed int64 // bytes per second // contains filtered or unexported fields }
func NewTokenBucket ¶
func NewTokenBucket(speed, max int64) *TokenBucket
func (*TokenBucket) Consume ¶
func (tb *TokenBucket) Consume(n int64)
Click to show internal directories.
Click to hide internal directories.