pike.git
/
lib
/
modules
/
Protocols.pmod
/
DNS.pmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Protocols.pmod/DNS.pmod:216:
return(replace(ip, ({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "." }), ({ "", "", "", "", "", "", "", "", "", "", "" })) == ""); } static private mapping etc_hosts; static private string match_etc_hosts(string host) { if (!etc_hosts) {
-
string raw =
Stdio.read_file
("/etc/hosts");
+
string raw
;
+
#ifdef
__NT__
+
raw
=
RegGetValue(HKEY
_
LOCAL_MACHINE,
+
"
SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
+
"DataBasePath");
+
raw+="\\hosts";
+
#else
+
raw="
/etc/hosts"
;
+
#endif
+
raw = Stdio.read_file(raw
);
etc_hosts = ([ "localhost":"127.0.0.1" ]); if (raw) { foreach(raw/"\n", string line) { // Handle comments, and split the line on white-space line = lower_case(replace((line/"#")[0], "\t", " ")); array arr = (line/" ") - ({ "" }); if (sizeof(arr) > 1) {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:250:
return(etc_hosts[lower_case(host)]); } array(string) nameservers = ({}); array domains = ({}); void create(void|string server) { if(!server) { string domain;
+
#if __NT__
+
domain=RegGetValue(HKEY_LOCAL_MACHINE,
+
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
+
"Domain");
+
nameservers = ({ RegGetValue(HKEY_LOCAL_MACHINE,
+
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
+
"NameServer") });
+
domains=RegGetValue(HKEY_LOCAL_MACHINE,
+
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
+
"SearchList") / " "- ({""});
+
#else
string resolv_conf = Stdio.read_file("/etc/resolv.conf"); if (!resolv_conf) { throw(({ "Protocols.DNS.client(): No /etc/resolv.conf!\n", backtrace() })); } foreach(resolv_conf/"\n", string line) { string rest;
pike.git/lib/modules/Protocols.pmod/DNS.pmod:294:
"Can't resolv nameserver \"%s\"\n", host)); break; } } if (sizeof(rest)) { nameservers += ({ rest }); } break; } }
+
#endif
if (!sizeof(nameservers)) { nameservers = ({ "127.0.0.1" }); } if(domain) domains = ({ domain }) + domains; domains = Array.map(domains, lambda(string d) { if (d[-1] == '.') { return d[..sizeof(d)-2]; } return d;