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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:398:    static private int is_ip(string ip)    {    return(replace(ip,    ({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "." }),    ({ "", "", "", "", "", "", "", "", "", "", "" })) == "");    }       static private mapping etc_hosts;      #ifdef __NT__ -  string get_tcpip_param(string val) +  string get_tcpip_param(string val, void|string fallbackvalue)    {    foreach(({    "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",    "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP"    }),string key)    {    catch {    return RegGetValue(HKEY_LOCAL_MACHINE, key, val);    };    }
pike.git/lib/modules/Protocols.pmod/DNS.pmod:423: Inside #if defined(__NT__) and #if constant(RegGetKeyNames)
   */    foreach(RegGetKeyNames(HKEY_LOCAL_MACHINE,    "SYSTEM\\CurrentControlSet\\Tcpip\\Parameters\\Interfaces"), string key)    {    catch {    return RegGetValue(HKEY_LOCAL_MACHINE,    "SYSTEM\\CurrentControlSet\\Tcpip\\Parameters\\Interfaces\\"+key,val);    };    }   #endif -  +  return fallbackvalue;    }   #endif       static private string match_etc_hosts(string host)    {    if (!etc_hosts) {    string raw;   #ifdef __NT__    raw=get_tcpip_param("DataBasePath")+"\\hosts";   #else
pike.git/lib/modules/Protocols.pmod/DNS.pmod:477:       array(string) nameservers = ({});    array domains = ({});    void create(void|string|array(string) server, void|int|array(string) domain)    {    if(!server)    {    string domain;      #if __NT__ -  domain=get_tcpip_param("Domain"); +  domain = get_tcpip_param("Domain");    if(!domain || !sizeof(domain)) -  domain=get_tcpip_param("DhcpDomain"); +  domain = get_tcpip_param("DhcpDomain");    -  nameservers = get_tcpip_param("NameServer") / " "; -  nameservers+= get_tcpip_param("DhcpNameServer") / " "; -  nameservers -= ({""}); +  nameservers += get_tcpip_param("NameServer", "") / " "; +  nameservers += get_tcpip_param("DhcpNameServer", "") / " "; +  nameservers -= ({ "" });    -  domains=get_tcpip_param("SearchList") / " "- ({""}); +  domains += (get_tcpip_param("SearchList", "") / " ") - ({ "" });   #else    string resolv_conf;    foreach(({"/etc/resolv.conf", "/amitcp/db/resolv.conf"}), string resolv_loc)    if ((resolv_conf = Stdio.read_file(resolv_loc)))    break;       if (!resolv_conf) {    /* FIXME: Is this a good idea?    * Why not just try the fallback?    * /grubba 1999-04-14
pike.git/lib/modules/Protocols.pmod/DNS.pmod:576:       mapping do_sync_query(string s)    {    object udp = Stdio.UDP();    udp->bind(0);    mapping m;    int i;    for (i=0; i < RETRIES; i++) {    udp->send(nameservers[i % sizeof(nameservers)], 53, s);    -  while (udp->wait(RETRY_DELAY)) { +  // upd->wait() can throw an error sometimes. +  catch +  { +  while (udp->wait(RETRY_DELAY)) +  {    // udp->read() can throw an error on connection refused.    catch {    m = udp->read();    if ((m->port == 53) &&    (m->data[0..1] == s[0..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,