Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var HTTPConfigTimeout = time.Duration(15 * time.Second)
HTTPConfigTimeout is how long we'll wait for a config download to timeout
var HTTPDownloadTimeout = time.Duration(15 * time.Minute)
HTTPDownloadTimeout is how long we'll wait for a download to timeout
var HTTPLatencyTimeout = time.Duration(15 * time.Second)
HTTPLatencyTimeout is how long we'll wait for a ping to timeout
var SpeedtestConfigURL = "http://c.speedtest.net/speedtest-config.php?x=" + uniuri.New()
SpeedtestConfigURL is where we pull the global 'config' from speedtest.net Per #39 in some situations we need to have a ?=RANDOMNUMBER or the resulting page is blank
var SpeedtestServersURL = "http://c.speedtest.net/speedtest-servers-static.php?x=" + uniuri.New()
SpeedtestServersURL is the global list of speedtest servers Per #39 in some situations we need to have a ?=RANDOMNUMBER or the resulting page is blank
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
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