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.
udp_listener: refactor ActiveUdpListener creation (envoyproxy#7884)
Signed-off-by: Dan Zhang <[email protected]>
- Loading branch information
1 parent
de61162
commit 680bf1b
Showing
25 changed files
with
386 additions
and
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
syntax = "proto3"; | ||
|
||
package envoy.api.v2.listener; | ||
|
||
option java_outer_classname = "ListenerProto"; | ||
option java_multiple_files = true; | ||
option java_package = "io.envoyproxy.envoy.api.v2.listener"; | ||
option go_package = "listener"; | ||
option csharp_namespace = "Envoy.Api.V2.ListenerNS"; | ||
option ruby_package = "Envoy::Api::V2::ListenerNS"; | ||
|
||
import "google/protobuf/struct.proto"; | ||
import "google/protobuf/any.proto"; | ||
|
||
// [#protodoc-title: Udp Listener Config] | ||
// Listener :ref:`configuration overview <config_listeners>` | ||
|
||
message UdpListenerConfig { | ||
// Used to look up UDP listener factory, matches "raw_udp_listener" or | ||
// "quic_listener" to create a specific udp listener. | ||
// If not specified, treat as "raw_udp_listener". | ||
string udp_listener_name = 1; | ||
|
||
// Used to create a specific listener factory. To some factory, e.g. | ||
// "raw_udp_listener", config is not needed. | ||
oneof config_type { | ||
google.protobuf.Struct config = 2; | ||
|
||
google.protobuf.Any typed_config = 3; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ Listeners | |
|
||
../api/v2/lds.proto | ||
../api/v2/listener/listener.proto | ||
../api/v2/listener/udp_listener_config.proto |
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,29 @@ | ||
#pragma once | ||
|
||
#include "envoy/network/connection_handler.h" | ||
|
||
namespace Envoy { | ||
namespace Server { | ||
|
||
/** | ||
* Interface to create udp listener according to | ||
* envoy::api::v2::listener::UdpListenerConfig.udp_listener_name. | ||
*/ | ||
class ActiveUdpListenerConfigFactory { | ||
public: | ||
virtual ~ActiveUdpListenerConfigFactory() = default; | ||
|
||
/** | ||
* Create an ActiveUdpListenerFactory object according to given message. | ||
*/ | ||
virtual Network::ActiveUdpListenerFactoryPtr | ||
createActiveUdpListenerFactory(const Protobuf::Message& message) PURE; | ||
|
||
/** | ||
* Used to identify which udp listener to create: quic or raw udp. | ||
*/ | ||
virtual std::string name() PURE; | ||
}; | ||
|
||
} // namespace Server | ||
} // 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
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,26 @@ | ||
#include "server/active_raw_udp_listener_config.h" | ||
|
||
#include "server/connection_handler_impl.h" | ||
#include "server/well_known_names.h" | ||
|
||
namespace Envoy { | ||
namespace Server { | ||
|
||
Network::ConnectionHandler::ActiveListenerPtr ActiveRawUdpListenerFactory::createActiveUdpListener( | ||
Network::ConnectionHandler& /*parent*/, Event::Dispatcher& dispatcher, | ||
spdlog::logger& /*logger*/, Network::ListenerConfig& config) const { | ||
return std::make_unique<ActiveUdpListener>(dispatcher, config); | ||
} | ||
|
||
Network::ActiveUdpListenerFactoryPtr | ||
ActiveRawUdpListenerConfigFactory::createActiveUdpListenerFactory( | ||
const Protobuf::Message& /*message*/) { | ||
return std::make_unique<Server::ActiveRawUdpListenerFactory>(); | ||
} | ||
|
||
std::string ActiveRawUdpListenerConfigFactory::name() { return UdpListenerNames::get().RawUdp; } | ||
|
||
REGISTER_FACTORY(ActiveRawUdpListenerConfigFactory, Server::ActiveUdpListenerConfigFactory); | ||
|
||
} // namespace Server | ||
} // 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,31 @@ | ||
#pragma once | ||
|
||
#include "envoy/network/connection_handler.h" | ||
#include "envoy/registry/registry.h" | ||
#include "envoy/server/active_udp_listener_config.h" | ||
|
||
namespace Envoy { | ||
namespace Server { | ||
|
||
class ActiveRawUdpListenerFactory : public Network::ActiveUdpListenerFactory { | ||
public: | ||
Network::ConnectionHandler::ActiveListenerPtr | ||
createActiveUdpListener(Network::ConnectionHandler& parent, Event::Dispatcher& disptacher, | ||
spdlog::logger& logger, Network::ListenerConfig& config) const override; | ||
}; | ||
|
||
// This class uses a protobuf config to create a UDP listener factory which | ||
// creates a Server::ConnectionHandlerImpl::ActiveUdpListener. | ||
// This is the default UDP listener if not specified in config. | ||
class ActiveRawUdpListenerConfigFactory : public ActiveUdpListenerConfigFactory { | ||
public: | ||
Network::ActiveUdpListenerFactoryPtr | ||
createActiveUdpListenerFactory(const Protobuf::Message&) override; | ||
|
||
std::string name() override; | ||
}; | ||
|
||
DECLARE_FACTORY(ActiveRawUdpListenerConfigFactory); | ||
|
||
} // namespace Server | ||
} // namespace Envoy |
Oops, something went wrong.