]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
COOKIES: more constness, rm unused func
authorPieter Lexis <pieter.lexis@powerdns.com>
Wed, 15 Sep 2021 08:02:40 +0000 (10:02 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 20 Sep 2021 08:54:41 +0000 (10:54 +0200)
pdns/dnspacket.cc
pdns/dnspacket.hh
pdns/ednscookies.cc
pdns/ednscookies.hh

index 5ba0eda092da56c1a59382b318cde192ba2c6d89..a4d68b57c2398654e25f55c63ac99ca710d3464c 100644 (file)
@@ -693,7 +693,7 @@ bool DNSPacket::hasWellFormedEDNSCookie() const
   return d_eco.isWellFormed();
 }
 
-bool DNSPacket::hasValidEDNSCookie()
+bool DNSPacket::hasValidEDNSCookie() const
 {
   if (!hasWellFormedEDNSCookie()) {
     return false;
index 6a7d178d6f56a6d7f56f2f8bdbf3aa9d4f47f26f..846df0a54a3035a7db3ee48d0d5c53ba59be3488 100644 (file)
@@ -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)
   {
index d9f079c03c078523576073c40de2ba56a648dfc8..c24c66a62ce172a15aa44f6ca0f149af9ad06913 100644 (file)
@@ -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;
index 7e25d37081220b9866a18614722ee861c812ef08..7eff3c63fe99fea2147ae604f2b10b5e5133969e 100644 (file)
@@ -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);
 };