diff options
author | Mickaël Rémond <mickael.remond@process-one.net> | 2006-11-30 13:39:05 +0000 |
---|---|---|
committer | Mickaël Rémond <mickael.remond@process-one.net> | 2006-11-30 13:39:05 +0000 |
commit | 4ab052a475541033d058a6adb352b8e626695401 (patch) | |
tree | e899f5eb8e3641780fc425e758ee4b108ca67e5f /src | |
parent | * Removed useless comments. (diff) |
* 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
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_proxy65/mod_proxy65_service.erl | 19 |
1 files changed, 14 insertions, 5 deletions
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 |