speedtest

package
v0.0.0-...-92ab757 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(lat1 float64, lon1 float64, lat2 float64, lon2 float64) float64

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(c *http.Client) *Client

func (*Client) CurrentUser

func (c *Client) CurrentUser() *User

func (*Client) FetchServerList

func (c *Client) FetchServerList(ctx context.Context) (ServerList, error)

func (*Client) FetchUserInfo

func (c *Client) FetchUserInfo(ctx context.Context) (*User, error)

func (*Client) GetInnerClient

func (c *Client) GetInnerClient() *http.Client

type Result

type Result struct {
	CurrentSpeed float64
	TotalBytes   int64
	Percent      float64
	Type         string
}

func (*Result) String

func (r *Result) String() string

type Server

type Server struct {
	URL  string `xml:"url,attr" json:"url"`
	URL2 string `xml:"url2,attr" json:"url_2"`

	Lat     string `xml:"lat,attr" json:"lat"`
	Lon     string `xml:"lon,attr" json:"lon"`
	Name    string `xml:"name,attr" json:"name"`
	Country string `xml:"country,attr" json:"country"`
	Sponsor string `xml:"sponsor,attr" json:"sponsor"`
	ID      string `xml:"id,attr" json:"id"`
	Host    string `xml:"host,attr" json:"host"`

	Distance float64       `json:"distance"`
	Latency  time.Duration `json:"latency"`
	DLSpeed  float64       `json:"dl_speed"` // Mbps
	ULSpeed  float64       `json:"ul_speed"` // Mbps
	// contains filtered or unexported fields
}

func (*Server) DownLoadTest

func (s *Server) DownLoadTest(ctx context.Context, c *http.Client, concurrency, downloadSize int, duration time.Duration) (chan Result, error)

func (*Server) GetPingLatency

func (s *Server) GetPingLatency(ctx context.Context, c *http.Client) error

func (*Server) String

func (s *Server) String() string

func (*Server) UpLoadTest

func (s *Server) UpLoadTest(ctx context.Context, c *http.Client, concurrency, size int, duration time.Duration) (chan Result, error)

type ServerList

type ServerList []*Server

func (ServerList) Len

func (svrs ServerList) Len() int

Len finds length of servers. For sorting servers.

func (ServerList) Less

func (svrs ServerList) Less(i, j int) bool

Swap swaps i-th and j-th. For sorting servers.

func (ServerList) Swap

func (svrs ServerList) Swap(i, j int)

Swap swaps i-th and j-th. For sorting servers.

type User

type User struct {
	IP  string `xml:"ip,attr"`
	Lat string `xml:"lat,attr"`
	Lon string `xml:"lon,attr"`
	Isp string `xml:"isp,attr"`
}

func (*User) String

func (u *User) String() string

type Users

type Users struct {
	Users []User `xml:"client"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL