]> git.ipfire.org Git - thirdparty/pdns.git/commit
geoipbackend: accept custom lookup mapping 8608/head
authorJeremy Clerc <j.clerc@criteo.com>
Thu, 21 Nov 2019 23:57:48 +0000 (00:57 +0100)
committerJeremy Clerc <j.clerc@criteo.com>
Mon, 9 Nov 2020 16:10:58 +0000 (17:10 +0100)
commit4a2fe186c55502433347bf9bce0e99c8b1604f07
treeae4c50bdba151409bb500aa373f37196c3f2a355
parentd770b6cadb88833327e39caeb9c773582a093e7e
geoipbackend: accept custom lookup mapping

If for example you want a per country granularity, but still want to
group by custom regions: uk, fr, be -> eu-central, pt, es -> eu-south;
you need to to use %cc and create identical country records. It means
you zones file can become huge and powerdns does not like it too much.

For a user to have a custom mapping without the need to rewrite the
GeoIP database, with this commit, he/she can specify a custom mapping,
so if we get from the GeoIP database fr, we will look in the custom
mapping and find eu-central. So we only need to create the eu-central
record and it will be used by for uk, fr and be as per our first
example.

Definition of mapping_lookup_formats or custom_mapping at the domain
level has priority, but if not defined the global config will be used
as default.

The custom lookup formats and mapping are specified in the zones file:

  ---
  mapping_lookup_formats: ['%cc-%re', '%cc']
  custom_mapping:
    'fr': 'eu-central'
    'be': 'eu-central'
    'es': 'eu-south'
    'pt': 'eu-south'
    'us-ca': 'us-west'
    'us-tx': 'us-south'
  domains:
  - domain: example.com
    services:
      www.example.com: [ '%mp.www.example.com' ]
    records:
      eu-central.www.example.com:
        - A: 1.1.1.1
      eu-south.www.example.com:
        - A: 1.1.1.2
      us-west.www.example.com:
        - A: 1.1.1.3
      us-south.www.example.com:
        - A: 1.1.1.4
  - domain: example2.com
    mapping_lookup_formats: ['%cc']
docs/backends/geoip.rst
modules/geoipbackend/geoipbackend.cc
modules/geoipbackend/geoipbackend.hh
modules/geoipbackend/regression-tests/custom-mapping-txt-resolution/command [new file with mode: 0755]
modules/geoipbackend/regression-tests/custom-mapping-txt-resolution/description [new file with mode: 0644]
modules/geoipbackend/regression-tests/custom-mapping-txt-resolution/expected_result [new file with mode: 0644]
regression-tests/backends/geoip-master