From: Pieter Lexis Date: Wed, 15 Sep 2021 08:02:40 +0000 (+0200) Subject: COOKIES: more constness, rm unused func X-Git-Tag: dnsdist-1.7.0-alpha1~3^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38118dcb4227018b04b6cd447852ef4bf874795a;p=thirdparty%2Fpdns.git COOKIES: more constness, rm unused func --- diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index 5ba0eda092..a4d68b57c2 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -693,7 +693,7 @@ bool DNSPacket::hasWellFormedEDNSCookie() const return d_eco.isWellFormed(); } -bool DNSPacket::hasValidEDNSCookie() +bool DNSPacket::hasValidEDNSCookie() const { if (!hasWellFormedEDNSCookie()) { return false; diff --git a/pdns/dnspacket.hh b/pdns/dnspacket.hh index 6a7d178d6f..846df0a54a 100644 --- a/pdns/dnspacket.hh +++ b/pdns/dnspacket.hh @@ -127,7 +127,7 @@ public: bool hasEDNS() const; bool hasEDNSCookie() const; bool hasWellFormedEDNSCookie() const; - bool hasValidEDNSCookie(); // Not const, some cookie params might be set + bool hasValidEDNSCookie() const; uint8_t getEDNSVersion() const { return d_ednsversion; }; void setEDNSRcode(uint16_t extRCode) { diff --git a/pdns/ednscookies.cc b/pdns/ednscookies.cc index d9f079c03c..c24c66a62c 100644 --- a/pdns/ednscookies.cc +++ b/pdns/ednscookies.cc @@ -75,7 +75,7 @@ void EDNSCookiesOpt::getEDNSCookiesOptFromString(const char* option, unsigned in } } -bool EDNSCookiesOpt::isValid(const string& secret, const ComboAddress& source) +bool EDNSCookiesOpt::isValid(const string& secret, const ComboAddress& source) const { #ifdef HAVE_CRYPTO_SHORTHASH if (server.length() != 16 || client.length() != 8) { @@ -115,7 +115,7 @@ bool EDNSCookiesOpt::isValid(const string& secret, const ComboAddress& source) #endif } -bool EDNSCookiesOpt::shouldRefresh() +bool EDNSCookiesOpt::shouldRefresh() const { if (server.size() < 16) { return true; diff --git a/pdns/ednscookies.hh b/pdns/ednscookies.hh index 7e25d37081..7eff3c63fe 100644 --- a/pdns/ednscookies.hh +++ b/pdns/ednscookies.hh @@ -48,7 +48,7 @@ struct EDNSCookiesOpt client.size() == 8 && (server.size() == 0 || (server.size() >= 8 && server.size() <= 32))); } - bool isValid(const string& secret, const ComboAddress& source); + bool isValid(const string& secret, const ComboAddress& source) const; bool makeServerCookie(const string& secret, const ComboAddress& source); string makeOptString() const; string getServer() const @@ -61,18 +61,12 @@ struct EDNSCookiesOpt } private: - bool shouldRefresh(); + bool shouldRefresh() const; // the client cookie string client; // the server cookie string server; - // Checks if the server cookie is correct - // 1. Checks the sizes of the client and server cookie - // 2. checks if the timestamp is still good (now - 3600 < ts < now + 300) - // 3. Whether or not the hash is correct - bool check(const string& secret, const ComboAddress& source); - void getEDNSCookiesOptFromString(const char* option, unsigned int len); };