diff --git a/ChangeLog b/ChangeLog index e249f98c1..29faebc93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-05-22 Mickael Remond + + * src/ejabberd_sm.erl: The max_user_sessions has been moved to + host configuration. + * src/ejabberd.cfg.example: Likewise. + * doc/guide.tex: Likewise. + 2006-05-21 Mickael Remond * src/ejabberd_sm.erl: An option to limit the number of opened sessions diff --git a/doc/guide.html b/doc/guide.html index 6dedae731..cf24854e3 100644 --- a/doc/guide.html +++ b/doc/guide.html @@ -55,6 +55,106 @@ BLOCKQUOTE{margin-left:4ex;margin-right:4ex;text-align:left;}

Contents

+ @@ -506,9 +606,24 @@ To define a shaper named “normal” with traffic speed limite
   {shaper, fast, {maxrate, 50000}}.
 
+ + +

3.1.5  Limitation of the number of opened sessions

+ + + +This option specifies the maximum number of sessions (authenticated +connections) per user. If a user tries to open more than the maximum number of +allowed sessions, with different resources, the first opened session will be +disconnected. The error “session replaced” is send to the +disconnected session. This value is either a number or infinity. For +example {max\_user\_sessions, 10}. The default value is 10.
+
+This option can be define per virtual host. See section 3.1.8.
+
-

3.1.5  Listened Sockets

+

3.1.6  Listened Sockets

