struct Configuration
{
std::set<std::string> d_capabilitiesToRetain;
+ std::vector<uint32_t> d_tcpFastOpenKey;
ComboAddress d_consoleServerAddress{"127.0.0.1:5199"};
std::string d_consoleKey;
#ifdef __linux__
});
luaCtx.writeFunction("setTCPFastOpenKey", [](const std::string& keyString) {
- setLuaSideEffect();
- std::array<uint32_t, 4> key{};
- // NOLINTNEXTLINE(readability-container-data-pointer)
- auto ret = sscanf(keyString.c_str(), "%" SCNx32 "-%" SCNx32 "-%" SCNx32 "-%" SCNx32, &key[0], &key[1], &key[2], &key[3]);
- if (ret != 4) {
+ std::vector<uint32_t> key(4);
+ auto ret = sscanf(keyString.c_str(), "%" SCNx32 "-%" SCNx32 "-%" SCNx32 "-%" SCNx32, &key.at(0), &key.at(1), &key.at(2), &key.at(3));
+ if (ret < 0 || static_cast<size_t>(ret) != key.size()) {
g_outputBuffer = "Invalid value passed to setTCPFastOpenKey()!\n";
return;
}
- extern vector<uint32_t> g_TCPFastOpenKey;
- for (const auto byte : key) {
- g_TCPFastOpenKey.push_back(byte);
- }
+ dnsdist::configuration::updateImmutableConfiguration([&key](dnsdist::configuration::Configuration& config) {
+ config.d_tcpFastOpenKey = std::move(key);
+ });
});
#ifdef HAVE_NET_SNMP
std::vector<std::shared_ptr<DynBPFFilter>> g_dynBPFFilters;
std::vector<std::unique_ptr<ClientState>> g_frontends;
-std::vector<uint32_t> g_TCPFastOpenKey;
/* UDP: the grand design. Per socket we listen on for incoming queries there is one thread.
Then we have a bunch of connected sockets for talking to downstream servers.
We send directly to those sockets.
#ifdef TCP_FASTOPEN
SSetsockopt(socket, IPPROTO_TCP, TCP_FASTOPEN, clientState.fastOpenQueueSize);
#ifdef TCP_FASTOPEN_KEY
- if (!g_TCPFastOpenKey.empty()) {
- auto res = setsockopt(socket, IPPROTO_IP, TCP_FASTOPEN_KEY, g_TCPFastOpenKey.data(), g_TCPFastOpenKey.size() * sizeof(g_TCPFastOpenKey[0]));
+ if (!immutableConfig.d_tcpFastOpenKey.empty()) {
+ auto res = setsockopt(socket, IPPROTO_IP, TCP_FASTOPEN_KEY, immutableConfig.d_tcpFastOpenKey.data(), immutableConfig.d_tcpFastOpenKey.size() * sizeof(immutableConfig.d_tcpFastOpenKey.at(0)));
if (res == -1) {
throw runtime_error("setsockopt for level IPPROTO_TCP and opname TCP_FASTOPEN_KEY failed: " + stringerror());
}