From 37ffea61191e752521822edfb33732f62596f099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Mon, 6 Apr 1998 20:52:30 -0700 Subject: [PATCH] modified to handle W95 (I hope) Rev: lib/modules/Protocols.pmod/DNS.pmod:1.12 --- lib/modules/Protocols.pmod/DNS.pmod | 84 ++++++++++++++++------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/lib/modules/Protocols.pmod/DNS.pmod b/lib/modules/Protocols.pmod/DNS.pmod index 334434a0dc..80eac245ac 100644 --- a/lib/modules/Protocols.pmod/DNS.pmod +++ b/lib/modules/Protocols.pmod/DNS.pmod @@ -220,44 +220,56 @@ class client { static private mapping etc_hosts; +#ifdef __NT__ + string get_tcpip_param(string val) + { + foreach(({ + "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", + "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP" + }),string key) + { + catch { + return RegGetValue(HKEY_LOCAL_MACHINE, key, value); + }; + } + } +#endif + static private string match_etc_hosts(string host) - { - if (!etc_hosts) { - string raw; + { + if (!etc_hosts) { + string raw; #ifdef __NT__ - raw = RegGetValue(HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", - "DataBasePath"); - raw+="\\hosts"; + raw=get_tcpip_param("DataBasePath")+"\\hosts"; #else - raw="/etc/hosts"; + 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) { - if (is_ip(arr[0])) { - foreach(arr[1..], string name) { - etc_hosts[name] = arr[0]; - } - } else { - // Bad /etc/hosts entry ignored. + 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) { + if (is_ip(arr[0])) { + foreach(arr[1..], string name) { + etc_hosts[name] = arr[0]; + } + } else { + // Bad /etc/hosts entry ignored. + } } } + } else { + // Couldn't read /etc/hosts. } - } else { - // Couldn't read /etc/hosts. } + return(etc_hosts[lower_case(host)]); } - return(etc_hosts[lower_case(host)]); - } array(string) nameservers = ({}); array domains = ({}); @@ -267,15 +279,11 @@ class client { { 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") / " "- ({""}); + + + domain=get_tcpip_param("Domain"); + nameservers = ({ get_tcpip_param("NameServer") }); + domains=get_tcpip_param("SearchList") / " "- ({""}); #else string resolv_conf = Stdio.read_file("/etc/resolv.conf"); -- GitLab