25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

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
This commit is contained in:
Badlop 2009-03-09 14:44:46 +00:00
parent ed3cae6f11
commit 4dde341c9d
2 changed files with 19 additions and 17 deletions

View File

@ -1,3 +1,9 @@
2009-03-09 Badlop <badlop@process-one.net>
* 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 <badlop@process-one.net> 2009-03-07 Badlop <badlop@process-one.net>
* src/Makefile.in: In SunOS, use different C flags (thanks to * src/Makefile.in: In SunOS, use different C flags (thanks to

View File

@ -223,26 +223,22 @@ parse_options(ServerHost, Opts) ->
ACL = gen_mod:get_opt(access, Opts, all), ACL = gen_mod:get_opt(access, Opts, all),
Name = gen_mod:get_opt(name, Opts, "SOCKS5 Bytestreams"), Name = gen_mod:get_opt(name, Opts, "SOCKS5 Bytestreams"),
IP = case gen_mod:get_opt(ip, Opts, none) of IP = case gen_mod:get_opt(ip, Opts, none) of
none -> get_proxy_or_domainip(ServerHost, MyHost); none -> get_my_ip();
Addr -> Addr Addr -> Addr
end, end,
StrIP = inet_parse:ntoa(IP), StrIP = inet_parse:ntoa(IP),
StreamAddr = [?XMLATTR('jid', MyHost), ?XMLATTR('host', StrIP), ?XMLATTR('port', Port)], StreamAddr = [?XMLATTR('jid', MyHost), ?XMLATTR('host', StrIP), ?XMLATTR('port', Port)],
#state{myhost = MyHost, #state{myhost = MyHost,
serverhost = ServerHost, serverhost = ServerHost,
name = Name, name = Name,
port = Port, port = Port,
ip = IP, ip = IP,
stream_addr = StreamAddr, stream_addr = StreamAddr,
acl = ACL}. acl = ACL}.
%% Return the IP of the proxy host, or if not found, the ip of the xmpp domain get_my_ip() ->
get_proxy_or_domainip(ServerHost, MyHost) -> {ok, MyHostName} = inet:gethostname(),
case inet:getaddr(MyHost, inet) of case inet:getaddr(MyHostName, inet) of
{ok, Addr} -> Addr; {ok, Addr} -> Addr;
{error, _} -> {error, _} -> {127,0,0,1}
case inet:getaddr(ServerHost, inet) of
{ok, Addr} -> Addr;
{error, _} -> {127,0,0,1}
end
end. end.