resolvers

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package resolvers implements primitives to resolve various identifiers against external data

Copyright (c) Philipp Mieden. SPDX-License-Identifier: GPL-3.0-or-later

Index

Constants

View Source
const DefaultGeoProviders = "dbip,geolite2"
View Source
const ManagedPopularityFile = "netapi-top1m.csv"
View Source
const MaxPopularityBytes = 128 << 20
View Source
const MaxPopularityRows = 1_000_000

Variables

View Source
var (

	// CurrentConfig holds the current configuration.
	CurrentConfig Config

	// ConfigRootPath points to the path for storing the netcap configuration and databases.
	// usually: /usr/local/etc/netcap
	ConfigRootPath string

	// DataBaseFolderPath points to the 'dbs' folder for storing the netcap databases.
	// usually: /usr/local/etc/netcap/dbs
	DataBaseFolderPath string

	// DataBaseBuildPath points to the build folder for db generation artifacts,
	// that are not tracked in version control.
	// usually: /usr/local/etc/netcap/build
	DataBaseBuildPath string
)
View Source
var DefaultConfig = Config{
	ReverseDNS:    false,
	LocalDNS:      false,
	MACDB:         true,
	ServiceDB:     true,
	GeolocationDB: true,
	DHCPDB:        true,
	JA4DB:         ja4plusadapter.Enabled,
}

DefaultConfig is an example configuration.

View Source
var ErrDHCPEnrichmentDisabled = errors.New("DHCP fingerprint enrichment disabled: no admitted reviewed offline catalogue; packet decoding remains available")
View Source
var ErrGeolocationDBMissing = errors.New("geolocation database not found")

Functions

func ExternalPopularityPath

func ExternalPopularityPath(path, managed string) (string, error)

ExternalPopularityPath resolves symlinks, including existing ancestors of a missing managed directory, before checking containment.

func GeoProviderOrder

func GeoProviderOrder(raw string) ([]string, error)

Explicit CLI/config values override the environment, saved UI order and default.

func GetJA4DBSize

func GetJA4DBSize() int

func GetJA4HDBSize

func GetJA4HDBSize() int

func GetJA4SDBSize

func GetJA4SDBSize() int

func GetJA4TDBSize

func GetJA4TDBSize() int

func GetJA4TSDBSize

func GetJA4TSDBSize() int

func GetJA4TScanDBSize

func GetJA4TScanDBSize() int

func GetJA4XDBSize

func GetJA4XDBSize() int

func Init

func Init(c Config, quietMode bool)

Init can be used to initialize the resolvers package according to the provided configuration.

func InitDHCPFingerprintAPIKey

func InitDHCPFingerprintAPIKey()

func InitDHCPFingerprintDB

func InitDHCPFingerprintDB()

func InitDNSWhitelist

func InitDNSWhitelist() error

InitDNSWhitelist loads each configuration once; failures never retain stale entries.

func InitLocalDNS

func InitLocalDNS()

InitLocalDNS initializes reverse dns resolution via local hosts mapping.

func InitServiceDB

func InitServiceDB()

InitServiceDB initializes the ports to service names mapping. TODO: include service names for other transport protocols

func IsPopularHTTPHost

func IsPopularHTTPHost(host string) bool

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

IsPrivateIP can be used whether an address belongs to private address space.

func IsWhitelistedDomain

func IsWhitelistedDomain(domain string) bool

IsWhitelistedDomain is a legacy name for popularity suppression only.

func LoadDHCPCatalogue

func LoadDHCPCatalogue(path string) error

LoadDHCPCatalogue accepts a local trusted override or installer-verified path. Failed refreshes retain the previous immutable catalogue.

func LoadDomainPopularityList

func LoadDomainPopularityList(path, format, managed string) (*DomainPopularityList, PopularityStats, error)

LoadDomainPopularityList reads an explicit local file only: rank-domain has no header, netapi requires NetAPI_Rank,Domain, majestic its 12-column header.

func LoadMACCatalogue

func LoadMACCatalogue(path string) error

func LoadManagedDomainPopularityList added in v0.16.0

func LoadManagedDomainPopularityList(dir string) (*DomainPopularityList, PopularityStats, error)

LoadManagedDomainPopularityList validates the dedicated NetAPI member only.

func LookupDHCPFingerprint

func LookupDHCPFingerprint(key string, _ string, _ []string) (*dhcpResult, error)

func LookupDHCPFingerprintLocal

func LookupDHCPFingerprintLocal(key string) string

func LookupDNSNameLocal

func LookupDNSNameLocal(ip string) string

LookupDNSNameLocal retrieves the DNS names associated with an IP addr.

func LookupDNSNames

func LookupDNSNames(ip string) []string

LookupDNSNames retrieves the DNS names associated with an IP address.

func LookupGeolocation

func LookupGeolocation(addr string) (string, string)

func LookupJA4

func LookupJA4(string) string

func LookupJA4H

func LookupJA4H(string) string

func LookupJA4S

func LookupJA4S(string) string

func LookupJA4T

func LookupJA4T(string) string

func LookupJA4TS

func LookupJA4TS(string) string

func LookupJA4TScan

func LookupJA4TScan(string) string

func LookupJA4X

func LookupJA4X(string) string

func LookupManufacturer

func LookupManufacturer(mac string) string

LookupManufacturer returns a registered organization, not a device identity.

func LookupServiceByPort

func LookupServiceByPort(port int, protocol string) string

LookupServiceByPort looks up the service name associated with a given port and protocol.

func OpenGeoDatabase

func OpenGeoDatabase(path, provider, kind string) (*maxminddb.Reader, error)

func ParseGeoProviders

