forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow additional network filters for QUIC listeners (envoyproxy#22722)
Signed-off-by: Paul Sohn <paulsohn@google.com>
- Loading branch information
Showing
10 changed files
with
199 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include "envoy/network/filter.h" | ||
|
||
#include "source/extensions/filters/network/common/factory_base.h" | ||
|
||
#include "test/integration/filters/test_network_filter.pb.h" | ||
#include "test/integration/filters/test_network_filter.pb.validate.h" | ||
|
||
namespace Envoy { | ||
namespace { | ||
|
||
/** | ||
* All stats for this filter. @see stats_macros.h | ||
*/ | ||
#define ALL_TEST_NETWORK_FILTER_STATS(COUNTER) \ | ||
COUNTER(on_new_connection) \ | ||
COUNTER(on_data) | ||
|
||
/** | ||
* Struct definition for stats. @see stats_macros.h | ||
*/ | ||
struct TestNetworkFilterStats { | ||
ALL_TEST_NETWORK_FILTER_STATS(GENERATE_COUNTER_STRUCT) | ||
}; | ||
|
||
class TestNetworkFilter : public Network::ReadFilter { | ||
public: | ||
TestNetworkFilter(Stats::Scope& scope) : stats_(generateStats("test_network_filter", scope)) {} | ||
|
||
Network::FilterStatus onData(Buffer::Instance&, bool) override { | ||
stats_.on_data_.inc(); | ||
return Network::FilterStatus::Continue; | ||
} | ||
|
||
Network::FilterStatus onNewConnection() override { | ||
stats_.on_new_connection_.inc(); | ||
return Network::FilterStatus::Continue; | ||
} | ||
|
||
void initializeReadFilterCallbacks(Network::ReadFilterCallbacks& callbacks) override { | ||
read_callbacks_ = &callbacks; | ||
} | ||
|
||
private: | ||
Envoy::Network::ReadFilterCallbacks* read_callbacks_{}; | ||
TestNetworkFilterStats generateStats(const std::string& prefix, Stats::Scope& scope) { | ||
return {ALL_TEST_NETWORK_FILTER_STATS(POOL_COUNTER_PREFIX(scope, prefix))}; | ||
} | ||
TestNetworkFilterStats stats_; | ||
}; | ||
|
||
class TestNetworkFilterConfigFactory : public Extensions::NetworkFilters::Common::FactoryBase< | ||
test::integration::filters::TestNetworkFilterConfig> { | ||
public: | ||
TestNetworkFilterConfigFactory() | ||
: Extensions::NetworkFilters::Common::FactoryBase< | ||
test::integration::filters::TestNetworkFilterConfig>("envoy.test.test_network_filter") { | ||
} | ||
|
||
private: | ||
Network::FilterFactoryCb createFilterFactoryFromProtoTyped( | ||
const test::integration::filters::TestNetworkFilterConfig& config, | ||
Server::Configuration::FactoryContext& context) override { | ||
return [config, &context](Network::FilterManager& filter_manager) -> void { | ||
filter_manager.addReadFilter(std::make_shared<TestNetworkFilter>(context.scope())); | ||
}; | ||
} | ||
}; | ||
|
||
// perform static registration | ||
static Registry::RegisterFactory<TestNetworkFilterConfigFactory, | ||
Server::Configuration::NamedNetworkFilterConfigFactory> | ||
register_; | ||
|
||
} // namespace | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
syntax = "proto3"; | ||
|
||
package test.integration.filters; | ||
|
||
message TestNetworkFilterConfig { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters