Documentation ¶
Index ¶
- type ByDistance
- type ByLatency
- type Client
- func (stClient *Client) DownloadSpeed(url string) (speed float64, err error)
- func (stClient *Client) GetClosestServers(servers []Server) []Server
- func (stClient *Client) GetConfig() (c Config, err error)
- func (stClient *Client) GetFastestServer(servers []Server) Server
- func (stClient *Client) GetLatency(server Server, url string) (result float64, err error)
- func (stClient *Client) GetLatencyURL(server Server) string
- func (stClient *Client) GetServers() (servers []Server, err error)
- func (stClient *Client) UploadSpeed(url string, mimetype string, data []byte) (speed float64, err error)
- type Config
- type HTTPConfig
- type Server
- type ServerSettings
- type SpeedtestConfig
- type TheClient
- type TheServersContainer
- type XMLConfigSettings
- type XMLServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 Client ¶
type Client struct { Config *Config SpeedtestConfig *SpeedtestConfig HTTPConfig *HTTPConfig Debug bool ReportChar string }
Client define a Speedtest HTTP client
func NewClient ¶
func NewClient(speedtestConfig *SpeedtestConfig, httpConfig *HTTPConfig, debug bool, reportChar string) *Client
NewClient define a new Speedtest client.
func (*Client) DownloadSpeed ¶
DownloadSpeed measures the mbps of downloading a URL
func (*Client) GetClosestServers ¶
GetClosestServers takes the full server list and sorts by distance
func (*Client) 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
func (*Client) 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 (*Client) GetLatencyURL ¶
GetLatencyURL will return the proper url for the latency
func (*Client) GetServers ¶
GetServers will get the full server list
type HTTPConfig ¶
HTTPConfig define settings for HTTP requests
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
type ServerSettings ¶
type ServerSettings struct { XMLName xml.Name `xml:"settings"` ServersContainer TheServersContainer `xml:"servers"` }
ServerSettings is the servers part of the setings
type SpeedtestConfig ¶
type SpeedtestConfig struct { ConfigURL string ServersURL string AlgoType string NumClosest int NumLatencyTests int Interface string Blacklist []string UserAgent string }
SpeedtestConfig define Speedtest settings
type TheClient ¶
type TheClient struct { IP string `xml:"ip,attr"` Lat string `xml:"lat,attr"` Lon string `xml:"lon,attr"` Isp string `xml:"isp,attr"` }
TheClient is our users information
type TheServersContainer ¶
type TheServersContainer struct { XMLName xml.Name `xml:"servers"` XMLServers []XMLServer `xml:"server"` }
TheServersContainer is a list of servers
type XMLConfigSettings ¶
XMLConfigSettings is a container for settings
type XMLServer ¶
type XMLServer struct { XMLName xml.Name `xml:"server"` 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"` CC string `xml:"cc,attr"` Sponsor string `xml:"sponsor,attr"` ID string `xml:"id,attr"` }
XMLServer is a candidate server