setLuaNoSideEffect();
return fe.local.toStringWithPort();
});
- luaCtx.registerFunction<std::string(ClientState::*)()>("__tostring", [](const ClientState& fe) {
+ luaCtx.registerFunction<std::string(ClientState::*)()const>("__tostring", [](const ClientState& fe) {
setLuaNoSideEffect();
return fe.local.toStringWithPort();
});
+ luaCtx.registerFunction<std::string(ClientState::*)()const>("getType", [](const ClientState& fe) {
+ setLuaNoSideEffect();
+ return fe.getType();
+ });
+ luaCtx.registerFunction<std::string(ClientState::*)()const>("getConfiguredTLSProvider", [](const ClientState& fe) {
+ setLuaNoSideEffect();
+ if (fe.tlsFrontend != nullptr) {
+ return fe.tlsFrontend->getRequestedProvider();
+ }
+ else if (fe.dohFrontend != nullptr) {
+ return std::string("openssl");
+ }
+ return std::string();
+ });
+ luaCtx.registerFunction<std::string(ClientState::*)()const>("getEffectiveTLSProvider", [](const ClientState& fe) {
+ setLuaNoSideEffect();
+ if (fe.tlsFrontend != nullptr) {
+ return fe.tlsFrontend->getEffectiveProvider();
+ }
+ else if (fe.dohFrontend != nullptr) {
+ return std::string("openssl");
+ }
+ return std::string();
+ });
luaCtx.registerMember("muted", &ClientState::muted);
#ifdef HAVE_EBPF
luaCtx.registerFunction<void(ClientState::*)(std::shared_ptr<BPFFilter>)>("attachFilter", [](ClientState& frontend, std::shared_ptr<BPFFilter> bpf) {
Remove the BPF filter associated to this frontend, if any.
+ .. method:: ClientState:getEffectiveTLSProvider() -> string
+
+ .. versionadded:: 1.7.0
+
+ Return the name of the TLS provider actually used.
+
+ .. method:: ClientState:getRequestedTLSProvider() -> string
+
+ .. versionadded:: 1.7.0
+
+ Return the name of the TLS provider requested in the configuration.
+
+ .. method:: ClientState:getType() -> string
+
+ .. versionadded:: 1.7.0
+
+ Return the type of the frontend: UDP, UDP (DNSCrypt), TCP, TCP (DNSCrypt), TCP (DNS over TLS) or TCP (DNS over HTTPS).
+
.. method:: ClientState:toString() -> string
Return the address and port this frontend is listening on.
{
return 0;
}
+
+ std::string getName() const override
+ {
+ return "Mockup TLS";
+ }
};
class MockupFDMultiplexer : public FDMultiplexer
return d_feContext->d_ticketKeys.getKeysCount();
}
+ std::string getName() const override
+ {
+ return "openssl";
+ }
+
private:
std::shared_ptr<OpenSSLFrontendContext> d_feContext;
std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)> d_tlsCtx; // client context
return *(d_ticketsKey.read_lock()) != nullptr ? 1 : 0;
}
+ std::string getName() const override
+ {
+ return "gnutls";
+ }
+
private:
std::unique_ptr<gnutls_certificate_credentials_st, void(*)(gnutls_certificate_credentials_t)> d_creds;
gnutls_priority_t d_priorityCache{nullptr};
}
virtual size_t getTicketsKeysCount() = 0;
+ virtual std::string getName() const = 0;
protected:
std::atomic_flag d_rotatingTicketsKey;
return res;
}
+ std::string getRequestedProvider() const
+ {
+ return d_provider;
+ }
+
+ std::string getEffectiveProvider() const
+ {
+ if (d_ctx) {
+ return d_ctx->getName();
+ }
+ return "";
+ }
+
TLSConfig d_tlsConfig;
TLSErrorCounters d_tlsCounters;
ComboAddress d_addr;