curl

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

type Probe

type Probe struct{}

curl.Probe is an implementation of the probes.Probe interface that uses the venerable curl tool to check for blocked egresses in a target network. It launches an unmodified RHEL9 instance (although any OS with curl v7.76.1 or compatible will work) and uses userdata to transmit at runtime a list of egress URLs to which curl will attempt to connect. Curl will return the results as JSON via serial console, which this probe can then parse into a standard output format. Any reported egressURL errors will contain curl's detailed error messages. Additional command line options can be provided to curl via the CURLOPT userdataVariable. This probe has been confirmed to support X86 instances on AWS. In theory, it should also support GCP and any CPU architecture supported by RHEL.

func (Probe) GetEndingToken

func (clp Probe) GetEndingToken() string

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

func (Probe) GetExpandedUserData

func (clp Probe) 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 (Probe) GetMachineImageID

func (clp Probe) GetMachineImageID(platformType cloud.Platform, cpuArch cpu.Architecture, region string) (string, error)

GetMachineImageID returns the string ID of the VM image to be used for the probe instance

func (Probe) GetStartingToken

func (clp Probe) GetStartingToken() string

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

func (Probe) ParseProbeOutput

func (clp Probe) ParseProbeOutput(ensurePrivate bool, 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

Jump to

Keyboard shortcuts

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