syntax = "proto3";

package envoy.extensions.geoip_providers.maxmind.v3;

import "envoy/extensions/geoip_providers/common/v3/common.proto";

import "xds/annotations/v3/status.proto";

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.geoip_providers.maxmind.v3";
option java_outer_classname = "MaxmindProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/geoip_providers/maxmind/v3;maxmindv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;
option (xds.annotations.v3.file_status).work_in_progress = true;

// [#protodoc-title: MaxMind Geolocation Provider]
// MaxMind geolocation provider :ref:`configuration overview <config_geoip_providers_maxmind>`.
//
// At least one geolocation database path must be configured:
//
// * :ref:`city_db_path <envoy_v3_api_field_extensions.geoip_providers.maxmind.v3.MaxMindConfig.city_db_path>`
// * :ref:`isp_db_path <envoy_v3_api_field_extensions.geoip_providers.maxmind.v3.MaxMindConfig.isp_db_path>`
// * :ref:`asn_db_path <envoy_v3_api_field_extensions.geoip_providers.maxmind.v3.MaxMindConfig.asn_db_path>`
// * :ref:`anon_db_path <envoy_v3_api_field_extensions.geoip_providers.maxmind.v3.MaxMindConfig.anon_db_path>`
// * :ref:`country_db_path <envoy_v3_api_field_extensions.geoip_providers.maxmind.v3.MaxMindConfig.country_db_path>`
// [#extension: envoy.geoip_providers.maxmind]

// [#next-free-field: 7]
message MaxMindConfig {
  // Full file path to the MaxMind city database, e.g., ``/etc/GeoLite2-City.mmdb``.
  // Database file is expected to have ``.mmdb`` extension.
  string city_db_path = 1 [(validate.rules).string = {pattern: "^$|^.*\\.mmdb$"}];

  // Full file path to the MaxMind ASN database, e.g., ``/etc/GeoLite2-ASN.mmdb``.
  // Database file is expected to have ``.mmdb`` extension.
  // When this is defined, the ASN information will always be fetched from the ``asn_db``.
  string asn_db_path = 2 [(validate.rules).string = {pattern: "^$|^.*\\.mmdb$"}];

  // Full file path to the MaxMind Anonymous IP database, e.g., ``/etc/GeoIP2-Anonymous-IP.mmdb``.
  // Database file is expected to have ``.mmdb`` extension.
  string anon_db_path = 3 [(validate.rules).string = {pattern: "^$|^.*\\.mmdb$"}];

  // Full file path to the MaxMind ISP database, e.g., ``/etc/GeoLite2-ISP.mmdb``.
  // Database file is expected to have ``.mmdb`` extension.
  // If ``asn_db_path`` is not defined, ASN information will be fetched from
  // ``isp_db`` instead.
  string isp_db_path = 5 [(validate.rules).string = {pattern: "^$|^.*\\.mmdb$"}];

  // Full file path to the MaxMind Country database, e.g., ``/etc/GeoLite2-Country.mmdb``.
  // Database file is expected to have ``.mmdb`` extension.
  //
  // If ``country_db_path`` is not specified, country information will be fetched from
  // ``city_db`` if ``city_db`` is configured.
  string country_db_path = 6 [(validate.rules).string = {pattern: "^$|^.*\\.mmdb$"}];

  // Common provider configuration that specifies which geolocation headers will be populated with geolocation data.
  common.v3.CommonGeoipProviderConfig common_provider_config = 4
      [(validate.rules).message = {required: true}];
}
