Documentation
¶
Index ¶
- Variables
- func DownloadSpeed(url string) (speed float64, err error)
- func GetLatency(server Server, url string, numtests int) (result float64, err error)
- func GetLatencyURL(server Server) string
- func UploadSpeed(url string, mimetype string, data []byte) (speed float64, err error)
- type ByDistance
- type ByLatency
- type Config
- type Server
Constants ¶
This section is empty.
Variables ¶
var HTTPConfigTimeout = time.Duration(viper.GetDuration("httpconfigtimeout") * time.Second)
HTTPConfigTimeout is how long we'll wait for a config download to timeout
var HTTPDownloadTimeout = time.Duration(viper.GetDuration("httpdownloadtimeout") * time.Minute)
HTTPDownloadTimeout is how long we'll wait for a download to timeout
var HTTPLatencyTimeout = time.Duration(viper.GetDuration("httplatencytimeout") * time.Second)
HTTPLatencyTimeout is how long we'll wait for a ping to timeout
Functions ¶
func DownloadSpeed ¶
DownloadSpeed measures the mbps of downloading a URL
func GetLatency ¶
GetLatency will test the latency (ping) the given server NUMLATENCYTESTS times and return either the lowest or average depending on what algorithm is set
func GetLatencyURL ¶ added in v1.0.0
GetLatencyURL will return the proper url for the latency test file when given a server name
Types ¶
type ByDistance ¶
type ByDistance []Server
ByDistance allows us to sort servers by distance
func (ByDistance) Len ¶
func (server ByDistance) Len() int
func (ByDistance) Less ¶
func (server ByDistance) Less(i, j int) bool
func (ByDistance) Swap ¶
func (server ByDistance) Swap(i, j int)
type Config ¶
Config struct holds our config (users current ip, lat, lon and isp)
var CONFIG Config
CONFIG is our global config space
type Server ¶
type Server struct { URL string Lat float64 Lon float64 Name string Country string CC string Sponsor string ID string Distance float64 Latency float64 }
Server struct is a speedtest candidate server
func GetClosestServers ¶
GetClosestServers takes the full server list and sorts by distance
func GetFastestServer ¶
GetFastestServer test all servers until we find numServers that respond, then find the fastest of them. Some servers show up in the master list but timeout or are "corrupt" therefore we bump their latency to something really high (1 minute) and they will drop out of this test