Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type NoProxy ¶
type NoProxy struct {
// contains filtered or unexported fields
}
func ParseNoProxy ¶
ParseNoProxy parses values of NO_PROXY environment variables similar to how "http/httpproxy".FromEnvironment parses them, with the following differences:
- If the port of a host is empty (i.e. "example.com:") then an error is returned.
- If the port of a host is a named port (i.e. "example.com:http") then an error is returned.
- If the port of a host is not positive (i.e. "zeronotallowed.example.com:0") then an error is returned.
- If the hostname of a host has non-ASCII characters then an error is returned. A hostname must be normalized as per "golang.org/x/net/idna".Lookup.ToASCII (otherwise it never matches anything). NOTE: validation of hostnames can be stricter, however this level of strictness matches the "http/httpproxy" and "http" Golang packages (despite lower level code potentially being stricter).
This function always returns a non-nil *NoProxy and any error returned is suitable for printing in logs, but the error's Error() may return a string with line feeds. As such, this function is suitable for validation of the NO_PROXY environment variable.
func (*NoProxy) FormatLibcurlCompatible ¶
FormatLibcurlCompatible formats the value of a NO_PROXY environment variable that is compatible with libcurl (see https://curl.haxx.se/libcurl/c/CURLOPT_NOPROXY.html). If the *NoProxy cannot be represented as such then an error is returned. For example, if the *NoProxy contains a CIDR or matches only specific ports of a hostname then an error is returned.