proxy

package
v0.26.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2016 License: BSD-3-Clause Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockedByGFWRule = "BlockedByGFW"
	InHostsRule      = "InHosts"
	IsCNIPRule       = "IsCNIP"
)

Variables

View Source
var ErrChannelAuthFailed = errors.New("Remote channel auth failed")
View Source
var ErrChannelReadTimeout = errors.New("Remote channel read timeout")

Functions

func DnsGetDoaminIP added in v0.26.2

func DnsGetDoaminIP(domain string) (string, error)

func HandleEvent

func HandleEvent(ev event.Event) error

func MatchPatterns added in v0.26.1

func MatchPatterns(str string, rules []string) bool

func NewAuthEvent

func NewAuthEvent(secureTransport bool) *event.AuthEvent

func NewHTTPClient added in v0.26.3

func NewHTTPClient(conf *ProxyChannelConfig) (*http.Client, error)

func RegisterProxyType added in v0.24.1

func RegisterProxyType(str string, p Proxy) error

func Start

func Start(home string, monitor InternalEventMonitor) error

func Stop

func Stop() error

func SyncConfig added in v0.24.0

func SyncConfig(addr string, localDir string) error

Types

type AdminConfig added in v0.24.0

type AdminConfig struct {
	Listen    string
	ConfigDir string
}

type EncryptConfig

type EncryptConfig struct {
	Method string
	Key    string
}

type Feature

type Feature struct {
	MaxRequestBody int
}

type GFWListConfig added in v0.26.0

type GFWListConfig struct {
	URL      string
	UserRule []string
	Proxy    string
}

type IPRange

type IPRange struct {
	Start, End uint64
	Country    string
}

type IPRangeHolder

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

func (*IPRangeHolder) Clear added in v0.24.0

func (h *IPRangeHolder) Clear()

func (*IPRangeHolder) FindCountry

func (h *IPRangeHolder) FindCountry(ip string) (string, error)

func (*IPRangeHolder) Len

func (h *IPRangeHolder) Len() int

func (*IPRangeHolder) Less

func (h *IPRangeHolder) Less(i, j int) bool

Less returns whether the element with index i should sort before the element with index j.

func (*IPRangeHolder) Swap

func (h *IPRangeHolder) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type InternalEventMonitor added in v0.24.1

type InternalEventMonitor func(code int, desc string) error

type LocalConfig

type LocalConfig struct {
	Log              []string
	Encrypt          EncryptConfig
	UserAgent        string
	Auth             string
	LocalDNS         LocalDNSConfig
	UDPGWAddr        string
	ChannelKeepAlive bool
	Admin            AdminConfig
	GFWList          GFWListConfig
	Proxy            []ProxyConfig
	Channel          []ProxyChannelConfig
}
var GConf LocalConfig

type LocalDNSConfig

type LocalDNSConfig struct {
	Listen     string
	TrustedDNS []string
	FastDNS    []string
	TCPConnect bool
	CacheSize  int
}

type PACConfig

type PACConfig struct {
	Method   []string
	Host     []string
	URL      []string
	Rule     []string
	Protocol []string
	Remote   string
}

func (*PACConfig) Match

func (pac *PACConfig) Match(protocol string, ip string, req *http.Request) bool

type Proxy

type Proxy interface {
	Init(conf ProxyChannelConfig) error
	//Type() string
	Config() *ProxyChannelConfig
	Destory() error
	Features() Feature
	PrintStat(w io.Writer)
	Serve(session *ProxySession, ev event.Event) error
}

type ProxyChannel

type ProxyChannel interface {
	Write(event.Event) (event.Event, error)
}

type ProxyChannelConfig added in v0.24.1

type ProxyChannelConfig struct {
	Enable              bool
	Name                string
	Type                string
	ServerList          []string
	ConnsPerServer      int
	SNI                 []string
	SNIProxy            string
	Proxy               string
	DialTimeout         int
	ReadTimeout         int
	ReconnectPeriod     int
	HeartBeatPeriod     int
	RCPRandomAdjustment int
	HTTPChunkPushEnable bool
	ForceTLS            bool
	// contains filtered or unexported fields
}

func (*ProxyChannelConfig) IsDirect added in v0.24.1

func (c *ProxyChannelConfig) IsDirect() bool

func (*ProxyChannelConfig) ProxyURL added in v0.26.0

func (c *ProxyChannelConfig) ProxyURL() *url.URL

type ProxyConfig

type ProxyConfig struct {
	Local    string
	PAC      []PACConfig
	SNISniff bool
}

type ProxySession

type ProxySession struct {
	Remote      *RemoteChannel
	Hijacked    bool
	SSLHijacked bool
	// contains filtered or unexported fields
}

func (*ProxySession) Close

func (s *ProxySession) Close() error

func (*ProxySession) SetRemoteChannel added in v0.24.0

func (s *ProxySession) SetRemoteChannel(r *RemoteChannel)

type RangeFetcher

type RangeFetcher struct {
	SingleFetchLimit  int64
	ConcurrentFetcher int32
	C                 *RemoteChannel
}

func (*RangeFetcher) Fetch

type RemoteChannel

type RemoteChannel struct {
	Addr                string
	Index               int
	DirectIO            bool
	WriteJoinAuth       bool
	OpenJoinAuth        bool
	SecureTransport     bool
	HeartBeatPeriod     int
	ReconnectPeriod     int
	RCPRandomAdjustment int
	C                   RemoteProxyChannel
	// contains filtered or unexported fields
}

func (*RemoteChannel) Close

func (rc *RemoteChannel) Close()

func (*RemoteChannel) GetActiveSessionNum added in v0.24.0

func (rc *RemoteChannel) GetActiveSessionNum() int32

func (*RemoteChannel) Init

func (rc *RemoteChannel) Init(authRequired bool) error

func (*RemoteChannel) Request

func (rc *RemoteChannel) Request(ev event.Event) (event.Event, error)

func (*RemoteChannel) Stop

func (rc *RemoteChannel) Stop()

func (*RemoteChannel) Write

func (rc *RemoteChannel) Write(ev event.Event) error

func (*RemoteChannel) WriteRaw

func (rc *RemoteChannel) WriteRaw(p []byte) (int, error)

type RemoteChannelTable

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

func NewRemoteChannelTable

func NewRemoteChannelTable() *RemoteChannelTable

func (*RemoteChannelTable) Add

func (p *RemoteChannelTable) Add(c *RemoteChannel)

func (*RemoteChannelTable) PrintStat added in v0.24.0

func (p *RemoteChannelTable) PrintStat(w io.Writer)

func (*RemoteChannelTable) Select

func (p *RemoteChannelTable) Select() *RemoteChannel

func (*RemoteChannelTable) StopAll

func (p *RemoteChannelTable) StopAll()

type RemoteProxyChannel

type RemoteProxyChannel interface {
	Open() error
	SetCryptoCtx(ctx *event.CryptoContext)
	Closed() bool
	Request([]byte) ([]byte, error)
	ReadTimeout() time.Duration
	HandleCtrlEvent(ev event.Event)
	io.ReadWriteCloser
}

Jump to

Keyboard shortcuts

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