Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type ClientConfig
- type Config
- type ConfigRef
- type ConfigTime
- type ConfigTimes
- type Coordinates
- type Opts
- type Response
- type Server
- type ServerID
- type Servers
- func (servers *Servers) Find(id ServerID) *Server
- func (servers *Servers) First() *Server
- func (servers *Servers) Len() int
- func (servers *Servers) Less(i, j int) bool
- func (servers *Servers) MeasureLatencies(times uint, errorLatency time.Duration) *Servers
- func (servers *Servers) String() string
- func (servers *Servers) Swap(i, j int)
- type ServersRef
Constants ¶
View Source
const DefaultErrorLatency = time.Hour
View Source
const DefaultLatencyMeasureTimes = 4
View Source
const Version = "1.0.0"
Variables ¶
View Source
var NoServersError error = errors.New("No servers available")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Log(format string, a ...interface{}) Config() (*Config, error) LoadConfig(ret chan ConfigRef) NewRequest(method string, url string, body io.Reader) (*http.Request, error) Get(url string) (resp *Response, err error) Post(url string, bodyType string, body io.Reader) (resp *Response, err error) AllServers() (*Servers, error) LoadAllServers(ret chan ServersRef) ClosestServers() (*Servers, error) LoadClosestServers(ret chan ServersRef) }
type ClientConfig ¶
type ClientConfig struct { Coordinates IP string `xml:"ip,attr"` ISP string `xml:"isp,attr"` ISPRating float32 `xml:"isprating,attr"` ISPDownloadAverage uint32 `xml:"ispdlavg,attr"` ISPUploadAverage uint32 `xml:"ispulavg,attr"` Rating float32 `xml:"rating,attr"` LoggedIn uint8 `xml:"loggedin,attr"` }
type Config ¶
type Config struct { Client ClientConfig `xml:"client"` Times ConfigTimes `xml:"times"` }
type ConfigTime ¶
type ConfigTimes ¶
type ConfigTimes []ConfigTime
func (ConfigTimes) UnmarshalXML ¶
func (times ConfigTimes) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type Coordinates ¶
func (Coordinates) DistanceTo ¶
func (org Coordinates) DistanceTo(dest Coordinates) float64
type Opts ¶
type Response ¶
func (*Response) ReadContent ¶
type Server ¶
type Server struct { Coordinates URL string `xml:"url,attr"` Name string `xml:"name,attr"` Country string `xml:"country,attr"` CC string `xml:"cc,attr"` Sponsor string `xml:"sponsor,attr"` ID ServerID `xml:"id,attr"` URL2 string `xml:"url2,attr"` Host string `xml:"host,attr"` Distance float64 `xml:"-"` Latency time.Duration `xml:"-"` // contains filtered or unexported fields }
func (*Server) DownloadSpeed ¶
func (*Server) MeasureLatency ¶
func (*Server) RelativeURL ¶
func (*Server) UploadSpeed ¶
type Servers ¶
type Servers struct {
List []*Server `xml:"servers>server"`
}
func (*Servers) MeasureLatencies ¶
Measures latencies for each server. Returns server list sorted by latencies. This is synchronous operation, because multiple simultaneous requests may affect results.
type ServersRef ¶
Click to show internal directories.
Click to hide internal directories.