Documentation
¶
Overview ¶
Package verify provides ProcessGeofeed so that it can be used by other programs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidGeofeed represents error that is returned in case of incomplete // compliance with RFC 8805 standards and the mode in which the program is // run. ErrInvalidGeofeed = errors.New("geofeed does not comply with the RFC 8805 standards") // ErrEmptyGeofeed indicates a Geofeed with no records. ErrEmptyGeofeed = errors.New("geofeed is empty") )
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶
type CheckResult struct { Total int Differences int Invalid int SampleInvalidRows map[RowInvalidity]string }
CheckResult holds the total number of rows for a geofeed file, the number of rows that differ from expected mmdb values as well as information about the rows that failed validation. To create new CheckResult instance use NewCheckResult() func.
func NewCheckResult ¶
func NewCheckResult() CheckResult
NewCheckResult returns new CheckResult instance.
func ProcessGeofeed ¶
func ProcessGeofeed( geofeedFilename, mmdbFilename, ispFilename string, opts Options, ) (CheckResult, []string, map[uint]int, error)
ProcessGeofeed attempts to validate a given geofeedFilename.
type Options ¶
type Options struct { // // LaxMode controls validation for region codes. If LaxMode is false // (default), ISO-3166-2 region codes format is required. Otherwise region // code is accepted both with or without country code. LaxMode bool // HideFilePathsInErrorMessages, if set to true, will prevent file paths // from appearing in error messages. This reduces information leakage in // contexts where the error messages might be shared. HideFilePathsInErrorMessages bool // EmptyOK, if set to true, will consider a geofeed with no records to be // valid. The default behavior (false) requires a geofeed to not be empty. EmptyOK bool }
Options contains configuration options for geofeed verification.
type RowInvalidity ¶
type RowInvalidity int
RowInvalidity represents type of row invalidity.
const ( FewerFieldsThanExpected RowInvalidity = iota EmptyNetwork UnableToParseNetwork UnableToFindCityRecord UnableToFindISPRecord InvalidRegionCode )
Invalidity types.
func (RowInvalidity) String ¶
func (ri RowInvalidity) String() string
String implements the Stringer interface.
Click to show internal directories.
Click to hide internal directories.