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:271:
return(etc_hosts[lower_case(host)]); } array(string) nameservers = ({}); array domains = ({}); void create(void|string|array(string) server, void|int|array(string) domain) { if(!server) { string domain;
-
#if __NT__
+
-
+
#if
__NT__
domain=get_tcpip_param("Domain"); nameservers = ({ get_tcpip_param("NameServer") }); 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
+
*/
throw(({ "Protocols.DNS.client(): No /etc/resolv.conf!\n", backtrace() })); } 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) { case "domain": // Save domain for later.
-
domain = rest;
+
domain =
sizeof(
rest
) && rest
;
break; case "search": rest = replace(rest, "\t", " ");
-
foreach
(rest
/
" " - ({""})
, string dom
)
-
domains += ({dom})
;
+
domains +=
(
(
rest/" "
)
- ({""}));
break; case "nameserver": if (!is_ip(rest)) { // Not an IP-number! string host = rest; if (!(rest = match_etc_hosts(host))) { werror(sprintf("Protocols.DNS.client(): " "Can't resolv nameserver \"%s\"\n", host)); break; } } if (sizeof(rest)) {
-
nameservers =
`+
(
nameservers, (
{ rest })
)
;
+
nameservers
+
= ({ rest });
} break; } } #endif if (!sizeof(nameservers)) {
-
+
/* Try localhost... */
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; });