From 4ab052a475541033d058a6adb352b8e626695401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20R=C3=A9mond?= Date: Thu, 30 Nov 2006 13:39:05 +0000 Subject: * src/mod_proxy65/mod_proxy65_services.erl: We now try to get the address of the component (if registered in DNS) or otherwise get the IP of the XMPP domain. SVN Revision: 686 --- src/mod_proxy65/mod_proxy65_service.erl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mod_proxy65/mod_proxy65_service.erl b/src/mod_proxy65/mod_proxy65_service.erl index 473507fb3..e4e58bece 100644 --- a/src/mod_proxy65/mod_proxy65_service.erl +++ b/src/mod_proxy65/mod_proxy65_service.erl @@ -180,11 +180,9 @@ parse_options(ServerHost, Opts) -> ACL = gen_mod:get_opt(access, Opts, all), Name = gen_mod:get_opt(name, Opts, "SOCKS5 Bytestreams"), IP = case gen_mod:get_opt(ip, Opts, none) of - none -> - {0,0,0,0}; - Addr -> - Addr - end, + none -> get_proxy_or_domainip(ServerHost, MyHost); + Addr -> Addr + end, [_ | StrIP] = lists:append([[$. | integer_to_list(X)] || X <- inet:ip_to_bytes(IP)]), StreamAddr = [{"jid", MyHost}, {"host", StrIP}, {"port", integer_to_list(Port)}], {IP, #state{myhost = MyHost, @@ -193,3 +191,14 @@ parse_options(ServerHost, Opts) -> port = Port, stream_addr = StreamAddr, acl = ACL}}. + +%% Return the IP of the proxy host, or if not found, the ip of the xmpp domain +get_proxy_or_domainip(ServerHost, MyHost) -> + case inet:getaddr(MyHost, inet) of + {ok, Addr} -> Addr; + {error, _} -> + case inet:getaddr(ServerHost) of + {ok, Addr} -> Addr; + {error, _} -> {127,0,0,1} + end + end. \ No newline at end of file -- cgit v1.2.3