Changeset 619

Show
Ignore:
Timestamp:
03/25/06 18:54:12 (3 years ago)
Author:
ahu
Message:

no longer pass around IPv4 addresses as.. strings (sorry about that)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pdns/pdns/lwres.cc

    r598 r619  
    5858//! returns -1 for permanent error, 0 for timeout, 1 for success 
    5959/** Never throws! */ 
    60 int LWRes::asyncresolve(const string &ip, const char *domain, int type, bool doTCP, struct timeval* now) 
     60int LWRes::asyncresolve(uint32_t ip, const char *domain, int type, bool doTCP, struct timeval* now) 
    6161{ 
    6262  vector<uint8_t> vpacket; 
     
    7171 
    7272  struct sockaddr_in toaddr; 
    73   struct in_addr inp; 
    7473  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); 
    7775 
    7876  toaddr.sin_port=htons(53); 
     
    9593  else { 
    9694    Socket s(InterNetwork, Stream); 
    97     IPEndpoint ie(ip, 53); 
     95    IPEndpoint ie(U32ToIP(ip), 53); 
    9896    s.setNonBlocking(); 
    9997    s.connect(ie); 
  • trunk/pdns/pdns/lwres.hh

    r598 r619  
    6262  typedef vector<DNSResourceRecord> res_t; 
    6363 
    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); 
    6565  vector<DNSResourceRecord> result(); 
    6666  int d_rcode; 
  • trunk/pdns/pdns/syncres.cc

    r618 r619  
    5050#define LOG if(s_log) L<<Logger::Warning 
    5151 
    52 Throttle<tuple<string,string,uint16_t> > SyncRes::s_throttle; 
     52Throttle<tuple<uint32_t,string,uint16_t> > SyncRes::s_throttle; 
    5353 
    5454/** everything begins here - this is the entry point just after receiving a packet */ 
     
    105105} 
    106106 
    107 vector<string> SyncRes::getAs(const string &qname, int depth, set<GetBestNSAnswer>& beenthere) 
     107vector<uint32_t> SyncRes::getAs(const string &qname, int depth, set<GetBestNSAnswer>& beenthere) 
    108108{ 
    109109  typedef vector<DNSResourceRecord> res_t; 
    110110  res_t res; 
    111111 
    112   vector<string> ret; 
     112  vector<uint32_t> ret; 
    113113 
    114114  if(!doResolve(qname,QType(QType::A), res,depth+1,beenthere) && !res.empty()) { 
    115115    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      } 
    118121  } 
    119122  if(ret.size() > 1) 
     
    399402      } 
    400403      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; 
    402405      remoteIPs_t remoteIPs=getAs(*tns, depth+1, beenthere); 
    403406      if(remoteIPs.empty()) { 
     
    408411      bool doTCP=false; 
    409412      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; 
    411414         
    412415        if(s_throttle.shouldThrottle(d_now.tv_sec, make_tuple(*remoteIP, qname, qtype.getCode()))) { 
     
    465468        continue; 
    466469      } 
    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; 
    468471      s_nsSpeeds[toLower(*tns)].submit(d_lwr.d_usec, &d_now); 
    469472 
  • trunk/pdns/pdns/syncres.hh

    r617 r619  
    247247  static nsspeeds_t s_nsSpeeds; 
    248248 
    249   typedef Throttle<tuple<string,string,uint16_t> > throttle_t; 
     249  typedef Throttle<tuple<uint32_t,string,uint16_t> > throttle_t; 
    250250  static throttle_t s_throttle; 
    251251  struct timeval d_now; 
     
    264264  inline vector<string> shuffle(set<string> &nameservers, const string &prefix); 
    265265  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); 
    267267 
    268268  SyncRes(const SyncRes&);