curl_json

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurlJSONProbe

type CurlJSONProbe struct{}

func (CurlJSONProbe) GetEndingToken

func (prb CurlJSONProbe) GetEndingToken() string

GetEndingToken returns the string token used to signal the end of the probe's output

func (CurlJSONProbe) GetExpandedUserData

func (prb CurlJSONProbe) GetExpandedUserData(userDataVariables map[string]string) (string, error)

GetExpandedUserData returns a YAML-formatted userdata string filled-in ("expanded") with the values provided in userDataVariables according to os.Expand(). E.g., if the userdata template contains "name: $FOO" and userDataVariables = {"FOO": "bar"}, the returned string will contain "name: bar". Errors will be returned if values aren't provided for required variables listed in the template's "network-verifier-required-variables" directive, or if values *are* provided for variables that must be set to a certain value for the probe to function correctly (presetUserDataVariables) -- this function will fill-in those values for you.

func (CurlJSONProbe) GetStartingToken

func (prb CurlJSONProbe) GetStartingToken() string

GetStartingToken returns the string token used to signal the beginning of the probe's output

func (CurlJSONProbe) ParseProbeOutput

func (prb CurlJSONProbe) ParseProbeOutput(probeOutput string, outputDestination *output.Output)

ParseProbeOutput accepts a string containing all probe output that appeared between the startingToken and the endingToken and a pointer to an Output object. outputDestination will be filled with the results from the egress check

type CurlJSONProbeResult

type CurlJSONProbeResult struct {
	ContentType          string  `json:"content_type"`
	ErrorMsg             string  `json:"errormsg"`
	ExitCode             int     `json:"exitcode"`
	FilenameEffective    string  `json:"filename_effective"`
	FTPEntryPath         string  `json:"ftp_entry_path"`
	HTTPCode             int     `json:"http_code"`
	HTTPConnect          int     `json:"http_connect"`
	HTTPVersion          string  `json:"http_version"`
	LocalIP              string  `json:"local_ip"`
	LocalPort            int     `json:"local_port"`
	Method               string  `json:"method"`
	NumConnects          int     `json:"num_connects"`
	NumHeaders           int     `json:"num_headers"`
	NumRedirects         int     `json:"num_redirects"`
	ProxySSLVerifyResult int     `json:"proxy_ssl_verify_result"`
	RedirectURL          string  `json:"redirect_url"`
	Referer              string  `json:"referer"`
	RemoteIP             string  `json:"remote_ip"`
	RemotePort           int     `json:"remote_port"`
	ResponseCode         int     `json:"response_code"`
	Scheme               string  `json:"scheme"`
	SizeDownload         int     `json:"size_download"`
	SizeHeader           int     `json:"size_header"`
	SizeRequest          int     `json:"size_request"`
	SizeUpload           int     `json:"size_upload"`
	SpeedDownload        int     `json:"speed_download"`
	SpeedUpload          int     `json:"speed_upload"`
	SSLVerifyResult      int     `json:"ssl_verify_result"`
	TimeAppConnect       float64 `json:"time_appconnect"`
	TimeConnect          float64 `json:"time_connect"`
	TimeNameLookup       float64 `json:"time_namelookup"`
	TimePreTransfer      float64 `json:"time_pretransfer"`
	TimeRedirect         float64 `json:"time_redirect"`
	TimeStartTransfer    float64 `json:"time_starttransfer"`
	TimeTotal            float64 `json:"time_total"`
	URL                  string  `json:"url"`
	URLEffective         string  `json:"url_effective"`
	URLNum               int     `json:"urlnum"`
	CurlVersion          string  `json:"curl_version"`
}

A CurlJSONProbeResult represents all the data the curl probe had to offer regarding its attempt(s) to reach a single URL. This struct is based on the fields curl v7.76.1 prints when given the `--write-out "%{json}"` flag. We only use a small fraction of the fields listed below; all others are included for potential future use

func (CurlJSONProbeResult) IsSuccessfulConnection

func (res CurlJSONProbeResult) IsSuccessfulConnection() bool

IsSuccessfulConnection returns true if the CurlJSONProbeResult reports a successful connection to its URLEffective, based on curl's exit code

Jump to

Keyboard shortcuts

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