From d7829a76ce10ff6c5520f15d7ab23d5fe0623a25 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 27 Apr 2009 20:36:19 +0000 Subject: [PATCH] * src/win32_dns.erl: Fix problem parsing some win32 dns (EJAB-927) SVN Revision: 2043 --- ChangeLog | 2 ++ src/win32_dns.erl | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a13d0265a..f5c8adc2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2009-04-27 Badlop + * src/win32_dns.erl: Fix problem parsing some win32 dns (EJAB-927) + * src/cyrsasl_digest.erl: Fix auth verification (EJAB-863) * src/jlib.erl: Fix recursive call to speedup base64 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.