25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

* src/win32_dns.erl: Fix problem parsing some win32 dns (EJAB-927)

SVN Revision: 2043
This commit is contained in:
Badlop 2009-04-27 20:36:19 +00:00
parent cabf128bbb
commit 709a536fb7
2 changed files with 19 additions and 2 deletions

View File

@ -1,5 +1,7 @@
2009-04-27 Badlop <badlop@process-one.net>
* 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

View File

@ -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.