From: Remi Gacogne Date: Tue, 4 Dec 2018 10:26:00 +0000 (+0100) Subject: dnsdist: Make getMsgLen32 and putMsgLen32 static X-Git-Tag: auth-4.2.0-alpha1~7^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F7257%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Make getMsgLen32 and putMsgLen32 static Only the console code uses them nowadays, so no need to export them. --- diff --git a/pdns/dnsdist-console.cc b/pdns/dnsdist-console.cc index da894202ab..091fa4bd85 100644 --- a/pdns/dnsdist-console.cc +++ b/pdns/dnsdist-console.cc @@ -76,6 +76,33 @@ static string historyFile(const bool &ignoreHOME = false) return ret; } +static bool getMsgLen32(int fd, uint32_t* len) +try +{ + uint32_t raw; + size_t ret = readn2(fd, &raw, sizeof raw); + if(ret != sizeof raw) + return false; + *len = ntohl(raw); + if(*len > g_consoleOutputMsgMaxSize) + return false; + return true; +} +catch(...) { + return false; +} + +static bool putMsgLen32(int fd, uint32_t len) +try +{ + uint32_t raw = htonl(len); + size_t ret = writen2(fd, &raw, sizeof raw); + return ret==sizeof raw; +} +catch(...) { + return false; +} + static bool sendMessageToServer(int fd, const std::string& line, SodiumNonce& readingNonce, SodiumNonce& writingNonce, const bool outputEmptyLine) { string msg = sodEncryptSym(line, g_consoleKey, writingNonce); @@ -707,30 +734,3 @@ catch(const std::exception& e) close(fd); errlog("Control connection died: %s", e.what()); } - -bool getMsgLen32(int fd, uint32_t* len) -try -{ - uint32_t raw; - size_t ret = readn2(fd, &raw, sizeof raw); - if(ret != sizeof raw) - return false; - *len = ntohl(raw); - if(*len > g_consoleOutputMsgMaxSize) - return false; - return true; -} -catch(...) { - return false; -} - -bool putMsgLen32(int fd, uint32_t len) -try -{ - uint32_t raw = htonl(len); - size_t ret = writen2(fd, &raw, sizeof raw); - return ret==sizeof raw; -} -catch(...) { - return false; -} diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 651d5b8810..c4ae2bac3a 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -1009,8 +1009,6 @@ void setWebserverPassword(const std::string& password); void setWebserverCustomHeaders(const boost::optional > customHeaders); void dnsdistWebserverThread(int sock, const ComboAddress& local); -bool getMsgLen32(int fd, uint32_t* len); -bool putMsgLen32(int fd, uint32_t len); void tcpAcceptorThread(void* p); void setLuaNoSideEffect(); // if nothing has been declared, set that there are no side effects