func ParseGeoProviders(raw string) ([]string, error)

func SaveFingerprintDB

func SaveFingerprintDB()

Retired API/cache entry points perform no file or network I/O.

func SaveGeoProviderOrder

func SaveGeoProviderOrder(raw string) error

func SetLogger

func SetLogger(lg *zap.Logger)

SetLogger sets the logger for the resolvers package.

func SetPerfTracker

func SetPerfTracker(pt *performance.Tracker)

SetPerfTracker sets the performance tracker for resolver operations

func ValidatePopularityFormat

func ValidatePopularityFormat(format string) error

Types

type Config

type Config struct {
	DomainPopularityList    string
	DomainPopularityFormat  string
	DisableDomainPopularity bool

	// Controls whether ip addresses are resolved through the default OS resolver
	ReverseDNS bool

	// Controls if ip addresses are resolved locally through a provided hosts mapping
	LocalDNS bool

	// Enables MAC address vendor lookups
	MACDB bool

	// Enables resolving port numbers to service names
	ServiceDB bool

	// Enables IP geolocation and ASN lookups.
	GeolocationDB bool
	GeoProviders  string

	// Enables DHCP fingerprint lookups
	DHCPDB bool

	// Enables JA4+ fingerprint lookups
	JA4DB bool
}

Config contains settings for the resolvers package.

type DeviceCatalogueStatus

type DeviceCatalogueStatus struct {
	Scope        string `json:"scope"`
	Kind         string `json:"kind"`
	State        string `json:"state"`
	Version      string `json:"version,omitempty"`
	Reason       string `json:"reason,omitempty"`
	Attribution  string `json:"attribution"`
	SourceURL    string `json:"source_url"`
	LicenseURL   string `json:"license_url"`
	DownloadFile string `json:"download_file"`
	NoticesFile  string `json:"notices_file"`
}

func DeviceCatalogueStatuses

func DeviceCatalogueStatuses() []DeviceCatalogueStatus

DeviceCatalogueStatuses is a read-only source summary for API/Pro consumers. It never resolves a channel, reads a file or performs network I/O.

func InstalledDeviceCatalogueStatuses

func InstalledDeviceCatalogueStatuses() []DeviceCatalogueStatus

InstalledDeviceCatalogueStatuses reports admission without changing capture state.

type DomainPopularityList

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

func (*DomainPopularityList) ContainsDNS

func (l *DomainPopularityList) ContainsDNS(name string) bool

ContainsDNS reports popularity, never safety. PRIVATE PSL rules isolate tenants.

func (*DomainPopularityList) ContainsHTTP

func (l *DomainPopularityList) ContainsHTTP(host string) bool

type GeoContext

type GeoContext struct {
	Country   string
	ASN       string
	Providers []string
}

func LookupGeoContext

func LookupGeoContext(addr string) GeoContext

type GeoProviderFiles

type GeoProviderFiles struct {
	Name string
	City string
	ASN  string
}

func GeoFiles

func GeoFiles(name string) GeoProviderFiles

type GeoProviderStatus

type GeoProviderStatus struct {
	Name      string `json:"name"`
	Selected  bool   `json:"selected"`
	Available bool   `json:"available"`
	Loaded    bool   `json:"loaded"`
	CityFile  string `json:"cityFile"`
	ASNFile   string `json:"asnFile"`
	CityBuild string `json:"cityBuild,omitempty"`
	ASNBuild  string `json:"asnBuild,omitempty"`
	Error     string `json:"error,omitempty"`
}

func GeoProviderStatuses

func GeoProviderStatuses(raw string) ([]GeoProviderStatus, error)

type JA4Entry

type JA4Entry struct {
	Application          string `json:"application"`
	Library              string `json:"library"`
	Device               string `json:"device"`
	OS                   string `json:"os"`
	UserAgentString      string `json:"user_agent_string"`
	CertificateAuthority string `json:"certificate_authority"`
	ObservationCount     int    `json:"observation_count"`
	Verified             bool   `json:"verified"`
	Notes                string `json:"notes"`
	JA4Fingerprint       string `json:"ja4_fingerprint"`
	JA4FingerprintString string `json:"ja4_fingerprint_string"`
	JA4SFingerprint      string `json:"ja4s_fingerprint"`
	JA4HFingerprint      string `json:"ja4h_fingerprint"`
	JA4XFingerprint      string `json:"ja4x_fingerprint"`
	JA4TFingerprint      string `json:"ja4t_fingerprint"`
	JA4TSFingerprint     string `json:"ja4ts_fingerprint"`
	JA4TScanFingerprint  string `json:"ja4tscan_fingerprint"`
}

JA4Entry preserves the public resolver API for records created by JA4+ opt-in builds. Official builds do not load or index JA4+ databases.

func LookupJA4Entry

func LookupJA4Entry(string) *JA4Entry

func LookupJA4HEntry

func LookupJA4HEntry(string) *JA4Entry

func LookupJA4SEntry

func LookupJA4SEntry(string) *JA4Entry

func LookupJA4TEntry

func LookupJA4TEntry(string) *JA4Entry

func LookupJA4TSEntry

func LookupJA4TSEntry(string) *JA4Entry

func LookupJA4TScanEntry

func LookupJA4TScanEntry(string) *JA4Entry

func LookupJA4XEntry

func LookupJA4XEntry(string) *JA4Entry

func (*JA4Entry) GetDescription

func (*JA4Entry) GetDescription() string

type PopularityStats

type PopularityStats struct{ Rows, Loaded, Duplicates, Invalid, Skipped int }

PopularityStats includes rejected input; failed loads never publish partial data.

Jump to

Keyboard shortcuts

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