@@ -532,9 +647,9 @@ Currently next modules are implemented:   Options access, certfile, inet6, - ip, max_stanza_size, max_user_sessions, - shaper, ssl, tls, starttls, - starttls_required, zlib + ip, max_stanza_size, shaper, ssl, + tls, starttls, starttls_required, + zlib ejabberd_s2s_in Description @@ -595,19 +710,9 @@ If HTTP Polling is enabled, it will be available at
{max_stanza_size, Size}
This option specifies an approximate maximal size in bytes of XML stanzas. For example {max\_stanza\_size, 65536}. The default value - is “infinity”.
-
-
{max_user_sessions, Max}
This - option specifies the maximum number of sessions (authenticated - connections) per user. If a user tries to open more than the maximum - number of allowed sessions, with different resources, the first opened - session will be disconnected. The error “session replaced” is - send to the disconnected session. This value is either a number or - infinity. For example {max\_user\_sessions, 10}. The - default value is 10.
-
-
{shaper, <access rule>}
This option defines a - shaper for the port (see section ??). The default value + is “infinity”. +
{shaper, <access rule>}
This option defines a + shaper for the port (see section 3.1.4). The default value is “none”.
ssl
This option specifies that traffic on the port will be encrypted using SSL. You should also set the @@ -652,7 +757,7 @@ c2s connections are listened for on port 5222 and 5223 (SSL) and denied traffic enabled.
  • Port 5280 is serving the web interface and the HTTP Polling service. Note that it is also possible to serve them on different ports. The second - example in section ?? shows how exactly this can be done. + example in section 3.4.1 shows how exactly this can be done.
  • All users except for the administrators have a traffic of limit 1,000 Bytes/second
  • The @@ -740,14 +845,14 @@ services you have to make the transports log and do XDB by themselves: -

    3.1.6  Modules

    +

    3.1.7  Modules

    The option modules defines the list of modules that will be loaded after ejabberd's startup. Each entry in the list is a tuple in which the first element is the name of a module and the second is a list of options for that -module. Read section ?? for detailed information about modules.
    +module. Read section A for detailed information about modules.

    Examples:
    • @@ -769,7 +874,7 @@ In this simple example, only the module mod_echo is loaded and no
    -

    3.1.7  Virtual Hosting

    +

    3.1.8  Virtual Hosting

    @@ -809,7 +914,7 @@ Domain example.net is using the internal authentication method while -

    3.1.8  SASL anonymous and anonymous login

    +

    3.1.9  SASL anonymous and anonymous login

    @@ -833,7 +938,7 @@ very special cases. It defaults to false.
    enabled. Those options are defined for each virtual host with the host_config -parameter (see section ??).
    +parameter (see section 3.1.8).

    Examples:
    • @@ -865,12 +970,12 @@ available from:
      -

      3.2  Relational Database Support

      +

      3.2  Relational Database Support

      -

      3.2.1  Authentication against a relational database

      +

      3.2.1  Authentication against a relational database

      ejabberd use its internal Mnesia database as a default. It is however possible @@ -925,7 +1030,7 @@ available from: 3.2.2  Relational database for other modules +

      3.2.2  Relational database for other modules

      It is possible to use a relational database to store pieces of @@ -942,7 +1047,7 @@ Last connection date and time: Use mod_last_odbc instead of
    -

    3.3  Creating an Initial Administrator

    +

    3.3  Creating an Initial Administrator

    Before the web interface can be entered to perform administration tasks, an @@ -954,10 +1059,10 @@ Register an account on your ejabberd deployment. An account can be created in two ways:
    1. Using the tool ejabberdctl (see - section ??): + section 3.4.2):
       % ejabberdctl node@host register admin example.org password
      -
    2. Using In-Band Registration (see section ??): you can +
    3. Using In-Band Registration (see section A.14): you can use a Jabber client to register an account.
  • Edit the configuration file to promote the account created in the previous @@ -974,22 +1079,22 @@ Register an account on your ejabberd deployment. An account can be -

    3.4  Online Configuration and Monitoring

    +

    3.4  Online Configuration and Monitoring

    -

    3.4.1  Web Interface

    +

    3.4.1  Web Interface

    To perform online configuration of ejabberd you need to enable the ejabberd_http listener with the option web_admin (see -section ??). Then you can open +section 3.1.6). Then you can open http://server:port/admin/ in your favourite web browser. You will be asked to enter the username (the full Jabber ID) and password of an ejabberd user with administrator rights. After authentication -you will see a page similar to figure ??. +you will see a page similar to figure 1.

    @@ -1053,7 +1158,7 @@ You can serve the web interface on the same port as the -

    3.4.2  ejabberdctl

    +

    3.4.2  ejabberdctl

    It is possible to do some administration operations using the command @@ -1099,7 +1204,7 @@ Additional information: -

    4  Firewall Settings

    +

    4  Firewall Settings

    @@ -1119,16 +1224,16 @@ You need to take the following TCP ports in mind when configuring your firewall: s2s connections. 4369 -Only for clustering (see ??). +Only for clustering (see 6). port range -Only for clustring (see ??). This range - is configurable (see ??). +Only for clustring (see 6). This range + is configurable (see 2.4).

    -

    5  SRV Records

    +

    5  SRV Records

    @@ -1140,13 +1245,13 @@ General information: -

    6  Clustering

    +

    6  Clustering

    -

    6.1  How it Works

    +

    6.1  How it Works

    @@ -1167,7 +1272,7 @@ router, -

    6.1.1  Router

    +

    6.1.1  Router

    This module is the main router of Jabber packets on each node. It @@ -1178,7 +1283,7 @@ appropriate process. If not, it is sent to the s2s manager.

    -

    6.1.2  Local Router

    +

    6.1.2  Local Router

    This module routes packets which have a destination domain equal to @@ -1188,7 +1293,7 @@ on its content.

    -

    6.1.3  Session Manager

    +

    6.1.3  Session Manager

    This module routes packets to local users. It looks up to which user @@ -1198,7 +1303,7 @@ storage, or bounced back.

    -

    6.1.4  s2s Manager

    +

    6.1.4  s2s Manager

    This module routes packets to other Jabber servers. First, it @@ -1209,7 +1314,7 @@ serving this connection, otherwise a new connection is opened.

    -

    6.2  Clustering Setup

    +

    6.2  Clustering Setup

    @@ -1282,13 +1387,13 @@ domain.
    -

    A  Built-in Modules

    +

    A  Built-in Modules

    -

    A.1  Overview

    +

    A.1  Overview

    @@ -1500,7 +1605,7 @@ XMPP compliancy.

    -

    A.2  Common Options

    +

    A.2  Common Options

    The following options are used by many modules. Therefore, they are described in @@ -1508,7 +1613,7 @@ this separate section.

    -

    A.2.1  iqdisc

    +

    A.2.1  iqdisc

    @@ -1542,7 +1647,7 @@ Example: -

    A.2.2  hosts

    +

    A.2.2  hosts

    @@ -1581,7 +1686,7 @@ Serving the echo module on one domain: -

    A.3  mod_announce

    +

    A.3  mod_announce

    @@ -1597,7 +1702,7 @@ hosts: to several resources, only the resource with the highest priority will receive the message. If the registered user is not connected, the message will be stored offline in assumption that offline storage - (see section ??) is enabled. + (see section A.10) is enabled.
    example.org/announce/online (example.org/announce/all-hosts/online)
    The message is sent to all connected users. If the user is online and connected to several resources, all resources will receive the message. @@ -1647,7 +1752,7 @@ Only administrators can send announcements: -

    A.4  mod_disco

    +

    A.4  mod_disco

    @@ -1664,7 +1769,7 @@ Options: iqdisc
    This specifies the processing discipline for Service Discovery (http://jabber.org/protocol/disco#items and http://jabber.org/protocol/disco#info) IQ queries -(see section ??). +(see section A.2.1).
    extra_domains
    With this option, extra domains can be added to the Service Discovery item list. @@ -1699,7 +1804,7 @@ To serve a link to the Jabber User Directory on jabber.org: -

    A.5  mod_echo

    +

    A.5  mod_echo

    @@ -1711,7 +1816,7 @@ Options:
    hosts
    This option defines the hostnames of the - service (see section ??). If neither hosts nor + service (see section A.2.2). If neither hosts nor the old host is present, the prefix “echo.” is added to all ejabberd hostnames. @@ -1728,11 +1833,11 @@ Mirror, mirror, on the wall, who is the most beautiful ... ]}.
  • If you still do not understand the inner workings of mod_echo, - you can find a few more examples in section ??. + you can find a few more examples in section A.2.2. -

    A.6  mod_irc

    +

    A.6  mod_irc

    @@ -1761,7 +1866,7 @@ Options:
    hosts
    This option defines the hostnames of the - service (see section ??). If neither hosts nor + service (see section A.2.2). If neither hosts nor the old host is present, the prefix “irc.” is added to all ejabberd hostnames. @@ -1802,7 +1907,7 @@ In the first example, the IRC transport is available on (all) your -

    A.7  mod_last

    +

    A.7  mod_last

    @@ -1815,11 +1920,11 @@ Options:
    iqdisc
    This specifies the processing discipline for Last activity (jabber:iq:last) IQ queries -(see section ??). +(see section A.2.1).
    -

    A.8  mod_muc

    +

    A.8  mod_muc

    @@ -1839,7 +1944,7 @@ Options:
    hosts
    This option defines the hostnames of the - service (see section ??). If neither hosts nor + service (see section A.2.2). If neither hosts nor the old host is present, the prefix “conference.” is added to all ejabberd hostnames. @@ -1909,7 +2014,7 @@ In the first example everyone is allowed to use the Multi-User Chat -

    A.9  mod_muc_log

    +

    A.9  mod_muc_log

    @@ -1981,7 +2086,7 @@ Example configuration: -

    A.10  mod_offline

    +

    A.10  mod_offline

    @@ -1989,11 +2094,11 @@ This module implements offline message storage. This means that all messages sent to an offline user will be stored on the server until that user comes online again. Thus it is very similar to how email works. Note that ejabberdctl has a command to delete expired messages -(see section ??).
    +(see section 3.4.2).

    -

    A.11  mod_privacy

    +

    A.11  mod_privacy

    @@ -2024,11 +2129,11 @@ Options:
    iqdisc
    This specifies the processing discipline for Blocking Communication (jabber:iq:privacy) IQ queries -(see section ??). +(see section A.2.1).
    -

    A.12  mod_private

    +

    A.12  mod_private

    @@ -2043,11 +2148,11 @@ Options:
    iqdisc
    This specifies the processing discipline for Private XML Storage (jabber:iq:private) IQ queries -(see section ??). +(see section A.2.1).
    -

    A.13  mod_pubsub

    +

    A.13  mod_pubsub

    @@ -2077,7 +2182,7 @@ Options:
    hosts
    This option defines the hostnames of the - service (see section ??). If neither hosts nor + service (see section A.2.2). If neither hosts nor the old host is present, the prefix “pubsub.” is added to all ejabberd hostnames. @@ -2096,7 +2201,7 @@ Example: -

    A.14  mod_register

    +

    A.14  mod_register

    @@ -2115,7 +2220,7 @@ Options: restrictions by default).
    iqdisc
    This specifies the processing discipline for In-Band Registration (jabber:iq:register) IQ queries -(see section ??). +(see section A.2.1).
    Examples:
    • @@ -2153,7 +2258,7 @@ Next example prohibits the registration of too short account names and of
    -

    A.15  mod_roster

    +

    A.15  mod_roster

    @@ -2163,11 +2268,11 @@ Options:
    iqdisc
    This specifies the processing discipline for Roster Management (jabber:iq:roster) IQ queries -(see section ??). +(see section A.2.1).
    -

    A.16  mod_service_log

    +

    A.16  mod_service_log

    @@ -2207,7 +2312,7 @@ To log all end user packets to the Bandersnatch service running on -

    A.17  mod_shared_roster

    +

    A.17  mod_shared_roster

    @@ -2334,7 +2439,7 @@ Take the case of a computer club that wants all its members seeing each -

    A.18  mod_stats

    +

    A.18  mod_stats

    @@ -2350,7 +2455,7 @@ Options:
    iqdisc
    This specifies the processing discipline for Statistics Gathering (http://jabber.org/protocol/stats) IQ queries -(see section ??). +(see section A.2.1).
    As there are only a small amount of clients (for example Tkabber) and software libraries with @@ -2376,7 +2481,7 @@ You can request the number of online users on the current virtual host -

    A.19  mod_time

    +

    A.19  mod_time

    @@ -2387,11 +2492,11 @@ Options:
    iqdisc
    This specifies the processing discipline for Entity Time (jabber:iq:time) IQ queries -(see section ??). +(see section A.2.1).
    -

    A.20  mod_vcard

    +

    A.20  mod_vcard

    @@ -2404,13 +2509,13 @@ Options:
    hosts
    This option defines the hostnames of the - service (see section ??). If neither hosts nor + service (see section A.2.2). If neither hosts nor the old host is present, the prefix “vjud.” is added to all ejabberd hostnames.
    iqdisc
    This specifies the processing discipline for vcard-temp IQ queries -(see section ??). +(see section A.2.1).
    search
    This option specifies whether the search functionality is enabled (value: true) or disabled (value: false). If disabled, the option hosts will be @@ -2457,7 +2562,7 @@ In this first situation, search results are limited to twenty items, -

    A.21  mod_version

    +

    A.21  mod_version

    @@ -2468,16 +2573,16 @@ Options:
    iqdisc
    This specifies the processing discipline for Software Version (jabber:iq:version) IQ queries -(see section ??). +(see section A.2.1).
    -

    B  Internationalization and Localization

    +

    B  Internationalization and Localization

    All built-in modules support the xml:lang attribute inside IQ queries. -Figure ??, for example, shows the reply to the following query: +Figure 2, for example, shows the reply to the following query:
       <iq id='5'
           to='example.org'
    @@ -2499,7 +2604,7 @@ Figure ??, for example, shows the reply to the
      
     

    The web interface also supports the Accept-Language HTTP header (compare -figure ?? with figure ??) +figure 3 with figure 1)

    @@ -2515,13 +2620,13 @@ figure ?? with figure 
    -

    C  Release Notes

    +

    C  Release Notes

    -

    C.1  ejabberd 0.9

    +

    C.1  ejabberd 0.9

            Release notes
    @@ -2615,7 +2720,7 @@ Bugfixes
     
    -

    C.2  ejabberd 0.9.1

    +

    C.2  ejabberd 0.9.1

            Release notes
    @@ -2683,7 +2788,7 @@ Bugfixes
     
    -

    C.3  ejabberd 0.9.8

    +

    C.3  ejabberd 0.9.8

            Release notes
    @@ -2788,7 +2893,7 @@ END
     
    -

    C.4  ejabberd 1.0.0

    +

    C.4  ejabberd 1.0.0

            Release Notes
    @@ -2914,7 +3019,7 @@ END
     
    -

    C.5  ejabberd 1.1.0

    +

    C.5  ejabberd 1.1.0

         Release Notes
    @@ -3035,7 +3140,7 @@ END
     
    -

    C.6  ejabberd 1.1.1

    +

    C.6  ejabberd 1.1.1

         Release Notes
    @@ -3160,7 +3265,7 @@ END
     
    -

    D  Acknowledgements

    +

    D  Acknowledgements

    diff --git a/doc/guide.tex b/doc/guide.tex index 5e2bc1af4..3bf520849 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -505,6 +505,19 @@ Examples: \end{verbatim} \end{itemize} +\subsubsection{Limitation of the number of opened sessions} +\label{sec:configmaxsessions} +\ind{options!max\_user\_sessions} + +This option specifies the maximum number of sessions (authenticated +connections) per user. If a user tries to open more than the maximum number of +allowed sessions, with different resources, the first opened session will be +disconnected. The error ``\term{session replaced}'' is send to the +disconnected session. This value is either a number or \term{infinity}. For +example \verb|{max\_user\_sessions, 10}|. The default value is \term{10}. + +This option can be define per virtual host. See section~\ref{sec:configvirtualhost}. + \subsubsection{Listened Sockets} \label{sec:configlistened} \ind{options!listen} @@ -526,9 +539,9 @@ Currently next modules are implemented: \begin{tabular}{|l|l|p{87mm}|} \hline \texttt{ejabberd\_c2s}& Description& Handles c2s connections.\\ \cline{2-3} & Options& \texttt{access}, \texttt{certfile}, \texttt{inet6}, - \texttt{ip}, \texttt{max\_stanza\_size}, \texttt{max\_user\_sessions}, - \texttt{shaper}, \texttt{ssl}, \texttt{tls}, \texttt{starttls}, - \texttt{starttls\_required}, \texttt{zlib}\\ + \texttt{ip}, \texttt{max\_stanza\_size}, \texttt{shaper}, \texttt{ssl}, + \texttt{tls}, \texttt{starttls}, \texttt{starttls\_required}, + \texttt{zlib}\\ \hline \texttt{ejabberd\_s2s\_in}& Description& Handles incoming s2s connections.\\ \cline{2-3} & Options& \texttt{inet6}, \texttt{ip}, @@ -574,16 +587,6 @@ The following options are available: option specifies an approximate maximal size in bytes of XML stanzas. For example \verb|{max\_stanza\_size, 65536}|. The default value is ``\term{infinity}''. - - \titem{\{max\_user\_sessions, Max\}} \ind{options!max\_user\_sessions}This - option specifies the maximum number of sessions (authenticated - connections) per user. If a user tries to open more than the maximum - number of allowed sessions, with different resources, the first opened - session will be disconnected. The error ``\term{session replaced}'' is - send to the disconnected session. This value is either a number or - \term{infinity}. For example \verb|{max\_user\_sessions, 10}|. The - default value is \term{10}. - \titem{\{shaper, \}} \ind{options!shaper}This option defines a shaper for the port (see section~\ref{sec:configshaper}). The default value is ``\term{none}''. diff --git a/src/ejabberd.cfg.example b/src/ejabberd.cfg.example index 9b894de13..e8ef5a4c5 100644 --- a/src/ejabberd.cfg.example +++ b/src/ejabberd.cfg.example @@ -97,6 +97,9 @@ % Host name: {hosts, ["localhost"]}. +%% Define the maximum number of time a single user is allowed to connect: +{max_user_sessions, 10}. + %% Anonymous login support: %% auth_method: anonymous %% anonymous_protocol: sasl_anon|login_anon|both @@ -114,7 +117,6 @@ {listen, [{5222, ejabberd_c2s, [{access, c2s}, {shaper, c2s_shaper}, {max_stanza_size, 65536}, - {max_user_sessions, 10}, starttls, {certfile, "./ssl.pem"}]}, {5223, ejabberd_c2s, [{access, c2s}, {max_stanza_size, 65536}, diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 4e82e5632..ec985f5b0 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -43,7 +43,7 @@ -record(state, {}). %% default value for the maximum number of user connections --define(MAX_USER_SESSIONS, 10). +-define(MAX_USER_SESSIONS, infinity). %%==================================================================== %% API @@ -534,7 +534,7 @@ check_max_sessions(LUser, LServer) -> SIDs = mnesia:dirty_select( session, [{#session{sid = '$1', usr = {LUser, LServer, '_'}, _ = '_'}, [], ['$1']}]), - MaxSessions = get_max_user_sessions(), + MaxSessions = get_max_user_sessions(LServer), if length(SIDs) =< MaxSessions -> ok; true -> {_, Pid} = lists:min(SIDs), Pid ! replaced @@ -544,21 +544,11 @@ check_max_sessions(LUser, LServer) -> %% Get the user_max_session setting %% This option defines the max number of time a given users are allowed to %% log in -%% This option is only used on c2s connections -%% Defaults to 10 -%% Can be set to infinity -get_max_user_sessions() -> - case ejabberd_config:get_local_option(listen) of +%% Defaults to infinity +get_max_user_sessions(Host) -> + case ejabberd_config:get_local_option({max_user_sessions, Host}) of undefined -> ?MAX_USER_SESSIONS; - Listeners -> - case lists:keysearch(ejabberd_c2s, 2, Listeners) of - {value, {_Port, _Method, Opts}} -> - case lists:keysearch(max_user_sessions, 1, Opts) of - {value, {_, Max}} -> Max; - _ -> ?MAX_USER_SESSIONS - end; - _ -> ?MAX_USER_SESSIONS - end + Max -> Max end.