Documentation ¶
Overview ¶
Multicurl package is a library for the multicurl tool to fetch a url from all its IPs. Some of this code is based on the fortio code. https://github.com/fortio/fortio/blob/master/fnet/network.go
Index ¶
- func Days(d time.Duration) float64
- func DumpResponseDetails(w io.Writer, r *http.Response)
- func Dur(days float64) time.Duration
- func Filename(cfg *Config, addr net.IP) string
- func GetCA(caFile string) (*x509.CertPool, error)
- func GetCertificate(cert, key string) ([]tls.Certificate, error)
- func IPPortString(ip net.IP, port int) string
- func ReadIPs(filename string) ([]net.IP, error)
- func Resolve(ctx context.Context, cfg *Config) ([]net.IP, error)
- func ResolveAll(ctx context.Context, host, resolveType string) ([]net.IP, error)
- func URLAddScheme(url string) string
- type Config
- type ResultStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpResponseDetails ¶
DumpResponseDetails sort of reconstitutes the server's response (but not really as go processes it and the raw response isn't available - use fortio curl fast client for exact bytes).
func GetCertificate ¶
func GetCertificate(cert, key string) ([]tls.Certificate, error)
func URLAddScheme ¶
Types ¶
type Config ¶
type Config struct { // URL is the url to access. URL string // ResolveType is a filter for the IPs to use, `ip4`, `ip6`, or `ip` for both. ResolveType string // Method is the HTTP method to use, defaults to GET. (do use POST/PUT/... if passing a Payload) Method string // RequestTimeout is the timeout for a single request to succeed by. // Pass `context.WithTimeout(context.Background(), totalTimeout)` as context to MultiCurl() for a total timeout. RequestTimeout time.Duration // IncludeHeaders if true will include the response headers in the output. IncludeHeaders bool // Headers are the headers to use for the request. Must be initialized. Or call NewConfig(). Headers http.Header // HostOverride is the host/authority to use for the request. If empty, the host from the URL is used. // This will also change the ServerName used for TLS handshake (sni) so in essence passing HostOverride // is the same as passing the IPs of the server of the url and using the name from HostOverride as the url. HostOverride string // OutputPattern is the pattern to use for the output file names, must contain a % which will get replaced by // the IP of the target. If empty or "-", output is written to stdout. If "none" no output is written. OutputPattern string // Payload to send or nil if none. Payload []byte // Source file of the IPs to use instead of resolving the host IPs. Use "-" to read from stdin. IPFile string // Expected http result code: other codes will count as errors. 0 (default) treats non 200 as warnings. ExpectedCode int // Repeat until no errors. 0 (default) means no repeat. -1 means repeat until no errors (context timeout still applies. // a positive number means repeat that at most that many times. MaxRepeat int // Delay between repeats. NewConfig will set this to 5 seconds as initial value. RepeatDelay time.Duration // Limit the number of IPs to use. 0 (default) means no limit. MaxIPs int // Re-Lookup between iterations. False by default. doesn't apply if IPFile is set. ReLookup bool // Cert expiration error threshold (if a cert is found expiring sooner than this). CertExpiryError time.Duration // Path of an alternate CA file to use for TLS validation (instead of system). CAFile string // Insecure will continue despite certificate validation errors. Insecure bool // Client certificate file path to provide to server for mutual TLS. Cert string // Client certificate key file path to provide to server for mutual TLS. Key string // contains filtered or unexported fields }
Config object for MultiCurl to avoid passing too many parameters.
func (*Config) AddAndValidateExtraHeader ¶
AddAndValidateExtraHeader collects extra headers (see cli/main.go for example). Inspired/borrowed from fortio/fhttp.
type ResultStats ¶
type ResultStats struct { // Number of errors (if any request is made at all) Errors int // Number of warnings, ie non 200 responses Warnings int // Addresses queried (keys of Codes and Sizes) Addresses []string // http result code for that address (maps to Warnings) Codes map[string]int // Size of the response from that address Sizes map[string]int // Iterations done Iterations int // Shortest certificate expiration found ShortestCertExpiry *time.Time `json:"ShortestCertExpiry,omitempty"` }
ResultStats is the details of the MultCurl run when any request is made at all.
Click to show internal directories.
Click to hide internal directories.