aboutsummaryrefslogtreecommitdiff
path: root/src/win32_dns.erl
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2009-04-27 20:36:19 +0000
committerBadlop <badlop@process-one.net>2009-04-27 20:36:19 +0000
commit709a536fb7d1534e2ed3aa0960a39f38690591c0 (patch)
treec20522da61e29273e0a9b526f84b06535fcf288c /src/win32_dns.erl
parent* src/cyrsasl_digest.erl: Fix auth verification (EJAB-863) (diff)
* src/win32_dns.erl: Fix problem parsing some win32 dns (EJAB-927)
SVN Revision: 2043
Diffstat (limited to '')
-rw-r--r--src/win32_dns.erl19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/win32_dns.erl b/src/win32_dns.erl
index 79725cbab..6d1bbca00 100644
--- a/src/win32_dns.erl
+++ b/src/win32_dns.erl
@@ -27,6 +27,8 @@
-module(win32_dns).
-export([get_nameservers/0]).
+-include("ejabberd.hrl").
+
-define(IF_KEY, "\\hklm\\system\\CurrentControlSet\\Services\\TcpIp\\Parameters\\Interfaces").
-define(TOP_KEY, "\\hklm\\system\\CurrentControlSet\\Services\\TcpIp\\Parameters").
@@ -54,14 +56,27 @@ config_keys(R, Key) ->
ok = win32reg:change_key(R, Key),
[ {K,
case win32reg:value(R, K) of
- {ok, V} -> translate(K, V);
+ {ok, V} -> try_translate(K, V);
_ -> undefined
end
} || K <- ["Domain", "DhcpDomain",
"NameServer", "DhcpNameServer", "SearchList"]].
+try_translate(K, V) ->
+ try translate(K, V) of
+ Res ->
+ Res
+ catch
+ A:B ->
+ ?ERROR_MSG("Error '~p' translating Win32 registry~n"
+ "K: ~p~nV: ~p~nError: ~p", [A, K, V, B]),
+ undefined
+ end.
+
translate(NS, V) when NS =:= "NameServer"; NS =:= "DhcpNameServer" ->
- IPsStrings = [string:tokens(IP, ".") || IP <- string:tokens(V, ",")],
+ %% The IPs may be separated by commas ',' or by spaces " "
+ %% The parts of an IP are separated by dots '.'
+ IPsStrings = [string:tokens(IP, ".") || IP <- string:tokens(V, " ,")],
[ list_to_tuple([list_to_integer(String) || String <- IpStrings])
|| IpStrings <- IPsStrings];
translate(_, V) -> V.