filterip2proxy

package
v0.0.0-...-c13075e Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 11 Imported by: 0

README

gogstash ip2proxy filter module

You need to download ip2proxy database manually and setup file path in config.

The database will be reloaded when changed on the disk. The paid proxy database is updated daily and you should make sure to download updates at regular intervals.

Synopsis

filter:
  - type: ip2proxy
    # (required) database file path
    db_path: "IP2PROXY-LITE-PX1.BIN"

    # (required) ip address field to parse
    ip_field: remote_addr

    # (optional) parsed ip2location info should be saved to field, default: ip2location
    key: ip2proxy

    # (optional) do not try to process private IP networks as they will fail, default: false
    skip_private: true

    # (optional) lets you specify your own definition for private IP addresses, both IPv4 and IPv6, default is private IP addresses
    private_net:
      - 10.0.0.0/8
      - 192.168.0.0/16

    # (optional) size of cache entries on IP addresses, so lookups don't go through the database, default is 100000
    cache_size: 100000

    # (optional) if true does not log lookup failures from the database, default is false
    quiet: true

Based on an input like this:

{
  "ip": "1.1.1.1"
}

You should get an output like this with a proxy database:

{
  "ip": "1.1.1.1",
  "ip2proxy": {
    "CountryLong": "United States of America",
    "CountryShort": "US",
    "ProxyType": "DCH",
    "isProxy": "2"
  }
}

Documentation

Index

Constants

View Source
const ErrorTag = "gogstash_filter_ip2location_error"

ErrorTag tag added to event when process ip2location failed

View Source
const ModuleName = "ip2proxy"

ModuleName is the name used in config file

Variables

This section is empty.

Functions

func InitHandler

func InitHandler(
	ctx context.Context,
	raw config.ConfigRaw,
	control config.Control,
) (config.TypeFilterConfig, error)

InitHandler initialize the filter plugin

Types

type FilterConfig

type FilterConfig struct {
	config.FilterConfig

	DBPath      string   `json:"db_path" yaml:"db_path"`           // ip2location .BIN file
	IPField     string   `json:"ip_field" yaml:"ip_field"`         // IP field to get geoip info
	Key         string   `json:"key"`                              // geoip destination field name, default: geoip
	QuietFail   bool     `json:"quiet" yaml:"quiet"`               // fail quietly
	SkipPrivate bool     `json:"skip_private" yaml:"skip_private"` // skip private IP addresses
	PrivateNet  []string `json:"private_net" yaml:"private_net"`   // list of own defined private IP addresses
	CacheSize   int      `json:"cache_size" yaml:"cache_size"`     // cache size
	// contains filtered or unexported fields
}

FilterConfig holds the configuration json fields and internal objects

func DefaultFilterConfig

func DefaultFilterConfig() FilterConfig

DefaultFilterConfig returns an FilterConfig struct with default values

func (*FilterConfig) Event

Event the main filter event

Jump to

Keyboard shortcuts

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