Documentation ¶
Overview ¶
Package check defines how to check an IP address. It provides types and functions that are useful for writing checks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultHttpClient = NewHttpClient(&http.Client{Timeout: 5 * time.Second})
DefaultHttpClient is reused by checks that make HTTP requests.
var GetConfigValue = func(key string) (string, error) { var v string if v = os.Getenv(key); v != "" { return v, nil } usr, err := user.Current() if err != nil { return "", err } confFile := filepath.Join(usr.HomeDir, ".checkip.yaml") buf, err := ioutil.ReadFile(confFile) if err != nil { return "", err } var data map[string]string err = yaml.Unmarshal(buf, &data) if err != nil { return "", err } if v, ok := data[key]; ok { return v, nil } return "", fmt.Errorf("%s not found in %s", key, confFile) }
GetConfigValue tries to get value for key first from an environment variable then from a configuration file at $HOME/.checkip.yaml.
Functions ¶
func UpdateFile ¶
UpdateFile updates file from url if the file is older than a week. If file does not exist it downloads and creates it. compressFmt is the compression format of the file to download; gz or tgz. Empty string means no compression.
Types ¶
type EmptyInfo ¶ added in v0.10.1
type EmptyInfo struct { }
EmptyInfo is returned by checks that don't provide generic information about an IP address.
func (EmptyInfo) JsonString ¶ added in v0.10.1
type Error ¶ added in v0.10.1
type Error struct { ErrString string `json:"error"` // secrets redacted // contains filtered or unexported fields }
Error is an error returned by a check.
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶ added in v0.15.2
func NewHttpClient(client *http.Client) HttpClient
type Result ¶
type Result struct { Name string `json:"name"` // check name Type Type `json:"type"` // check type Info Info `json:"info"` // provided by TypeInfo check Malicious bool `json:"malicious"` // provided by TypeSec check }
Result is the results of a check.