check

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package check checks an IP address using various public services. An IP address is checked by running one or more Checkers. There are two kinds of Checkers. An InfoChecker just gathers some useful information about the IP address. A SecChecker says whether the IP address is considered malicious or not.

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

type Data

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

type EmptyData

type EmptyData struct {
}

func (EmptyData) JsonString

func (EmptyData) JsonString() (string, error)

func (EmptyData) String

func (EmptyData) String() 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 Result

type Result struct {
	CheckName         string
	CheckType         Type
	IsIPaddrMalicious bool
	Data              Data
	Error             *ResultError
}

type ResultError

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

func NewResultError

func NewResultError(err error) *ResultError

func (*ResultError) Error

func (e *ResultError) Error() string

type Results

type Results []Result

func Run

func Run(checkers []Check, ipaddr net.IP) Results

Run runs checkers concurrently checking the ipaddr.

func (Results) Print

func (rs Results) Print() error

Print prints condensed results to stdout.

func (Results) SortByName

func (rs Results) SortByName()

type Type

type Type string
const (
	TypeInfoSec Type = "InfoSec"
	TypeInfo    Type = "Info"
	TypeSec     Type = "Sec"
)

Jump to

Keyboard shortcuts

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