diff --git a/doc/guide.tex b/doc/guide.tex index e4d4c9264..0828693ad 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -112,11 +112,11 @@ \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} diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 28afc12ae..4d44928d9 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -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. - diff --git a/src/mod_echo.erl b/src/mod_echo.erl index cb873ed64..72ef83419 100644 --- a/src/mod_echo.erl +++ b/src/mod_echo.erl @@ -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}}. diff --git a/src/mod_muc/mod_muc.erl b/src/mod_muc/mod_muc.erl index b1f3f0dd5..afab036f5 100644 --- a/src/mod_muc/mod_muc.erl +++ b/src/mod_muc/mod_muc.erl @@ -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, diff --git a/src/mod_proxy65/mod_proxy65_service.erl b/src/mod_proxy65/mod_proxy65_service.erl index 31c96d8eb..0cf2bea25 100644 --- a/src/mod_proxy65/mod_proxy65_service.erl +++ b/src/mod_proxy65/mod_proxy65_service.erl @@ -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"), diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index f621b59fd..bf5f59377 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -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'), diff --git a/src/mod_pubsub/mod_pubsub_odbc.erl b/src/mod_pubsub/mod_pubsub_odbc.erl index 31cf229f4..c485852ef 100644 --- a/src/mod_pubsub/mod_pubsub_odbc.erl +++ b/src/mod_pubsub/mod_pubsub_odbc.erl @@ -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'), diff --git a/src/mod_vcard.erl b/src/mod_vcard.erl index cbb11fa8a..10ee85e88 100644 --- a/src/mod_vcard.erl +++ b/src/mod_vcard.erl @@ -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 ++ [ diff --git a/src/mod_vcard_ldap.erl b/src/mod_vcard_ldap.erl index ee580085f..61987d80b 100644 --- a/src/mod_vcard_ldap.erl +++ b/src/mod_vcard_ldap.erl @@ -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;