]> granicus.if.org Git - ejabberd/commitdiff
* src/mod_proxy65/mod_proxy65_service.erl: if an ip option is not defined, the module...
authorEvgeniy Khramtsov <xramtsov@gmail.com>
Fri, 27 Feb 2009 03:22:40 +0000 (03:22 +0000)
committerEvgeniy Khramtsov <xramtsov@gmail.com>
Fri, 27 Feb 2009 03:22:40 +0000 (03:22 +0000)
SVN Revision: 1925

ChangeLog
src/mod_proxy65/mod_proxy65_service.erl

index 323f1814e38b7a6e70c5cbaedac42c9336f3c54b..f5c73dde06368f2fc9635f476b6ab0c767f0617d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-02-27  Evgeniy Khramtsov <ekhramtsov@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.
+
 2009-02-26  Badlop  <badlop@process-one.net>
 
        * doc/guide.tex: No mention to the release date in ejabberd Guide
index ee11e3db05eccf4ae19333cff7ddff8ce236b655..901b5261c6973ae026317ae4177cd9d01637952c 100644 (file)
@@ -215,26 +215,22 @@ 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)}],
     #state{myhost      = MyHost,
-               serverhost  = ServerHost,
-               name        = Name,
-               port        = Port,
-               ip          = IP,
-               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
+          serverhost  = ServerHost,
+          name        = Name,
+          port        = Port,
+          ip          = IP,
+          stream_addr = StreamAddr, 
+          acl         = ACL}.
+
+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.