]> granicus.if.org Git - ejabberd/commitdiff
Use the 'host' option also for static_modules, instead of 'prefix'
authorBadlop <badlop@process-one.net>
Thu, 20 Oct 2011 09:13:36 +0000 (11:13 +0200)
committerBadlop <badlop@process-one.net>
Thu, 20 Oct 2011 09:13:36 +0000 (11:13 +0200)
doc/guide.tex
src/gen_mod.erl
src/mod_echo.erl
src/mod_muc/mod_muc.erl
src/mod_proxy65/mod_proxy65_service.erl
src/mod_pubsub/mod_pubsub.erl
src/mod_pubsub/mod_pubsub_odbc.erl
src/mod_vcard.erl
src/mod_vcard_ldap.erl

index e4d4c9264e18e0651e76723faa28065a9794b41d..0828693adbd99170b213a52856259f33b0278e9a 100644 (file)
 \newcommand{\iqdiscitem}[1]{\titem{\{iqdisc, Discipline\}} \ind{options!iqdisc}This specifies
 the processing discipline for #1 IQ queries (see section~\ref{modiqdiscoption}).}
 \newcommand{\hostitem}[1]{
-  \titem{\{host, HostName\} or \{prefix, PrefixName\}} \ind{options!host}
-  Those options define the Jabber ID of the service.
-  If no option is specified, the Jabber ID of the service will be the
+  \titem{\{host, HostName\}} \ind{options!host}
+  This option defines the Jabber ID of the service.
+  If the option is not specified, the Jabber ID of the service will be the
   hostname of the virtual host preceded with `\jid{#1.}'.
-  For more details see \ref{modhostoption} and \ref{modprefixoption}.
+  For more details see \ref{modhostoption}.
 }
 \newcommand{\backend}[1]{\titem{\{backend, mnesia|odbc\}} \ind{options!backend}
 Specify the backend used to store the tables: #1.
@@ -2628,7 +2628,7 @@ Examples:
  ]}.
 {static_modules,
  [
-  {mod_echo,      [{prefix, "echostatic"}]}
+  {mod_echo,      [{host, "echostatic.@HOST@"}]}
   {mod_time,      []},
   {mod_version,   []}
  ]}.
@@ -2768,15 +2768,14 @@ Example:
 \makesubsubsection{modhostoption}{\option{host}}
 \ind{options!host}
 
-This option defines the Jabber ID of a service provided by a dynamic \ejabberd{} module.
+This option defines the Jabber ID of a service provided by an \ejabberd{} module.
 
 The syntax is:
 \esyntax{\{host, HostName\}}
 
 If you include the keyword "@HOST@" in the HostName,
 it is replaced at start time with the real virtual host string.
-
-If the module is started statically, use the option \term{prefix} instead (see~\ref{modprefixoption}).
+If you configure the module to be started statically, then the keyword @HOST@ is mandatory.
 
 This example configures
 the \ind{modules!\modecho{}}echo module to provide its echoing service
@@ -2801,16 +2800,6 @@ the "@HOST@" keyword must be used:
  ]}.
 \end{verbatim}
 
-\makesubsubsection{modprefixoption}{\option{prefix}}
-\ind{options!prefix}
-
-This option defines the prefix that will be used to build the Jabber ID of a service provided by a static \ejabberd{} module.
-
-The syntax is:
-\esyntax{\{prefix, PrefixName\}}
-
-If the module is started dynamically, use the option \term{host} instead (see~\ref{modhostoption}).
-
 This example configures
 the \ind{modules!\modecho{}}echo module to provide its echoing service
 in Jabber IDs like
@@ -2820,7 +2809,7 @@ in Jabber IDs like
 {static_modules,
  [
   ...
-  {mod_echo, [{prefix, "mirror"}]},
+  {mod_echo, [{host, "mirror.@HOST@"}]},
   ...
  ]}.
 \end{verbatim}
index 28afc12ae6cc6603d58a401a2cbd0e09352251de..4d44928d9a1f4d013972b7b900fc43021d7d0545 100644 (file)
@@ -41,7 +41,6 @@
         get_hosts/2,
         get_module_proc/2,
         get_module_proc_existing/2,
-         expand_host_name/3,
         is_loaded/2]).
 
 -export([behaviour_info/1]).
@@ -211,8 +210,14 @@ get_module_opt_host(Host, Module, Default) ->
     re:replace(Val, "@HOST@", Host, [global,{return,list}]).
 
 get_opt_host(Host, Opts, Default) ->
-    Val = get_opt(host, Opts, Default),
-    re:replace(Val, "@HOST@", Host, [global,{return,list}]).
+    case Host of
+       global ->
+           Val = get_opt(host, Opts, Default),
+           {global, re:replace(Val, ".@HOST@", "", [global,{return,list}])};
+       Host ->
+           Val = get_opt(host, Opts, Default),
+           re:replace(Val, "@HOST@", Host, [global,{return,list}])
+    end.
 
 loaded_modules(Host) ->
     ets:select(ejabberd_modules,
@@ -290,12 +295,3 @@ get_module_proc(Host, Base) ->
 is_loaded(Host, Module) ->
     ets:member(ejabberd_modules, {Module, Host})
     orelse ets:member(ejabberd_modules, {Module, global}).
-
-expand_host_name(Host, Opts, DefaultPrefix) ->
-    case Host of
-        global ->
-            {global, gen_mod:get_opt(prefix, Opts, DefaultPrefix)};
-        _ ->
-            gen_mod:get_opt_host(Host, Opts, DefaultPrefix ++ ".@HOST@")
-    end.
-
index cb873ed64838f0a026ed95c6df06a27285073092..72ef834197f31463f0c40b7727947be548ce497c 100644 (file)
@@ -86,7 +86,7 @@ stop(Host) ->
 %% Description: Initiates the server
 %%--------------------------------------------------------------------
 init([Host, Opts]) ->
-    MyHost = gen_mod:expand_host_name(Host, Opts, "echo"),
+    MyHost = gen_mod:get_opt_host(Host, Opts, "echo.@HOST@"),
     ClientVersion = gen_mod:get_opt(client_version, Opts, false),
     ejabberd_router:register_route(MyHost),
     {ok, #state{host = MyHost, client_version = ClientVersion}}.
index b1f3f0dd5e3fb7a32e7204f60167b581ff925cad..afab036f58d5b3c22c1554b1734a332a683de2d6 100644 (file)
@@ -321,7 +321,7 @@ remove_host(MyHostB) when is_binary(MyHostB) ->
 %% Description: Initiates the server
 %%--------------------------------------------------------------------
 init([Host, Opts]) ->
-    MyHostStr = gen_mod:expand_host_name(Host, Opts, "conference"),
+    MyHostStr = gen_mod:get_opt_host(Host, Opts, "conference.@HOST@"),
     MyHost = l2b(MyHostStr),
     Backend = gen_mod:get_opt(backend, Opts, mnesia),
     gen_storage:create_table(Backend, MyHost, muc_room_opt,
index 31c96d8eba1322d671eb46cbfe839db1ea23cbc2..0cf2bea254edf333084e8a5d421925d8543030db 100644 (file)
@@ -222,7 +222,7 @@ iq_vcard(Lang) ->
        "\nCopyright (c) 2003-2011 ProcessOne")}]}].
 
 parse_options(ServerHost, Opts) ->
-    MyHost = gen_mod:expand_host_name(ServerHost, Opts, "proxy"),
+    MyHost = gen_mod:get_opt_host(ServerHost, Opts, "proxy.@HOST@"),
     Port = gen_mod:get_opt(port, Opts, 7777),
     ACL = gen_mod:get_opt(access, Opts, all),
     Name = gen_mod:get_opt(name, Opts, "SOCKS5 Bytestreams"),
index f621b59fd9b74823dde567a4f2d6ef5fa768c4be..bf5f59377b2af8544e0c15f75b95306cfee235b5 100644 (file)
@@ -203,7 +203,7 @@ stop(Host) ->
 
 init([ServerHost, Opts]) ->
     ?DEBUG("pubsub init ~p ~p",[ServerHost,Opts]),
-    Host = gen_mod:expand_host_name(ServerHost, Opts, "pubsub"),
+    Host = gen_mod:get_opt_host(ServerHost, Opts, "pubsub.@HOST@"),
     Access = gen_mod:get_opt('access_createnode', Opts, 'all'),
     PepOffline = gen_mod:get_opt('ignore_pep_from_offline', Opts, true),
     IQDisc = gen_mod:get_opt('iqdisc', Opts, 'one_queue'),
index 31cf229f492bc8087c23d43b70ab8200a13f9ae6..c485852efa30426b58757e76368115859e9ff857 100644 (file)
@@ -203,7 +203,7 @@ stop(Host) ->
 
 init([ServerHost, Opts]) ->
     ?DEBUG("pubsub init ~p ~p",[ServerHost,Opts]),
-    Host = gen_mod:expand_host_name(ServerHost, Opts, "pubsub"),
+    Host = gen_mod:get_opt_host(ServerHost, Opts, "pubsub.@HOST@"),
     Access = gen_mod:get_opt('access_createnode', Opts, 'all'),
     PepOffline = gen_mod:get_opt('ignore_pep_from_offline', Opts, true),
     IQDisc = gen_mod:get_opt('iqdisc', Opts, 'one_queue'),
index cbb11fa8a27220c5cf659cdd113678004629b7de..10ee85e881063d925c2cd09bff4c91b4aa20bee7 100644 (file)
@@ -148,7 +148,7 @@ start(HostB, Opts) ->
     gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_VCARD,
                                  ?MODULE, process_sm_iq, IQDisc),
     ejabberd_hooks:add(disco_sm_features, HostB, ?MODULE, get_sm_features, 50),
-    MyHost = gen_mod:expand_host_name(HostB, Opts, "vjud"),
+    MyHost = gen_mod:get_opt_host(HostB, Opts, "vjud.@HOST@"),
     Search = gen_mod:get_opt(search, Opts, true),
     register(gen_mod:get_module_proc(HostB, ?PROCNAME),
             spawn(?MODULE, init, [MyHost, HostB, Search])).
@@ -444,9 +444,8 @@ do_route(ServerHost, From, To, Packet) ->
                        Err = exmpp_iq:error(Packet, 'not-allowed'),
                        ejabberd_router:route(To, From, Err);
                    {get, ?NS_DISCO_INFO} ->
-                       ServerHostB = list_to_binary(ServerHost),
                        Info = ejabberd_hooks:run_fold(
-                                disco_info, ServerHostB, [],
+                                disco_info, ServerHost, [],
                                 [ServerHost, ?MODULE, <<>>, ""]),
                        Result = #xmlel{ns = ?NS_DISCO_INFO, name = 'query',
                          children = Info ++ [
index ee580085f51ae1fb70f7c9ff35b9d478b13ef3e6..61987d80b795962a3f70babb68fdff4412fcb95f 100644 (file)
@@ -650,7 +650,7 @@ find_xdata_el1([_ | Els]) ->
     find_xdata_el1(Els).
 
 parse_options(Host, Opts) ->
-    MyHost = gen_mod:expand_host_name(Host, Opts, "vjud"),
+    MyHost = gen_mod:get_opt_host(Host, Opts, "vjud.@HOST@"),
     Search = gen_mod:get_opt(search, Opts, true),
     Matches = case gen_mod:get_opt(matches, Opts, 30) of
                infinity  -> 0;