checknet

package
v0.0.0-...-cc86db0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNetworkCategoryNotDetected = errors.New("Network category has not been detected")
)

Functions

func DeclareNetworkCategory

func DeclareNetworkCategory(category networkcategory.NetworkCategory)

DeclareNetworkCategory sets the network category in cache of this module, which is used to specify the network environment when running netcheck program.

func HttpDownlod

func HttpDownlod(url string, filePath string) error

HttpDownload simply directly calls util.HttpDownload function without wrapping

func HttpGet

func HttpGet(url string) (error, string)

HttpGet calls util.HttpGet with wrapping code which issue network diagnostic when encoutering network error

func HttpPost

func HttpPost(url string, data string, contentType string) (string, error)

HttpPost calls util.HttpPost with wrapping code which issue network diagnostic when encoutering network error

func RequestNetcheck

func RequestNetcheck(requestType NetcheckRequestType)

RequestNetcheck would asynchronously invoke netcheck program for network diagnostic, when no other network diagnostic is running or the last diagnostic report has outdated.

Types

type CheckReport

type CheckReport struct {
	Result       int
	FinishedTime time.Time
}

func RecentReport

func RecentReport() *CheckReport

RecentReport would return the most recent available network diagnostic report, or nil pointer if the report has not been generated. When the report has been outdated, it would call RequestNetcheck to refresh netcheck report.

type NetcheckRequestType

type NetcheckRequestType string
const (
	NetcheckRequestNormal    NetcheckRequestType = "normal"
	NetcheckRequestForceOnce NetcheckRequestType = "forceOnce"
)

Jump to

Keyboard shortcuts

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