proxy

package
v0.0.0-...-df37d59 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2019 License: MIT Imports: 42 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PolicyMITM = 1 << iota
	PolicyGlobal
	PolicyVPN
	PolicyWebSocket
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher struct {
	IO io_t

	Key     string
	Block   cipher.Block
	Rand    *rand.Rand
	Partial bool
	Alias   string
	// contains filtered or unexported fields
}

func (*Cipher) Decrypt

func (gc *Cipher) Decrypt(text string, iv *[ivLen]byte) string

Decrypt decrypts a string

func (*Cipher) Encrypt

func (gc *Cipher) Encrypt(text string, iv *[ivLen]byte) string

Encrypt encrypts a string

func (*Cipher) Init

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

Init inits the Cipher struct with key

func (*Cipher) Jibber

func (gc *Cipher) Jibber() string

func (*Cipher) Xor

func (gc *Cipher) Xor(buf []byte, full *[ivLen]byte, quad *[4]byte) []byte

Xor is an inplace xor method, and it just returns buf then

type ClientConfig

type ClientConfig struct {
	ClientConfigMarshal

	LocalRPBind string
	MITMDump    *os.File
	DNSCache    *lru.Cache
	CA          tls.Certificate
	CACache     *lru.Cache
	ACL         *acr.ACL
	KCP         KCPConfig
	HTTPS       bool
	Logger      *logg.Logger

	*Cipher
}

type ClientConfigMarshal

type ClientConfigMarshal struct {
	Upstream       string  `json:"u"`
	Policy         Options `json:"p"`
	UserAuth       string  `json:"a"`
	UDPRelayCoconn int     `json:"r"`
	Mux            int     `json:"m"`

	// Upstream params
	Connect2     string `json:"c"`
	Connect2Auth string `json:"t"`
	DummyDomain  string `json:"d"`
	URLHeader    string `json:"h"`
}

type DummyConn

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

func (*DummyConn) Close

func (d *DummyConn) Close() error

func (*DummyConn) Init

func (d *DummyConn) Init()

func (*DummyConn) LocalAddr

func (d *DummyConn) LocalAddr() net.Addr

func (*DummyConn) Read

func (d *DummyConn) Read(b []byte) (n int, err error)

func (*DummyConn) RemoteAddr

func (d *DummyConn) RemoteAddr() net.Addr

func (*DummyConn) SetDeadline

func (d *DummyConn) SetDeadline(t time.Time) error

func (*DummyConn) SetReadDeadline

func (d *DummyConn) SetReadDeadline(t time.Time) error

func (*DummyConn) SetWriteDeadline

func (d *DummyConn) SetWriteDeadline(t time.Time) error

func (*DummyConn) Write

func (d *DummyConn) Write(b []byte) (n int, err error)

type DummyConnWrapper

type DummyConnWrapper struct {
	*DummyConn
}

func (*DummyConnWrapper) Read

func (d *DummyConnWrapper) Read(b []byte) (n int, err error)

func (*DummyConnWrapper) Write

func (d *DummyConnWrapper) Write(b []byte) (n int, err error)

type IOConfig

type IOConfig struct {
	Bucket  *TokenBucket
	Chunked bool
	Partial bool
	Print   bool
	Role    byte
	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 KCPConfig

type KCPConfig struct {
	Enable bool
}

type Options

type Options byte

func (*Options) IsSet

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

func (*Options) Set

func (o *Options) Set(options ...byte)

func (*Options) UnSet

func (o *Options) UnSet(options ...byte)

func (*Options) Val

func (o *Options) Val() byte

type ProxyClient

type ProxyClient struct {
	*ClientConfig

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

func NewClient

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

func (*ProxyClient) Bridge

func (proxy *ProxyClient) Bridge(down net.Conn, host string)

func (*ProxyClient) DialUpstream

func (proxy *ProxyClient) DialUpstream(conn net.Conn, host string, resp []byte, extra, dialStyle byte) net.Conn

func (*ProxyClient) ServeHTTP

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

func (*ProxyClient) Start

func (proxy *ProxyClient) Start() error

func (*ProxyClient) StartLocalRP

func (proxy *ProxyClient) StartLocalRP(n int)

type ProxyServer

type ProxyServer struct {
	Localaddr string
	Listener  net.Listener

	*ServerConfig
	// contains filtered or unexported fields
}

ProxyServer is the main struct for upstream server

func NewServer

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

func (*ProxyServer) ServeHTTP

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

func (*ProxyServer) Start

func (proxy *ProxyServer) Start() (err error)

func (*ProxyServer) Write

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

type ResponseHook

type ResponseHook interface {
	SetBody(r io.ReadCloser)
}

type Rule

type Rule struct {
	IP     string
	Ans    byte
	OldAns byte
	R      byte
}

type ServerConfig

type ServerConfig struct {
	Throttling    int64
	ThrottlingMax int64
	LBindTimeout  int64
	LBindCap      int64
	DisableUDP    bool
	DisableLRP    bool
	HTTPS         *tls.Config
	ProxyPassAddr string
	Logger        *logg.Logger
	KCP           KCPConfig

	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
}

UserConfig is 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