Line data Source code
1 : #include "source/extensions/http/original_ip_detection/xff/xff.h" 2 : 3 : #include "source/common/http/utility.h" 4 : 5 : namespace Envoy { 6 : namespace Extensions { 7 : namespace Http { 8 : namespace OriginalIPDetection { 9 : namespace Xff { 10 : 11 : XffIPDetection::XffIPDetection( 12 : const envoy::extensions::http::original_ip_detection::xff::v3::XffConfig& config) 13 140 : : xff_num_trusted_hops_(config.xff_num_trusted_hops()) {} 14 : 15 : XffIPDetection::XffIPDetection(uint32_t xff_num_trusted_hops) 16 0 : : xff_num_trusted_hops_(xff_num_trusted_hops) {} 17 : 18 : Envoy::Http::OriginalIPDetectionResult 19 387 : XffIPDetection::detect(Envoy::Http::OriginalIPDetectionParams& params) { 20 387 : auto ret = 21 387 : Envoy::Http::Utility::getLastAddressFromXFF(params.request_headers, xff_num_trusted_hops_); 22 387 : return {ret.address_, ret.allow_trusted_address_checks_, absl::nullopt}; 23 387 : } 24 : 25 : } // namespace Xff 26 : } // namespace OriginalIPDetection 27 : } // namespace Http 28 : } // namespace Extensions 29 : } // namespace Envoy