aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/mod_proxy65/mod_proxy65_service.erl19
2 files changed, 20 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ac7bd4a1..1d24c8c39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-30 Mickael Remond <mickael.remond@process-one.net>
+
+ * 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.
+
2006-11-29 Mickael Remond <mickael.remond@process-one.net>
* src/ejabberd_logger_h.erl: Removed useless comments.
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