sthttp

package
Version: v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2016 License: GPL-2.0, GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTPConfigTimeout = time.Duration(15 * time.Second)

HTTPConfigTimeout is how long we'll wait for a config download to timeout

View Source
var HTTPDownloadTimeout = time.Duration(15 * time.Minute)

HTTPDownloadTimeout is how long we'll wait for a download to timeout

View Source
var HTTPLatencyTimeout = time.Duration(15 * time.Second)

HTTPLatencyTimeout is how long we'll wait for a ping to timeout

View Source
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

View Source
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

func DownloadSpeed(url string) float64

DownloadSpeed measures the mbps of downloading a URL

func GetLatency

func GetLatency(server Server) float64

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 UploadSpeed

func UploadSpeed(url string, mimetype string, data []byte) float64

UploadSpeed measures the mbps to http.Post to a URL

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 ByLatency

type ByLatency []Server

ByLatency allows us to sort servers by latency

func (ByLatency) Len

func (server ByLatency) Len() int

func (ByLatency) Less

func (server ByLatency) Less(i, j int) bool

func (ByLatency) Swap

func (server ByLatency) Swap(i, j int)

type Config

type Config struct {
	IP  string
	Lat float64
	Lon float64
	Isp string
}

Config struct holds our config (users current ip, lat, lon and isp)

var CONFIG Config

CONFIG is our global config space

func GetConfig

func GetConfig() Config

GetConfig downloads the master config from speedtest.net

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

func GetClosestServers(servers []Server) []Server

GetClosestServers takes the full server list and sorts by distance

func GetFastestServer

func GetFastestServer(servers []Server) Server

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

func GetServers

func GetServers() []Server

GetServers will get the full server list

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL