Repository: envoyproxy/envoy
File: api/envoy/extensions/filters/http/geoip/v3/geoip.proto (Protocol Buffers)

Code before:
    // :ref:`config_http_conn_man_headers_x-forwarded-for` for more information.
    //
    // Defaults to ``0``.
    uint32 xff_num_trusted_hops = 1;
  }

  // Configuration for extracting the client IP address from the
  // ``x-forwarded-for`` header. If set, the
  // :ref:`xff_num_trusted_hops <envoy_v3_api_field_extensions.filters.http.geoip.v3.Geoip.XffConfig.xff_num_trusted_hops>`
  // field will be used to determine the trusted client address from the ``x-forwarded-for`` header.
  // If not set, the immediate downstream connection source address will be used.
  //
  // Only one of ``xff_config`` or
  // :ref:`ip_address_header <envoy_v3_api_field_extensions.filters.http.geoip.v3.Geoip.ip_address_header>`
  // can be set.
  XffConfig xff_config = 1;

  // If set, the client IP address will be extracted from the specified request header.
  // The header value must contain a valid IP address (IPv4 or IPv6). If the header is
  // missing or contains an invalid IP address, the filter will fall back to using the
  // immediate downstream connection source address.
  //
  // Only one of ``ip_address_header`` or
  // :ref:`xff_config <envoy_v3_api_field_extensions.filters.http.geoip.v3.Geoip.xff_config>`
  // can be set.
  string ip_address_header = 4;

  // Geoip driver specific configuration which depends on the driver being instantiated.
  // See the geoip drivers for examples:
  //
  // - :ref:`MaxMindConfig <envoy_v3_api_msg_extensions.geoip_providers.maxmind.v3.MaxMindConfig>`
  // [#extension-category: envoy.geoip_providers]
  config.core.v3.TypedExtensionConfig provider = 3 [(validate.rules).message = {required: true}];
}


Review comment (suggestion):
May create a new CustomHeaderConfig message to wrap this, then we can extend it in the future? Because I see similar case long time ago we when support the original ip detection.

Code after:
    // :ref:`config_http_conn_man_headers_x-forwarded-for` for more information.
    //
    // Defaults to ``0``.
    uint32 xff_num_trusted_hops = 1;
  }

  message CustomHeaderConfig {
    // The name of the request header to extract the client IP address from.
    // The header value must contain a valid IP address (IPv4 or IPv6).
    //
    // If the header is missing or contains an invalid IP address, the filter will fall back
    // to using the immediate downstream connection source address.
    string header_name = 1 [(validate.rules).string = {min_len: 1}];
  }

  // Configuration for extracting the client IP address from the
  // ``x-forwarded-for`` header. If set, the
  // :ref:`xff_num_trusted_hops <envoy_v3_api_field_extensions.filters.http.geoip.v3.Geoip.XffConfig.xff_num_trusted_hops>`
  // field will be used to determine the trusted client address from the ``x-forwarded-for`` header.
  // If not set, the immediate downstream connection source address will be used.
  //
  // Only one of ``xff_config`` or
  // :ref:`custom_header_config <envoy_v3_api_field_extensions.filters.http.geoip.v3.Geoip.custom_header_config>`
  // can be set.
  XffConfig xff_config = 1;

  // Configuration for extracting the client IP address from a custom request header.
  //
  // If set, the
  // :ref:`header_name <envoy_v3_api_field_extensions.filters.http.geoip.v3.Geoip.CustomHeaderConfig.header_name>`
  // field will be used to extract the client IP address from the specified request header.
  //
  // Only one of ``custom_header_config`` or
  // :ref:`xff_config <envoy_v3_api_field_extensions.filters.http.geoip.v3.Geoip.xff_config>`
  // can be set.
  CustomHeaderConfig custom_header_config = 4;

  // Geoip driver specific configuration which depends on the driver being instantiated.
  // See the geoip drivers for examples:
  //
  // - :ref:`MaxMindConfig <envoy_v3_api_msg_extensions.geoip_providers.maxmind.v3.MaxMindConfig>`
  // [#extension-category: envoy.geoip_providers]
  config.core.v3.TypedExtensionConfig provider = 3 [(validate.rules).message = {required: true}];
}