From 3b67e90a16b04c6dbfa7332f513a5b5a455df3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Mon, 26 Jan 1998 19:28:08 +0100 Subject: [PATCH] Fixed several bugs. Rev: lib/modules/Protocols.pmod/DNS.pmod:1.10 --- lib/modules/Protocols.pmod/DNS.pmod | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/modules/Protocols.pmod/DNS.pmod b/lib/modules/Protocols.pmod/DNS.pmod index 1a29643032..2766fe8b9e 100644 --- a/lib/modules/Protocols.pmod/DNS.pmod +++ b/lib/modules/Protocols.pmod/DNS.pmod @@ -213,9 +213,9 @@ class client { static private int is_ip(string ip) { - return(replace(rest, + return(replace(ip, ({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "." }), - ({ "", "", "", "", "", "", "", "", ""; "", "" })) == ""); + ({ "", "", "", "", "", "", "", "", "", "", "" })) == ""); } static private mapping etc_hosts; @@ -225,17 +225,17 @@ class client { if (!etc_hosts) { string raw = Stdio.read_file("/etc/hosts"); - etc_hosts = ([ "localhost", "127.0.0.1" ]); + etc_hosts = ([ "localhost":"127.0.0.1" ]); if (raw) { foreach(raw/"\n", string line) { // Handle comments, and split the line on white-space - line = replace((line/"#")[0], "\t", " "); + line = lower_case(replace((line/"#")[0], "\t", " ")); array arr = (line/" ") - ({ "" }); if (sizeof(arr) > 1) { if (is_ip(arr[0])) { - foreach(arr[1..], name) { + foreach(arr[1..], string name) { etc_hosts[name] = arr[0]; } } else { @@ -247,7 +247,7 @@ class client { // Couldn't read /etc/hosts. } } - return(etc_hosts[host]); + return(etc_hosts[lower_case(host)]); } array(string) nameservers = ({}); @@ -306,6 +306,12 @@ class client { } if(domain) domains = ({ domain }) + domains; + domains = Array.map(domains, lambda(string d) { + if (d[-1] == '.') { + return d[..sizeof(d)-2]; + } + return d; + }); } else { nameservers= ({ server }); } -- GitLab