]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
poc for making dnsdist ixfr-axfr aware
authorslowr <jim.mavrommatis@gmail.com>
Fri, 4 Jun 2021 18:46:21 +0000 (20:46 +0200)
committerslowr <jim.mavrommatis@gmail.com>
Fri, 4 Jun 2021 18:46:21 +0000 (20:46 +0200)
pdns/dnsdist-tcp.cc
pdns/dnsdistdist/dnsdist-tcp-downstream.cc
pdns/dnsdistdist/dnsdist-tcp-upstream.hh

index aa27cb2a51d130febcc2f0fb3b84bd448a4116d9..69ecb90b431a3ecf6d8989c60ef6f599e9466cb1 100644 (file)
@@ -435,6 +435,9 @@ void IncomingTCPConnectionState::resetForNewQuery()
   d_buffer.resize(sizeof(uint16_t));
   d_currentPos = 0;
   d_querySize = 0;
+  d_xfrMasterSerial = 0;
+  d_xfrSerialCount = 0;
+  d_xfrMasterSerialCount = 0;
   d_state = State::waitingForQuery;
 }
 
index 94387e53b93ed8d06c9fbc2fd20270e720f41ac4..f6163439aee2484dec6044f2580d994c8ae6d010 100644 (file)
@@ -501,7 +501,24 @@ IOState TCPConnectionToBackend::handleResponse(std::shared_ptr<TCPConnectionToBa
           }
           auto raw = unknownContent->getRawContent();
           auto serial = getSerialFromRawSOAContent(raw);
-          cerr << "Got serial: " << serial << endl;
+
+          ++d_clientConn->d_xfrSerialCount;
+          if (d_clientConn->d_xfrMasterSerial == 0) {
+            // store the first SOA in our client's connection metadata
+            ++d_clientConn->d_xfrMasterSerialCount;
+            d_clientConn->d_xfrMasterSerial = serial;
+          } else if (d_clientConn->d_xfrMasterSerial == serial) {
+            ++d_clientConn->d_xfrMasterSerialCount;
+            // figure out if it's end when receiving master's SOA again
+            if (d_clientConn->d_xfrSerialCount == 2) {
+              // if there are only two SOA records marks a finished AXFR
+              done = true;
+            }
+            if (d_clientConn->d_xfrMasterSerialCount == 3) {
+              // receiving master's SOA 3 times marks a finished IXFR
+              done = true;
+            }
+          }
         }
       }
     }
index ae971b070eab796b13c5cfd0d558bef65bcaaafd..b54b3eb630a540b31b0466bba89ed4af5f4a6e69 100644 (file)
@@ -209,4 +209,7 @@ public:
   bool d_proxyProtocolPayloadHasTLV{false};
   bool d_lastIOBlocked{false};
   bool d_hadErrors{false};
+  uint32_t d_xfrMasterSerial{0};
+  uint32_t d_xfrSerialCount{0};
+  uint8_t d_xfrMasterSerialCount{0};
 };