pike.git / lib / modules / Protocols.pmod / DNS.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:1:   // Not yet finished -- Fredrik Hubinette      //! module Protocols   //! submodule DNS   //! - //! $Id: DNS.pmod,v 1.41 2000/09/06 21:33:03 leif Exp $ + //! $Id: DNS.pmod,v 1.42 2000/09/07 15:33:05 leif Exp $      constant NOERROR=0;   constant FORMERR=1;   constant SERVFAIL=2;   constant NXDOMAIN=3;   constant NOTIMPL=4;   constant NXRRSET=8;      constant QUERY=0;   
pike.git/lib/modules/Protocols.pmod/DNS.pmod:393:    domains = ({ domain });    }    }       mapping do_sync_query(string s)    {    object udp = Stdio.UDP();    udp->bind(0);    mapping m;    int i; -  for (i=0; i < RETRIES; i++) { +  for (i=0; i < RETRIES; i++) +  {    udp->send(nameservers[i % sizeof(nameservers)], 53, s);    -  while (udp->wait(RETRY_DELAY)) { +  // udp->wait() can throw an error sometimes +  catch +  { +  while (udp->wait(RETRY_DELAY)) +  {    // udp->read can throw an error on connection refused. -  catch { +  catch +  {    m = udp->read();    if ((m->port == 53) &&    (m->data[0..1] == s[0..1]) && -  (search(nameservers, m->ip) != -1)) { +  (search(nameservers, m->ip) != -1)) +  {    // Success.    return decode_res(m->data);    }    };    } -  +  };    }    // Failure.    return 0;    }       //!    //! method array gethostbyname(string hostname)    //! method array gethostbyaddr(string hostip)    //! Querys the host name or ip from the default or given    //! DNS server. The result is a mapping with three elements,