session

package
v0.0.0-...-324f9bf Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName               = "ipscout"
	DefaultIndentSpaces   = 2
	DefaultMaxReports     = 5
	DefaultConfigFileName = "config.yaml"
)

Variables

View Source
var DefaultConfig string

Functions

func CreateConfigPathStructure

func CreateConfigPathStructure(configRoot string) error

CreateConfigPathStructure creates all the necessary paths under session root if they don't exist and returns an error if it fails to create the directory, or the session root does not exist

func CreateDefaultConfigIfMissing

func CreateDefaultConfigIfMissing(path string) (bool, error)

CreateDefaultConfigIfMissing creates a default session configuration file if it does not exist and returns true if it was created, or false if it already exists

func GetConfigRoot

func GetConfigRoot(root string, appName string) string

GetConfigRoot returns the root path for the app's session directory if root is specified, it will use that, otherwise it will use the user's home directory

Types

type Config

type Config struct {
	Global GlobalConfig `mapstructure:"global"`
}

type GlobalConfig

type GlobalConfig struct {
	LogLevel            string   `mapstructure:"log-level"`
	Output              string   `mapstructure:"output"`
	IndentSpaces        int      `mapstructure:"indent-spaces"`
	Ports               []string `mapstructure:"ports"`
	MaxValueChars       int32    `mapstructure:"max-value-chars"`
	MaxAge              string   `mapstructure:"max-age"`
	MaxReports          int      `mapstructure:"max-reports"`
	DisableCache        bool     `mapstructure:"disable-cache"`
	Style               string   `mapstructure:"style"`
	InitialiseCacheOnly bool
}

type Messages

type Messages struct {
	Mu      sync.Mutex
	Info    []string
	Warning []string
	Error   []string
}

func (*Messages) AddError

func (m *Messages) AddError(msg string)

func (*Messages) AddInfo

func (m *Messages) AddInfo(msg string)

func (*Messages) AddWarn

func (m *Messages) AddWarn(msg string)

type Providers

type Providers struct {
	AbuseIPDB struct {
		APIKey         string
		Enabled        *bool `mapstructure:"enabled"`
		ResultCacheTTL int64 `mapstructure:"result_cache_ttl"`
		MaxAge         int   `mapstructure:"max-age"`
	} `mapstructure:"abuseipdb"`
	Annotated struct {
		Enabled          *bool    `mapstructure:"enabled"`
		DocumentCacheTTL int64    `mapstructure:"document_cache_ttl"`
		Paths            []string `mapstructure:"paths"`
	} `mapstructure:"annotated"`
	AWS struct {
		Enabled          *bool  `mapstructure:"enabled"`
		DocumentCacheTTL int64  `mapstructure:"document_cache_ttl"`
		URL              string `mapstructure:"url"`
	} `mapstructure:"aws"`
	Azure struct {
		Enabled          *bool  `mapstructure:"enabled"`
		DocumentCacheTTL int64  `mapstructure:"document_cache_ttl"`
		URL              string `mapstructure:"url"`
	} `mapstructure:"azure"`
	Bingbot struct {
		Enabled          *bool  `mapstructure:"enabled"`
		DocumentCacheTTL int64  `mapstructure:"document_cache_ttl"`
		URL              string `mapstructure:"url"`
	} `mapstructure:"bingbot"`
	CriminalIP struct {
		APIKey         string
		ResultCacheTTL int64 `mapstructure:"result_cache_ttl"`
		Enabled        *bool `mapstructure:"enabled"`
	} `mapstructure:"criminalip"`
	DigitalOcean struct {
		Enabled          *bool `mapstructure:"enabled"`
		DocumentCacheTTL int64 `mapstructure:"document_cache_ttl"`
		URL              string
	} `mapstructure:"digitalocean"`
	GCP struct {
		Enabled          *bool `mapstructure:"enabled"`
		DocumentCacheTTL int64 `mapstructure:"document_cache_ttl"`
		URL              string
	} `mapstructure:"gcp"`
	Google struct {
		Enabled          *bool `mapstructure:"enabled"`
		DocumentCacheTTL int64 `mapstructure:"document_cache_ttl"`
		URL              string
	} `mapstructure:"google"`
	Googlebot struct {
		Enabled          *bool `mapstructure:"enabled"`
		DocumentCacheTTL int64 `mapstructure:"document_cache_ttl"`
		URL              string
	} `mapstructure:"googlebot"`
	ICloudPR struct {
		Enabled          *bool  `mapstructure:"enabled"`
		DocumentCacheTTL int64  `mapstructure:"document_cache_ttl"`
		URL              string `mapstructure:"url"`
	} `mapstructure:"icloudpr"`
	IPAPI struct {
		APIKey         string
		Enabled        *bool `mapstructure:"enabled"`
		ResultCacheTTL int64 `mapstructure:"result_cache_ttl"`
	} `mapstructure:"ipapi"`
	IPURL struct {
		Enabled          *bool    `mapstructure:"enabled"`
		DocumentCacheTTL int64    `mapstructure:"document_cache_ttl"`
		URLs             []string `mapstructure:"urls"`
	} `mapstructure:"ipurl"`
	Linode struct {
		Enabled          *bool `mapstructure:"enabled"`
		DocumentCacheTTL int64 `mapstructure:"document_cache_ttl"`
		URL              string
	} `mapstructure:"linode"`
	Shodan struct {
		APIKey         string
		ResultCacheTTL int64 `mapstructure:"result_cache_ttl"`
		Enabled        *bool `mapstructure:"enabled"`
	} `mapstructure:"shodan"`
	PTR struct {
		Enabled        *bool    `mapstructure:"enabled"`
		ResultCacheTTL int64    `mapstructure:"result_cache_ttl"`
		Nameservers    []string `mapstructure:"nameservers"`
	} `mapstructure:"ptr"`
	VirusTotal struct {
		APIKey         string
		ResultCacheTTL int64 `mapstructure:"result_cache_ttl"`
		ShowProviders  *bool `mapstructure:"show_providers"`
		ShowUnrated    *bool `mapstructure:"show_unrated"`
		ShowHarmless   *bool `mapstructure:"show_harmless"`
		ShowClean      *bool `mapstructure:"show_clean"`
		Enabled        *bool `mapstructure:"enabled"`
	} `mapstructure:"virustotal"`
}

type Session

type Session struct {
	App struct {
		Version string
		SemVer  string
	}
	Logger   *slog.Logger
	Stats    *Stats
	Target   *os.File
	Output   string
	Messages *Messages
	Cache    *badger.DB
	Config   Config

	HTTPClient   *retryablehttp.Client
	Host         netip.Addr
	Providers    Providers `mapstructure:"providers"`
	HideProgress bool      `mapstructure:"hide-progress"`

	UseTestData bool
}

func New

func New() *Session

func (*Session) Validate

func (c *Session) Validate() error

type Stats

type Stats struct {
	Mu                  sync.Mutex
	InitialiseDuration  map[string]time.Duration
	InitialiseUsedCache map[string]bool
	FindHostDuration    map[string]time.Duration
	FindHostUsedCache   map[string]bool
	CreateTableDuration map[string]time.Duration
}

func CreateStats

func CreateStats() *Stats

Jump to

Keyboard shortcuts

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