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 Base32Decode ¶ added in v1.0.9
func Base32Encode ¶ added in v1.0.9
func SafeAddHeader ¶
func StartServer ¶
func StartServer(addr string, config *ServerConfig)
Types ¶
type ClientConfig ¶ added in v1.0.9
type GCipher ¶ added in v1.0.9
func (*GCipher) DecryptString ¶ added in v1.0.9
func (*GCipher) EncryptString ¶ added in v1.0.9
func (*GCipher) GenerateIV ¶ added in v1.0.9
func (*GCipher) GetCipherStream ¶ added in v1.0.9
func (gc *GCipher) GetCipherStream(key []byte) *InplaceCTR
type IOConfig ¶ added in v1.0.9
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
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 ¶ added in v1.0.9
type OneBytePool chan []byte
func NewOneBytePool ¶ added in v1.0.9
func NewOneBytePool(s int) *OneBytePool
func (*OneBytePool) Free ¶ added in v1.0.9
func (p *OneBytePool) Free(buf []byte)
func (*OneBytePool) Get ¶ added in v1.0.9
func (p *OneBytePool) Get() []byte
type ProxyClient ¶ added in v1.0.9
type ProxyClient struct { *ClientConfig DNSCache *lru.Cache Nickname string Localaddr string Listener *listenerWrapper // contains filtered or unexported fields }
func NewClient ¶ added in v1.0.10
func NewClient(localaddr string, config *ClientConfig) *ProxyClient
func (*ProxyClient) PleaseUnlockMe ¶ added in v1.0.10
func (proxy *ProxyClient) PleaseUnlockMe()
func (*ProxyClient) ServeHTTP ¶ added in v1.0.9
func (proxy *ProxyClient) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*ProxyClient) Start ¶ added in v1.0.10
func (proxy *ProxyClient) Start() error
func (*ProxyClient) UpdateKey ¶ added in v1.0.10
func (proxy *ProxyClient) UpdateKey(newKey string)
type ProxyUpstream ¶ added in v1.0.9
type ProxyUpstream struct { *ServerConfig // contains filtered or unexported fields }
func (*ProxyUpstream) ServeHTTP ¶ added in v1.0.9
func (proxy *ProxyUpstream) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ServerConfig ¶ added in v1.0.9
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)
type UserConfig ¶ added in v1.0.9
for multi-users server, not implemented yet
Click to show internal directories.
Click to hide internal directories.