-
Notifications
You must be signed in to change notification settings - Fork 845
Add interface for NetVC services #9482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e55e757
Add interface for NetVC services
maskit 1da4321
Update QUICNetVC
maskit 72d272a
Rename N_MAX to N_SERVICES
maskit 11ec168
Add helper functions
maskit 7d0d689
Make the helper function a member of NetVConnection
maskit 9d1aee6
Move NetVConnection::_services private member
maskit 5432a17
Use init-statement in if statements
maskit fa45f3b
Move template specializations into I_NetVConnection.h
maskit 82d1c01
Update proxy/http/Http1ClientSession.cc
maskit 7e24552
Add template function for the setter
maskit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -507,7 +507,20 @@ class NetVConnection : public VConnection, public PluginUserArgs<TS_USER_ARGS_VC | |
| bool has_proxy_protocol(IOBufferReader *); | ||
| bool has_proxy_protocol(char *, int64_t *); | ||
|
|
||
| template <typename S> S *get_service() const; | ||
|
|
||
| protected: | ||
| enum class Service : uint8_t { | ||
| TLS_ALPN, | ||
| TLS_Basic, | ||
| TLS_CertSwitch, | ||
| TLS_EarlyData, | ||
| TLS_SNI, | ||
| TLS_SessionResumption, | ||
| TLS_Tunnel, | ||
| N_SERVICES, | ||
| }; | ||
|
|
||
| IpEndpoint local_addr; | ||
| IpEndpoint remote_addr; | ||
| ProxyProtocol pp_info; | ||
|
|
@@ -526,6 +539,16 @@ class NetVConnection : public VConnection, public PluginUserArgs<TS_USER_ARGS_VC | |
| int write_buffer_empty_event = 0; | ||
| /// NetVConnection Context. | ||
| NetVConnectionContext_t netvc_context = NET_VCONNECTION_UNSET; | ||
|
|
||
| template <typename S> void _set_service(S *instance); | ||
|
|
||
| private: | ||
| void *_services[static_cast<unsigned int>(Service::N_SERVICES)] = { | ||
jpeach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, | ||
| }; | ||
|
|
||
| void *_get_service(enum Service mixin_index) const; | ||
| void _set_service(enum Service mixin_index, void *instance); | ||
| }; | ||
|
|
||
| inline NetVConnection::NetVConnection() : VConnection(nullptr) | ||
|
|
@@ -540,3 +563,113 @@ NetVConnection::trapWriteBufferEmpty(int event) | |
| { | ||
| write_buffer_empty_event = event; | ||
| } | ||
|
|
||
| inline void * | ||
| NetVConnection::_get_service(enum NetVConnection::Service service) const | ||
| { | ||
| return _services[static_cast<unsigned int>(service)]; | ||
| } | ||
|
|
||
| inline void | ||
| NetVConnection::_set_service(enum NetVConnection::Service service, void *instance) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that this isn't type-safe. I expect it would be possible to make it typesafe if you had a template that mapped the enum to the type directly. |
||
| { | ||
| this->_services[static_cast<unsigned int>(service)] = instance; | ||
| } | ||
|
|
||
| class ALPNSupport; | ||
| template <> | ||
| inline ALPNSupport * | ||
| NetVConnection::get_service() const | ||
| { | ||
| return static_cast<ALPNSupport *>(this->_get_service(NetVConnection::Service::TLS_ALPN)); | ||
| } | ||
| template <> | ||
| inline void | ||
| NetVConnection::_set_service(ALPNSupport *instance) | ||
| { | ||
| this->_set_service(NetVConnection::Service::TLS_ALPN, instance); | ||
| } | ||
|
|
||
| class TLSBasicSupport; | ||
| template <> | ||
| inline TLSBasicSupport * | ||
| NetVConnection::get_service() const | ||
| { | ||
| return static_cast<TLSBasicSupport *>(this->_get_service(NetVConnection::Service::TLS_Basic)); | ||
| } | ||
| template <> | ||
| inline void | ||
| NetVConnection::_set_service(TLSBasicSupport *instance) | ||
| { | ||
| this->_set_service(NetVConnection::Service::TLS_Basic, instance); | ||
| } | ||
|
|
||
| class TLSEarlyDataSupport; | ||
| template <> | ||
| inline TLSEarlyDataSupport * | ||
| NetVConnection::get_service() const | ||
| { | ||
| return static_cast<TLSEarlyDataSupport *>(this->_get_service(NetVConnection::Service::TLS_EarlyData)); | ||
| } | ||
| template <> | ||
| inline void | ||
| NetVConnection::_set_service(TLSEarlyDataSupport *instance) | ||
| { | ||
| this->_set_service(NetVConnection::Service::TLS_EarlyData, instance); | ||
| } | ||
|
|
||
| class TLSCertSwitchSupport; | ||
| template <> | ||
| inline TLSCertSwitchSupport * | ||
| NetVConnection::get_service() const | ||
| { | ||
| return static_cast<TLSCertSwitchSupport *>(this->_get_service(NetVConnection::Service::TLS_CertSwitch)); | ||
| } | ||
| template <> | ||
| inline void | ||
| NetVConnection::_set_service(TLSCertSwitchSupport *instance) | ||
| { | ||
| this->_set_service(NetVConnection::Service::TLS_CertSwitch, instance); | ||
| } | ||
|
|
||
| class TLSSNISupport; | ||
| template <> | ||
| inline TLSSNISupport * | ||
| NetVConnection::get_service() const | ||
| { | ||
| return static_cast<TLSSNISupport *>(this->_get_service(NetVConnection::Service::TLS_SNI)); | ||
| } | ||
| template <> | ||
| inline void | ||
| NetVConnection::_set_service(TLSSNISupport *instance) | ||
| { | ||
| this->_set_service(NetVConnection::Service::TLS_SNI, instance); | ||
| } | ||
|
|
||
| class TLSSessionResumptionSupport; | ||
| template <> | ||
| inline TLSSessionResumptionSupport * | ||
| NetVConnection::get_service() const | ||
| { | ||
| return static_cast<TLSSessionResumptionSupport *>(this->_get_service(NetVConnection::Service::TLS_SessionResumption)); | ||
| } | ||
| template <> | ||
| inline void | ||
| NetVConnection::_set_service(TLSSessionResumptionSupport *instance) | ||
| { | ||
| this->_set_service(NetVConnection::Service::TLS_SessionResumption, instance); | ||
| } | ||
|
|
||
| class TLSTunnelSupport; | ||
| template <> | ||
| inline TLSTunnelSupport * | ||
| NetVConnection::get_service() const | ||
| { | ||
| return static_cast<TLSTunnelSupport *>(this->_get_service(NetVConnection::Service::TLS_Tunnel)); | ||
| } | ||
| template <> | ||
| inline void | ||
| NetVConnection::_set_service(TLSTunnelSupport *instance) | ||
| { | ||
| this->_set_service(NetVConnection::Service::TLS_Tunnel, instance); | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.