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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:1: - // $Id: DNS.pmod,v 1.93 2008/01/31 13:08:59 grubba Exp $ + // $Id: DNS.pmod,v 1.94 2008/01/31 22:45:09 grubba Exp $   // Not yet finished -- Fredrik Hubinette      //! Domain Name System   //! RFC 1035      #pike __REAL_VERSION__      constant NOERROR=0;   constant FORMERR=1;   constant SERVFAIL=2;
pike.git/lib/modules/Protocols.pmod/DNS.pmod:593:      }         #define RETRIES 12   #define RETRY_DELAY 5      //! Synchronous DNS client.   class client   { -  +     inherit protocol;    -  static private int is_ip(string ip) -  { -  // FIXME: Doesn't work with IPv6 -  return (replace(ip, "0123456789."/1, allocate(11,"")) == ""); -  } -  +    #ifdef __NT__    array(string) get_tcpip_param(string val, void|string fallbackvalue)    {    array(string) res = ({});    foreach(({    "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",    "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP"    }),string key)    {    catch {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:633: Inside #if defined(__NT__) and #if constant(RegGetKeyNames)
   catch {    res += ({ RegGetValue(HKEY_LOCAL_MACHINE,    "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\"    "Parameters\\Interfaces\\" + key, val) });    };    }    };   #endif    return sizeof(res) ? res : ({ fallbackvalue });    } - #endif +     -  + #else /* !__NT__ */ +     static private mapping(string:string) etc_hosts;    -  +  static private int is_ip(string ip) +  { +  // FIXME: Doesn't work with IPv6 +  return (replace(ip, "0123456789."/1, allocate(11,"")) == ""); +  } +     static private string read_etc_file(string fname)    {    array(string) paths;    string res;   #ifdef __NT__    paths = get_tcpip_param("DataBasePath");   #else    paths = ({ "/etc", "/amitcp/db" });   #endif    foreach(paths, string path) {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:663:    }    res += raw;    } else {    res = raw;    }    }    }    return res;    }    - #ifndef __NT__ +     static private string match_etc_hosts(string host)    {    if (!etc_hosts) {    etc_hosts = ([ "localhost":"127.0.0.1" ]);       string raw = read_etc_file("hosts");       if (raw && sizeof(raw)) {    foreach(raw/"\n"-({""}), string line) {    // Handle comments, and split the line on white-space