Version: v0.7.0 Latest Latest

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

Go to latest
Published: Apr 22, 2021 License: GPL-3.0 Imports: 21 Imported by: 0




This section is empty.


View Source
var DelayTimeout = defaultURLTestTimeout
View Source
var RelayTimeout = defaultURLTestTimeout * 2
View Source
var SpeedExist = false
View Source
var SpeedTimeout = time.Second * 10


func CleanBadProxiesWithGrpool

func CleanBadProxiesWithGrpool(proxies []proxy.Proxy) (cproxies []proxy.Proxy)

func HTTPGetBodyViaProxy

func HTTPGetBodyViaProxy(clashProxy C.Proxy, url string) ([]byte, error)

func HTTPGetBodyViaProxyWithTime

func HTTPGetBodyViaProxyWithTime(clashProxy C.Proxy, url string, t time.Duration) ([]byte, error)

func HTTPGetBodyViaProxyWithTimeNoReturn

func HTTPGetBodyViaProxyWithTimeNoReturn(clashProxy C.Proxy, url string, t time.Duration) error

Get body without return to save memory

func HTTPGetViaProxy

func HTTPGetViaProxy(clashProxy C.Proxy, url string) error

func HTTPHeadViaProxy

func HTTPHeadViaProxy(clashProxy C.Proxy, url string) error

func ProxySpeedTest

func ProxySpeedTest(p proxy.Proxy) (speedResult float64, err error)

ProxySpeedTest returns a speed result of a proxy. The speed result is like 20Mbit/s. -1 for error.

func RelayCheck

func RelayCheck(proxies proxy.ProxyList)

func SpeedTestAll

func SpeedTestAll(proxies []proxy.Proxy, conns int)

SpeedTestAll tests speed of a group of proxies. Results are stored in ProxyStats

func SpeedTestNew

func SpeedTestNew(proxies []proxy.Proxy, conns int)

SpeedTestNew tests speed of new proxies which is not in ProxyStats. Then appended to ProxyStats


type ByDistance

type ByDistance struct {

ByDistance : For sorting servers.

func (ByDistance) Less

func (b ByDistance) Less(i, j int) bool

Less : compare the distance. For sorting servers.

type Server

type Server struct {
	URL      string `xml:"url,attr"`
	Lat      string `xml:"lat,attr"`
	Lon      string `xml:"lon,attr"`
	Name     string `xml:"name,attr"`
	Country  string `xml:"country,attr"`
	Sponsor  string `xml:"sponsor,attr"`
	ID       string `xml:"id,attr"`
	URL2     string `xml:"url2,attr"`
	Host     string `xml:"host,attr"`
	Distance float64
	DLSpeed  float64

Server information

type ServerList

type ServerList struct {
	Servers []Server `xml:"servers>server"`

ServerList : List of Server. for xml decoding

type Servers

type Servers []Server

Servers : For sorting servers.

func (Servers) GetResult

func (svrs Servers) GetResult() float64

GetResult : return testing result. -1 for no effective result

func (Servers) Len

func (s Servers) Len() int

Len : length of servers. For sorting servers.

func (Servers) StartTest

func (svrs Servers) StartTest(clashProxy C.Proxy)

StartTest : start testing to the servers.

func (Servers) Swap

func (s Servers) Swap(i, j int)

Swap : swap i-th and j-th. For sorting servers.

type Stat

type Stat struct {
	Speed    float64
	Delay    uint16
	ReqCount uint16
	Relay    bool
	Pool     bool
	OutIp    string
	Id       string

Statistic for a proxy

func (*Stat) UpdatePSCount

func (ps *Stat) UpdatePSCount()

Count + 1 for a Stat

func (*Stat) UpdatePSDelay

func (ps *Stat) UpdatePSDelay(delay uint16)

Update delay for a Stat

func (*Stat) UpdatePSOutIp

func (ps *Stat) UpdatePSOutIp(outIp string)

Update out ip for a Stat

func (*Stat) UpdatePSSpeed

func (ps *Stat) UpdatePSSpeed(speed float64)

Update speed for a Stat

type StatList

type StatList []Stat

Statistic array for proxies

var ProxyStats StatList

ProxyStats stores proxies' statistics

func (StatList) Find

func (psList StatList) Find(p proxy.Proxy) (*Stat, bool)

Find a proxy's Stat in StatList

func (StatList) ReqCountThan

func (psList StatList) ReqCountThan(n uint16, pl []proxy.Proxy, reset bool) []proxy.Proxy

Return proxies that request count more than a given nubmer

func (StatList) SortProxiesBySpeed

func (psList StatList) SortProxiesBySpeed(proxies []proxy.Proxy) []proxy.Proxy

Sort proxies by speed. Notice that this returns the same pointer.

type User

type User struct {
	IP  string `xml:"ip,attr"`
	Lat string `xml:"lat,attr"`
	Lon string `xml:"lon,attr"`
	Isp string `xml:"isp,attr"`
} config

type Users

type Users struct {
	Users []User `xml:"client"`

Users : for decode xml

Jump to

Keyboard shortcuts

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