healthcheck

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: GPL-3.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func CleanBadProxiesWithGrpool

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

func HTTPGetBodyViaProxy added in v0.3.12

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

func HTTPGetBodyViaProxyWithTime added in v0.6.0

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

func HTTPGetBodyViaProxyWithTimeNoReturn added in v0.7.0

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

Get body without return to save memory

func HTTPGetViaProxy added in v0.3.12

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

func HTTPHeadViaProxy added in v0.5.0

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

func ProxySpeedTest added in v0.3.12

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 added in v0.6.0

func RelayCheck(proxies proxy.ProxyList)

func SpeedTestAll added in v0.5.0

func SpeedTestAll(proxies []proxy.Proxy)

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

func SpeedTestNew added in v0.5.0

func SpeedTestNew(proxies []proxy.Proxy)

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

Types

type ByDistance added in v0.3.12

type ByDistance struct {
	Servers
}

ByDistance : For sorting servers.

func (ByDistance) Less added in v0.3.12

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

Less : compare the distance. For sorting servers.

type Server added in v0.3.12

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 added in v0.3.12

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

ServerList : List of Server. for xml decoding

type Servers added in v0.3.12

type Servers []Server

Servers : For sorting servers.

func (Servers) GetResult added in v0.3.12

func (svrs Servers) GetResult() float64

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

func (Servers) Len added in v0.3.12

func (s Servers) Len() int

Len : length of servers. For sorting servers.

func (Servers) StartTest added in v0.3.12

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

StartTest : start testing to the servers.

func (Servers) Swap added in v0.3.12

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

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

type Stat added in v0.5.0

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

Statistic for a proxy

func (*Stat) UpdatePSCount added in v0.5.0

func (ps *Stat) UpdatePSCount()

Count + 1 for a Stat

func (*Stat) UpdatePSDelay added in v0.5.0

func (ps *Stat) UpdatePSDelay(delay uint16)

Update delay for a Stat

func (*Stat) UpdatePSOutIp added in v0.6.0

func (ps *Stat) UpdatePSOutIp(outIp string)

Update out ip for a Stat

func (*Stat) UpdatePSSpeed added in v0.5.0

func (ps *Stat) UpdatePSSpeed(speed float64)

Update speed for a Stat

type StatList added in v0.5.0

type StatList []Stat

Statistic array for proxies

var ProxyStats StatList

ProxyStats stores proxies' statistics

func (StatList) Find added in v0.5.0

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

Find a proxy's Stat in StatList

func (StatList) ReqCountThan added in v0.5.0

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 added in v0.5.0

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

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

type User added in v0.3.12

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

speedtest.net config

type Users added in v0.3.12

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

Users : for decode speedtest.net xml

Jump to

Keyboard shortcuts

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