Documentation ¶
Index ¶
- Constants
- Variables
- type BytesCounter
- func (c *BytesCounter) AvgBytes() float64
- func (c *BytesCounter) AvgHumanize() string
- func (c *BytesCounter) AvgMbps() float64
- func (c *BytesCounter) CurrentSpeed() float64
- func (c *BytesCounter) GenerateBlob()
- func (c *BytesCounter) Read(p []byte) (int, error)
- func (c *BytesCounter) SetMebi(mebi bool)
- func (c *BytesCounter) SetUploadSize(uploadSize int)
- func (c *BytesCounter) Start()
- func (c *BytesCounter) Total() uint64
- func (c *BytesCounter) Write(p []byte) (int, error)
- type GetIPResult
- type IPInfoResponse
- type NoFormatter
- type SeekWrapper
- type Server
- func (s *Server) Download(silent bool, useBytes, useMebi bool, requests int, chunks int, ...) (float64, uint64, error)
- func (s *Server) GetIPInfo(distanceUnit string) (*GetIPResult, error)
- func (s *Server) GetURL() (*url.URL, error)
- func (s *Server) ICMPPingAndJitter(count int, srcIp, network string) (float64, float64, error)
- func (s *Server) IsUp() bool
- func (s *Server) PingAndJitter(count int) (float64, float64, error)
- func (s *Server) Sponsor() string
- func (s *Server) Upload(noPrealloc, silent, useBytes, useMebi bool, requests int, uploadSize int, ...) (float64, uint64, error)
- type TelemetryExtra
- type TelemetryLog
- type TelemetryServer
- func (t *TelemetryServer) Basic() bool
- func (t *TelemetryServer) Debug() bool
- func (t *TelemetryServer) Disabled() bool
- func (t *TelemetryServer) Full() bool
- func (t *TelemetryServer) GetLevel() int
- func (t *TelemetryServer) GetPath() (*url.URL, error)
- func (t *TelemetryServer) GetShare() (*url.URL, error)
Constants ¶
const ( OptionHelp = "help" OptionIPv4 = "ipv4" OptionIPv4Alt = "4" OptionIPv6 = "ipv6" OptionIPv6Alt = "6" OptionNoDownload = "no-download" OptionNoUpload = "no-upload" OptionNoICMP = "no-icmp" OptionConcurrent = "concurrent" OptionBytes = "bytes" OptionMebiBytes = "mebibytes" OptionDistance = "distance" OptionSimple = "simple" OptionCSV = "csv" OptionCSVDelimiter = "csv-delimiter" OptionCSVHeader = "csv-header" OptionJSON = "json" OptionList = "list" OptionServer = "server" OptionExclude = "exclude" OptionServerJSON = "server-json" OptionSource = "source" OptionInterface = "interface" OptionTimeout = "timeout" OptionChunks = "chunks" OptionUploadSize = "upload-size" OptionDuration = "duration" OptionSecure = "secure" OptionCACert = "ca-cert" OptionSkipCertVerify = "skip-cert-verify" OptionNoPreAllocate = "no-pre-allocate" OptionVersion = "version" OptionLocalJSON = "local-json" OptionDebug = "debug" OptionTelemetryJSON = "telemetry-json" OptionTelemetryLevel = "telemetry-level" OptionTelemetryServer = "telemetry-server" OptionTelemetryPath = "telemetry-path" OptionTelemetryExtra = "telemetry-extra" )
const ( TelemetryLevelDisabled = "disabled" TelemetryLevelBasic = "basic" TelemetryLevelFull = "full" TelemetryLevelDebug = "debug" )
Variables ¶
var ( // values to be filled in by build script BuildDate string ProgName string ProgVersion string UserAgent = ProgName + "/" + ProgVersion )
Functions ¶
This section is empty.
Types ¶
type BytesCounter ¶
type BytesCounter struct {
// contains filtered or unexported fields
}
BytesCounter implements io.Reader and io.Writer interface, for counting bytes being read/written in HTTP requests
func NewCounter ¶
func NewCounter() *BytesCounter
func (*BytesCounter) AvgBytes ¶
func (c *BytesCounter) AvgBytes() float64
AvgBytes returns the average bytes/second
func (*BytesCounter) AvgHumanize ¶
func (c *BytesCounter) AvgHumanize() string
AvgHumanize returns the average bytes/kilobytes/megabytes/gigabytes (or bytes/kibibytes/mebibytes/gibibytes) per second
func (*BytesCounter) AvgMbps ¶
func (c *BytesCounter) AvgMbps() float64
AvgMbps returns the average mbits/second
func (*BytesCounter) CurrentSpeed ¶
func (c *BytesCounter) CurrentSpeed() float64
CurrentSpeed returns the current bytes/second
func (*BytesCounter) GenerateBlob ¶
func (c *BytesCounter) GenerateBlob()
GenerateBlob generates a random byte array of `uploadSize` in the `payload` field, and sets the `reader` field to read from it
func (*BytesCounter) Read ¶
func (c *BytesCounter) Read(p []byte) (int, error)
Read implements io.Reader
func (*BytesCounter) SetMebi ¶
func (c *BytesCounter) SetMebi(mebi bool)
SetBase sets the base for dividing bytes into megabyte or mebibyte
func (*BytesCounter) SetUploadSize ¶
func (c *BytesCounter) SetUploadSize(uploadSize int)
SetUploadSize sets the size of payload being uploaded
func (*BytesCounter) Start ¶
func (c *BytesCounter) Start()
Start will set the `start` field to current time
func (*BytesCounter) Total ¶
func (c *BytesCounter) Total() uint64
Total returns the total bytes read/written
type GetIPResult ¶
type GetIPResult struct { ProcessedString string `json:"processedString"` RawISPInfo IPInfoResponse `json:"rawIspInfo"` }
GetIPResults represents the returned JSON from backend server's getIP.php endpoint
type IPInfoResponse ¶
type IPInfoResponse struct { IP string `json:"ip"` Hostname string `json:"hostname"` City string `json:"city"` Region string `json:"region"` Country string `json:"country"` Location string `json:"loc"` Organization string `json:"org"` Postal string `json:"postal"` Timezone string `json:"timezone"` Readme string `json:"readme,omitempty"` }
IPInfoResponse represents the returned JSON from IPInfo.io's API
type SeekWrapper ¶
SeekWrapper is a wrapper around io.Reader to give it a noop io.Seeker interface
type Server ¶
type Server struct { ID int `json:"id"` Name string `json:"name"` Server string `json:"server"` DownloadURL string `json:"dlURL"` UploadURL string `json:"ulURL"` PingURL string `json:"pingURL"` GetIPURL string `json:"getIpURL"` SponsorName string `json:"sponsorName"` SponsorURL string `json:"sponsorURL"` NoICMP bool `json:"-"` TLog TelemetryLog `json:"-"` }
Server represents a speed test server
func (*Server) Download ¶
func (s *Server) Download(silent bool, useBytes, useMebi bool, requests int, chunks int, duration time.Duration) (float64, uint64, error)
Download performs the actual download test
func (*Server) GetIPInfo ¶
func (s *Server) GetIPInfo(distanceUnit string) (*GetIPResult, error)
GetIPInfo accesses the backend's getIP.php endpoint and get current client's IP information
func (*Server) ICMPPingAndJitter ¶
ICMPPingAndJitter pings the server via ICMP echos and calculate the average ping and jitter
func (*Server) PingAndJitter ¶
PingAndJitter pings the server via accessing ping URL and calculate the average ping and jitter
type TelemetryExtra ¶
type TelemetryExtra struct { ServerName string `json:"server"` Extra string `json:"extra,omitempty"` }
TelemetryExtra represents the `extra` field in the telemetry data
type TelemetryLog ¶
type TelemetryLog struct {
// contains filtered or unexported fields
}
TelemetryLog is the logger for `log` field in telemetry data
func (*TelemetryLog) Logf ¶
func (t *TelemetryLog) Logf(format string, a ...interface{})
Logf logs when log level is higher than or equal to "full"
func (*TelemetryLog) SetLevel ¶
func (t *TelemetryLog) SetLevel(level int)
SetLevel sets the log level
func (*TelemetryLog) String ¶
func (t *TelemetryLog) String() string
String returns the concatenated string of field `content`
func (*TelemetryLog) Verbosef ¶
func (t *TelemetryLog) Verbosef(format string, a ...interface{})
Verbosef logs when log level is higher than or equal to "debug"
func (*TelemetryLog) Warnf ¶
func (t *TelemetryLog) Warnf(format string, a ...interface{})
Warnf logs when log level is higher than or equal to "full", with a WARN prefix
type TelemetryServer ¶
type TelemetryServer struct { Level string `json:"telemetryLevel"` Server string `json:"server"` Path string `json:"path"` }
TelemetryServer represents the telemetry server configuration
func (*TelemetryServer) Basic ¶
func (t *TelemetryServer) Basic() bool
Basic checks if the telemetry level is "basic"
func (*TelemetryServer) Debug ¶
func (t *TelemetryServer) Debug() bool
Debug checks if the telemetry level is "debug"
func (*TelemetryServer) Disabled ¶
func (t *TelemetryServer) Disabled() bool
Disabled checks if the telemetry level is "disabled"
func (*TelemetryServer) Full ¶
func (t *TelemetryServer) Full() bool
Full checks if the telemetry level is "full"
func (*TelemetryServer) GetLevel ¶
func (t *TelemetryServer) GetLevel() int
GetLevel translates the level string to corresponding integer value