Documentation
¶
Index ¶
- func ConditionalResetTopLevelMergeWith(newValue mmdbtype.DataType, cfg []ConditionalResetConfig) inserter.Func
- func WriteMMDB(dbConfig DatabaseConfig, sources []Source, updates chan string) error
- type CSVSource
- type ConditionalResetConfig
- type Config
- type DatabaseConfig
- type DatabaseInput
- type DefaultConfig
- type IPFireSource
- type MMDBConfig
- type MergeConfig
- type Optimizations
- type Source
- type SourceEntry
- type SourceValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConditionalResetTopLevelMergeWith ¶ added in v0.2.0
func ConditionalResetTopLevelMergeWith(newValue mmdbtype.DataType, cfg []ConditionalResetConfig) inserter.Func
ConditionalResetTopLevelMergeWith is based on TopLevelMergeWith, but conditionally resets fields as defined in the conditional reset config. Both the new and existing value must be a Map. An error will be returned otherwise.
Types ¶
type CSVSource ¶
type CSVSource struct {
// contains filtered or unexported fields
}
CSVSource reads geoip data in csv format.
func LoadCSVSource ¶
func LoadCSVSource(input DatabaseInput, types map[string]string) (*CSVSource, error)
LoadCSVSource returns a new CSVSource.
func (*CSVSource) NextEntry ¶
func (csv *CSVSource) NextEntry() (*SourceEntry, error)
NextEntry returns the next entry of the source. If nil, nil is returned, stop reading and check Err().
type ConditionalResetConfig ¶ added in v0.2.0
type ConditionalResetConfig struct {
IfChanged []string `yaml:"ifChanged"`
Reset []string `yaml:"reset"`
}
ConditionalResetConfig defines a conditional reset merge config.
type Config ¶
type Config struct {
Databases []DatabaseConfig `yaml:"databases"`
Defaults DefaultConfig `yaml:"defaults"`
}
Config is the geoip build config.
func LoadConfig ¶
LoadConfig loads a configuration file.
type DatabaseConfig ¶
type DatabaseConfig struct {
Name string `yaml:"name"`
MMDB MMDBConfig `yaml:"mmdb"`
Types map[string]string `yaml:"types"`
Inputs []DatabaseInput `yaml:"inputs"`
Output string `yaml:"output"`
Optimize Optimizations `yaml:"optimize"`
Merge MergeConfig `yaml:"merge"`
}
DatabaseConfig holds the config for building one database.
type DatabaseInput ¶
type DatabaseInput struct {
File string `yaml:"file"`
Fields []string `yaml:"fields"`
FieldMap map[string]string `yaml:"fieldMap"`
}
DatabaseInput holds database input config.
type DefaultConfig ¶ added in v0.3.0
type DefaultConfig struct {
Types map[string]string `yaml:"types"`
Optimize Optimizations `yaml:"optimize"`
Merge MergeConfig `yaml:"merge"`
}
DefaultConfig holds a subset of DatabaseConfig fields to be used as a default config.
func (DefaultConfig) ApplyTo ¶ added in v0.3.0
func (d DefaultConfig) ApplyTo(c *DatabaseConfig)
ApplyTo applies the default config to the given database config.
type IPFireSource ¶
type IPFireSource struct {
// contains filtered or unexported fields
}
IPFireSource reads geoip data in the ipfire format.
func LoadIPFireSource ¶
func LoadIPFireSource(input DatabaseInput, types map[string]string) (*IPFireSource, error)
LoadIPFireSource returns a new IPFireSource.
func (*IPFireSource) Err ¶
func (ipf *IPFireSource) Err() error
Err returns the processing error encountered by the source.
func (*IPFireSource) Name ¶
func (ipf *IPFireSource) Name() string
Name returns an identifying name for the source.
func (*IPFireSource) NextEntry ¶
func (ipf *IPFireSource) NextEntry() (*SourceEntry, error)
NextEntry returns the next entry of the source. If nil, nil is returned, stop reading and check Err().
func (*IPFireSource) SourceEntryFromMimeHeader ¶
func (ipf *IPFireSource) SourceEntryFromMimeHeader(data textproto.MIMEHeader) (*SourceEntry, error)
SourceEntryFromMimeHeader parses an IPFire entry. The keys in the IPFire file are: - net - aut-num - name - country - is-anycast - is-satellite-provider - is-anonymous-proxy - drop .
type MMDBConfig ¶
MMDBConfig holds mmdb specific config.
type MergeConfig ¶ added in v0.2.0
type MergeConfig struct {
ConditionalResets []ConditionalResetConfig `yaml:"conditionalResets"`
}
MergeConfig holds merge configuration.
type Optimizations ¶
type Optimizations struct {
FloatDecimals int `yaml:"floatDecimals"`
ForceIPVersion *bool `yaml:"forceIPVersion"`
MaxPrefix int `yaml:"maxPrefix"`
}
Optimizations holds optimization config.
func (Optimizations) ForceIPVersionEnabled ¶ added in v0.3.0
func (o Optimizations) ForceIPVersionEnabled() bool
ForceIPVersionEnabled reports whether ForceIPVersion is set and true.
type Source ¶
type Source interface {
Name() string
NextEntry() (*SourceEntry, error)
Err() error
}
Source describes a generic geoip data source.
func LoadSources ¶
func LoadSources(dbConfig DatabaseConfig) ([]Source, error)
LoadSources loads the given input files from the database config.
type SourceEntry ¶
SourceEntry describes a geoip data source entry. Either Net or both From and To must be set.
func (SourceEntry) ToMMDBMap ¶
func (se SourceEntry) ToMMDBMap(optim Optimizations) (mmdbtype.Map, error)
ToMMDBMap transforms the source entry to a mmdb map type.
type SourceValue ¶
SourceValue holds an unprocessed source data value, including its type.
func (SourceValue) ToMMDBType ¶
func (sv SourceValue) ToMMDBType(optim Optimizations) (mmdbtype.DataType, error)
ToMMDBType transforms the source value to the correct mmdb type.