speedtest

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// serverListUrl is the default remote server JSON URL
	ServerListUrl = `https://librespeed.org/backend-servers/servers.php`

	DefaultPingCount       = 10
	DefaultTelemetryLevel  = "basic"
	DefaultTelemetryServer = "https://librespeed.org"
	DefaultTelemetryPath   = "/results/telemetry.php"
	DefaultTelemetryShare  = "/results/"
)

Variables

This section is empty.

Functions

func AutoSpeedTest

func AutoSpeedTest(
	distanceUnit string,
	forceHTTPS bool,
	noICMP bool,
	noShare bool,
) (*defs.Report, error)

AutoSpeedTest is a function that selects the fastest server and runs a fully automatic speedtest with default parameters, distanceUnit shoulr be one of ["mi", "km", "NM"] (miles, kilometers, nautical miles)

func FetchServerList

func FetchServerList(listURL string) (*[]defs.Server, error)

FetchServerList fetches a server list from a URL

func GetLocalServerList

func GetLocalServerList(listPath string) (*[]defs.Server, error)

GetLocalServerList reads a server list from a filesystem path

func PreprocessServers

func PreprocessServers(
	servers *[]defs.Server,
	forceHTTPS bool,
	noICMP bool,
) error

PreprocessServers sets a few key attributes of the servers

func RankServers

func RankServers(servers *[]defs.Server) (defs.Server, error)

RankServer performs a ping request to each server frin the given slice and returns the fastest one

func SendTelemetry

func SendTelemetry(
	telemetryServer defs.TelemetryServer,
	extra defs.TelemetryExtra,
	ispInfo *defs.GetIPResult,
	report *defs.Report,
	telemetryLog *defs.TelemetryLog,
) (string, error)

sendTelemetry sends the telemetry result to server, if --share is given

func SingleSpeedTest

func SingleSpeedTest(
	server *defs.Server,
	noDownload bool,
	noUpload bool,
	pingCount int,
	distanceUnit string,
	requests int,
	chunks int,
	noPrealloc bool,
	uploadSize int,
	duration time.Duration,
	noShare bool,
) (*defs.Report, error)

SingleSpeedTest runs a speedtest for one server and returns a corresponding Report object distanceUnit shoulr be one of ["mi", "km", "NM"] (miles, kilometers, nautical miles)

Types

type PingJob

type PingJob struct {
	Index  int
	Server defs.Server
}

type PingResult

type PingResult struct {
	Index int
	Ping  float64
}

Jump to

Keyboard shortcuts

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