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   // RFC 1035      //! module Protocols   //! submodule DNS    - //! $Id: DNS.pmod,v 1.56 2001/03/14 15:43:04 grubba Exp $ + //! $Id: DNS.pmod,v 1.57 2001/04/09 16:51:09 jonasw Exp $      #pike __REAL_VERSION__      constant NOERROR=0;   constant FORMERR=1;   constant SERVFAIL=2;   constant NXDOMAIN=3;   constant NOTIMPL=4;   constant NXRRSET=8;   
pike.git/lib/modules/Protocols.pmod/DNS.pmod:506:    }) * ({});   #else    string domain;    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) { +  if (system->get_netinfo_property) { +  // Mac OS X / Darwin (and possibly other systems) that use +  // NetInfo may have these values in the database. +  if (nameservers = +  system->get_netinfo_property(".", +  "/locations/resolver", +  "nameserver")) { +  nameservers = sizeof(nameservers) && map(nameservers, `-, "\n"); +  } +  +  if (domains = system->get_netinfo_property(".", +  "/locations/resolver", +  "domain")) { +  domains = sizeof(domains) && map(domains, `-, "\n"); +  } +  } else {    /* FIXME: Is this a good idea?    * Why not just try the fallback?    * /grubba 1999-04-14    *    * Now uses 127.0.0.1 as fallback.    * /grubba 2000-10-17    */    resolv_conf = "nameserver 127.0.0.1"; -  +  }   #if 0    throw(({ "Protocols.DNS.client(): No /etc/resolv.conf!\n",    backtrace() }));   #endif /* 0 */    }    -  +  if (resolv_conf)    foreach(resolv_conf/"\n", string line)    {    string rest;    sscanf(line,"%s#",line);    sscanf(line,"%*[\r \t]%s",line);    line=reverse(line);    sscanf(line,"%*[\r \t]%s",line);    line=reverse(line);    sscanf(line,"%s%*[ \t]%s",line,rest);    switch(line)
pike.git/lib/modules/Protocols.pmod/DNS.pmod:556:    "Can't resolv nameserver \"%s\"\n", host));    break;    }    }    if (sizeof(rest)) {    nameservers += ({ rest });    }    break;    }    } +  }    if(domain)    domains = ({ domain }) + domains;   #endif    nameservers -= ({ "" });    if (!sizeof(nameservers)) {    /* Try localhost... */    nameservers = ({ "127.0.0.1" });    }    domains -= ({ "" });    domains = Array.map(domains, lambda(string d) {