From: Badlop Date: Mon, 9 Mar 2009 14:44:46 +0000 (+0000) Subject: Merge 1925 from trunk. X-Git-Tag: v2.0.5~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=10b22b52ef616ca06bd85e5fdc027f1debcfbd8c;p=ejabberd Merge 1925 from trunk. * src/mod_proxy65/mod_proxy65_service.erl: if an ip option is not defined, the module takes an IP address of a local hostname (thanks to Evgeniy Khramtsov) SVN Revision: 1978 --- diff --git a/ChangeLog b/ChangeLog index a6fab3410..e708a69e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-03-09 Badlop + + * src/mod_proxy65/mod_proxy65_service.erl: if an ip option is not + defined, the module takes an IP address of a local + hostname (thanks to Evgeniy Khramtsov) + 2009-03-07 Badlop * src/ejabberd_c2s.erl: Enforce privacy rules also for diff --git a/src/mod_proxy65/mod_proxy65_service.erl b/src/mod_proxy65/mod_proxy65_service.erl index ff05ad327..1e1815092 100644 --- a/src/mod_proxy65/mod_proxy65_service.erl +++ b/src/mod_proxy65/mod_proxy65_service.erl @@ -197,9 +197,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 -> get_proxy_or_domainip(ServerHost, MyHost); - Addr -> Addr - end, + none -> get_my_ip(); + Addr -> Addr + end, StrIP = inet_parse:ntoa(IP), StreamAddr = [{"jid", MyHost}, {"host", StrIP}, {"port", integer_to_list(Port)}], {IP, #state{myhost = MyHost, @@ -209,13 +209,9 @@ parse_options(ServerHost, Opts) -> 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 +get_my_ip() -> + {ok, MyHostName} = inet:gethostname(), + case inet:getaddr(MyHostName, inet) of {ok, Addr} -> Addr; - {error, _} -> - case inet:getaddr(ServerHost, inet) of - {ok, Addr} -> Addr; - {error, _} -> {127,0,0,1} - end + {error, _} -> {127,0,0,1} end.