Line data Source code
1 : #include "source/extensions/http/original_ip_detection/xff/config.h" 2 : 3 : #include "envoy/extensions/http/original_ip_detection/xff/v3/xff.pb.h" 4 : #include "envoy/extensions/http/original_ip_detection/xff/v3/xff.pb.validate.h" 5 : #include "envoy/http/original_ip_detection.h" 6 : 7 : #include "source/common/config/utility.h" 8 : #include "source/extensions/http/original_ip_detection/xff/xff.h" 9 : 10 : namespace Envoy { 11 : namespace Extensions { 12 : namespace Http { 13 : namespace OriginalIPDetection { 14 : namespace Xff { 15 : 16 : Envoy::Http::OriginalIPDetectionSharedPtr 17 : XffIPDetectionFactory::createExtension(const Protobuf::Message& message, 18 140 : Server::Configuration::FactoryContext& context) { 19 140 : auto mptr = Envoy::Config::Utility::translateAnyToFactoryConfig( 20 140 : dynamic_cast<const ProtobufWkt::Any&>(message), context.messageValidationVisitor(), *this); 21 140 : const auto& proto_config = MessageUtil::downcastAndValidate< 22 140 : const envoy::extensions::http::original_ip_detection::xff::v3::XffConfig&>( 23 140 : *mptr, context.messageValidationVisitor()); 24 140 : return std::make_shared<XffIPDetection>(proto_config); 25 140 : } 26 : 27 : REGISTER_FACTORY(XffIPDetectionFactory, Envoy::Http::OriginalIPDetectionFactory); 28 : 29 : } // namespace Xff 30 : } // namespace OriginalIPDetection 31 : } // namespace Http 32 : } // namespace Extensions 33 : } // namespace Envoy