proxy

package
v0.0.0-...-a047029 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FullCipher _CipherMode = iota
	PartialCipher
	NoneCipher
)
View Source
const (
	PolicyMITM = 1 << iota
	PolicyForward
	PolicyAgent
	PolicyGlobal
	PolicyVPN
	PolicyWebSocket
	PolicyHTTPS
	PolicyKCP
	PolicyDisableUDP
	PolicyDisableLRP
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher struct {
	IO  io_t
	Key string

	Block cipher.Block
	GCM   cipher.AEAD
	Rand  *rand.Rand
	Mode  _CipherMode
	Alias string
	// contains filtered or unexported fields
}

func NewCipher

func NewCipher(key string, mode _CipherMode) *Cipher

NewCipher createa a new cipher object

func (*Cipher) Decrypt

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

Decrypt decrypts a string

func (*Cipher) Encrypt

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

Encrypt encrypts a string

func (*Cipher) Jibber

func (gc *Cipher) Jibber() string

type ClientConfig

type ClientConfig struct {
	Upstream       string
	UserAuth       string
	UDPRelayCoconn int64
	Mux            int64
	Connect2       string
	Connect2Auth   string
	DummyDomain    string
	LocalRPBind    string
	MITMDump       *os.File
	DNSCache       *lru.Cache
	CA             tls.Certificate
	CACache        *lru.Cache
	ACL            *acr.ACL
	Logger         *logg.Logger
	Policy         Options

	*Cipher
}

type IOConfig

type IOConfig struct {
	Bucket  *TokenBucket
	Chunked bool
	Mode    _CipherMode
	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 Options

type Options uint32

func (*Options) IsSet

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

func (*Options) Set

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

func (*Options) SetBool

func (o *Options) SetBool(b bool, option uint32)

func (*Options) UnSet

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

type ProxyClient

type ProxyClient struct {
	*ClientConfig

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

func NewClient

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

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 uint32, dialStyle byte) (net.Conn, error)

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)

StartLocalRP is a block call, it will never return

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, error)

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
	Policy        Options
	ProxyPassAddr string
	Logger        *logg.Logger
	ACL           *acr.ACL
	ACLCache      *lru.Cache
	HTTPS         *tls.Config
	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