proxy

package
v0.0.0-...-f790dc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2019 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PolicyDisabled = 1 << iota
	PolicyManInTheMiddle
	PolicyGlobal
	PolicyTrustClientDNS
	PolicyAggrClosing
	PolicyWebSocket
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher struct {
	IO io_t

	Key       []byte
	KeyString string
	Block     cipher.Block
	Rand      *rand.ConcurrentRand
	Partial   bool
	Alias     string
}

func (*Cipher) Decrypt

func (gc *Cipher) Decrypt(buf []byte, ss ...byte) []byte

func (*Cipher) DecryptDecompress

func (gc *Cipher) DecryptDecompress(str string, rkey ...byte) string

func (*Cipher) DecryptString

func (gc *Cipher) DecryptString(text string, rkey ...byte) string

func (*Cipher) Encrypt

func (gc *Cipher) Encrypt(buf []byte, ss ...byte) []byte

func (*Cipher) EncryptCompress

func (gc *Cipher) EncryptCompress(str string, rkey ...byte) string

func (*Cipher) EncryptString

func (gc *Cipher) EncryptString(text string, rkey ...byte) string

func (*Cipher) Init

func (gc *Cipher) Init(key string) (err error)

func (*Cipher) NewIV

func (gc *Cipher) NewIV(o Options, payload []byte, auth string) (string, []byte)

func (*Cipher) ReverseIV

func (gc *Cipher) ReverseIV(key string) (o Options, iv []byte, auth []byte)

type ClientConfig

type ClientConfig struct {
	Upstream string
	Policy   Options
	UserAuth string

	Connect2     string
	Connect2Auth string
	DummyDomain  string
	URLHeader    string

	UDPRelayPort   int
	UDPRelayCoconn int

	Mux int

	DNSCache *lru.Cache
	CA       tls.Certificate
	CACache  *lru.Cache

	*Cipher
}

type IOConfig

type IOConfig struct {
	Bucket  *TokenBucket
	Chunked bool
	Partial bool
	WSCtrl  byte
}

type IOReadCloserCipher

type IOReadCloserCipher struct {
	// contains filtered or unexported fields
}

func (*IOReadCloserCipher) Close

func (rc *IOReadCloserCipher) Close() error

func (*IOReadCloserCipher) Read

func (rc *IOReadCloserCipher) Read(p []byte) (n int, err error)

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 Options

type Options byte

func (*Options) IsSet

func (o *Options) IsSet(option byte) bool

func (*Options) Set

func (o *Options) Set(option byte)

func (*Options) UnSet

func (o *Options) UnSet(option byte)

func (*Options) Val

func (o *Options) Val() byte

type ProxyClient

type ProxyClient struct {
	*ClientConfig

	UDP struct {
		sync.Mutex
		Conns map[string]*udp_tcp_conn_t
		Addrs map[net.Addr]bool
	}

	Localaddr string
	Listener  *listenerWrapper
	// contains filtered or unexported fields
}

func NewClient

func NewClient(localaddr string, config *ClientConfig) *ProxyClient

func (*ProxyClient) PACFile

func (proxy *ProxyClient) PACFile(w http.ResponseWriter, r *http.Request)

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 {
	Localaddr string

	*ServerConfig
	// contains filtered or unexported fields
}

func NewServer

func NewServer(addr string, config *ServerConfig) *ProxyUpstream

func (*ProxyUpstream) ServeHTTP

func (proxy *ProxyUpstream) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ProxyUpstream) Start

func (proxy *ProxyUpstream) Start() error

func (*ProxyUpstream) Write

func (proxy *ProxyUpstream) Write(w http.ResponseWriter, key, p []byte, code int) (n int, err error)

type ServerConfig

type ServerConfig struct {
	Throttling     int64
	ThrottlingMax  int64
	UDPRelayListen int
	ProxyPassAddr  string

	Mux bool

	Users map[string]UserConfig

	*Cipher
}

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

type UserConfig struct {
	Auth          string
	Throttling    int64
	ThrottlingMax int64
}

for multi-users server, not implemented yet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL