From: Pieter Lexis Date: Tue, 28 May 2019 13:00:14 +0000 (+0200) Subject: dnsdist: disallow TCP disablement X-Git-Tag: dnsdist-1.4.0-rc1~129^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0230e350b2948074346cbded2ee06a1fd3eea209;p=thirdparty%2Fpdns.git dnsdist: disallow TCP disablement --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 71421a1862..3db0e822fc 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -89,12 +89,9 @@ void resetLuaSideEffect() typedef std::unordered_map > > > localbind_t; -static void parseLocalBindVars(boost::optional vars, bool& doTCP, bool& reusePort, int& tcpFastOpenQueueSize, std::string& interface, std::set& cpus) +static void parseLocalBindVars(boost::optional vars, bool& reusePort, int& tcpFastOpenQueueSize, std::string& interface, std::set& cpus) { if (vars) { - if (vars->count("doTCP")) { - doTCP = boost::get((*vars)["doTCP"]); - } if (vars->count("reusePort")) { reusePort = boost::get((*vars)["reusePort"]); } @@ -485,13 +482,12 @@ void setupLuaConfig(bool client) g_outputBuffer="setLocal cannot be used at runtime!\n"; return; } - bool doTCP = true; bool reusePort = false; int tcpFastOpenQueueSize = 0; std::string interface; std::set cpus; - parseLocalBindVars(vars, doTCP, reusePort, tcpFastOpenQueueSize, interface, cpus); + parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus); try { ComboAddress loc(addr, 53); @@ -507,9 +503,7 @@ void setupLuaConfig(bool client) // only works pre-startup, so no sync necessary g_frontends.push_back(std::unique_ptr(new ClientState(loc, false, reusePort, tcpFastOpenQueueSize, interface, cpus))); - if (doTCP) { - g_frontends.push_back(std::unique_ptr(new ClientState(loc, true, reusePort, tcpFastOpenQueueSize, interface, cpus))); - } + g_frontends.push_back(std::unique_ptr(new ClientState(loc, true, reusePort, tcpFastOpenQueueSize, interface, cpus))); } catch(const std::exception& e) { g_outputBuffer="Error: "+string(e.what())+"\n"; @@ -524,21 +518,18 @@ void setupLuaConfig(bool client) g_outputBuffer="addLocal cannot be used at runtime!\n"; return; } - bool doTCP = true; bool reusePort = false; int tcpFastOpenQueueSize = 0; std::string interface; std::set cpus; - parseLocalBindVars(vars, doTCP, reusePort, tcpFastOpenQueueSize, interface, cpus); + parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus); try { ComboAddress loc(addr, 53); // only works pre-startup, so no sync necessary g_frontends.push_back(std::unique_ptr(new ClientState(loc, false, reusePort, tcpFastOpenQueueSize, interface, cpus))); - if (doTCP) { - g_frontends.push_back(std::unique_ptr(new ClientState(loc, true, reusePort, tcpFastOpenQueueSize, interface, cpus))); - } + g_frontends.push_back(std::unique_ptr(new ClientState(loc, true, reusePort, tcpFastOpenQueueSize, interface, cpus))); } catch(std::exception& e) { g_outputBuffer="Error: "+string(e.what())+"\n"; @@ -1100,13 +1091,12 @@ void setupLuaConfig(bool client) return; } #ifdef HAVE_DNSCRYPT - bool doTCP = true; bool reusePort = false; int tcpFastOpenQueueSize = 0; std::string interface; std::set cpus; - parseLocalBindVars(vars, doTCP, reusePort, tcpFastOpenQueueSize, interface, cpus); + parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus); try { auto ctx = std::make_shared(providerName, certFile, keyFile); @@ -1680,15 +1670,13 @@ void setupLuaConfig(bool client) frontend->d_urls = {"/"}; } - bool doTCP = true; bool reusePort = false; int tcpFastOpenQueueSize = 0; std::string interface; std::set cpus; - (void) doTCP; if(vars) { - parseLocalBindVars(vars, doTCP, reusePort, tcpFastOpenQueueSize, interface, cpus); + parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus); if (vars->count("idleTimeout")) { frontend->d_idleTimeout = boost::get((*vars)["idleTimeout"]); @@ -1779,15 +1767,13 @@ void setupLuaConfig(bool client) return; } - bool doTCP = true; bool reusePort = false; int tcpFastOpenQueueSize = 0; std::string interface; std::set cpus; - (void) doTCP; if (vars) { - parseLocalBindVars(vars, doTCP, reusePort, tcpFastOpenQueueSize, interface, cpus); + parseLocalBindVars(vars, reusePort, tcpFastOpenQueueSize, interface, cpus); if (vars->count("provider")) { frontend->d_provider = boost::get((*vars)["provider"]); diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index 623ef6c2d4..bd94c1a922 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -66,6 +66,9 @@ Listen Sockets .. versionchanged:: 1.3.0 Added ``cpus`` to the options. + .. versionchanged:: 1.4.0 + Removed ``doTCP`` from the options. A listen socket on TCP is always created. + Add to the list of listen addresses. :param str address: The IP Address with an optional port to listen on. @@ -74,7 +77,7 @@ Listen Sockets Options: - * ``doTCP=true``: bool - Also bind on TCP on ``address``. + * ``doTCP=true``: bool - Also bind on TCP on ``address``. Removed in 1.4.0. * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option. * ``tcpFastOpenSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0. * ``interface=""``: str - Set the network interface to use. @@ -82,7 +85,7 @@ Listen Sockets .. code-block:: lua - addLocal('0.0.0.0:5300', { doTCP=true, reusePort=true }) + addLocal('0.0.0.0:5300', { reusePort=true }) This will bind to both UDP and TCP on port 5300 with SO_REUSEPORT enabled. diff --git a/pdns/dnsdistdist/docs/reference/dnscrypt.rst b/pdns/dnsdistdist/docs/reference/dnscrypt.rst index 3e689a452f..68a7703b9d 100644 --- a/pdns/dnsdistdist/docs/reference/dnscrypt.rst +++ b/pdns/dnsdistdist/docs/reference/dnscrypt.rst @@ -6,6 +6,9 @@ DNSCrypt objects and functions .. versionchanged:: 1.3.0 ``cpus`` option added. + .. versionchanged:: 1.4.0 + Removed ``doTCP`` from the options. A listen socket on TCP is always created. + Adds a DNSCrypt listen socket on ``address``. :param string address: The address and port to listen on @@ -16,7 +19,7 @@ DNSCrypt objects and functions Options: - * ``doTCP=true``: bool - Also bind on TCP on ``address``. + * ``doTCP=true``: bool - Also bind on TCP on ``address``, removed in 1.4.0. * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option. * ``tcpFastOpenSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0 * ``interface=""``: str - Sets the network interface to use