Changeset 619
- Timestamp:
- 03/25/06 18:54:12 (3 years ago)
- Files:
-
- trunk/pdns/pdns/lwres.cc (modified) (3 diffs)
- trunk/pdns/pdns/lwres.hh (modified) (1 diff)
- trunk/pdns/pdns/syncres.cc (modified) (5 diffs)
- trunk/pdns/pdns/syncres.hh (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pdns/pdns/lwres.cc
r598 r619 58 58 //! returns -1 for permanent error, 0 for timeout, 1 for success 59 59 /** Never throws! */ 60 int LWRes::asyncresolve( const string &ip, const char *domain, int type, bool doTCP, struct timeval* now)60 int LWRes::asyncresolve(uint32_t ip, const char *domain, int type, bool doTCP, struct timeval* now) 61 61 { 62 62 vector<uint8_t> vpacket; … … 71 71 72 72 struct sockaddr_in toaddr; 73 struct in_addr inp;74 73 Utility::socklen_t addrlen=sizeof(toaddr); 75 Utility::inet_aton(ip.c_str(),&inp); 76 toaddr.sin_addr.s_addr=inp.s_addr; 74 toaddr.sin_addr.s_addr=htonl(ip); 77 75 78 76 toaddr.sin_port=htons(53); … … 95 93 else { 96 94 Socket s(InterNetwork, Stream); 97 IPEndpoint ie( ip, 53);95 IPEndpoint ie(U32ToIP(ip), 53); 98 96 s.setNonBlocking(); 99 97 s.connect(ie); trunk/pdns/pdns/lwres.hh
r598 r619 62 62 typedef vector<DNSResourceRecord> res_t; 63 63 64 int asyncresolve( const string &ip, const char *domain, int type, bool doTCP, struct timeval* now);64 int asyncresolve(uint32_t ip, const char *domain, int type, bool doTCP, struct timeval* now); 65 65 vector<DNSResourceRecord> result(); 66 66 int d_rcode; trunk/pdns/pdns/syncres.cc
r618 r619 50 50 #define LOG if(s_log) L<<Logger::Warning 51 51 52 Throttle<tuple< string,string,uint16_t> > SyncRes::s_throttle;52 Throttle<tuple<uint32_t,string,uint16_t> > SyncRes::s_throttle; 53 53 54 54 /** everything begins here - this is the entry point just after receiving a packet */ … … 105 105 } 106 106 107 vector< string> SyncRes::getAs(const string &qname, int depth, set<GetBestNSAnswer>& beenthere)107 vector<uint32_t> SyncRes::getAs(const string &qname, int depth, set<GetBestNSAnswer>& beenthere) 108 108 { 109 109 typedef vector<DNSResourceRecord> res_t; 110 110 res_t res; 111 111 112 vector< string> ret;112 vector<uint32_t> ret; 113 113 114 114 if(!doResolve(qname,QType(QType::A), res,depth+1,beenthere) && !res.empty()) { 115 115 for(res_t::const_iterator i=res.begin(); i!= res.end(); ++i) 116 if(i->qtype.getCode()==QType::A) 117 ret.push_back(i->content); 116 if(i->qtype.getCode()==QType::A) { 117 uint32_t ip; 118 if(IpToU32(i->content, &ip)) 119 ret.push_back(ntohl(ip)); 120 } 118 121 } 119 122 if(ret.size() > 1) … … 399 402 } 400 403 LOG<<prefix<<qname<<": Trying to resolve NS "<<*tns<<" ("<<1+tns-rnameservers.begin()<<"/"<<rnameservers.size()<<")"<<endl; 401 typedef vector< string> remoteIPs_t;404 typedef vector<uint32_t> remoteIPs_t; 402 405 remoteIPs_t remoteIPs=getAs(*tns, depth+1, beenthere); 403 406 if(remoteIPs.empty()) { … … 408 411 bool doTCP=false; 409 412 for(remoteIP = remoteIPs.begin(); remoteIP != remoteIPs.end(); ++remoteIP) { 410 LOG<<prefix<<qname<<": Resolved '"+auth+"' NS "<<*tns<<" to "<< *remoteIP<<", asking '"<<qname<<"|"<<qtype.getName()<<"'"<<endl;413 LOG<<prefix<<qname<<": Resolved '"+auth+"' NS "<<*tns<<" to "<<U32ToIP(*remoteIP)<<", asking '"<<qname<<"|"<<qtype.getName()<<"'"<<endl; 411 414 412 415 if(s_throttle.shouldThrottle(d_now.tv_sec, make_tuple(*remoteIP, qname, qtype.getCode()))) { … … 465 468 continue; 466 469 } 467 LOG<<prefix<<qname<<": Got "<<result.size()<<" answers from "<<*tns<<" ("<< *remoteIP<<"), rcode="<<d_lwr.d_rcode<<", in "<<d_lwr.d_usec/1000<<"ms"<<endl;470 LOG<<prefix<<qname<<": Got "<<result.size()<<" answers from "<<*tns<<" ("<<U32ToIP(*remoteIP)<<"), rcode="<<d_lwr.d_rcode<<", in "<<d_lwr.d_usec/1000<<"ms"<<endl; 468 471 s_nsSpeeds[toLower(*tns)].submit(d_lwr.d_usec, &d_now); 469 472 trunk/pdns/pdns/syncres.hh
r617 r619 247 247 static nsspeeds_t s_nsSpeeds; 248 248 249 typedef Throttle<tuple< string,string,uint16_t> > throttle_t;249 typedef Throttle<tuple<uint32_t,string,uint16_t> > throttle_t; 250 250 static throttle_t s_throttle; 251 251 struct timeval d_now; … … 264 264 inline vector<string> shuffle(set<string> &nameservers, const string &prefix); 265 265 bool moreSpecificThan(const string& a, const string &b); 266 vector< string> getAs(const string &qname, int depth, set<GetBestNSAnswer>& beenthere);266 vector<uint32_t> getAs(const string &qname, int depth, set<GetBestNSAnswer>& beenthere); 267 267 268 268 SyncRes(const SyncRes&);