]> granicus.if.org Git - pdns/commitdiff
add rec_control dump-edns, plus implement 'third try' for remotes that need to descen...
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 9 Feb 2009 06:21:26 +0000 (06:21 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 9 Feb 2009 06:21:26 +0000 (06:21 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1334 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/rec_channel_rec.cc
pdns/syncres.cc
pdns/syncres.hh

index 42f88507643bdaabd79c2fe67569629aff6b8187..86ba3e45771444dc678a3c146e344894f4eb731d 100644 (file)
@@ -109,6 +109,25 @@ string doDumpCache(T begin, T end)
   return "done\n";
 }
 
+template<typename T>
+string doDumpEDNSStatus(T begin, T end)
+{
+  T i=begin;
+  string fname;
+
+  if(i!=end) 
+    fname=*i;
+
+  int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660);
+  if(fd < 0) 
+    return "Error opening dump file for writing: "+string(strerror(errno))+"\n";
+
+  SyncRes::doEDNSDumpAndClose(fd);
+
+  return "done\n";
+}
+
+
 template<typename T>
 string doWipeCache(T begin, T end)
 {
@@ -329,6 +348,10 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
   if(cmd=="dump-cache") 
     return doDumpCache(begin, end);
 
+  if(cmd=="dump-ednsstatus" || cmd=="dump-edns") 
+    return doDumpEDNSStatus(begin, end);
+
+
   if(cmd=="slash-cache") 
     return doSlashCache(begin, end);
 
index 11e51cc97937b1d23cd70dda7f2a0d46ec8406fd..735850e37145ebe01bc137da23eccef2505b74ed 100644 (file)
@@ -189,6 +189,16 @@ bool SyncRes::doOOBResolve(const string &qname, const QType &qtype, vector<DNSRe
   return true;
 }
 
+void SyncRes::doEDNSDumpAndClose(int fd)
+{
+  FILE* fp=fdopen(fd, "w");
+  fprintf(fp,"IP Address\tMode\tMode last updated at\n");
+  for(ednsstatus_t::const_iterator iter = s_ednsstatus.begin(); iter != s_ednsstatus.end(); ++iter) {
+    fprintf(fp, "%s\t%d\t%s", iter->first.toString().c_str(), (int)iter->second.mode, ctime(&iter->second.modeSetAt));
+  }
+  fclose(fp);
+}
+
 int SyncRes::asyncresolveWrapper(const ComboAddress& ip, const string& domain, int type, bool doTCP, struct timeval* now, LWResult* res) 
 {
   /* what is your QUEST?
@@ -233,7 +243,7 @@ int SyncRes::asyncresolveWrapper(const ComboAddress& ip, const string& domain, i
   int EDNSLevel=0;
 
   int ret;
-  for(int tries = 0; tries < 2; ++tries) {
+  for(int tries = 0; tries < 3; ++tries) {
     //    cerr<<"Remote '"<<ip.toString()<<"' currently in mode "<<mode<<endl;
 
     if(mode==EDNSStatus::CONFIRMEDPINGER || mode==EDNSStatus::UNKNOWN || mode==EDNSStatus::EDNSPINGOK || mode==EDNSStatus::EDNSIGNORANT)
index f9a39a5e5be3c6a82f32442b2fe3798401271037..528ca80c39b59249d5a4590ee82667d219f78e36 100644 (file)
@@ -237,7 +237,11 @@ public:
     d_doEDNS0=state;
   }
 
+
+
   int asyncresolveWrapper(const ComboAddress& ip, const string& domain, int type, bool doTCP, struct timeval* now, LWResult* res);
+  
+  static void doEDNSDumpAndClose(int fd);
 
   static unsigned int s_queries;
   static unsigned int s_outgoingtimeouts;