#!/usr/bin/env bash
#
# Configuration file for geoip
# ============================
#
# Usage
# -----
#
# $ ./t2plconf
#
# Defining the configurations options
# -----------------------------------
#
# If no configuration options are available, ITEMS must be set as follows:
#   - ITEMS=(none)
#
# Otherwise, enter configurations items as follows:
#   "NAME" "TYPE" "DEPENDENCIES" "DESCRIPTION"
#
#   - TYPE can be:
#       - bitfield
#       - check (boolean),
#       - radio (set of values),
#       - range (min <= val <= max)
#       - text
#
#   - DEPENDENCIES MUST be numeric, e.g., "A == 1 && (B < 4 || C >= 1)"
#
#   - DESCRIPTION for type 'bitfield' MUST NOT contain '\t', ':' or ';'
#   - DESCRIPTION for type 'check' MUST NOT contain tabs ('\t')
#   - DESCRIPTION for type 'radio' MUST NOT contain '\t', ':' or ';'
#   - DESCRIPTION for type 'range' MUST NOT contain '\t' or ':'
#   - DESCRIPTION for type 'text'  MUST NOT contain '\t'
#
#   - DESCRIPTION MUST be formatted according to the type (see examples below):
#       - bitfield : description ';' val1 ':' description1 ';' valN ':' descriptionN
#       - check    : description
#       - radio    : description ';' val1 ':' description1 ';' valN ':' descriptionN
#       - range    : description ':' min ' ' max
#       - text     : description
#
# Examples
# --------
#
#ITEMS=(
#    # An item can be specified in one line...
#    T2PSKEL_VAR1 check "" "Description of option" # No dependencies
#
#    # Or span multiple lines
#    T2PSKEL_VAR1 radio "T2PSKEL_VAR1 == 1"
#           "Description of option; \
#                   0: description of val 0; \
#                   1: description of val 1; \
#                   2: description of val 2"
#
#    T2PSKEL_SIZE range "T2PSKEL_VAR1 == 1 || T2PSKEL_VAR2 > 0"
#           "Description: 0 255" # min=0, max=255
#
#    T2PSKEL_STR text
#           "T2PSKEL_SIZE <= 5 && (T2PSKEL_VAR1 != 0 || T2PSKEL_VAR2 <= 1)"
#           "Description"
#
#    T2PSKEL_BITFIELD bitfield ""
#           "Description of option; \
#                   0x01: description of bit 0; \
#                   0x02: description of bit 1; \
#                   0x04: description of bit 2; \
#                   0x08: description of bit 3; \
#                   0x10: description of bit 4; \
#                   0x20: description of bit 5; \
#                   0x40: description of bit 6; \
#                   0x80: description of bit 7"
#)
#
# If no configuration option is available, use the value 'none'
#ITEMS=(none)
#
# Source the master t2plconf file
# source ../../scripts/t2conf/t2plconf

ITEMS=(
    GEOIP_LIB radio "" "Library to use; \
        0: GeoLite  / geoip (legacy); \
        1: GeoLite2 / libmaxmind; \
        2: GeoLite2 / Internal libmaxmind (faster)"

    GEOIP_SRC check ""
        "Extract geo info for source IP"

    GEOIP_DST check ""
        "Extract geo info for destination IP"

    GEOIP_CONTINENT radio
        "GEOIP_SRC == 1 || GEOIP_DST == 1"
        "Extract the continent of the IP; \
                0: no continent; \
                1: continent name (Geolite 2); \
                2: two letters code"

    GEOIP_COUNTRY radio
        "GEOIP_SRC == 1 || GEOIP_DST == 1"
        "Extract the country of the IP; \
                0: no country; \
                1: country name; \
                2: two letters code; \
                3: three letters code (Legacy)"

    GEOIP_CITY check
        "GEOIP_SRC == 1 || GEOIP_DST == 1"
        "Extract the city of the IP"

    GEOIP_POSTCODE check
        "GEOIP_SRC == 1 || GEOIP_DST == 1"
        "Extract the postal code of the IP"

    GEOIP_POSITION check
        "GEOIP_SRC == 1 || GEOIP_DST == 1"
        "Extract the position (latitude, longitude) of the IP"

    GEOIP_METRO_CODE check
        "GEOIP_SRC == 1 || GEOIP_DST == 1"
        "Extract the metro (dma) code of the IP (US only)"

    GEOIP_ACCURACY check
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Extract the accuracy of the geolocation"

    GEOIP_TIMEZONE check
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Extract the time zone of the IP"

    GEOIP_ORG check
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Display the organisation (Enterprise version only)"

    GEOIP_ISP check
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Display the ISP name (Enterprise version only)"

    GEOIP_ASN check
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Display the AS number (Enterprise version only)"

    GEOIP_ASNAME check
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Display the AS name (Enterprise version only)"

    GEOIP_CONNT check
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Display the connection type (Enterprise version only)"

    GEOIP_USRT check
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Display the user type (Enterprise version only)"

    GEOIP_LANG radio
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Language of the output; \
                en: English; \
                de: German; \
                fr: French; \
                es: Spanish; \
                ja: Japanese; \
                pt-BR: Brazilian Portuguese; \
                ru: Russian; \
                zh-CN: Simplified Chinese"

    GEOIP_BUFSIZE range
        "GEOIP_LIB != 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Buffer size: 0 255"

    GEOIP_REGION radio
        "GEOIP_LIB == 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Region of the IP; \
                0: no region; \
                1: region name; \
                2: two letters code; \
                3: three letters code"

    GEOIP_AREA_CODE check
        "GEOIP_LIB == 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Extract the telephone area code of the IP"

    GEOIP_NETMASK radio
        "GEOIP_LIB == 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "Extraction of the netmask; \
                0: no netmask; \
                1: netmask as int (cidr); \
                2: netmask as hex; \
                3: netmask as IP"

    GEOIP_DB_CACHE radio
        "GEOIP_LIB == 0 && (GEOIP_SRC == 1 || GEOIP_DST == 1)"
        "; \
                0: read DB from file system (slower, least memory); \
                1: index cache (cache frequently used index only); \
                2: memory cache (faster, more memory)"

    GEOIP_UNKNOWN text
        "GEOIP_SRC == 1 || GEOIP_DST == 1"
        "Representation of unknown locations"

    GEOIP_DB_FILE  text "GEOIP_LIB != 0" "Name of the database to use for IPv4 and IPv6 (combined)"
    GEOIP_DB_FILE4 text "GEOIP_LIB == 0" "Name of the database to use for IPv4"
    GEOIP_DB_FILE6 text "GEOIP_LIB == 0" "Name of the database to use for IPv6"
)

# Source the master t2plconf file
source "$(dirname "$0")/../../scripts/t2conf/t2plconf"
