File tree Expand file tree Collapse file tree 4 files changed +56
-5
lines changed
source/extensions/filters/udp/dns_filter Expand file tree Collapse file tree 4 files changed +56
-5
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,15 @@ envoy_cc_library(
1414 srcs = [
1515 "dns_filter.cc" ,
1616 "dns_filter_access_log.cc" ,
17+ "dns_filter_command_parser_factory.cc" ,
1718 "dns_filter_resolver.cc" ,
1819 "dns_filter_utils.cc" ,
1920 "dns_parser.cc" ,
2021 ],
2122 hdrs = [
2223 "dns_filter.h" ,
2324 "dns_filter_access_log.h" ,
25+ "dns_filter_command_parser_factory.h" ,
2426 "dns_filter_constants.h" ,
2527 "dns_filter_resolver.h" ,
2628 "dns_filter_utils.h" ,
@@ -35,6 +37,7 @@ envoy_cc_library(
3537 "//envoy/network:dns_interface" ,
3638 "//envoy/network:filter_interface" ,
3739 "//envoy/network:listener_interface" ,
40+ "//envoy/registry" ,
3841 "//source/common/buffer:buffer_lib" ,
3942 "//source/common/common:empty_string" ,
4043 "//source/common/common:radix_tree_lib" ,
Original file line number Diff line number Diff line change 1010#include " source/common/network/dns_resolver/dns_factory_util.h"
1111#include " source/common/protobuf/message_validator_impl.h"
1212#include " source/common/protobuf/utility.h"
13- #include " source/extensions/filters/udp/dns_filter/dns_filter_access_log.h"
1413#include " source/extensions/filters/udp/dns_filter/dns_filter_utils.h"
1514
1615namespace Envoy {
@@ -198,12 +197,10 @@ DnsFilterEnvoyConfig::DnsFilterEnvoyConfig(
198197 max_pending_lookups_ = 0 ;
199198 }
200199
201- // Initialize access logs with DNS-specific command parser
200+ // Initialize access logs. DNS-specific command parser is now registered as a built-in formatter.
202201 for (const auto & log_config : config.access_log ()) {
203- std::vector<Formatter::CommandParserPtr> command_parsers;
204- command_parsers.push_back (createDnsFilterCommandParser ());
205202 AccessLog::InstanceSharedPtr current_access_log =
206- AccessLog::AccessLogFactory::fromProto (log_config, context, std::move (command_parsers) );
203+ AccessLog::AccessLogFactory::fromProto (log_config, context);
207204 access_logs_.push_back (current_access_log);
208205 }
209206}
Original file line number Diff line number Diff line change 1+ #include " source/extensions/filters/udp/dns_filter/dns_filter_command_parser_factory.h"
2+ #include " source/extensions/filters/udp/dns_filter/dns_filter_access_log.h"
3+
4+ namespace Envoy {
5+ namespace Extensions {
6+ namespace UdpFilters {
7+ namespace DnsFilter {
8+
9+ std::string DnsFilterCommandParserFactory::name () const {
10+ return " envoy.built_in_formatters.dns_filter" ;
11+ }
12+
13+ Formatter::CommandParserPtr DnsFilterCommandParserFactory::createCommandParser () const {
14+ return createDnsFilterCommandParser ();
15+ }
16+
17+ REGISTER_FACTORY (DnsFilterCommandParserFactory, Formatter::BuiltInCommandParserFactory);
18+
19+ } // namespace DnsFilter
20+ } // namespace UdpFilters
21+ } // namespace Extensions
22+ } // namespace Envoy
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include " envoy/formatter/substitution_formatter_base.h"
4+ #include " envoy/registry/registry.h"
5+
6+ namespace Envoy {
7+ namespace Extensions {
8+ namespace UdpFilters {
9+ namespace DnsFilter {
10+
11+ /* *
12+ * Factory for DNS filter command parser that handles DNS-specific format commands.
13+ * This factory is registered as a built-in formatter to ensure DNS-specific tags
14+ * are available during config initialization.
15+ */
16+ class DnsFilterCommandParserFactory : public Formatter ::BuiltInCommandParserFactory {
17+ public:
18+ DnsFilterCommandParserFactory () = default ;
19+
20+ std::string name () const override ;
21+ Formatter::CommandParserPtr createCommandParser () const override ;
22+ };
23+
24+ DECLARE_FACTORY (DnsFilterCommandParserFactory);
25+
26+ } // namespace DnsFilter
27+ } // namespace UdpFilters
28+ } // namespace Extensions
29+ } // namespace Envoy
You can’t perform that action at this time.
0 commit comments