check

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 15 Imported by: 2

Documentation

Overview

Package check checks an IP address using various public services.

Index

Constants

This section is empty.

Variables

View Source
var DefaultHttpClient = HttpClient{/* contains filtered or unexported fields */}

Functions

func GetConfigValue

func GetConfigValue(key string) (string, error)

GetConfigValue tries to get value for key first from an environment variable then from a configuration file at $HOME/.checkip.yaml

func Na

func Na(s string) string

func NonEmpty

func NonEmpty(strings ...string) []string

func UpdateFile

func UpdateFile(file, url string, compressFmt string) error

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 Check

type Check func(ipaddr net.IP) (Result, error)

type EmptyInfo added in v0.10.1

type EmptyInfo struct {
}

func (EmptyInfo) JsonString added in v0.10.1

func (EmptyInfo) JsonString() (string, error)

func (EmptyInfo) String added in v0.10.1

func (EmptyInfo) String() string

type Error added in v0.10.1

type Error struct {
	ErrString string `json:"error"`
	// contains filtered or unexported fields
}

func NewError added in v0.10.1

func NewError(err error) *Error

func (*Error) Error added in v0.10.1

func (e *Error) Error() string

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}

func (HttpClient) Get

func (c HttpClient) Get(apiUrl string, headers map[string]string, queryParams map[string]string) ([]byte, error)

func (HttpClient) GetJson

func (c HttpClient) GetJson(apiUrl string, headers map[string]string, queryParams map[string]string, response interface{}) error

type Info added in v0.10.1

type Info interface {
	String() string
	JsonString() (string, error)
}

type Result

type Result struct {
	Name            string
	Type            Type
	IPaddrMalicious bool
	Info            Info
}

type Type

type Type string
const (
	TypeInfo    Type = "Info" // provides some useful information about the IP address
	TypeSec     Type = "Sec"  // says whether the IP address is considered malicious
	TypeInfoSec Type = "InfoSec"
)

Jump to

Keyboard shortcuts

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