diff --git a/Makefile.in b/Makefile.in index 06788a176..75bbcac19 100644 --- a/Makefile.in +++ b/Makefile.in @@ -109,9 +109,9 @@ install: all # # Configuration files $(INSTALL) -d -m 750 $(G_USER) $(ETCDIR) - [ -f $(ETCDIR)/ejabberd.cfg ] \ - && $(INSTALL) -b -m 640 $(G_USER) ejabberd.cfg.example $(ETCDIR)/ejabberd.cfg-new \ - || $(INSTALL) -b -m 640 $(G_USER) ejabberd.cfg.example $(ETCDIR)/ejabberd.cfg + [ -f $(ETCDIR)/ejabberd.yml ] \ + && $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml-new \ + || $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml $(SED) -e "s*{{rootdir}}*@prefix@*" \ -e "s*{{installuser}}*@INSTALLUSER@*" \ -e "s*{{libdir}}*@libdir@*" \ @@ -120,9 +120,9 @@ install: all -e "s*{{docdir}}*@docdir@*" \ -e "s*{{erl}}*@ERL@*" ejabberdctl.template \ > ejabberdctl.example - [ -f $(ETCDIR)/ejabberdctl.cfg ] \ - && $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg-new \ - || $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg + [ -f $(ETCDIR)/ejabberdctl.yml ] \ + && $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.yml.example $(ETCDIR)/ejabberdctl.yml-new \ + || $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.yml.example $(ETCDIR)/ejabberdctl.yml $(INSTALL) -b -m 644 $(G_USER) inetrc $(ETCDIR)/inetrc # # Administration script diff --git a/README b/README index 2d084603e..d6b95bcda 100644 --- a/README +++ b/README @@ -9,6 +9,7 @@ To compile ejabberd you need: - GNU Make - GCC - Libexpat 1.95 or higher + - Libyaml 1.4 or higher - Erlang/OTP R15B or higher. - OpenSSL 0.9.8 or higher, for STARTTLS, SASL and SSL encryption. - Zlib 1.2.3 or higher, for Stream Compression support diff --git a/doc/guide.html b/doc/guide.html index c9827def0..9e956f18f 100644 --- a/doc/guide.html +++ b/doc/guide.html @@ -6,7 +6,7 @@ - ejabberd 2.1.12 + ejabberd Installation and Operation Guide @@ -76,7 +76,7 @@ BLOCKQUOTE.figure DIV.center DIV.center HR{display:none;}


- +
ejabberd 2.1.12
ejabberd
 
Installation and Operation Guide

@@ -116,111 +116,109 @@ BLOCKQUOTE.figure DIV.center DIV.center HR{display:none;} -
  • Chapter 4  Managing an ejabberd Server +
  • Chapter 4  Managing an ejabberd Server -
  • Chapter 5  Securing ejabberd +
  • Chapter 5  Securing ejabberd -
  • Chapter 6  Clustering +
  • Chapter 6  Clustering -
  • Chapter 7  Debugging +
  • Chapter 7  Debugging -
  • Appendix A  Internationalization and Localization -
  • Appendix B  Release Notes -
  • Appendix C  Acknowledgements -
  • Appendix D  Copyright Information +
  • Appendix A  Internationalization and Localization +
  • Appendix B  Release Notes +
  • Appendix C  Acknowledgements +
  • Appendix D  Copyright Information
  • Chapter 1  Introduction

    ejabberd is a free and open source instant messaging server written in Erlang/OTP.

    ejabberd is cross-platform, distributed, fault-tolerant, and based on open standards to achieve real-time communication.

    ejabberd is designed to be a rock-solid and feature rich XMPP server.

    ejabberd is suitable for small deployments, whether they need to be scalable or not, as well as extremely big deployments.

    @@ -308,7 +306,10 @@ copy ejabberd.init from the ’bin’ directory to something Create a system user called ejabberd, give it write access to the directories database/ and logs/, and set that as home; the script will start the server with that user. -Then you can call /etc/inid.d/ejabberd start as root to start the server.

    If ejabberd doesn’t start correctly in Windows, +Then you can call /etc/inid.d/ejabberd start as root to start the server.

    When ejabberd is started, the processes that are started in the system +are beam or beam.smp, and also epmd. +In Microsoft Windows, the processes are erl.exe and epmd.exe. +For more information regarding epmd consult the section 5.2.

    If ejabberd doesn’t start correctly in Windows, try to start it using the shortcut in desktop or start menu. If the window shows error 14001, the solution is to install: "Microsoft Visual C++ 2005 SP1 Redistributable Package". @@ -348,22 +349,20 @@ as long as your system have all the dependencies.

  • GCC
  • Libexpat 1.95 or higher -
  • Erlang/OTP R10B-9 or higher. The recommended versions are R13B04 and R14B04. -Don’t use R14A or R14B because they have a bug. +
  • Erlang/OTP R15B or higher. +
  • Libyaml 1.4 or higher
  • OpenSSL 0.9.8 or higher, for STARTTLS, SASL and SSL encryption.
  • Zlib 1.2.3 or higher, for Stream Compression support (XEP-0138). Optional. -
  • Erlang mysql library. Optional. For MySQL authentication or storage. See section 3.2.1. -
  • Erlang pgsql library. Optional. For PostgreSQL authentication or storage. See section 3.2.3. -
  • PAM library. Optional. For Pluggable Authentication Modules (PAM). See section 3.1.4. +
  • PAM library. Optional. For Pluggable Authentication Modules (PAM). See section 3.1.5.
  • GNU Iconv 1.8 or higher, for the IRC Transport (mod_irc). Optional. Not needed on systems with GNU Libc. See section 3.3.8. -
  • ImageMagick’s Convert program. Optional. For CAPTCHA challenges. See section 3.1.8. +
  • ImageMagick’s Convert program. Optional. For CAPTCHA challenges. See section 3.1.9.
  • exmpp 0.9.6 or higher. Optional. For import/export user data with XEP-0227 XML files.
  • 2.4.2  Download Source Code

    Released versions of ejabberd are available in the ProcessOne ejabberd downloads page: http://www.process-one.net/en/ejabberd/downloads

    Alternatively, the latest development source code can be retrieved from the Git repository using the commands: -

    git clone git://git.process-one.net/ejabberd/mainline.git ejabberd
    +

    git clone git://github.com/processone/ejabberd.git ejabberd
     cd ejabberd
     git checkout -b 2.1.x origin/2.1.x
     

    @@ -388,15 +387,21 @@ To get the full list run the command: before running make install. This account doesn’t need an explicit HOME directory, because /var/lib/ejabberd/ will be used by default.

    --enable-pam
    - Enable the PAM authentication method (see section 3.1.4).

    --enable-odbc or --enable-mssql
    + Enable the PAM authentication method (see section 3.1.5).

    --enable-mssql
    Required if you want to use an external database. - See section 3.2 for more information.

    --enable-full-xml
    + See section 3.2 for more information.
    --enable-tools
    +Enable the use of development tools.
    --enable-mysql
    +Enable MySQL support (see section 3.2.1).
    --enable-pgsql
    +Enable PostgreSQL support (see section 3.2.1).
    --enable-zlib
    +Enable Stream Compression (XEP-0138) using zlib.
    --enable-stun
    +Enable STUN support (see section 3.1.10).
    --enable-iconv
    +Enable iconv support. This is needed for mod_irc (see seciont 3.3.8).
    --enable-debug
    +Compile with +debug_info enabled.

    --enable-full-xml
    Enable the use of XML based optimisations. It will for example use CDATA to escape characters in the XMPP stream. Use this option only if you are sure your XMPP clients include a fully compliant XML parser.

    --disable-transient-supervisors
    Disable the use of Erlang/OTP supervision for transient processes.

    --enable-nif
    Replaces some critical Erlang functions with equivalents written in C to improve performance. -This feature requires Erlang/OTP R13B04 or higher.

    2.4.4  Install

    To install ejabberd in the destination directories, run the command: @@ -406,7 +411,7 @@ to install ejabberd.

    The files and directories created are, by de

    /etc/ejabberd/
    Configuration directory:
    - ejabberd.cfg
    ejabberd configuration file + ejabberd.yml
    ejabberd configuration file
    ejabberdctl.cfg
    Configuration file of the administration script
    inetrc
    Network DNS configuration file
    @@ -511,7 +516,7 @@ variable.
  • While in the directory ejabberd\src run:
    configure.bat
     nmake -f Makefile.win32
    -
  • Edit the file ejabberd\src\ejabberd.cfg and run +
  • Edit the file ejabberd\src\ejabberd.yml and run
    werl -s ejabberd -name ejabberd
     
  • 2.5  Create an XMPP Account for Administration

    You need an XMPP account and grant him administrative privileges @@ -525,8 +530,13 @@ Using ejabberdctl (see section 4.1):

  • Using an XMPP client and In-Band Registration (see section 3.3.19).
  • Edit the ejabberd configuration file to give administration rights to the XMPP account you created: -
    {acl, admin, {user, "admin1", "example.org"}}.
    -{access, configure, [{allow, admin}]}.
    +
    acl:
    +  admin:
    +    user:
    +      - "admin1": "example.org"
    +access:
    +  configure:
    +    admin: allow
     
    You can grant administrative privileges to many XMPP accounts, and also to accounts in other XMPP servers.
  • Restart ejabberd to load the new configuration. @@ -544,119 +554,157 @@ check if the release notes of the new ejabberd version indicates you need to also update those tables.

    Chapter 3  Configuring ejabberd

    -

    3.1  Basic Configuration

    The configuration file will be loaded the first time you start ejabberd. The -content from this file will be parsed and stored in the internal ejabberd database. Subsequently the -configuration will be loaded from the database and any commands in the -configuration file are appended to the entries in the database.

    Note that ejabberd never edits the configuration file. -So, the configuration changes done using the Web Admin -are stored in the database, but are not reflected in the configuration file. -If you want those changes to be use after ejabberd restart, you can either -edit the configuration file, or remove all its content.

    The configuration file contains a sequence of Erlang terms. Lines beginning with a -‘%’ sign are ignored. Each term is a tuple of which the first element is -the name of an option, and any further elements are that option’s values. If the -configuration file do not contain for instance the ‘hosts’ option, the old -host name(s) stored in the database will be used.

    You can override the old values stored in the database by adding next lines to -the beginning of the configuration file: -

    override_global.
    -override_local.
    -override_acls.
    -

    With these lines the old global options (shared between all ejabberd nodes in a -cluster), local options (which are specific for this particular ejabberd node) -and ACLs will be removed before new ones are added.

    -

    3.1.1  Host Names

    +

    3.1  Basic Configuration

    The configuration file will be loaded the first time you start ejabberd. +The configuration file name MUST have “.yml” extension. This helps ejabberd +to differentiate between the new and legacy file formats (see section 3.1.1).

    Note that ejabberd never edits the configuration file.

    The configuration file is written in +YAML. +However, different scalars are treated as different types: +

    +

    3.1.1  Legacy Configuration File

    +In previous ejabberd version the configuration file should be written +in Erlang terms. The format is still supported, but it is highly recommended +to convert it to the new YAML format using convert_to_yaml command +from ejabberdctl (see 4.1 for details).

    +

    3.1.2  Host Names

    The option hosts defines a list containing one or more domains that ejabberd will serve.

    The syntax is: -

    {hosts, [HostName, ...]}.

    Examples: +

    [HostName]

    Examples:

    -

    3.1.2  Virtual Hosting

    +

    3.1.3  Virtual Hosting

    Options can be defined separately for every virtual host using the host_config option.

    The syntax is: -

    {host_config, HostName, [Option, ...]}

    Examples: +

    {HostName: [Option, ...]}

    Examples:

    To define specific ejabberd modules in a virtual host, you can define the global modules option with the common modules, and later add specific modules to certain virtual hosts. -To accomplish that, instead of defining each option in host_config with the general syntax -

    {OptionName, OptionValue}

    -use this syntax: -

    {{add, OptionName}, OptionValue}

    In this example three virtual hosts have some similar modules, but there are also +To accomplish that, instead of defining each option in host_config +use append_host_config with the same syntax.

    In this example three virtual hosts have some similar modules, but there are also other different modules for some specific virtual hosts: -

    %% This ejabberd server has three vhosts:
    -{hosts, ["one.example.org", "two.example.org", "three.example.org"]}.
    +

    ## This ejabberd server has three vhosts:
    +hosts:
    +  - "one.example.org"
    +  - "two.example.org"
    +  - "three.example.org"
     
    -%% Configuration of modules that are common to all vhosts
    -{modules,
    - [
    -  {mod_roster,     []},
    -  {mod_configure,  []},
    -  {mod_disco,      []},
    -  {mod_private,    []},
    -  {mod_time,       []},
    -  {mod_last,       []},
    -  {mod_version,    []}
    - ]}.
    +## Configuration of modules that are common to all vhosts
    +modules:
    +  mod_roster:    {}
    +  mod_configure: {}
    +  mod_disco:     {}
    +  mod_private:   {}
    +  mod_time:      {}
    +  mod_last:      {}
    +  mod_version:   {}
     
    -%% Add some modules to vhost one:
    -{host_config, "one.example.org",
    - [{{add, modules}, [
    -                    {mod_echo,       [{host, "echo-service.one.example.org"}]}
    -                    {mod_http_bind,  []},
    -                    {mod_logxml,     []}
    -                   ]
    -  }
    - ]}.
    +## Add some modules to vhost one:
    +append_host_config:
    +  "one.example.org":
    +    modules:
    +      mod_echo:
    +        host: "echo-service.one.example.org"
    +      mod_http_bind: {}
    +      mod_logxml: {}
     
    -%% Add a module just to vhost two:
    -{host_config, "two.example.org",
    - [{{add, modules}, [
    -                    {mod_echo,       [{host, "mirror.two.example.org"}]}
    -                   ]
    -  }
    - ]}.
    +## Add a module just to vhost two:
    +append_host_config:
    +  "two.example.org":
    +    modules:
    +      mod_echo:
    +        host: "mirror.two.example.org"
     

    -

    3.1.3  Listening Ports

    +

    3.1.4  Listening Ports

    The option listen defines for which ports, addresses and network protocols ejabberd -will listen and what services will be run on them. Each element of the list is a -tuple with the following elements: +will listen and what services will be run on them. Each element of the list is an +associative array with the following elements:

    The option syntax is: -

    {listen, [Listener, ...]}.

    To define a listener there are several syntax. -

    {PortNumber, Module, [Option, ...]}
    {{PortNumber, IPaddress}, Module, [Option, ...]}
    {{PortNumber, TransportProtocol}, Module, [Option, ...]}
    {{PortNumber, IPaddress, TransportProtocol}, Module, [Option, ...]}

    +

    [Listener, ...]

    +Example: +

    listen:
    +  -
    +    port: 5222
    +    module: ejabberd_c2s
    +    starttls: true
    +    certfile: "/path/to/certfile.pem"
    +  -
    +    port: 5269
    +    module: ejabberd_s2s_in
    +    transport: tcp
    +

    Port Number, IP Address and Transport Protocol

    The port number defines which port to listen for incoming connections. It can be a Jabber/XMPP standard port -(see section 5.1) or any other valid port number.

    The IP address can be represented with a string -or an Erlang tuple with decimal or hexadecimal numbers. +(see section 5.1) or any other valid port number.

    The IP address can be represented as a string. The socket will listen only in that network interface. It is possible to specify a generic address, so ejabberd will listen in all addresses. @@ -667,9 +715,6 @@ When not specified the IP address, it will listen on all IPv4 network addresses.

  • "::" to listen in all IPv6 network interfaces
  • "10.11.12.13" is the IPv4 address 10.11.12.13
  • "::FFFF:127.0.0.1" is the IPv6 address ::FFFF:127.0.0.1/128 -
  • {10, 11, 12, 13} is the IPv4 address 10.11.12.13 -
  • {0, 0, 0, 0, 0, 65535, 32512, 1} is the IPv6 address ::FFFF:127.0.0.1/128 -
  • {16#fdca, 16#8ab6, 16#a243, 16#75ef, 0, 0, 0, 1} is the IPv6 address FDCA:8AB6:A243:75EF::1/128
  • The transport protocol can be tcp or udp. Default is tcp.

    Listening Module

    @@ -680,15 +725,15 @@ Handles c2s connections.
    Options: access, certfile, max_fsm_queue, max_stanza_size, shaper, starttls, starttls_required, tls, -zlib +zlib, tls_compression

    ejabberd_s2s_in
    Handles incoming s2s connections.
    - Options: max_stanza_size, shaper + Options: max_stanza_size, shaper, tls_compression
    ejabberd_service
    Interacts with an external component (as defined in the Jabber Component Protocol (XEP-0114).
    Options: access, hosts, max_fsm_queue, -service_check_from, shaper +service_check_from, shaper_rule
    ejabberd_stun
    Handles STUN Binding requests as defined in RFC 5389.
    @@ -696,37 +741,37 @@ Handles STUN Binding requests as defined in
    ejabberd_http
    Handles incoming HTTP connections.
    Options: captcha, certfile, default_host, http_bind, http_poll, -request_handlers, tls, trusted_proxies, web_admin
    +request_handlers, tls, tls_compression, trusted_proxies, web_admin

    Options

    This is a detailed description of each option allowed by the listening modules:

    -{access, AccessName}
    This option defines +access: AccessName
    This option defines access to the port. The default value is all. -
    {backlog, Value}
    The backlog value +
    backlog: Value
    The backlog value defines the maximum length that the queue of pending connections may grow to. This should be increased if the server is going to handle lots of new incoming connections as they may be dropped if there is no space in the queue (and ejabberd was not able to accept them immediately). Default value is 5. -
    captcha
    -Simple web page that allows a user to fill a CAPTCHA challenge (see section 3.1.8). -
    {certfile, Path}
    Full path to a file containing the default SSL certificate. +
    captcha: true|false
    +Simple web page that allows a user to fill a CAPTCHA challenge (see section 3.1.9). +
    certfile: Path
    Full path to a file containing the default SSL certificate. To define a certificate file specific for a given domain, use the global option domain_certfile. -
    {default_host, undefined|HostName}
    +
    default_host: undefined|HostName}
    If the HTTP request received by ejabberd contains the HTTP header Host -with an ambiguous virtual host that doesn’t match any one defined in ejabberd (see 3.1.1), +with an ambiguous virtual host that doesn’t match any one defined in ejabberd (see 3.1.2), then this configured HostName is set as the request Host. The default value of this option is: undefined. -
    {hosts, [Hostname, ...], [HostOption, ...]}
    +
    hosts: {Hostname: [HostOption, ...]}
    The external Jabber component that connects to this ejabberd_service can serve one or more hostnames. As HostOption you can define options for the component; currently the only allowed option is the password required to the component -when attempt to connect to ejabberd: {password, Secret}. +when attempt to connect to ejabberd: password: Secret. Note that you cannot define in a single ejabberd_service components of different services: add an ejabberd_service for each service, as seen in an example below. -
    http_bind
    +
    http_bind: true|false
    This option enables HTTP Binding (XEP-0124 and XEP-0206) support. HTTP Bind enables access via HTTP requests to ejabberd from behind firewalls which do not allow outgoing sockets on port 5222.

    Remember that you must also install and enable the module mod_http_bind.

    If HTTP Bind is enabled, it will be available at @@ -737,7 +782,7 @@ interesting to host a web-based XMPP client such as (check the tutorials to install JWChat with ejabberd and an embedded local web server or Apache). -

    http_poll
    +

    http_poll: true|false
    This option enables HTTP Polling (XEP-0025) support. HTTP Polling enables access via HTTP requests to ejabberd from behind firewalls which do not allow outgoing sockets on port 5222.

    If HTTP Polling is enabled, it will be available at @@ -747,9 +792,9 @@ interesting to host a web-based XMPP client such as JWChat.

    The maximum period of time to keep a client session active without an incoming POST request can be configured with the global option http_poll_timeout. The default value is five minutes. -The option can be defined in ejabberd.cfg, expressing the time +The option can be defined in ejabberd.yml, expressing the time in seconds: {http_poll_timeout, 300}. -

    {max_fsm_queue, Size}
    +

    max_fsm_queue: Size
    This option specifies the maximum number of elements in the queue of the FSM (Finite State Machine). Roughly speaking, each message in such queues represents one XML @@ -767,7 +812,7 @@ If the option is not specified for ejabberd_service or the globally configured value is used. The allowed values are integers and ’undefined’. Default value: ’undefined’. -
    {max_stanza_size, Size}
    +
    max_stanza_size: Size
    This option specifies an approximate maximum size in bytes of XML stanzas. Approximate, because it is calculated with the precision of one block of read @@ -776,12 +821,15 @@ value is infinity. Recommended values are 65536 for c2s connections and 131072 for s2s connections. s2s max stanza size must always much higher than c2s limit. Change this value with extreme care as it can cause unwanted disconnect if set too low. -
    {request_handlers, [ {Path, Module}, ...]}
    To define one or several handlers that will serve HTTP requests. -The Path is a list of strings; so the URIs that start with that Path will be served by Module. +
    request_handlers: {Path: Module}
    To define one or several handlers that will serve HTTP requests. +The Path is a string; so the URIs that start with that Path will be served by Module. For example, if you want mod_foo to serve the URIs that start with /a/b/, and you also want mod_http_bind to serve the URIs /http-bind/, -use this option: {request_handlers, [{["a", "b"], mod_foo}, {["http-bind"], mod_http_bind}]} -
    {service_check_from, true|false}
    +use this option: +
    request_handlers:
    +  /"a"/"b": mod_foo
    +  /"http-bind": mod_http_bind
    +
    service_check_from: true|false
    This option can be used with ejabberd_service only. XEP-0114 requires that the domain must match the hostname of the component. @@ -789,19 +837,25 @@ If this option is set to false, ejabberd will allow the compon to send stanzas with any arbitrary domain in the ’from’ attribute. Only use this option if you are completely sure about it. The default value is true, to be compliant with XEP-0114. -
    {shaper, none|ShaperName}
    This option defines a -shaper for the port (see section 3.1.6). The default value +
    shaper: none|ShaperName
    This option defines a +shaper for the port (see section 3.1.7). The default value is none. -
    starttls
    This option +
    shaper_rule: none|ShaperRule
    This option defines a +shaper rule for the ejabberd_service (see section 3.1.7). The recommended value +is fast. +
    starttls: true|false
    This option specifies that STARTTLS encryption is available on connections to the port. You should also set the certfile option. You can define a certificate file for a specific domain using the global option domain_certfile. -
    starttls_required
    This option +
    starttls_required: true|false
    This option specifies that STARTTLS encryption is required on connections to the port. No unencrypted connections will be allowed. You should also set the certfile option. You can define a certificate file for a specific domain using the global option domain_certfile. -
    tls
    This option specifies that traffic on +
    timeout: Integer
    +Timeout of the connections, expressed in milliseconds. +Default: 5000 +
    tls: true|false
    This option specifies that traffic on the port will be encrypted using SSL immediately after connecting. This was the traditional encryption method in the early Jabber software, commonly on port 5223 for client-to-server communications. @@ -811,49 +865,51 @@ The preferable encryption method is STARTTLS on port 5222, as defined which can be enabled in ejabberd with the option starttls. If this option is set, you should also set the certfile option. The option tls can also be used in ejabberd_http to support HTTPS. -
    {trusted_proxies, all | [IpString]}
    +
    tls_compression: true|false
    +Whether to enable or disable TLS compression. The default value is true. +
    trusted_proxies: all | [IpString]
    Specify what proxies are trusted when an HTTP request contains the header X-Forwarded-For You can specify all to allow all proxies, or specify a list of IPs in string format. The default value is: ["127.0.0.1"] -
    web_admin
    This option +
    web_admin: true|false
    This option enables the Web Admin for ejabberd administration which is available at http://server:port/admin/. Login and password are the username and password of one of the registered users who are granted access by the ‘configure’ access rule. -
    zlib
    This +
    zlib: true|false
    This option specifies that Zlib stream compression (as defined in XEP-0138) is available on connections to the port.

    There are some additional global options that can be specified in the ejabberd configuration file (outside listen):

    -{s2s_use_starttls, false|optional|required|required_trusted}
    +s2s_use_starttls: false|optional|required|required_trusted
    This option defines if s2s connections don’t use STARTTLS encryption; if STARTTLS can be used optionally; if STARTTLS is required to establish the connection; or if STARTTLS is required and the remote certificate must be valid and trusted. The default value is to not use STARTTLS: false. -
    {s2s_certfile, Path}
    Full path to a +
    s2s_certfile: Path
    Full path to a file containing a SSL certificate. -
    {domain_certfile, Domain, Path}
    +
    domain_certfile: Path
    Full path to the file containing the SSL certificate for a specific domain. -
    {outgoing_s2s_options, [Family, ...], Timeout}
    -Specify which address families to try, in what order, and connect timeout in milliseconds. -By default it first tries connecting with IPv4, if that fails it tries using IPv6, -with a timeout of 10000 milliseconds. -
    {s2s_dns_options, [ {Property, Value}, ...]}
    -Define properties to use for DNS resolving. -Allowed Properties are: timeout in seconds which default value is 10 -and retries which default value is 2. -
    {s2s_default_policy, allow|deny}
    -The default policy for incoming and outgoing s2s connections to other XMPP servers. -The default value is allow. -
    {{s2s_host, Host}, allow|deny}
    -Defines if incoming and outgoing s2s connections with a specific remote host are allowed or denied. -This allows to restrict ejabberd to only establish s2s connections -with a small list of trusted servers, or to block some specific servers. -
    {s2s_max_retry_delay, Seconds}
    +
    outgoing_s2s_families: [Family, ...]
    +Specify which address families to try, in what order. +By default it first tries connecting with IPv4, if that fails it tries using IPv6. +
    outgoing_s2s_timeout: Timeout
    +The timeout in milliseconds for outgoing S2S connection attempts. +
    s2s_dns_timeout: Timeout
    +The timeout in seconds for DNS resolving. The default value is 10. +
    s2s_dns_retries: Number
    +DNS resolving retries in seconds. The default value is 2. +
    s2s_policy: Access
    +The policy for incoming and outgoing s2s connections to other XMPP servers. +The default value is all. +
    s2s_max_retry_delay: Seconds
    The maximum allowed delay for retry to connect after a failed connection attempt. Specified in seconds. The default value is 300 seconds (5 minutes). -
    {max_fsm_queue, Size}
    +
    s2s_tls_compression: true|false
    +Whether to enable or disable TLS compression for s2s connections. +The default value is true. +
    max_fsm_queue: Size
    This option specifies the maximum number of elements in the queue of the FSM (Finite State Machine). Roughly speaking, each message in such queues represents one XML @@ -871,7 +927,7 @@ If the option is not specified for ejabberd_service or the globally configured value is used. The allowed values are integers and ’undefined’. Default value: ’undefined’. -
    {route_subdomains, local|s2s}
    +
    route_subdomains: local|s2s
    Defines if ejabberd must route stanzas directed to subdomains locally (compliant with RFC 3920: XMPP Core), or to foreign server using S2S (compliant with @@ -889,40 +945,60 @@ and also allows plain connections for old clients.
  • Port 5280 listens for HTTP requests, and serves the HTTP Poll service.
  • Port 5281 listens for HTTP requests, using HTTPS to serve HTTP-Bind (BOSH) and the Web Admin as explained in section 4.3. The socket only listens connections to the IP address 127.0.0.1. -
  • {hosts, ["example.com", "example.org", "example.net"]}.
    -{listen,
    - [
    -  {5222, ejabberd_c2s, [
    -                        {access, c2s},
    -                        {shaper, c2s_shaper},
    -                        starttls, {certfile, "/etc/ejabberd/server.pem"},
    -                        {max_stanza_size, 65536}
    -                       ]},
    -  {5223, ejabberd_c2s, [
    -                        {access, c2s},
    -                        {shaper, c2s_shaper},
    -                        tls, {certfile, "/etc/ejabberd/server.pem"},
    -                        {max_stanza_size, 65536}
    -                       ]},
    -  {{5269, "::"}, ejabberd_s2s_in, [
    -                                   {shaper, s2s_shaper},
    -                                   {max_stanza_size, 131072}
    -                                  ]},
    -  {{3478, udp}, ejabberd_stun, []},
    -  {5280, ejabberd_http, [
    -                         http_poll
    -                        ]},
    -  {{5281, "127.0.0.1"}, ejabberd_http, [
    -                                        web_admin,
    -                                        http_bind,
    -                                        tls, {certfile, "/etc/ejabberd/server.pem"},
    -                                       ]}
    - ]
    -}.
    -{s2s_use_starttls, optional}.
    -{s2s_certfile, "/etc/ejabberd/server.pem"}.
    -{domain_certfile, "example.com", "/etc/ejabberd/example_com.pem"}.
    -{outgoing_s2s_options, [ipv4, ipv6], 10000}.
    +
    hosts:
    +  - "example.com"
    +  - "example.org"
    +  - "example.net"
    +
    +listen:
    +  - 
    +    port: 5222
    +    module: ejabberd_c2s
    +    access: c2s
    +    shaper: c2s_shaper
    +    starttls: true
    +    certfile: "/etc/ejabberd/server.pem"
    +    max_stanza_size: 65536
    +  - 
    +    port: 5223
    +    module: ejabberd_c2s
    +    access: c2s
    +    shaper: c2s_shaper
    +    tls: true
    +    certfile: "/etc/ejabberd/server.pem"
    +    max_stanza_size: 65536
    +  - 
    +    port: 5269
    +    ip: "::"
    +    module: ejabberd_s2s_in
    +    shaper: s2s_shaper
    +    max_stanza_size: 131072
    +  - 
    +    port: 3478
    +    transport: udp
    +    module: ejabberd_stun
    +  - 
    +    port: 5280
    +    module: ejabberd_http
    +    http_poll: true
    +  - 
    +    port: 5281
    +    ip: "127.0.0.1"
    +    module: ejabberd_http
    +    web_admin: true
    +    http_bind: true
    +    tls: true
    +    certfile: "/etc/ejabberd/server.pem"
    +
    +s2s_use_starttls: optional
    +s2s_certfile: "/etc/ejabberd/server.pem"
    +host_config:
    +  "example.com":
    +    domain_certfile: "/etc/ejabberd/example_com.pem"
    +outgoing_s2s_families:
    +  - ipv4
    +  - ipv6
    +outgoing_s2s_timeout: 10000
     

    In this example, the following configuration defines that:

    • c2s connections are listened for on port 5222 (all IPv4 addresses) and @@ -960,59 +1036,117 @@ connected to port 5237 with password ‘ggsecret’. jmc.example.org is connected to port 5238 with password ‘jmcsecret’.
    • The service custom has enabled the special option to avoiding checking the from attribute in the packets send by this component. The component can send packets in behalf of any users from the server, or even on behalf of any server. -
    {acl, blocked, {user, "bad"}}.
    -{access, c2s, [{deny, blocked},
    -               {allow, all}]}.
    -{shaper, normal, {maxrate, 1000}}.
    -{access, c2s_shaper, [{none, admin},
    -                      {normal, all}]}.
    -{listen,
    - [{5222, ejabberd_c2s, [
    -                        {access, c2s},
    -                        {shaper, c2s_shaper}
    -                       ]},
    -  {{5223, {192, 168, 0, 1}}, ejabberd_c2s, [
    -                                            {access, c2s},
    -                                            ssl, {certfile, "/path/to/ssl.pem"}
    -                                           ]},
    -  {{5223, {16#fdca, 16#8ab6, 16#a243, 16#75ef, 0, 0, 0, 1}},
    -   ejabberd_c2s, [
    -                  {access, c2s},
    -                  ssl, {certfile, "/path/to/ssl.pem"}
    -                 ]},
    -  {5269, ejabberd_s2s_in, []},
    -  {{5280, {0, 0, 0, 0}}, ejabberd_http, [
    -                                         http_poll,
    -                                         web_admin
    -                                        ]},
    -  {{5233, {127, 0, 0, 1}}, ejabberd_service, [
    -                                              {hosts, ["aim.example.org"],
    -                                                 [{password, "aimsecret"}]}
    -                                             ]},
    -  {{5233, "::1"}, ejabberd_service, [
    -                                     {hosts, ["aim.example.org"],
    -                                        [{password, "aimsecret"}]}
    -                                    ]},
    -  {5234, ejabberd_service, [{hosts, ["icq.example.org", "sms.example.org"],
    -                             [{password, "jitsecret"}]}]},
    -  {5235, ejabberd_service, [{hosts, ["msn.example.org"],
    -                             [{password, "msnsecret"}]}]},
    -  {5236, ejabberd_service, [{hosts, ["yahoo.example.org"],
    -                             [{password, "yahoosecret"}]}]},
    -  {5237, ejabberd_service, [{hosts, ["gg.example.org"],
    -                             [{password, "ggsecret"}]}]},
    -  {5238, ejabberd_service, [{hosts, ["jmc.example.org"],
    -                             [{password, "jmcsecret"}]}]},
    -  {5239, ejabberd_service, [{hosts, ["custom.example.org"],
    -                             [{password, "customsecret"}]},
    -                            {service_check_from, false}]}
    - ]
    -}.
    -{s2s_use_starttls, required_trusted}.
    -{s2s_certfile, "/path/to/ssl.pem"}.
    -{s2s_default_policy, deny}.
    -{{s2s_host,"jabber.example.org"}, allow}.
    -{{s2s_host,"example.com"}, allow}.
    +
    acl: 
    +  blocked: 
    +    user: "bad"
    +  trusted_servers: 
    +    server:
    +      - "example.com"
    +      - "jabber.example.org"
    +  xmlrpc_bot: 
    +    user: 
    +      - "xmlrpc-robot": "example.org"
    +shaper: 
    +  normal: 1000
    +access: 
    +  c2s: 
    +    blocked: deny
    +    all: allow
    +  c2s_shaper: 
    +    admin: none
    +    all: normal
    +  xmlrpc_access: 
    +    xmlrpc_bot: allow
    +  s2s_access:
    +    trusted_servers: allow
    +    all: deny
    +s2s_certfile: "/path/to/ssl.pem"
    +s2s_policy: s2s_access
    +s2s_use_starttls: required_trusted
    +listen: 
    +  - 
    +    port: 5222
    +    module: ejabberd_c2s
    +    shaper: c2s_shaper
    +    access: c2s
    +  - 
    +    ip: "192.168.0.1"
    +    port: 5223
    +    module: ejabberd_c2s
    +    certfile: "/path/to/ssl.pem"
    +    tls: true
    +    access: c2s
    +  - 
    +    ip: "FDCA:8AB6:A243:75EF::1"
    +    port: 5223
    +    module: ejabberd_c2s
    +    certfile: "/path/to/ssl.pem"
    +    tls: true
    +    access: c2s
    +  - 
    +    port: 5269
    +    module: ejabberd_s2s_in
    +  - 
    +    port: 5280
    +    module: ejabberd_http
    +    web_admin: true
    +    http_poll: true
    +  - 
    +    port: 4560
    +    module: ejabberd_xmlrpc
    +  - 
    +    ip: "127.0.0.1"
    +    port: 5233
    +    module: ejabberd_service
    +    hosts: 
    +      "aim.example.org": 
    +        password: "aimsecret"
    +  - 
    +    ip: "::1"
    +    port: 5233
    +    module: ejabberd_service
    +    hosts: 
    +      "aim.example.org": 
    +        password: "aimsecret"
    +  - 
    +    port: 5234
    +    module: ejabberd_service
    +    hosts: 
    +      "icq.example.org": 
    +        password: "jitsecret"
    +      "sms.example.org": 
    +        password: "jitsecret"
    +  - 
    +    port: 5235
    +    module: ejabberd_service
    +    hosts: 
    +      "msn.example.org": 
    +        password: "msnsecret"
    +  - 
    +    port: 5236
    +    module: ejabberd_service
    +    hosts: 
    +      "yahoo.example.org": 
    +        password: "yahoosecret"
    +  - 
    +    port: 5237
    +    module: ejabberd_service
    +    hosts: 
    +      "gg.example.org": 
    +        password: "ggsecret"
    +  - 
    +    port: 5238
    +    module: ejabberd_service
    +    hosts: 
    +      "jmc.example.org": 
    +        password: "jmcsecret"
    +  - 
    +    port: 5239
    +    module: ejabberd_service
    +    service_check_from: false
    +    hosts: 
    +      "custom.example.org": 
    +        password: "customsecret"
     

    Note, that for services based in jabberd14 or WPJabber you have to make the transports log and do XDB by themselves:

      <!--
    @@ -1044,22 +1178,21 @@ you have to make the transports log and do XDB by themselves:
         </xdb_file>
       </xdb>
     

    -

    3.1.4  Authentication

    +

    3.1.5  Authentication

    The option auth_method defines the authentication methods that are used for user authentication. The syntax is: -

    {auth_method, [Method, ...]}.

    The following authentication methods are supported by ejabberd: +

    [Method, ...]

    The following authentication methods are supported by ejabberd:

    • -internal (default) — See section 3.1.4. -
    • external — See section 3.1.4. -
    • ldap — See section 3.2.5. -
    • odbc — See section 3.2.1, 3.2.3, -3.2.2 and 3.2.4. -
    • anonymous — See section 3.1.4. -
    • pam — See section 3.1.4. +internal (default) — See section 3.1.5. +
    • external — See section 3.1.5. +
    • ldap — See section 3.2.2. +
    • odbc — See section 3.2.1. +
    • anonymous — See section 3.1.5. +
    • pam — See section 3.1.5.

    Account creation is only supported by internal, external and odbc methods.

    The option resource_conflict defines the action when a client attempts to login to an account with a resource that is already connected. The option syntax is: -

    {resource_conflict, setresource|closenew|closeold}.

    +

    resource_conflict: setresource|closenew|closeold

    The possible values match exactly the three possibilities described in XMPP Core: section 7.7.2.2. The default value is closeold. @@ -1068,10 +1201,10 @@ then this option is not respected, and the action performed is closeold of the machine, in case it isn’t detected automatically. The FQDN is used to authenticate some clients that use the DIGEST-MD5 SASL mechanism. The option syntax is: -

    {fqdn, undefined|FqdnString|[FqdnString]}.

    +

    fqdn: undefined|FqdnString|[FqdnString]

    Internal

    ejabberd uses its internal Mnesia database as the default authentication method. -The value internal will enable the internal authentication method.

    The option {auth_password_format, plain|scram} +The value internal will enable the internal authentication method.

    The option auth_password_format: plain|scram defines in what format the users passwords are stored:

    plain
    @@ -1089,11 +1222,14 @@ This format allows clients to authenticate using: SASL PLAIN and SA

    • To use internal authentication on example.org and LDAP authentication on example.net: -
      {host_config, "example.org", [{auth_method, [internal]}]}.
      -{host_config, "example.net", [{auth_method, [ldap]}]}.
      +
      host_config:
      +  "example.org":
      +    auth_method: [internal]
      +  "example.net":
      +    auth_method: [ldap]
       
    • To use internal authentication with hashed passwords on all virtual hosts: -
      {auth_method, internal}.
      -{auth_password_format, scram}.
      +
      auth_method: internal
      +auth_password_format: scram
       

    External Script

    In this authentication method, when ejabberd starts, @@ -1103,11 +1239,11 @@ The details on the interface between ejabberd and the script are described in the ejabberd Developers Guide. There are also several example authentication scripts.

    These are the specific options:

    -{extauth_program, PathToScript}
    +extauth_program: PathToScript
    Indicate in this option the full path to the external authentication script. -The script must be executable by ejabberd.
    {extauth_instances, Integer}
    +The script must be executable by ejabberd.
    extauth_instances: Integer
    Indicate how many instances of the script to run simultaneously to serve authentication in the virtual host. -The default value is the minimum number: 1.
    {extauth_cache, false|CacheTimeInteger}
    +The default value is the minimum number: 1.
    extauth_cache: false|CacheTimeInteger
    The value false disables the caching feature, this is the default. The integer 0 (zero) enables caching for statistics, but doesn’t use that cached information to authenticate users. If another integer value is set, caching is enabled both for statistics and for authentication: @@ -1118,51 +1254,78 @@ Note: caching should not be enabled in a host if internal auth is also enabled. If caching is enabled, mod_last must be enabled also in that vhost.

    This example sets external authentication, the extauth script, enables caching for 10 minutes, and starts three instances of the script for each virtual host defined in ejabberd: -

    {auth_method, [external]}.
    -{extauth_program, "/etc/ejabberd/JabberAuth.class.php"}.
    -{extauth_cache, 600}.
    -{extauth_instances, 3}. 
    -

    -

    SASL Anonymous and Anonymous Login

    -

    The value anonymous will enable the internal authentication method.

    The anonymous authentication method can be configured with the following +

    auth_method: [external]
    +extauth_program: "/etc/ejabberd/JabberAuth.class.php"
    +extauth_cache: 600
    +extauth_instances: 3
    +

    +

    Anonymous Login and SASL Anonymous

    +

    The anonymous authentication method enables two modes for anonymous authentication: +

    +Anonymous login:
    This is a standard login, that use the +classical login and password mechanisms, but where password is +accepted or preconfigured for all anonymous users. This login is +compliant with SASL authentication, password and digest non-SASL +authentication, so this option will work with almost all XMPP +clients
    SASL Anonymous:
    This is a special SASL authentication +mechanism that allows to login without providing username or +password (see XEP-0175). The main advantage of SASL Anonymous +is that the protocol was designed to give the user a login. This is +useful to avoid in some case, where the server has many users +already logged or registered and when it is hard to find a free +username. The main disavantage is that you need a client that +specifically supports the SASL Anonymous protocol. +

    The anonymous authentication method can be configured with the following options. Remember that you can use the host_config option to set virtual -host specific options (see section 3.1.2). Note that there also -is a detailed tutorial regarding SASL -Anonymous and anonymous login configuration.

    -{allow_multiple_connections, false|true}
    This option is only used +host specific options (see section 3.1.3).

    +allow_multiple_connections: false|true
    This option is only used when the anonymous mode is enabled. Setting it to true means that the same username can be taken multiple times in anonymous login mode if different resource are used to connect. This option is only useful in very special occasions. The default value is false. -
    {anonymous_protocol, sasl_anon | login_anon | both}
    -sasl_anon means -that the SASL Anonymous method will be used. login_anon means that the -anonymous login method will be used. both means that SASL Anonymous and -login anonymous are both enabled. +
    anonymous_protocol: login_anon | sasl_anon | both
    +login_anon means that the anonymous login method will be used. +sasl_anon means that the SASL Anonymous method will be used. +both means that SASL Anonymous and login anonymous are both enabled.

    Those options are defined for each virtual host with the host_config -parameter (see section 3.1.2).

    Examples: +parameter (see section 3.1.3).

    Examples:

    • To enable anonymous login on all virtual hosts: -
      {auth_method, [anonymous]}.
      -{anonymous_protocol, login_anon}.
      +
      auth_method: [anonymous]
      +anonymous_protocol: login_anon
       
    • Similar as previous example, but limited to public.example.org: -
      {host_config, "public.example.org", [{auth_method, [anonymous]},
      -                                     {anonymous_protocol, login_anon}]}.
      +
      host_config:
      +  "public.example.org":
      +    auth_method: [anonymous]
      +    anonymous_protoco: login_anon
       
    • To enable anonymous login and internal authentication on a virtual host: -
      {host_config, "public.example.org", [{auth_method, [internal,anonymous]},
      -                                     {anonymous_protocol, login_anon}]}.
      +
      host_config:
      +  "public.example.org":
      +    auth_method:
      +      - internal
      +      - anonymous
      +    anonymous_protocol: login_anon
       
    • To enable SASL Anonymous on a virtual host: -
      {host_config, "public.example.org", [{auth_method, [anonymous]},
      -                                     {anonymous_protocol, sasl_anon}]}.
      +
      host_config:
      +  "public.example.org":
      +    auth_method: [anonymous]
      +    anonymous_protocol: sasl_anon
       
    • To enable SASL Anonymous and anonymous login on a virtual host: -
      {host_config, "public.example.org", [{auth_method, [anonymous]},
      -                                     {anonymous_protocol, both}]}.
      +
      host_config:
      +  "public.example.org":
      +    auth_method: [anonymous]
      +    anonymous_protocol: both
       
    • To enable SASL Anonymous, anonymous login, and internal authentication on a virtual host: -
      {host_config, "public.example.org", [{auth_method, [internal,anonymous]},
      -                                     {anonymous_protocol, both}]}.
      -

    +
    host_config:
    +  "public.example.org":
    +    auth_method:
    +      - internal
    +      - anonymous
    +    anonymous_protocol: both
    +

    There are more configuration examples and XMPP client example stanzas in +Anonymous users support.

    PAM Authentication

    ejabberd supports authentication via Pluggable Authentication Modules (PAM). PAM is currently supported in AIX, FreeBSD, HP-UX, Linux, Mac OS X, NetBSD and Solaris. @@ -1171,16 +1334,16 @@ PAM authentication is disabled by default, so you have to configure and compile

    ./configure --enable-pam && make install
     

    Options:

    -{pam_service, Name}
    This option defines the PAM service name. +pam_service: Name
    This option defines the PAM service name. Default is "ejabberd". Refer to the PAM documentation of your operation system for more information. -
    {pam_userinfotype, username|jid}
    +
    pam_userinfotype: username|jid
    This option defines what type of information about the user ejabberd provides to the PAM service: only the username, or the user JID. Default is username.

    Example: -

    {auth_method, [pam]}.
    -{pam_service, "ejabberd"}.
    +

    auth_method: [pam]
    +pam_service: "ejabberd"
     

    Though it is quite easy to set up PAM support in ejabberd, PAM itself introduces some security issues:

    • To perform PAM authentication ejabberd uses external C-program called @@ -1212,52 +1375,85 @@ module provides such functionality.
    • If you use pam_winbind to authorise against a Windows Active Directory, then /etc/nsswitch.conf must be configured to use winbind as well.

    -

    3.1.5  Access Rules

    +

    3.1.6  Access Rules

    ACL Definition

    Access control in ejabberd is performed via Access Control Lists (ACLs). The declarations of ACLs in the configuration file have the following syntax: -

    {acl, ACLName, ACLValue}.

    ACLValue can be one of the following: +

    acl: { ACLName: { ACLType: ACLValue } }

    ACLType: ACLValue can be one of the following:

    all
    Matches all JIDs. Example: -
    {acl, all, all}.
    -
    {user, Username}
    Matches the user with the name +
    acl:
    +  world: all
    +
    user: Username
    Matches the user with the name Username at the first virtual host. Example: -
    {acl, admin, {user, "yozhik"}}.
    -
    {user, Username, Server}
    Matches the user with the JID +
    acl:
    +  admin:
    +    user: "yozhik"
    +
    user: {Username: Server}
    Matches the user with the JID Username@Server and any resource. Example: -
    {acl, admin, {user, "yozhik", "example.org"}}.
    -
    {server, Server}
    Matches any JID from server +
    acl:
    +  admin:
    +    user:
    +      "yozhik": "example.org"
    +
    server: Server
    Matches any JID from server Server. Example: -
    {acl, exampleorg, {server, "example.org"}}.
    -
    {resource, Resource}
    Matches any JID with a resource +
    acl:
    +  exampleorg:
    +    server: "example.org"
    +
    resource: Resource
    Matches any JID with a resource Resource. Example: -
    {acl, mucklres, {resource, "muckl"}}.
    -
    {shared_group, Groupname}
    Matches any member of a Shared Roster Group with name Groupname in the virtual host. Example: -
    {acl, techgroupmembers, {shared_group, "techteam"}}.
    -
    {shared_group, Groupname, Server}
    Matches any member of a Shared Roster Group with name Groupname in the virtual host Server. Example: -
    {acl, techgroupmembers, {shared_group, "techteam", "example.org"}}.
    -
    {user_regexp, Regexp}
    Matches any local user with a name that +
    acl:
    +  mucklres:
    +   resource: "muckl"
    +
    shared_group: Groupname
    Matches any member of a Shared Roster Group with name Groupname in the virtual host. Example: +
    acl:
    +  techgroupmembers:
    +    shared_group: "techteam"
    +
    shared_group: {Groupname: Server}
    Matches any member of a Shared Roster Group with name Groupname in the virtual host Server. Example: +
    acl:
    +  techgroupmembers:
    +    shared_group:
    +      "techteam": "example.org"
    +
    ip: Network
    Matches any IP address from the Network. Example: +
    acl:
    +  loopback:
    +    ip:
    +      - "127.0.0.0/8"
    +      - "::"
    +
    user_regexp: Regexp
    Matches any local user with a name that matches Regexp on local virtual hosts. Example: -
    {acl, tests, {user_regexp, "^test[0-9]*$"}}.
    -
    {user_regexp, Regexp, Server}
    Matches any user with a name +
    acl:
    +  tests:
    +    user_regexp: "^test[0-9]*$"
    +
    user_regexp: {Regexp: Server}
    Matches any user with a name that matches Regexp at server Server. Example: -
    {acl, tests, {user_regexp, "^test", "example.org"}}.
    -
    {server_regexp, Regexp}
    Matches any JID from the server that +
    acl:
    +  tests:
    +    user_regexp:
    +      "^test": "example.org"
    +
    server_regexp: Regexp
    Matches any JID from the server that matches Regexp. Example: -
    {acl, icq, {server_regexp, "^icq\\."}}.
    -
    {resource_regexp, Regexp}
    Matches any JID with a resource that +
    acl:
    +  icq:
    +    server_regexp: "^icq\\."
    +
    resource_regexp: Regexp
    Matches any JID with a resource that matches Regexp. Example: -
    {acl, icq, {resource_regexp, "^laptop\\."}}.
    -
    {node_regexp, UserRegexp, ServerRegexp}
    Matches any user +
    acl:
    +  icq:
    +    resource_regexp: "^laptop\\."
    +
    node_regexp: {UserRegexp: ServerRegexp}
    Matches any user with a name that matches UserRegexp at any server that matches ServerRegexp. Example: -
    {acl, yozhik, {node_regexp, "^yozhik$", "^example.(com|org)$"}}.
    -
    {user_glob, Glob}
    -
    {user_glob, Glob, Server}
    -
    {server_glob, Glob}
    -
    {resource_glob, Glob}
    -
    {node_glob, UserGlob, ServerGlob}
    This is the same as +
    acl:
    +  yozhik:
    +    node_regexp:
    +      "^yozhik$": "^example.(com|org)$"
    +
    user_glob: Glob}
    +
    user_glob: {Glob: Server}
    +
    server_glob: Glob
    +
    resource_glob: Glob
    +
    node_glob: {UserGlob: ServerGlob}
    This is the same as above. However, it uses shell glob patterns instead of regexp. These patterns can have the following special characters:
    @@ -1276,7 +1472,7 @@ character not enclosed is matched.

    Access Rights

    An entry allowing or denying access to different services. The syntax is: -

    {access, AccessName, [ {allow|deny, ACLName}, ...]}.

    When a JID is checked to have access to Accessname, the server +

    access: { AccessName: { ACLName: allow|deny } }

    When a JID is checked to have access to Accessname, the server sequentially checks if that JID matches any of the ACLs that are named in the second elements of the tuples in the list. If it matches, the first element of the first matched tuple is returned, otherwise the value ‘deny’ is @@ -1284,9 +1480,12 @@ returned.

    If you define specific Access rights in a virtual host, remember that the globally defined Access rights have precedence over those. This means that, in case of conflict, the Access granted or denied in the global server is used and the Access of a virtual host doesn’t have effect.

    Example: -

    {access, configure, [{allow, admin}]}.
    -{access, something, [{deny, badmans},
    -                     {allow, all}]}.
    +

    access:
    +  configure:
    +    admin: allow
    +  something
    +    badmans: deny
    +    all: allow
     

    The following AccessName are pre-defined:

    all
    Always returns the value ‘allow’. @@ -1300,26 +1499,28 @@ opened session will be disconnected. The error session replaced will be sent to the disconnected session. The value for this option can be either a number, or infinity. The default value is infinity.

    The syntax is: -

    {access, max_user_sessions, [ {MaxNumber, ACLName}, ...]}.

    This example limits the number of sessions per user to 5 for all users, and to 10 for admins: -

    {access, max_user_sessions, [{10, admin}, {5, all}]}.
    +

    { max_user_sessions: { ACLName: MaxNumber } }

    This example limits the number of sessions per user to 5 for all users, and to 10 for admins: +

    access:
    +  max_user_sessions:
    +    admin: 10
    +    all: 5
     

    Several connections to a remote XMPP server with ACL

    The special access max_s2s_connections specifies how many simultaneous S2S connections can be established to a specific remote XMPP server. The default value is 1. There’s also available the access max_s2s_connections_per_node.

    The syntax is: -

    {access, max_s2s_connections, [ {MaxNumber, ACLName}, ...]}.

    Examples: +

    { max_s2s_connections: { ACLName: MaxNumber } }

    Examples:

    • Allow up to 3 connections with each remote server: -
      {access, max_s2s_connections, [{3, all}]}.
      +
      access:
      +  max_s2s_connections:
      +    all: 3
       

    -

    3.1.6  Shapers

    +

    3.1.7  Shapers

    Shapers enable you to limit connection traffic. The syntax is: -

    {shaper, ShaperName, Kind}.

    -Currently only one kind of shaper called maxrate is available. It has the -following syntax: -

    {maxrate, Rate}

    +

    shaper: { ShaperName: Rate }

    where Rate stands for the maximum allowed incoming rate in bytes per second. When a connection exceeds this limit, ejabberd stops reading from the socket @@ -1327,30 +1528,32 @@ until the average rate is again below the allowed maximum.

    Examples:

    • To define a shaper named ‘normal’ with traffic speed limited to 1,000 bytes/second: -
      {shaper, normal, {maxrate, 1000}}.
      +
      shaper:
      +  normal: 1000
       
    • To define a shaper named ‘fast’ with traffic speed limited to 50,000 bytes/second: -
      {shaper, fast, {maxrate, 50000}}.
      +
      shaper:
      +  fast: 50000
       

    -

    3.1.7  Default Language

    +

    3.1.8  Default Language

    The option language defines the default language of server strings that can be seen by XMPP clients. If a XMPP client does not support xml:lang, the specified language is used.

    The option syntax is: -

    {language, Language}.

    The default value is en. +

    language: Language

    The default value is en. In order to take effect there must be a translation file Language.msg in ejabberd’s msgs directory.

    For example, to set Russian as default language: -

    {language, "ru"}.
    +

    language: "ru"
     

    Appendix A provides more details about internationalization and localization.

    -

    3.1.8  CAPTCHA

    +

    3.1.9  CAPTCHA

    Some ejabberd modules can be configured to require a CAPTCHA challenge on certain actions. If the client does not support CAPTCHA Forms (XEP-0158), a web link is provided so the user can fill the challenge in a web browser.

    An example script is provided that generates the image using ImageMagick’s Convert program.

    The configurable options are:

    -{captcha_cmd, Path}
    +captcha_cmd: Path
    Full path to a script that generates the image. The default value disables the feature: undefined -
    {captcha_host, ProtocolHostPort}
    +
    captcha_host: ProtocolHostPort
    ProtocolHostPort is a string with the host, and optionally the Protocol and Port number. It must identify where ejabberd listens for CAPTCHA requests. The URL sent to the user is formed by: Protocol://Host:Port/captcha/ @@ -1359,44 +1562,46 @@ If you specify a port number that does not match exactly an ejabberd listener (because you are using a reverse proxy or other port-forwarding tool), then you must specify the transfer protocol, as seen in the example below.

    Additionally, an ejabberd_http listener must be enabled with the captcha option. -See section 3.1.3.

    Example configuration: -

    {hosts, ["example.org"]}.
    +See section 3.1.4.

    Example configuration: +

    hosts: ["example.org"]
     
    -{captcha_cmd, "/lib/ejabberd/priv/bin/captcha.sh"}.
    -{captcha_host, "example.org:5280"}.
    -%% {captcha_host, "https://example.org:443"}.
    -%% {captcha_host, "http://example.com"}.
    +captcha_cmd: "/lib/ejabberd/priv/bin/captcha.sh"
    +captcha_host: "example.org:5280"
    +## captcha_host: "https://example.org:443"
    +## captcha_host: "http://example.com"
     
    -{listen,
    - [
    +listen:
    +  ...
    +  -
    +    port: 5280
    +    module: ejabberd_http
    +    captcha: true
       ...
    -  {5280, ejabberd_http, [
    -                         captcha,
    -                         ...
    -                        ]
    -  }
    -
    -]}.
     

    -

    3.1.9  STUN

    +

    3.1.10  STUN

    ejabberd is able to act as a stand-alone STUN server (RFC 5389). Currently only Binding usage -is supported. In that role ejabberd helps clients with Jingle ICE (XEP-0176) support to discover their external addresses and ports.

    You should configure ejabberd_stun listening module as described in 3.1.3 section. +is supported. In that role ejabberd helps clients with Jingle ICE (XEP-0176) support to discover their external addresses and ports.

    You should configure ejabberd_stun listening module as described in 3.1.4 section. If certfile option is defined, ejabberd multiplexes TCP and TLS over TCP connections on the same port. Obviously, certfile option is defined for tcp only. Note however that TCP or TLS over TCP support is not required for Binding usage and is reserved for TURN functionality. Feel free to configure udp transport only.

    Example configuration: -

    {listen,
    - [
    +

    listen:
       ...
    -  {{3478, udp}, ejabberd_stun, []},
    -  {3478, ejabberd_stun, []},
    -  {5349, ejabberd_stun, [{certfile, "/etc/ejabberd/server.pem"}]},
    +  - 
    +    port: 3478
    +    transport: udp
    +    module: ejabberd_stun
    +  - 
    +    port: 3478
    +    module: ejabberd_stun
    +  -
    +    port: 5349
    +    module: ejabberd_stun
    +    certfile: "/etc/ejabberd/server.pem"
       ...
    - ]
    -}.
     

    You also need to configure DNS SRV records properly so clients can easily discover a STUN server serving your XMPP domain. Refer to section DNS Discovery of a Server @@ -1405,41 +1610,55 @@ of RFC 5389 for details.

    _stun._tcp IN SRV 0 0 3478 stun.example.com. _stuns._tcp IN SRV 0 0 5349 stun.example.com.

    -

    3.1.10  Include Additional Configuration Files

    +

    3.1.11  Include Additional Configuration Files

    The option include_config_file in a configuration file instructs ejabberd to include other configuration files immediately.

    The basic syntax is: -

    {include_config_file, Filename}.

    +

    include_config_file: [Filename]

    It is possible to specify suboptions using the full syntax: -

    {include_config_file, Filename, [Suboption, ...]}.

    The filename can be indicated either as an absolute path, +

    include_config_file: { Filename: [Suboption, ...] }

    The filename can be indicated either as an absolute path, or relative to the main ejabberd configuration file. It isn’t possible to use wildcards. The file must exist and be readable.

    The allowed suboptions are:

    -{disallow, [Optionname, ...]}
    Disallows the usage of those options in the included configuration file. +disallow: [Optionname, ...]
    Disallows the usage of those options in the included configuration file. The options that match this criteria are not accepted. The default value is an empty list: [] -
    {allow_only, [Optionname, ...]}
    Allows only the usage of those options in the included configuration file. +
    allow_only: [Optionname, ...]
    Allows only the usage of those options in the included configuration file. The options that do not match this criteria are not accepted. The default value is: all

    This is a basic example: -

    {include_config_file, "/etc/ejabberd/additional.cfg"}.
    +

    include_config_file: "/etc/ejabberd/additional.yml"
     

    In this example, the included file is not allowed to contain a listen option. If such an option is present, the option will not be accepted. The file is in a subdirectory from where the main configuration file is. -

    {include_config_file, "./example.org/additional_not_listen.cfg", [{disallow, [listen]}]}.
    -

    In this example, ejabberd.cfg defines some ACL and Access rules, +

    include_config_file:
    +  "./example.org/additional_not_listen.yml":
    +    disallow: [listen]
    +

    In this example, ejabberd.yml defines some ACL and Access rules, and later includes another file with additional rules: -

    {acl, admin, {user, "admin", "localhost"}}.
    -{access, announce, [{allow, admin}]}.
    -{include_config_file, "/etc/ejabberd/acl_and_access.cfg", [{allow_only, [acl, access]}]}.
    -

    and content of the file acl_and_access.cfg can be, for example: -

    {acl, admin, {user, "bob", "localhost"}}.
    -{acl, admin, {user, "jan", "localhost"}}.
    +

    acl:
    +  admin:
    +    user:
    +      - "admin": "localhost"
    +access:
    +  announce:
    +    admin: allow
    +include_config_file:
    +  "/etc/ejabberd/acl_and_access.yml":
    +    allow_only:
    +      - acl
    +      - access
    +

    and content of the file acl_and_access.yml can be, for example: +

    acl:
    +  admin:
    +    user:
    +      - "bob": "localhost"
    +      - "jan": "localhost"
     

    -

    3.1.11  Option Macros in Configuration File

    +

    3.1.12  Option Macros in Configuration File

    In the ejabberd configuration file, it is possible to define a macro for a value and later use this macro when defining an option.

    A macro is defined with this syntax: -

    {define_macro, ’MACRO’, Value}.

    +

    define_macro: { ’MACRO’: Value }

    The MACRO must be surrounded by single quotation marks, and all letters in uppercase; check the examples bellow. The value can be any valid arbitrary Erlang term.

    The first definition of a macro is preserved, @@ -1447,44 +1666,43 @@ and additional definitions of the same macro are forgotten.

    Macros are pro additional configuration files have been included, so it is possible to use macros that are defined in configuration files included before the usage.

    It isn’t possible to use a macro in the definition -of another macro.

    There are two ways to use a macro: -

    ’MACRO’
    -You can put this instead of a value in an ejabberd option, -and will be replaced with the value previously defined. -If the macro is not defined previously, -the program will crash and report an error.
    {use_macro, ’MACRO’, Defaultvalue}
    -Use a macro even if it may not be defined. -If the macro is not defined previously, -the provided defaultvalue is used. -This usage behaves as if it were defined and used this way: -
    {define_macro, 'MACRO', Defaultvalue}.
    -'MACRO'
    -

    This example shows the basic usage of a macro: -

    {define_macro, 'LOG_LEVEL_NUMBER', 5}.
    -{loglevel, 'LOG_LEVEL_NUMBER'}.
    -

    The resulting option interpreted by ejabberd is: {loglevel, 5}.

    This example shows that values can be any arbitrary Erlang term: -

    {define_macro, 'USERBOB', {user, "bob", "localhost"}}.
    -{acl, admin, 'USERBOB'}.
    -

    The resulting option interpreted by ejabberd is: {acl, admin, {user, "bob", "localhost"}}.

    This complex example: -

    {define_macro, 'NUMBER_PORT_C2S', 5222}.
    -{define_macro, 'PORT_S2S_IN', {5269, ejabberd_s2s_in, []}}.
    -{listen,
    - [
    -  {'NUMBER_PORT_C2S', ejabberd_c2s, []},
    -  'PORT_S2S_IN',
    -  {{use_macro, 'NUMBER_PORT_HTTP', 5280}, ejabberd_http, []}
    - ]
    -}.
    +of another macro.

    This example shows the basic usage of a macro: +

    define_macro:
    +  'LOG_LEVEL_NUMBER': 5
    +loglevel: 'LOG_LEVEL_NUMBER'
    +

    The resulting option interpreted by ejabberd is: loglevel: 5.

    This example shows that values can be any arbitrary Erlang term: +

    define_macro:
    +  'USERBOB':
    +    user:
    +      - "bob": "localhost"
    +acl:
    +  admin: 'USERBOB'
    +

    The resulting option interpreted by ejabberd is: +

    acl:
    +  admin:
    +    user:
    +      - "bob": "localhost"
    +

    This complex example: +

    define_macro:
    +  'NUMBER_PORT_C2S': 5222
    +  'NUMBER_PORT_HTTP': 5280
    +listen:
    +  - 
    +    port: 'NUMBER_PORT_C2S'
    +    module: ejabberd_c2s
    +  - 
    +    port: 'NUMBER_PORT_HTTP'
    +    module: ejabberd_http
     

    produces this result after being interpreted: -

    {listen,
    - [
    -  {5222, ejabberd_c2s, []},
    -  {5269, ejabberd_s2s_in, []},
    -  {5280, ejabberd_http, []}
    - ]
    -}.
    +

    listen:
    +  - 
    +    port: 5222
    +    module: ejabberd_c2s
    +  - 
    +    port: 5280
    +    module: ejabberd_http
     

    -

    3.2  Database and LDAP Configuration

    +

    3.2  Database and LDAP Configuration

    ejabberd uses its internal Mnesia database by default. However, it is possible to use a relational database or an LDAP server to store persistent, @@ -1493,206 +1711,70 @@ authentication methods for different virtual hosts, you can configure different authentication mechanisms for the same virtual host (fallback), you can set different storage systems for modules, and so forth.

    The following databases are supported by ejabberd:

    The following LDAP servers are tested with ejabberd:

    Important note about virtual hosting: -if you define several domains in ejabberd.cfg (see section 3.1.1), +if you define several domains in ejabberd.yml (see section 3.1.2), you probably want that each virtual host uses a different configuration of database, authentication and storage, so that usernames do not conflict and mix between different virtual hosts. For that purpose, the options described in the next sections -must be set inside a host_config for each vhost (see section 3.1.2). +must be set inside a host_config for each vhost (see section 3.1.3). For example: -

    {host_config, "public.example.org", [
    -  {odbc_server, {pgsql, "localhost", "database-public-example-org", "ejabberd", "password"}},
    -  {auth_method, [odbc]}
    -]}.
    -

    -

    3.2.1  MySQL

    -

    Although this section will describe ejabberd’s configuration when you want to -use the native MySQL driver, it does not describe MySQL’s installation and -database creation. Check the MySQL documentation and the tutorial Using ejabberd with MySQL native driver for information regarding these topics. -Note that the tutorial contains information about ejabberd’s configuration -which is duplicate to this section.

    Moreover, the file mysql.sql in the directory src/odbc might be interesting for -you. This file contains the ejabberd schema for MySQL. At the end of the file -you can find information to update your database schema.

    -

    Driver Compilation

    -

    You can skip this step if you installed ejabberd using a binary installer or -if the binary packages of ejabberd you are using include support for MySQL.

    1. -First, install the Erlang -MySQL library. Make sure the compiled files are in your Erlang path; you can -put them for example in the same directory as your ejabberd .beam files. -
    2. Then, configure and install ejabberd with ODBC support enabled (this is -also needed for native MySQL support!). This can be done, by using next -commands: -
      ./configure --enable-odbc && make install
      -

    -

    Database Connection

    -

    The actual database access is defined in the option odbc_server. Its -value is used to define if we want to use ODBC, or one of the two native -interface available, PostgreSQL or MySQL.

    To use the native MySQL interface, you can pass a tuple of the following form as -parameter: -

    {mysql, "Server", "Database", "Username", "Password"}

    mysql is a keyword that should be kept as is. For example: -

    {odbc_server, {mysql, "localhost", "test", "root", "password"}}.

    Optionally, it is possible to define the MySQL port to use. This -option is only useful, in very rare cases, when you are not running -MySQL with the default port setting. The mysql parameter -can thus take the following form: -

    {mysql, "Server", Port, "Database", "Username", "Password"}

    The Port value should be an integer, without quotes. For example: -

    {odbc_server, {mysql, "localhost", Port, "test", "root", "password"}}.

    By default ejabberd opens 10 connections to the database for each virtual host. -Use this option to modify the value: -

    {odbc_pool_size, 10}.
    -

    You can configure an interval to make a dummy SQL request -to keep alive the connections to the database. +

    host_config:
    +  "public.example.org":
    +    odbc_type: pgsql
    +    odbc_server: "localhost"
    +    odbc_database: "database-public-example-org"
    +    odbc_username: "ejabberd"
    +    odbc_password: "password"
    +    auth_method: [odbc]
    +

    +

    3.2.1  ODBC

    The actual database access is defined in the options with odbc_ prefix. The +values are used to define if we want to use ODBC, or one of the two native +interface available, PostgreSQL or MySQL.

    The following paramaters are available: +

    +odbc_type: mysql | pgsql | odbc
    The type of an ODBC connection. +The default is odbc. +
    odbc_server: String
    A hostname of the ODBC server. The default is +‘‘localhost’’. +
    odbc_port: Port
    The port where the ODBC server is accepting connections. +The option is only valid for mysql and pgsql. The default is +3306 and 5432 respectively. +
    odbc_database: String
    The database name. The default is ‘‘ejabberd’’. +The option is only valid for mysql and pgsql. +
    odbc_username: String
    The username. The default is ‘‘ejabberd’’. +The option is only valid for mysql and pgsql. +
    odbc_password: String
    The password. The default is empty string. +The option is only valid for mysql and pgsql. +
    odbc_pool_size: N
    By default ejabberd opens 10 connections to +the database for each virtual host. You can change this number by using this option. +
    odbc_keepalive_interval: N
    You can configure an interval to +make a dummy SQL request to keep alive the connections to the database. The default value is ’undefined’, so no keepalive requests are made. Specify in seconds: for example 28800 means 8 hours. -

    {odbc_keepalive_interval, undefined}.
    -

    If the connection to the database fails, ejabberd waits 30 seconds before retrying. -You can modify this interval with this option: -

    {odbc_start_interval, 30}.
    -

    -

    Authentication

    -

    The option value name may be misleading, as the auth_method name is used -for access to a relational database through ODBC, as well as through the native -MySQL interface. Anyway, the first configuration step is to define the odbc -auth_method. For example: -

    {auth_method, [odbc]}.
    -

    -

    Storage

    -

    MySQL also can be used to store information into from several ejabberd -modules. See section 3.3.1 to see which modules can be used with -relational databases like MySQL. To enable storage to your database, just make -sure that your database is running well (see previous sections), and add the -module option {db_type, odbc}.

    -

    3.2.2  Microsoft SQL Server

    -

    Although this section will describe ejabberd’s configuration when you want to -use Microsoft SQL Server, it does not describe Microsoft SQL Server’s -installation and database creation. Check the MySQL documentation and the -tutorial Using ejabberd with MySQL native driver for information regarding these topics. -Note that the tutorial contains information about ejabberd’s configuration -which is duplicate to this section.

    Moreover, the file mssql.sql in the directory src/odbc might be interesting for -you. This file contains the ejabberd schema for Microsoft SQL Server. At the end -of the file you can find information to update your database schema.

    -

    Driver Compilation

    -

    You can skip this step if you installed ejabberd using a binary installer or -if the binary packages of ejabberd you are using include support for ODBC.

    If you want to use Microsoft SQL Server with ODBC, you need to configure, -compile and install ejabberd with support for ODBC and Microsoft SQL Server -enabled. This can be done, by using next commands: -

    ./configure --enable-odbc --enable-mssql && make install
    -

    -

    Database Connection

    -

    The configuration of Database Connection for a Microsoft SQL Server -is the same as the configuration for -ODBC compatible servers (see section 3.2.4).

    -

    Authentication

    -

    The configuration of Authentication for a Microsoft SQL Server -is the same as the configuration for -ODBC compatible servers (see section 3.2.4).

    -

    Storage

    -

    Microsoft SQL Server also can be used to store information into from several -modules. See section 3.3.1 to see which modules can be used with -relational databases like MySQL. To enable storage to your database, just make -sure that your database is running well (see previous sections), and add the -module option {db_type, odbc}.

    -

    3.2.3  PostgreSQL

    -

    Although this section will describe ejabberd’s configuration when you want to -use the native PostgreSQL driver, it does not describe PostgreSQL’s installation -and database creation. Check the PostgreSQL documentation and the tutorial Using ejabberd with MySQL native driver for information regarding these topics. -Note that the tutorial contains information about ejabberd’s configuration -which is duplicate to this section.

    Also the file pg.sql in the directory src/odbc might be interesting for you. -This file contains the ejabberd schema for PostgreSQL. At the end of the file -you can find information to update your database schema.

    -

    Driver Compilation

    -

    You can skip this step if you installed ejabberd using a binary installer or -if the binary packages of ejabberd you are using include support for -PostgreSQL.

    1. -First, install the Erlang pgsql library from -ejabberd-modules SVN repository. -Make sure the compiled -files are in your Erlang path; you can put them for example in the same -directory as your ejabberd .beam files. -
    2. Then, configure, compile and install ejabberd with ODBC support enabled -(this is also needed for native PostgreSQL support!). This can be done, by -using next commands: -
      ./configure --enable-odbc && make install
      -

    -

    Database Connection

    -

    The actual database access is defined in the option odbc_server. Its -value is used to define if we want to use ODBC, or one of the two native -interface available, PostgreSQL or MySQL.

    To use the native PostgreSQL interface, you can pass a tuple of the following -form as parameter: -

    {pgsql, "Server", "Database", "Username", "Password"}

    pgsql is a keyword that should be kept as is. For example: -

    {odbc_server, {pgsql, "localhost", "database", "ejabberd", "password"}}.

    Optionally, it is possible to define the PostgreSQL port to use. This -option is only useful, in very rare cases, when you are not running -PostgreSQL with the default port setting. The pgsql parameter -can thus take the following form: -

    {pgsql, "Server", Port, "Database", "Username", "Password"}

    The Port value should be an integer, without quotes. For example: -

    {odbc_server, {pgsql, "localhost", 5432, "database", "ejabberd", "password"}}.

    By default ejabberd opens 10 connections to the database for each virtual host. -Use this option to modify the value: -

    {odbc_pool_size, 10}.
    -

    You can configure an interval to make a dummy SQL request -to keep alive the connections to the database. -The default value is ’undefined’, so no keepalive requests are made. -Specify in seconds: for example 28800 means 8 hours. -

    {odbc_keepalive_interval, undefined}.
    -

    -

    Authentication

    -

    The option value name may be misleading, as the auth_method name is used -for access to a relational database through ODBC, as well as through the native -PostgreSQL interface. Anyway, the first configuration step is to define the odbc -auth_method. For example: -

    {auth_method, [odbc]}.
    -

    -

    Storage

    -

    PostgreSQL also can be used to store information into from several ejabberd -modules. See section 3.3.1 to see which modules can be used with -relational databases like MySQL. To enable storage to your database, just make -sure that your database is running well (see previous sections), and add the -module option {db_type, odbc}.

    -

    3.2.4  ODBC Compatible

    -

    Although this section will describe ejabberd’s configuration when you want to -use the ODBC driver, it does not describe the installation and database creation -of your database. Check the documentation of your database. The tutorial Using ejabberd with MySQL native driver also can help you. Note that the tutorial -contains information about ejabberd’s configuration which is duplicate to -this section.

    -

    Driver Compilation

    You can skip this step if you installed ejabberd using a binary installer or -if the binary packages of ejabberd you are using include support for -ODBC.

    1. -First, install the Erlang -MySQL library. Make sure the compiled files are in your Erlang path; you can -put them for example in the same directory as your ejabberd .beam files. -
    2. Then, configure, compile and install ejabberd with ODBC support -enabled. This can be done, by using next commands: -
      ./configure --enable-odbc && make install
      -

    -

    Database Connection

    -

    The actual database access is defined in the option odbc_server. Its -value is used to defined if we want to use ODBC, or one of the two native -interface available, PostgreSQL or MySQL.

    To use a relational database through ODBC, you can pass the ODBC connection -string as odbc_server parameter. For example: -

    {odbc_server, "DSN=database;UID=ejabberd;PWD=password"}.
    -

    By default ejabberd opens 10 connections to the database for each virtual host. -Use this option to modify the value: -

    {odbc_pool_size, 10}.
    -

    You can configure an interval to make a dummy SQL request -to keep alive the connections to the database. -The default value is ’undefined’, so no keepalive requests are made. -Specify in seconds: for example 28800 means 8 hours. -

    {odbc_keepalive_interval, undefined}.
    -

    -

    Authentication

    -

    The first configuration step is to define the odbc auth_method. For -example: -

    {auth_method, [odbc]}.
    +
    odbc_start_interval: N
    If the connection to the database fails, +ejabberd waits 30 seconds before retrying. +You can modify this interval with this option. +

    Example of plain ODBC connection: +

    odbc_server: "DSN=database;UID=ejabberd;PWD=password"
    +

    Example of MySQL connection: +

    odbc_type: mysql
    +odbc_server: "server.company.com"
    +odbc_port: 3306 # the default
    +odbc_database: "mydb"
    +odbc_username: "user1"
    +odbc_password: "**********"
    +odbc_pool_size: 5
     

    Storage

    An ODBC compatible database also can be used to store information into from @@ -1700,8 +1782,8 @@ several ejabberd modules. See section 3.3.1 to see which modules can be used with relational databases like MySQL. To enable storage to your database, just make sure that your database is running well (see previous sections), and add the -module option {db_type, odbc}.

    -

    3.2.5  LDAP

    +module option db_type: odbc.

    +

    3.2.2  LDAP

    ejabberd has built-in LDAP support. You can authenticate users against LDAP server and use LDAP directory as vCard storage.

    Usually ejabberd treats LDAP as a read-only storage: it is possible to consult data, but not possible to @@ -1712,50 +1794,51 @@ and LDAP server supports

    Connection

    Two connections are established to the LDAP server per vhost, one for authentication and other for regular calls.

    Parameters:

    -{ldap_servers, [Servers, ...]}
    List of IP addresses or DNS names of your +ldap_servers: [Servers, ...]
    List of IP addresses or DNS names of your LDAP servers. This option is required. -
    {ldap_encrypt, none|tls}
    Type of connection encryption to the LDAP server. +
    ldap_encrypt: none|tls
    Type of connection encryption to the LDAP server. Allowed values are: none, tls. The value tls enables encryption by using LDAP over SSL. Note that STARTTLS encryption is not supported. The default value is: none. -
    {ldap_tls_verify, false|soft|hard}
    +
    ldap_tls_verify: false|soft|hard
    This option specifies whether to verify LDAP server certificate or not when TLS is enabled. When hard is enabled ejabberd doesn’t proceed if a certificate is invalid. When soft is enabled ejabberd proceeds even if check fails. The default is false which means no checks are performed. -
    {ldap_tls_cacertfile, Path}
    +
    ldap_tls_cacertfile: Path
    Path to file containing PEM encoded CA certificates. This option is needed (and required) when TLS verification is enabled. -
    {ldap_tls_depth, Number}
    +
    ldap_tls_depth: Number
    Specifies the maximum verification depth when TLS verification is enabled, i.e. how far in a chain of certificates the verification process can proceed before the verification is considered to fail. Peer certificate = 0, CA certificate = 1, higher level CA certificate = 2, etc. The value 2 thus means that a chain can at most contain peer cert, CA cert, next CA cert, and an additional CA cert. The default value is 1. -
    {ldap_port, Number}
    Port to connect to your LDAP server. +
    ldap_port: Number
    Port to connect to your LDAP server. The default port is 389 if encryption is disabled; and 636 if encryption is enabled. If you configure a value, it is stored in ejabberd’s database. Then, if you remove that value from the configuration file, the value previously stored in the database will be used instead of the default port. -
    {ldap_rootdn, RootDN}
    Bind DN. The default value +
    ldap_rootdn: RootDN
    Bind DN. The default value is "" which means ‘anonymous connection’. -
    {ldap_password, Password}
    Bind password. The default +
    ldap_password: Password
    Bind password. The default value is "". -
    {ldap_deref_aliases, never|always|finding|searching}
    Whether or not to dereference aliases. The default is never. +
    ldap_deref_aliases: never|always|finding|searching
    Whether or not to dereference aliases. The default is never.

    Example: -

    {auth_method, ldap}.
    -{ldap_servers, ["ldap.example.org"]}.
    -{ldap_port, 389}.
    -{ldap_rootdn, "cn=Manager,dc=domain,dc=org"}.
    -{ldap_password, "secret"}.
    +

    auth_method: [ldap]
    +ldap_servers:
    +  - "ldap1.example.org"
    +ldap_port: 389
    +ldap_rootdn: "cn=Manager,dc=domain,dc=org"
    +ldap_password: "**********"
     

    Authentication

    You can authenticate users against an LDAP directory. Note that current LDAP implementation does not support SASL authentication.

    Available options are:

    -{ldap_base, Base}
    LDAP base directory which stores +ldap_base: Base
    LDAP base directory which stores users accounts. This option is required. -
    {ldap_uids, [ {ldap_uidattr} | {ldap_uidattr, ldap_uidattr_format}, ...]}
    +
    ldap_uids: [ ldap_uidattr | {ldap_uidattr: ldap_uidattr_format} ]
    LDAP attribute which holds a list of attributes to use as alternatives for getting the JID. The default attributes are [{"uid", "%u"}]. The attributes are of the form: @@ -1772,14 +1855,14 @@ only one pattern variable "%u" which will be replaced by the user’s part of a JID. For example, "%u@example.org". The default value is "%u".
    -
    {ldap_filter, Filter}
    +
    ldap_filter: Filter
    RFC 4515 LDAP filter. The default Filter value is: undefined. Example: "(&(objectClass=shadowAccount)(memberOf=Jabber Users))". Please, do not forget to close brackets and do not use superfluous whitespaces. Also you must not use ldap_uidattr attribute in filter because this attribute will be substituted in LDAP filter automatically. -
    {ldap_dn_filter, { Filter, FilterAttrs }}
    +
    ldap_dn_filter: { Filter: FilterAttrs }
    This filter is applied on the results returned by the main filter. This filter performs additional LDAP lookup to make the complete result. This is useful when you are unable to define all filter rules in ldap_filter. You @@ -1790,7 +1873,8 @@ all "%s" variables are consecutively replaced by values of FilterAttrs attributes and "%D" is replaced by Distinguished Name. By default ldap_dn_filter is undefined. Example: -
    {ldap_dn_filter, {"(&(name=%s)(owner=%D)(user=%u@%d))", ["sn"]}}.
    +
    ldap_dn_filter:
    +  "(&(name=%s)(owner=%D)(user=%u@%d))": ["sn"]
     
    Since this filter makes additional LDAP lookups, use it only in the last resort: try to define all filter rules in ldap_filter if possible.
    {ldap_local_filter, Filter}
    @@ -1812,140 +1896,130 @@ Also we have addressbook, which contains users emails and their additional infos in "ou=AddressBook,dc=example,dc=org" directory. The connection to the LDAP server is encrypted using TLS, and using the custom port 6123. -Corresponding authentication section should looks like this:

    %% Authentication method
    -{auth_method, ldap}.
    -%% DNS name of our LDAP server
    -{ldap_servers, ["ldap.example.org"]}.
    -%% Bind to LDAP server as "cn=Manager,dc=example,dc=org" with password "secret"
    -{ldap_rootdn, "cn=Manager,dc=example,dc=org"}.
    -{ldap_password, "secret"}.
    -{ldap_encrypt, tls}.
    -{ldap_port, 6123}.
    -%% Define the user's base
    -{ldap_base, "ou=Users,dc=example,dc=org"}.
    -%% We want to authorize users from 'shadowAccount' object class only
    -{ldap_filter, "(objectClass=shadowAccount)"}.
    +Corresponding authentication section should looks like this:

    ## Authentication method
    +auth_method: [ldap]
    +## DNS name of our LDAP server
    +ldap_servers: ["ldap.example.org"]
    +## Bind to LDAP server as "cn=Manager,dc=example,dc=org" with password "secret"
    +ldap_rootdn: "cn=Manager,dc=example,dc=org"
    +ldap_password: "secret"
    +ldap_encrypt: tls
    +ldap_port: 6123
    +## Define the user's base
    +ldap_base: "ou=Users,dc=example,dc=org"
    +## We want to authorize users from 'shadowAccount' object class only
    +ldap_filter: "(objectClass=shadowAccount)"
     

    Now we want to use users LDAP-info as their vCards. We have four attributes defined in our LDAP schema: "mail" — email address, "givenName" — first name, "sn" — second name, "birthDay" — birthday. -Also we want users to search each other. Let’s see how we can set it up:

    {modules,
    - [
    +Also we want users to search each other. Let’s see how we can set it up:

    modules:
       ...
    -  {mod_vcard_ldap,
    -   [
    -    %% We use the same server and port, but want to bind anonymously because
    -    %% our LDAP server accepts anonymous requests to
    -    %% "ou=AddressBook,dc=example,dc=org" subtree.
    -    {ldap_rootdn, ""},
    -    {ldap_password, ""},
    -    %% define the addressbook's base
    -    {ldap_base, "ou=AddressBook,dc=example,dc=org"},
    -    %% uidattr: user's part of JID is located in the "mail" attribute
    -    %% uidattr_format: common format for our emails
    -    {ldap_uids, [{"mail", "%u@mail.example.org"}]},
    -    %% We have to define empty filter here, because entries in addressbook does not
    -    %% belong to shadowAccount object class
    -    {ldap_filter, ""},
    -    %% Now we want to define vCard pattern
    -    {ldap_vcard_map,
    -     [{"NICKNAME", "%u", []}, % just use user's part of JID as his nickname
    -      {"GIVEN", "%s", ["givenName"]},
    -      {"FAMILY", "%s", ["sn"]},
    -      {"FN", "%s, %s", ["sn", "givenName"]}, % example: "Smith, John"
    -      {"EMAIL", "%s", ["mail"]},
    -      {"BDAY", "%s", ["birthDay"]}]},
    -    %% Search form
    -    {ldap_search_fields,
    -     [{"User", "%u"},
    -      {"Name", "givenName"},
    -      {"Family Name", "sn"},
    -      {"Email", "mail"},
    -      {"Birthday", "birthDay"}]},
    -    %% vCard fields to be reported
    -    %% Note that JID is always returned with search results
    -    {ldap_search_reported,
    -     [{"Full Name", "FN"},
    -      {"Nickname", "NICKNAME"},
    -      {"Birthday", "BDAY"}]}
    -  ]},
    +  mod_vcard_ldap:
    +    ## We use the same server and port, but want to bind anonymously because
    +    ## our LDAP server accepts anonymous requests to
    +    ## "ou=AddressBook,dc=example,dc=org" subtree.
    +    ldap_rootdn: ""
    +    ldap_password: ""
    +    ## define the addressbook's base
    +    ldap_base: "ou=AddressBook,dc=example,dc=org"
    +    ## uidattr: user's part of JID is located in the "mail" attribute
    +    ## uidattr_format: common format for our emails
    +    ldap_uids:
    +      "mail": "%u@mail.example.org"
    +    ## We have to define empty filter here, because entries in addressbook does not
    +    ## belong to shadowAccount object class
    +    ldap_filter: ""
    +    ## Now we want to define vCard pattern
    +    ldap_vcard_map:
    +     "NICKNAME": {"%u": []} # just use user's part of JID as his nickname
    +     "GIVEN": {"%s": ["givenName"]}
    +     "FAMILY": {"%s": ["sn"]}
    +     "FN": {"%s, %s": ["sn", "givenName"]}, # example: "Smith, John"
    +     "EMAIL": {"%s": ["mail"]}
    +     "BDAY": {"%s": ["birthDay"]}]}
    +    ## Search form
    +    ldap_search_fields:
    +      "User": "%u"
    +      "Name": "givenName"
    +      "Family Name": "sn"
    +      "Email": "mail"
    +      "Birthday": "birthDay"
    +    ## vCard fields to be reported
    +    ## Note that JID is always returned with search results
    +    ldap_search_reported:
    +      "Full Name": "FN"
    +      "Nickname": "NICKNAME"
    +      "Birthday": "BDAY"
       ...
    - ]}.
     

    Note that mod_vcard_ldap module checks for the existence of the user before searching in his information in LDAP.

    Active Directory

    Active Directory is just an LDAP-server with predefined attributes. A sample -configuration is shown below:

    {auth_method, ldap}.
    -{ldap_servers, ["office.org"]}.    % List of LDAP servers
    -{ldap_base, "DC=office,DC=org"}. % Search base of LDAP directory
    -{ldap_rootdn, "CN=Administrator,CN=Users,DC=office,DC=org"}. % LDAP manager
    -{ldap_password, "*******"}. % Password to LDAP manager
    -{ldap_uids, [{"sAMAccountName"}]}.
    -{ldap_filter, "(memberOf=*)"}.
    +configuration is shown below:

    auth_method: [ldap]
    +ldap_servers: ["office.org"]  # List of LDAP servers
    +ldap_base: "DC=office,DC=org" # Search base of LDAP directory
    +ldap_rootdn: "CN=Administrator,CN=Users,DC=office,DC=org" # LDAP manager
    +ldap_password: "*******" # Password to LDAP manager
    +ldap_uids: ["sAMAccountName"]
    +ldap_filter: "(memberOf=*)"
     
    -{modules,
    - [
    +modules: 
       ...
    -  {mod_vcard_ldap,
    -   [{ldap_vcard_map,
    -     [{"NICKNAME", "%u", []},
    -      {"GIVEN", "%s", ["givenName"]},
    -      {"MIDDLE", "%s", ["initials"]},
    -      {"FAMILY", "%s", ["sn"]},
    -      {"FN", "%s", ["displayName"]},
    -      {"EMAIL", "%s", ["mail"]},
    -      {"ORGNAME", "%s", ["company"]},
    -      {"ORGUNIT", "%s", ["department"]},
    -      {"CTRY", "%s", ["c"]},
    -      {"LOCALITY", "%s", ["l"]},
    -      {"STREET", "%s", ["streetAddress"]},
    -      {"REGION", "%s", ["st"]},
    -      {"PCODE", "%s", ["postalCode"]},
    -      {"TITLE", "%s", ["title"]},
    -      {"URL", "%s", ["wWWHomePage"]},
    -      {"DESC", "%s", ["description"]},
    -      {"TEL", "%s", ["telephoneNumber"]}]},
    -    {ldap_search_fields,
    -     [{"User", "%u"},
    -      {"Name", "givenName"},
    -      {"Family Name", "sn"},
    -      {"Email", "mail"},
    -      {"Company", "company"},
    -      {"Department", "department"},
    -      {"Role", "title"},
    -      {"Description", "description"},
    -      {"Phone", "telephoneNumber"}]},
    -    {ldap_search_reported,
    -     [{"Full Name", "FN"},
    -      {"Nickname", "NICKNAME"},
    -      {"Email", "EMAIL"}]}
    -  ]},
    +  mod_vcard_ldap: 
    +    ldap_vcard_map: 
    +      "NICKNAME": {"%u", []}
    +      "GIVEN": {"%s", ["givenName"]}
    +      "MIDDLE": {"%s", ["initials"]}
    +      "FAMILY": {"%s", ["sn"]}
    +      "FN": {"%s", ["displayName"]}
    +      "EMAIL": {"%s", ["mail"]}
    +      "ORGNAME": {"%s", ["company"]}
    +      "ORGUNIT": {"%s", ["department"]}
    +      "CTRY": {"%s", ["c"]}
    +      "LOCALITY": {"%s", ["l"]}
    +      "STREET": {"%s", ["streetAddress"]}
    +      "REGION": {"%s", ["st"]}
    +      "PCODE": {"%s", ["postalCode"]}
    +      "TITLE": {"%s", ["title"]}
    +      "URL": {"%s", ["wWWHomePage"]}
    +      "DESC": {"%s", ["description"]}
    +      "TEL": {"%s", ["telephoneNumber"]}]}
    +    ldap_search_fields: 
    +      "User": "%u"
    +      "Name": "givenName"
    +      "Family Name": "sn"
    +      "Email": "mail"
    +      "Company": "company"
    +      "Department": "department"
    +      "Role": "title"
    +      "Description": "description"
    +      "Phone": "telephoneNumber"
    +    ldap_search_reported: 
    +      "Full Name": "FN"
    +      "Nickname": "NICKNAME"
    +      "Email": "EMAIL"
       ...
    - ]}.
     

    -

    3.3  Modules Configuration

    +

    3.3  Modules Configuration

    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.

    The syntax is: -

    {modules, [ {ModuleName, ModuleOptions}, ...]}.

    Examples: +

    modules: { ModuleName: ModuleOptions }

    Examples:

    • In this example only the module mod_echo is loaded and no module options are specified between the square brackets: -
      {modules,
      - [
      -  {mod_echo,      []}
      - ]}.
      +
      modules:
      +  mod_echo: {}
       
    • In the second example the modules mod_echo, mod_time, and mod_version are loaded without options. Remark that, besides the last entry, all entries end with a comma: -
      {modules,
      - [
      -  {mod_echo,      []},
      -  {mod_time,      []},
      -  {mod_version,   []}
      - ]}.
      +
      modules:
      +  mod_echo:      {}
      +  mod_time:      {}
      +  mod_version:   {}
       

    -

    3.3.1  Modules Overview

    +

    3.3.1  Modules Overview

    The following table lists all modules included in ejabberd.


    @@ -1995,14 +2069,14 @@ Mnesia as backend, or a ODBC database in some cases (see 

    -

    3.3.2  Common Options

    The following options are used by many modules. Therefore, they are described in +

    3.3.2  Common Options

    The following options are used by many modules. Therefore, they are described in this separate section.

    iqdisc

    Many modules define handlers for processing IQ queries of different namespaces to this server or to a user (e. g. to example.org or to user@example.org). This option defines processing discipline for these queries.

    The syntax is: -

    {iqdisc, Value}

    Possible Value are: +

    iqdisc: Value

    Possible Value are:

    no_queue
    All queries of a namespace with this processing discipline are processed directly. This means that the XMPP connection that sends this IQ query gets blocked: @@ -2013,7 +2087,7 @@ recommended if the processing of a query can take a relatively long time. of IQ queries of a namespace with this discipline. In addition, the processing of this queue is done in parallel with that of other packets. This discipline is most recommended. -
    {queues, N}
    N separate queues are created to process the +
    N
    N separate queues are created to process the queries. The queries are thus processed in parallel, but in a controlled way.
    parallel
    For every packet with this discipline a separate Erlang process @@ -2022,35 +2096,32 @@ Although spawning of Erlang process has a relatively low cost, this can break the server’s normal work, because the Erlang emulator has a limit on the number of processes (32000 by default).

    Example: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_time, [{iqdisc, no_queue}]},
    +  mod_time:
    +    iqdisc: no_queue
       ...
    - ]}.
     

    host

    This option defines the Jabber ID of a service provided by an ejabberd module.

    The syntax is: -

    {host, HostName}

    If you include the keyword "@HOST@" in the HostName, +

    host: HostName

    If you include the keyword "@HOST@" in the HostName, it is replaced at start time with the real virtual host string.

    This example configures the echo module to provide its echoing service in the Jabber ID mirror.example.org: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_echo, [{host, "mirror.example.org"}]},
    +  mod_echo:
    +    host: "mirror.example.org"
       ...
    - ]}.
     

    However, if there are several virtual hosts and this module is enabled in all of them, the "@HOST@" keyword must be used: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_echo, [{host, "mirror.@HOST@"}]},
    +  mod_echo:
    +    host: "mirror.@HOST@"
       ...
    - ]}.
     

    -

    3.3.3  mod_announce

    +

    3.3.3  mod_announce

    This module enables configured users to broadcast announcements and to set the message of the day (MOTD). Configured users can perform these actions with a @@ -2081,44 +2152,50 @@ login. The message is not sent to any currently connected user. Any message sent to this JID removes the existing message of the day (MOTD).

    Options:

    -{db_type, mnesia|odbc}
    +db_type: internal|odbc
    Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2. -
    {access, AccessName}
    This option specifies who is allowed to +
    access: AccessName
    This option specifies who is allowed to send announcements and to set the message of the day (by default, nobody is able to send such messages).

    Examples:

    • Only administrators can send announcements: -
      {access, announce, [{allow, admin}]}.
      +
      access:
      +  announce:
      +    admin: allow
       
      -{modules,
      - [
      +modules:
         ...
      -  {mod_adhoc, []},
      -  {mod_announce, [{access, announce}]},
      +  mod_adhoc: {}
      +  mod_announce:
      +    access: announce
         ...
      - ]}.
       
    • Administrators as well as the direction can send announcements: -
      {acl, direction, {user, "big_boss", "example.org"}}.
      -{acl, direction, {user, "assistant", "example.org"}}.
      -{acl, admin, {user, "admin", "example.org"}}.
      +
      acl:
      +  direction:
      +    user:
      +      "big_boss": "example.org"
      +      "assistant": "example.org"
      +  admin:
      +    user:
      +      "admin": "example.org"
      +access:
      +  announce:
      +    admin: allow
      +    direction: allow
       
      -{access, announce, [{allow, admin},
      -                    {allow, direction}]}.
      -
      -{modules,
      - [
      +modules:
         ...
      -  {mod_adhoc, []},
      -  {mod_announce, [{access, announce}]},
      +  mod_adhoc: {}
      +  mod_announce:
      +    access: announce
         ...
      - ]}.
       

    Note that mod_announce can be resource intensive on large deployments as it can broadcast lot of messages. This module should be disabled for instances of ejabberd with hundreds of thousands users.

    -

    3.3.4  mod_disco

    +

    3.3.4  mod_disco

    @@ -2131,162 +2208,163 @@ for the superseded Jabber Browsing (

    -{iqdisc, Discipline}
    This specifies +iqdisc: Discipline
    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 3.3.2). -
    {extra_domains, [Domain, ...]}
    With this option, +
    extra_domains: [Domain, ...]
    With this option, you can specify a list of extra domains that are added to the Service Discovery item list. -
    {server_info, [ {Modules, Field, [Value, ...]}, ... ]}
    +
    server_info: [ { modules: Modules, name: Name, urls: [URL, ...] } ]
    Specify additional information about the server, as described in Contact Addresses for XMPP Services (XEP-0157). Modules can be the keyword ‘all’, in which case the information is reported in all the services; or a list of ejabberd modules, in which case the information is only specified for the services provided by those modules. -Any arbitrary Field and Value can be specified, not only contact addresses. +Any arbitrary Name and URL can be specified, not only contact addresses.

    Examples:

    • To serve a link to the Jabber User Directory on jabber.org: -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_disco, [{extra_domains, ["users.jabber.org"]}]},
      +  mod_disco:
      +    extra_domains: ["users.jabber.org"]
         ...
      - ]}.
       
    • To serve a link to the transports on another server: -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_disco, [{extra_domains, ["icq.example.com",
      -                                "msn.example.com"]}]},
      +  mod_disco:
      +    extra_domains:
      +      - "icq.example.com"
      +      - "msn.example.com"
         ...
      - ]}.
       
    • To serve a link to a few friendly servers: -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_disco, [{extra_domains, ["example.org",
      -                                "example.com"]}]},
      +  mod_disco:
      +    extra_domains:
      +      - "example.org"
      +      - "example.com"
         ...
      - ]}.
       
    • With this configuration, all services show abuse addresses, feedback address on the main server, and admin addresses for both the main server and the vJUD service: -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_disco, [{server_info, [
      -      {all,
      -       "abuse-addresses",
      -       ["mailto:abuse@shakespeare.lit"]},
      -      {[mod_muc],
      -       "Web chatroom logs",
      -       ["http://www.example.org/muc-logs"]},
      -      {[mod_disco],
      -       "feedback-addresses",
      -       ["http://shakespeare.lit/feedback.php", "mailto:feedback@shakespeare.lit", "xmpp:feedback@shakespeare.lit"]},
      -      {[mod_disco, mod_vcard],
      -       "admin-addresses",
      -       ["mailto:xmpp@shakespeare.lit", "xmpp:admins@shakespeare.lit"]}
      -  ]}]},
      +  mod_disco:
      +    server_info:
      +      - 
      +        modules: all
      +        name: "abuse-addresses"
      +        urls: ["mailto:abuse@shakespeare.lit"]
      +      - 
      +        modules: [mod_muc]
      +        name: "Web chatroom logs"
      +        urls: ["http://www.example.org/muc-logs"]
      +      - 
      +        modules: [mod_disco]
      +        name: "feedback-addresses"
      +        urls:
      +          - "http://shakespeare.lit/feedback.php"
      +          - "mailto:feedback@shakespeare.lit"
      +          - "xmpp:feedback@shakespeare.lit"
      +      - 
      +        modules:
      +          - mod_disco
      +          - mod_vcard
      +        name: "admin-addresses"
      +        urls:
      +          - "mailto:xmpp@shakespeare.lit"
      +          - "xmpp:admins@shakespeare.lit"
         ...
      - ]}.
       

    -

    3.3.5  mod_echo

    +

    3.3.5  mod_echo

    This module simply echoes any XMPP packet back to the sender. This mirror can be of interest for ejabberd and XMPP client debugging.

    Options:

    -{host, HostName}
    This option defines the Jabber ID of the +host: HostName
    This option defines the Jabber ID of the service. If the host option is not specified, the Jabber ID will be the hostname of the virtual host with the prefix ‘echo.’. The keyword "@HOST@" is replaced at start time with the real virtual host name.

    Example: Mirror, mirror, on the wall, who is the most beautiful of them all? -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_echo, [{host, "mirror.example.org"}]},
    +  mod_echo:
    +    host: "mirror.example.org"
       ...
    - ]}.
     

    -

    3.3.6  mod_http_bind

    +

    3.3.6  mod_http_bind

    This module implements XMPP over Bosh (formerly known as HTTP Binding) as defined in XEP-0124 and XEP-0206. It extends ejabberd’s built in HTTP service with a configurable resource at which this service will be hosted.

    To use HTTP-Binding, enable the module: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_http_bind, []},
    +  mod_http_bind: {}
       ...
    -]}.
     

    and add http_bind in the HTTP service. For example: -

    {listen, 
    - [
    +

    listen:
       ...
    -  {5280, ejabberd_http, [
    -                         http_bind,
    -                         http_poll,
    -                         web_admin
    -                        ]
    -  },
    +  - 
    +    port: 5280
    +    module: ejabberd_http
    +    http_bind: true
    +    http_poll: true
    +    web_admin: true
       ...
    -]}.
     

    With this configuration, the module will serve the requests sent to http://example.org:5280/http-bind/ Remember that this page is not designed to be used by web browsers, it is used by XMPP clients that support XMPP over Bosh.

    If you want to set the service in a different URI path or use a different module, you can configure it manually using the option request_handlers. For example: -

    {listen, 
    - [
    +

    listen:
       ...
    -  {5280, ejabberd_http, [
    -                         {request_handlers, [{["http-bind"], mod_http_bind}]},
    -                         http_poll,
    -                         web_admin
    -                        ]
    -  },
    +  - 
    +    port: 5280
    +    module: ejabberd_http
    +    request_handlers:
    +       "/http-bind": mod_http_bind
    +    http_poll: true
    +    web_admin: true
       ...
    -]}.
     

    Options:

    {max_inactivity, Seconds}
    Define the maximum inactivity period in seconds. Default value is 30 seconds. For example, to set 50 seconds: -
    {modules,
    - [
    +
    modules:
       ...
    -  {mod_http_bind, [ {max_inactivity, 50} ]},
    +  mod_http_bind:
    +    max_inactivity: 50
       ...
    -]}.
     

    -

    3.3.7  mod_http_fileserver

    +

    3.3.7  mod_http_fileserver

    This simple module serves files from the local disk over HTTP.

    Options:

    -{docroot, Path}
    +docroot: Path
    Directory to serve the files. -
    {accesslog, Path}
    +
    accesslog: Path
    File to log accesses using an Apache-like format. No log will be recorded if this option is not specified. -
    {directory_indices, [Index, ...]}
    +
    directory_indices: [Index, ...]
    Indicate one or more directory index files, similarly to Apache’s DirectoryIndex variable. When a web request hits a directory instead of a regular file, those directory indices are looked in order, and the first one found is returned. -
    {custom_headers, [ {Name, Value}, ...]}
    +
    custom_headers: {Name: Value}
    Indicate custom HTTP headers to be included in all responses. Default value is: [] -
    {content_types, [ {Name, Type}, ...]}
    +
    content_types: {Name: Type}
    Specify mappings of extension to content type. There are several content types already defined, with this option you can add new definitions, modify or delete existing ones. To delete an existing definition, simply define it with a value: ‘undefined’. -
    {default_content_type, Type}
    +
    default_content_type: Type
    Specify the content type to use for unknown extensions. Default value is ‘application/octet-stream’.

    This example configuration will serve the files from @@ -2295,44 +2373,36 @@ in the address http://example.org:5280/pub/archive/. In this example a new content type ogg is defined, png is redefined, and jpg definition is deleted. To use this module you must enable it: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_http_fileserver, [
    -                         {docroot, "/var/www"}, 
    -                         {accesslog, "/var/log/ejabberd/access.log"},
    -                         {directory_indices, ["index.html", "main.htm"]},
    -                         {custom_headers, [{"X-Powered-By", "Erlang/OTP"},
    -                                           {"X-Fry", "It's a widely-believed fact!"}
    -                                          ]},
    -                         {content_types, [{".ogg", "audio/ogg"},
    -                                          {".png", "image/png"},
    -                                          {".jpg", undefined}
    -                                         ]},
    -                         {default_content_type, "text/html"}
    -                        ]
    -  },
    +  mod_http_fileserver:
    +    docroot: "/var/www"
    +    accesslog: "/var/log/ejabberd/access.log"
    +    directory_indices:
    +      - "index.html"
    +      - "main.htm"
    +    custom_headers:
    +      "X-Powered-By": "Erlang/OTP"
    +      "X-Fry": "It's a widely-believed fact!"
    +    content_types:
    +      ".ogg": "audio/ogg"
    +      ".png": "image/png"
    +      ".jpg": undefined
    +    default_content_type: "text/html"
       ...
    -]}.
     

    And define it as a handler in the HTTP service: -

    {listen, 
    - [
    +

    listen:
       ...
    -  {5280, ejabberd_http, [
    -                         ...
    -                         {request_handlers, [
    -                                             ...
    -                                             {["pub", "archive"], mod_http_fileserver},
    -                                             ...
    -                                            ]
    -                         },
    -                         ...
    -                        ]
    -  },
    +  - 
    +    port: 5280
    +    module: ejabberd_http
    +    request_handlers:
    +      ...
    +      "/pub/archive": mod_http_fileserver
    +      ...
       ...
    -]}.
     

    -

    3.3.8  mod_irc

    +

    3.3.8  mod_irc

    This module is an IRC transport that can be used to join channels on IRC servers.

    End user information: @@ -2356,61 +2426,66 @@ number of connections from one IP.

    Options:

    -{host, HostName}
    This option defines the Jabber ID of the +host: HostName
    This option defines the Jabber ID of the service. If the host option is not specified, the Jabber ID will be the hostname of the virtual host with the prefix ‘irc.’. The keyword "@HOST@" is replaced at start time with the real virtual host name. -
    {db_type, mnesia|odbc}
    +
    db_type: internal|odbc
    Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2. -
    {access, AccessName}
    This option can be used to specify who +
    access: AccessName
    This option can be used to specify who may use the IRC transport (default value: all). -
    {default_encoding, Encoding}
    Set the default IRC encoding. +
    default_encoding: Encoding
    Set the default IRC encoding. Default value: "iso8859-1"

    Examples:

    • In the first example, the IRC transport is available on (all) your virtual host(s) with the prefix ‘irc.’. Furthermore, anyone is able to use the transport. The default encoding is set to "iso8859-15". -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_irc, [{access, all}, {default_encoding, "iso8859-15"}]},
      +  mod_irc:
      +    access: all
      +    default_encoding: "iso8859-15"
         ...
      - ]}.
       
    • In next example the IRC transport is available with JIDs with prefix irc-t.net. Moreover, the transport is only accessible to two users of example.org, and any user of example.com: -
      {acl, paying_customers, {user, "customer1", "example.org"}}.
      -{acl, paying_customers, {user, "customer2", "example.org"}}.
      -{acl, paying_customers, {server, "example.com"}}.
      +
      acl:
      +  paying_customers:
      +    user:
      +      - "customer1": "example.org"
      +      - "customer2": "example.org"
      +    server: "example.com"
       
      -{access, irc_users, [{allow, paying_customers}, {deny, all}]}.
      +access:
      +  irc_users:
      +    paying_customers: allow
      +    all: deny
       
      -{modules,
      - [
      +modules:
         ...
      -  {mod_irc, [{access, irc_users},
      -             {host, "irc.example.net"}]},
      +  mod_irc:
      +    access: irc_users
      +    host: "irc.example.net"
         ...
      - ]}.
       

    -

    3.3.9  mod_last

    +

    3.3.9  mod_last

    This module adds support for Last Activity (XEP-0012). It can be used to discover when a disconnected user last accessed the server, to know when a connected user was last active on the server, or to query the uptime of the ejabberd server.

    Options:

    -{iqdisc, Discipline}
    This specifies +iqdisc: Discipline
    This specifies the processing discipline for Last activity (jabber:iq:last) IQ queries (see section 3.3.2). -
    {db_type, mnesia|odbc}
    +
    db_type: internal|odbc
    Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2.

    -

    3.3.10  mod_muc

    +

    3.3.10  mod_muc

    This module provides a Multi-User Chat (XEP-0045) service. Users can discover existing rooms, join or create them. Occupants of a room can chat in public or have private chats.

    Some of the features of Multi-User Chat: @@ -2432,24 +2507,24 @@ set of rooms goes down, the rooms disappear and they will be recreated on an available node on first connection attempt.

    Module options:

    -{host, HostName}
    This option defines the Jabber ID of the +host: HostName
    This option defines the Jabber ID of the service. If the host option is not specified, the Jabber ID will be the hostname of the virtual host with the prefix ‘conference.’. The keyword "@HOST@" is replaced at start time with the real virtual host name. -
    {db_type, mnesia|odbc}
    +
    db_type: internal|odbc
    Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2. -
    {access, AccessName}
    You can specify who is allowed to use +
    access: AccessName
    You can specify who is allowed to use the Multi-User Chat service. By default everyone is allowed to use it. -
    {access_create, AccessName}
    To configure who is +
    access_create: AccessName
    To configure who is allowed to create new rooms at the Multi-User Chat service, this option can be used. By default any account in the local ejabberd server is allowed to create rooms. -
    {access_persistent, AccessName}
    To configure who is +
    access_persistent: AccessName
    To configure who is allowed to modify the ’persistent’ room option. By default any account in the local ejabberd server is allowed to modify that option. -
    {access_admin, AccessName}
    This option specifies +
    access_admin: AccessName
    This option specifies who is allowed to administrate the Multi-User Chat service. The default value is none, which means that only the room creator can administer his room. @@ -2457,7 +2532,7 @@ The administrators can send a normal message to the service JID, and it will be shown in all active rooms as a service message. The administrators can send a groupchat message to the JID of an active room, and the message will be shown in the room as a service message. -
    {history_size, Size}
    A small history of +
    history_size: Size
    A small history of the current discussion is sent to users when they enter the room. With this option you can define the number of history messages to keep and send to users joining the room. The value is an @@ -2465,35 +2540,35 @@ integer. Setting the value to 0 disables the history feature and, as a result, nothing is kept in memory. The default value is 20. This value is global and thus affects all rooms on the service. -
    {max_users, Number}
    This option defines at +
    max_users: Number
    This option defines at the service level, the maximum number of users allowed per room. It can be lowered in each room configuration but cannot be increased in individual room configuration. The default value is 200. -
    {max_users_admin_threshold, Number}
    +
    max_users_admin_threshold: Number
    This option defines the number of service admins or room owners allowed to enter the room when the maximum number of allowed occupants was reached. The default limit is 5. -
    {max_user_conferences, Number}
    +
    max_user_conferences: Number
    This option defines the maximum number of rooms that any given user can join. The default value is 10. This option is used to prevent possible abuses. Note that this is a soft limit: some users can sometimes join more conferences in cluster configurations. -
    {max_room_id, Number}
    +
    max_room_id: Number
    This option defines the maximum number of characters that Room ID can have when creating a new room. The default value is to not limit: infinite. -
    {max_room_name, Number}
    +
    max_room_name: Number
    This option defines the maximum number of characters that Room Name can have when configuring the room. The default value is to not limit: infinite. -
    {max_room_desc, Number}
    +
    max_room_desc: Number
    This option defines the maximum number of characters that Room Description can have when configuring the room. The default value is to not limit: infinite. -
    {min_message_interval, Number}
    +
    min_message_interval: Number
    This option defines the minimum interval between two messages send by an occupant in seconds. This option is global and valid for all rooms. A decimal value can be used. When this option is not defined, @@ -2503,7 +2578,7 @@ be broadcasted by the service. A good value for this minimum message interval is 0.4 second. If an occupant tries to send messages faster, an error is send back explaining that the message has been discarded and describing the reason why the message is not acceptable. -
    {min_presence_interval, Number}
    +
    min_presence_interval: Number
    This option defines the minimum of time between presence changes coming from a given occupant in seconds. This option is global and valid for all rooms. A @@ -2515,41 +2590,41 @@ presence is cached by ejabberd and only the last presence is broadcasted to all occupants in the room after expiration of the interval delay. Intermediate presence packets are silently discarded. A good value for this option is 4 seconds. -
    {default_room_options, [ {OptionName, OptionValue}, ...]}
    +
    default_room_options: {OptionName: OptionValue}
    This module option allows to define the desired default room options. Note that the creator of a room can modify the options of his room at any time using an XMPP client with MUC capability. The available room options and the default values are:
    -{allow_change_subj, true|false}
    Allow occupants to change the subject. -
    {allow_private_messages, true|false}
    Occupants can send private messages to other occupants. -
    {allow_private_messages_from_visitors, anyone|moderators|nobody}
    Visitors can send private messages to other occupants. -
    {allow_query_users, true|false}
    Occupants can send IQ queries to other occupants. -
    {allow_user_invites, false|true}
    Allow occupants to send invitations. -
    {allow_visitor_nickchange, true|false}
    Allow visitors to +allow_change_subj: true|false
    Allow occupants to change the subject. +
    allow_private_messages: true|false
    Occupants can send private messages to other occupants. +
    allow_private_messages_from_visitors: anyone|moderators|nobody
    Visitors can send private messages to other occupants. +
    allow_query_users: true|false
    Occupants can send IQ queries to other occupants. +
    allow_user_invites: false|true
    Allow occupants to send invitations. +
    allow_visitor_nickchange: true|false
    Allow visitors to change nickname. -
    {allow_visitor_status, true|false}
    Allow visitors to send +
    allow_visitor_status: true|false
    Allow visitors to send status text in presence updates. If disallowed, the status text is stripped before broadcasting the presence update to all the room occupants. -
    {anonymous, true|false}
    The room is anonymous: +
    anonymous: true|false
    The room is anonymous: occupants don’t see the real JIDs of other occupants. Note that the room moderators can always see the real JIDs of the occupants. -
    {captcha_protected, false}
    +
    captcha_protected: false
    When a user tries to join a room where he has no affiliation (not owner, admin or member), -the room requires him to fill a CAPTCHA challenge (see section 3.1.8) +the room requires him to fill a CAPTCHA challenge (see section 3.1.9) in order to accept her join in the room. -
    {logging, false|true}
    The public messages are logged using mod_muc_log. -
    {max_users, 200}
    Maximum number of occupants in the room. -
    {members_by_default, true|false}
    The occupants that enter the room are participants by default, so they have ’voice’. -
    {members_only, false|true}
    Only members of the room can enter. -
    {moderated, true|false}
    Only occupants with ’voice’ can send public messages. -
    {password, "roompass123"}
    Password of the room. You may want to enable the next option too. -
    {password_protected, false|true}
    The password is required to enter the room. -
    {persistent, false|true}
    The room persists even if the last participant leaves. -
    {public, true|false}
    The room is public in the list of the MUC service, so it can be discovered. -
    {public_list, true|false}
    The list of participants is public, without requiring to enter the room. -
    {title, "Room Title"}
    A human-readable title of the room. +
    logging: false|true
    The public messages are logged using mod_muc_log. +
    max_users: 200
    Maximum number of occupants in the room. +
    members_by_default: true|false
    The occupants that enter the room are participants by default, so they have ’voice’. +
    members_only: false|true
    Only members of the room can enter. +
    moderated: true|false
    Only occupants with ’voice’ can send public messages. +
    password: "roompass123"
    Password of the room. You may want to enable the next option too. +
    password_protected: false|true
    The password is required to enter the room. +
    persistent: false|true
    The room persists even if the last participant leaves. +
    public: true|false
    The room is public in the list of the MUC service, so it can be discovered. +
    public_list: true|false
    The list of participants is public, without requiring to enter the room. +
    title: "Room Title"
    A human-readable title of the room.
    All of those room options can be set to true or false, except password and title which are strings, @@ -2565,19 +2640,23 @@ to new hardware. This will involve service breakdowns around 23:00 UMT. We apologise for this inconvenience.’ to conference.example.org, it will be displayed in all active rooms. In this example the history feature is disabled. -
    {acl, admin, {user, "admin", "example.org"}}.
    +
    acl:
    +  admin:
    +    user:
    +      - "admin": "example.org"
     
    -{access, muc_admin, [{allow, admin}]}.
    +access:
    +  muc_admin:
    +    admin: allow
     
    -{modules,
    - [
    +modules:
       ...
    -  {mod_muc, [{access, all},
    -             {access_create, all},
    -             {access_admin, muc_admin},
    -             {history_size, 0}]},
    +  mod_muc:
    +    access: all
    +    access_create: all
    +    access_admin: muc_admin
    +    history_size: 0
       ...
    - ]}.
     
  • In the second example the Multi-User Chat service is only accessible by paying customers registered on our domains and on other servers. Of course the administrator is also allowed to access rooms. In addition, he is the @@ -2588,61 +2667,64 @@ around 23:00 UMT. We apologise for this inconvenience.’ to conference.example.org, it will be displayed in all active rooms. No history_size option is used, this means that the feature is enabled and the default value of 20 history messages will be send to the users. -
    {acl, paying_customers, {user, "customer1", "example.net"}}.
    -{acl, paying_customers, {user, "customer2", "example.com"}}.
    -{acl, paying_customers, {user, "customer3", "example.org"}}.
    -{acl, admin, {user, "admin", "example.org"}}.
    +
    acl:
    +  paying_customers:
    +    user:
    +      - "customer1": "example.net"
    +      - "customer2": "example.com"
    +      - "customer3": "example.org"
    +  admin:
    +    user:
    +      - "admin": "example.org"
     
    -{access, muc_admin, [{allow, admin},
    -                      {deny, all}]}.
    -{access, muc_access, [{allow, paying_customers},
    -                      {allow, admin},
    -                      {deny, all}]}.
    +access:
    +  muc_admin
    +    admin: allow
    +    all: deny
    +  muc_access:
    +    paying_customers: allow
    +    admin: allow
    +    all: deny
     
    -{modules,
    - [
    +modules:
       ...
    -  {mod_muc, [{access, muc_access},
    -             {access_create, muc_admin},
    -             {access_admin, muc_admin}]},
    +  mod_muc:
    +    access: muc_access
    +    access_create: muc_admin
    +    access_admin: muc_admin
       ...
    - ]}.
     
  • In the following example, MUC anti abuse options are used. An occupant cannot send more than one message every 0.4 seconds and cannot change its presence more than once every 4 seconds. The length of Room IDs and Room Names are limited to 20 characters, and Room Description to 300 characters. No ACLs are -defined, but some user restriction could be added as well:
    {modules,
    - [
    +defined, but some user restriction could be added as well:
    modules:
       ...
    -  {mod_muc, [{min_message_interval, 0.4},
    -             {min_presence_interval, 4},
    -             {max_room_id, 20},
    -             {max_room_name, 20},
    -             {max_room_desc, 300}]},
    +  mod_muc:
    +    min_message_interval: 0.4
    +    min_presence_interval: 4
    +    max_room_id: 20
    +    max_room_name: 20
    +    max_room_desc: 300
       ...
    - ]}.
     
  • This example shows how to use default_room_options to make sure the newly created rooms have by default those options. -
    {modules,
    - [
    +
    modules:
       ...
    -  {mod_muc, [{access, muc_access},
    -             {access_create, muc_admin},
    -             {default_room_options,
    -              [
    -               {allow_change_subj, false},
    -               {allow_query_users, true},
    -               {allow_private_messages, true},
    -               {members_by_default, false},
    -               {title, "New chatroom"},
    -               {anonymous, false}
    -              ]},
    -             {access_admin, muc_admin}]},
    +  mod_muc:
    +    access: muc_access
    +    access_create: muc_admin
    +    default_room_options:
    +      allow_change_subj: false
    +      allow_query_users: true
    +      allow_private_messages: true
    +      members_by_default: false
    +      title: "New chatroom"
    +      anonymous: false
    +    access_admin: muc_admin
       ...
    - ]}.
     
  • -

    3.3.11  mod_muc_log

    +

    3.3.11  mod_muc_log

    This module enables optional logging of Multi-User Chat (MUC) public conversations to HTML. Once you enable this module, users can join a room using a MUC capable XMPP client, and if they have enough privileges, they can request the @@ -2665,54 +2747,54 @@ displayed, including the reason if available.

  • A custom link can be added on top of each page.
  • Options:

    -{access_log, AccessName}
    +access_log: AccessName
    This option restricts which occupants are allowed to enable or disable room logging. The default value is muc_admin. Note for this default setting you need to have an access rule for muc_admin in order to take effect. -
    {cssfile, false|URL}
    +
    cssfile: false|URL
    With this option you can set whether the HTML files should have a custom CSS file or if they need to use the embedded CSS file. Allowed values are false and an URL to a CSS file. With the first value, HTML files will include the embedded CSS code. With the latter, you can specify the URL of the custom CSS file (for example: "http://example.com/my.css"). The default value is false. -
    {dirname, room_jid|room_name}
    +
    dirname: room_jid|room_name
    Allows to configure the name of the room directory. Allowed values are room_jid and room_name. With the first value, the room directory name will be the full room JID. With the latter, the room directory name will be only the room name, not including the MUC service name. The default value is room_jid. -
    {dirtype, subdirs|plain}
    +
    dirtype: subdirs|plain
    The type of the created directories can be specified with this option. Allowed values are subdirs and plain. With the first value, subdirectories are created for each year and month. With the latter, the names of the log files contain the full date, and there are no subdirectories. The default value is subdirs. -
    {file_format, html|plaintext}
    +
    file_format: html|plaintext
    Define the format of the log files: html stores in HTML format, plaintext stores in plain text. The default value is html. -
    {file_permissions, {Mode, Group}}
    +
    file_permissions: {mode: Mode, group: Group}
    Define the permissions that must be used when creating the log files: the number of the mode, and the numeric id of the group that will own the files. The default value is {644, 33}. -
    {outdir, Path}
    +
    outdir: Path
    This option sets the full path to the directory in which the HTML files should be stored. Make sure the ejabberd daemon user has write access on that directory. The default value is "www/muc". -
    {spam_prevention true|false}
    +
    spam_prevention: true|false
    To prevent spam, the spam_prevention option adds a special attribute to links that prevent their indexation by search engines. The default value is true, which mean that nofollow attributes will be added to user submitted links. -
    {timezone, local|universal}
    +
    timezone: local|universal
    The time zone for the logs is configurable with this option. Allowed values are local and universal. With the first value, the local time, as reported to Erlang by the operating system, will be used. With the latter, GMT/UTC time will be used. The default value is local. -
    {top_link, {URL, Text}}
    +
    top_link: {URL: Text}
    With this option you can customize the link on the top right corner of each log file. The default value is {"/", "Home"}.

    Examples: @@ -2723,120 +2805,131 @@ of the log files will contain the full date, and there will be no subdirectories. The log files will be stored in /var/www/muclogs, and the time zone will be GMT/UTC. Finally, the top link will be <a href="http://www.jabber.ru/">Jabber.ru</a>. -

    {access, muc, [{allow, all}]}.
    +
    access: 
    +  muc: 
    +    all: allow
     
    -{modules,
    - [
    +modules: 
       ...
    -  {mod_muc_log, [
    -                 {access_log, muc},
    -                 {cssfile, "http://example.com/my.css"},
    -                 {dirtype, plain},
    -                 {dirname, room_jid},
    -                 {outdir, "/var/www/muclogs"},
    -                 {timezone, universal},
    -                 {spam_prevention, true},
    -                 {top_link, {"http://www.jabber.ru/", "Jabber.ru"}}
    -                ]},
    +  mod_muc_log: 
    +    access_log: muc
    +    cssfile: "http://example.com/my.css"
    +    dirtype: plain
    +    dirname: room_jid
    +    outdir: "/var/www/muclogs"
    +    timezone: universal
    +    spam_prevention: true
    +    top_link: 
    +      "http://www.jabber.ru/": "Jabber.ru"
       ...
    - ]}.
     
  • In the second example only admin1@example.org and admin2@example.net can enable logging, and the embedded CSS file will be used. The names of the log files will only contain the day (number), and there will be subdirectories for each year and month. The log files will be stored in /var/www/muclogs, and the local time will be used. Finally, the top link will be the default <a href="/">Home</a>. -
    {acl, admin, {user, "admin1", "example.org"}}.
    -{acl, admin, {user, "admin2", "example.net"}}.
    +
    acl: 
    +  admin: 
    +    user: 
    +      - "admin1": "example.org"
    +      - "admin2": "example.net"
    +access: 
    +  muc_log: 
    +    admin: allow
    +    all: deny
     
    -{access, muc_log, [{allow, admin},
    -                   {deny, all}]}.
    -
    -{modules,
    - [
    +modules: 
       ...
    -  {mod_muc_log, [
    -                 {access_log, muc_log},
    -                 {cssfile, false},
    -                 {dirtype, subdirs},
    -                 {dirtype, subdirs},
    -                 {file_permissions, {644, 33}},
    -                 {outdir, "/var/www/muclogs"},
    -                 {timezone, local}
    -                ]},
    +  mod_muc_log: 
    +    access_log: muc_log
    +    cssfile: false
    +    dirtype: subdirs
    +    file_permissions:
    +      mode: 644
    +      group: 33
    +    outdir: "/var/www/muclogs"
    +    timezone: local
       ...
    - ]}.
     
  • -

    3.3.12  mod_offline

    +

    3.3.12  mod_offline

    This module implements offline message storage (XEP-0160). 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 4.1).

    -{db_type, mnesia|odbc}
    +db_type: internal|odbc
    Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2. -
    {access_max_user_messages, AccessName}
    +
    access_max_user_messages: AccessName
    This option defines which access rule will be enforced to limit the maximum number of offline messages that a user can have (quota). When a user has too many offline messages, any new messages that he receive are discarded, and a resource-constraint error is returned to the sender. The default value is max_user_offline_messages. Then you can define an access rule with a syntax similar to -max_user_sessions (see 3.1.5). +max_user_sessions (see 3.1.6).

    This example allows power users to have as much as 5000 offline messages, administrators up to 2000, and all the other users up to 100. -

    {acl, admin, {user, "admin1", "localhost"}}.
    -{acl, admin, {user, "admin2", "example.org"}}.
    -{acl, poweruser, {user, "bob", "example.org"}}.
    -{acl, poweruser, {user, "jane", "example.org"}}.
    +

    acl: 
    +  admin: 
    +    user: 
    +      - "admin1": "localhost"
    +      - "admin2": "example.org"
    +  poweruser: 
    +    user: 
    +      - "bob": "example.org"
    +      - "jane": "example.org"
     
    -{access, max_user_offline_messages, [ {5000, poweruser}, {2000, admin}, {100, all} ]}.
    +access: 
    +  max_user_offline_messages: 
    +    poweruser: 5000
    +    admin: 2000
    +    all: 100
     
    -{modules,
    - [
    +modules: 
       ...
    -  {mod_offline,  [ {access_max_user_messages, max_user_offline_messages} ]},
    +  mod_offline: 
    +    access_max_user_messages: max_user_offline_messages
       ...
    - ]}.
     

    -

    3.3.13  mod_ping

    +

    3.3.13  mod_ping

    This module implements support for XMPP Ping (XEP-0199) and periodic keepalives. When this module is enabled ejabberd responds correctly to ping requests, as defined in the protocol.

    Configuration options:

    -{send_pings, true|false}
    +send_pings: true|false
    If this option is set to true, the server sends pings to connected clients that are not active in a given interval ping_interval. This is useful to keep client connections alive or checking availability. By default this option is disabled. -
    {ping_interval, Seconds}
    +
    ping_interval: Seconds
    How often to send pings to connected clients, if the previous option is enabled. If a client connection does not send or receive any stanza in this interval, a ping request is sent to the client. The default value is 60 seconds. -
    {timeout_action, none|kill}
    +
    timeout_action: none|kill
    What to do when a client does not answer to a server ping request in less than 32 seconds. The default is to do nothing.

    This example enables Ping responses, configures the module to send pings to client connections that are inactive for 4 minutes, and if a client does not answer to the ping in less than 32 seconds, its connection is closed: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_ping,  [{send_pings, true}, {ping_interval, 240}, {timeout_action, kill}]},
    +  mod_ping:
    +    send_pings: true
    +    ping_interval: 240
    +    timeout_action: kill
       ...
    - ]}.
     

    -

    3.3.14  mod_pres_counter

    +

    3.3.14  mod_pres_counter

    This module detects flood/spam in presence subscription stanza traffic. If a user sends or receives more of those stanzas in a time interval, the exceeding stanzas are silently dropped, and warning is logged.

    Configuration options:

    -{count, StanzaNumber}
    +count: StanzaNumber
    The number of subscription presence stanzas (subscribe, unsubscribe, subscribed, unsubscribed) allowed for any direction (input or output) @@ -2844,19 +2937,19 @@ per time interval. Please note that two users subscribing to each other usually generate 4 stanzas, so the recommended value is 4 or more. The default value is: 5. -
    {interval, Seconds}
    +
    interval: Seconds
    The time interval defined in seconds. The default value is 60.

    This example enables the module, and allows up to 5 presence subscription stanzas to be sent or received by the users in 60 seconds: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_pres_counter,  [{count, 5}, {interval, 60}]},
    +  mod_pres_counter:
    +    count: 5
    +    interval: 60
       ...
    - ]}.
     

    -

    3.3.15  mod_privacy

    +

    3.3.15  mod_privacy

    This module implements Blocking Communication (also known as Privacy Rules) as defined in section 10 from XMPP IM. If end users have support for it in their XMPP client, they will be able to: @@ -2881,14 +2974,14 @@ subscription type (or globally). (from http://xmpp.org/rfcs/rfc3921.html#privacy)

    Options:

    -{iqdisc, Discipline}
    This specifies +iqdisc: Discipline
    This specifies the processing discipline for Blocking Communication (jabber:iq:privacy) IQ queries (see section 3.3.2). -
    {db_type, mnesia|odbc}
    +
    db_type: internal|odbc
    Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2.

    -

    3.3.16  mod_private

    +

    3.3.16  mod_private

    This module adds support for Private XML Storage (XEP-0049):

    Using this method, XMPP entities can store private data on the server and @@ -2897,78 +2990,87 @@ it is valid XML. One typical usage for this namespace is the server-side storage of client-specific preferences; another is Bookmark Storage (XEP-0048).

    Options:

    -{iqdisc, Discipline}
    This specifies +iqdisc: Discipline
    This specifies the processing discipline for Private XML Storage (jabber:iq:private) IQ queries (see section 3.3.2). -
    {db_type, mnesia|odbc}
    +
    db_type: internal|odbc
    Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2.

    -

    3.3.17  mod_proxy65

    +

    3.3.17  mod_proxy65

    This module implements SOCKS5 Bytestreams (XEP-0065). It allows ejabberd to act as a file transfer proxy between two XMPP clients.

    Options:

    -{host, HostName}
    This option defines the Jabber ID of the +host: HostName
    This option defines the Jabber ID of the service. If the host option is not specified, the Jabber ID will be the hostname of the virtual host with the prefix ‘proxy.’. The keyword "@HOST@" is replaced at start time with the real virtual host name. -
    {name, Text}
    Defines Service Discovery name of the service. +
    name: Text
    Defines Service Discovery name of the service. Default is "SOCKS5 Bytestreams". -
    {ip, IPTuple}
    This option specifies which network interface +
    ip: IP
    This option specifies which network interface to listen for. Default is an IP address of the service’s DNS name, or, -if fails, {127,0,0,1}. -
    {port, Number}
    This option defines port to listen for +if fails, "127.0.0.1". +
    port: Number
    This option defines port to listen for incoming connections. Default is 7777. -
    {hostname, HostName}
    Defines a hostname advertised +
    hostname: HostName
    Defines a hostname advertised by the service when establishing a session with clients. This is useful when you run the service behind a NAT. The default is the value of ip option. Examples: "proxy.mydomain.org", "200.150.100.50". Note that not all clients understand domain names in stream negotiation, so you should think twice before setting domain name in this option. -
    {auth_type, anonymous|plain}
    SOCKS5 authentication type. +
    auth_type: anonymous|plain
    SOCKS5 authentication type. Possible values are anonymous and plain. Default is anonymous. -
    {access, AccessName}
    Defines ACL for file transfer initiators. +
    access: AccessName
    Defines ACL for file transfer initiators. Default is all. -
    {max_connections, Number}
    Maximum number of +
    max_connections: Number
    Maximum number of active connections per file transfer initiator. No limit by default. -
    {shaper, none|ShaperName}
    This option defines shaper for +
    shaper: none|ShaperName
    This option defines shaper for the file transfer peers. Shaper with the maximum bandwidth will be selected. Default is none.

    Examples:

    • The simpliest configuration of the module: -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_proxy65, []},
      +  mod_proxy65: {}
         ...
      - ]}.
       
    • More complicated configuration. -
      {acl, proxy_users, {server, "example.org"}}.
      -{access, proxy65_access, [{allow, proxy_users}, {deny, all}]}.
      +
      acl: 
      +  admin: 
      +    user: 
      +      - "admin": "example.org"
      +  proxy_users: 
      +    server: 
      +      - "example.org"
       
      -{acl, admin, {user, "admin", "example.org"}}.
      -{shaper, proxyrate, {maxrate, 10240}}. %% 10 Kbytes/sec
      -{access, proxy65_shaper, [{none, admin}, {proxyrate, proxy_users}]}.
      +access: 
      +  proxy65_access: 
      +    proxy_users: allow
      +    all: deny
      +  proxy65_shaper: 
      +    admin: none
      +    proxy_users: proxyrate
       
      -{modules,
      - [
      +shaper: 
      +  proxyrate: 10240
      +
      +modules: 
         ...
      -  {mod_proxy65, [{host, "proxy1.example.org"},
      -                 {name, "File Transfer Proxy"},
      -                 {ip, {200,150,100,1}},
      -                 {port, 7778},
      -                 {max_connections, 5},
      -                 {access, proxy65_access},
      -                 {shaper, proxy65_shaper}]},
      +  mod_proxy65: 
      +    host: "proxy1.example.org"
      +    name: "File Transfer Proxy"
      +    ip: "200.150.100.1"
      +    port: 7778
      +    max_connections: 5
      +    access: proxy65_access
      +    shaper: proxy65_shaper
         ...
      - ]}.
       

    -

    3.3.18  mod_pubsub

    +

    3.3.18  mod_pubsub

    This module offers a Publish-Subscribe Service (XEP-0060). The functionality in mod_pubsub can be extended using plugins. The plugin that implements PEP (Personal Eventing via Pubsub) (XEP-0163) @@ -2976,27 +3078,27 @@ is enabled in the default ejabberd configuration file, and it requires mod_caps.

    Options:

    -{host, HostName}
    This option defines the Jabber ID of the +host: HostName
    This option defines the Jabber ID of the service. If the host option is not specified, the Jabber ID will be the hostname of the virtual host with the prefix ‘pubsub.’. The keyword "@HOST@" is replaced at start time with the real virtual host name. If you use mod_pubsub_odbc, please ensure the prefix contains only one dot, for example ‘pubsub.’, or ‘publish.’,. -
    {access_createnode, AccessName}
    +
    access_createnode: AccessName
    This option restricts which users are allowed to create pubsub nodes using ACL and ACCESS. By default any account in the local ejabberd server is allowed to create pubsub nodes. -
    {max_items_node, MaxItems}
    +
    max_items_node: MaxItems
    Define the maximum number of items that can be stored in a node. Default value is 10. -
    {plugins, [ Plugin, ...]}
    +
    plugins: [ Plugin, ...]
    To specify which pubsub node plugins to use. The first one in the list is used by default. If this option is not defined, the default plugins list is: ["flat"]. PubSub clients can define which plugin to use when creating a node: add type=’plugin-name’ attribute to the create stanza element. -
    {nodetree, Nodetree}
    +
    nodetree: Nodetree
    To specify which nodetree to use. If not defined, the default pubsub nodetree is used: "tree". Only one nodetree can be used per host, and is shared by all node plugins.

    The "virtual" nodetree does not store nodes on database. @@ -3010,43 +3112,48 @@ and this can not be changed. Using "virtual" nodetree requires to start from a clean database, it will not work if you used the default "tree" nodetree before.

    The "dag" nodetree provides experimental support for PubSub Collection Nodes (XEP-0248). In that case you should also add "dag" node plugin as default, for example: -{plugins, ["dag","flat","hometree","pep"]} -

    {ignore_pep_from_offline, false|true}
    +plugins: ["dag","flat","hometree","pep"] +

    ignore_pep_from_offline: false|true
    To specify whether or not we should get last published PEP items from users in our roster which are offline when we connect. Value is true or false. If not defined, pubsub assumes true so we only get last items of online contacts. -
    {last_item_cache, false|true}
    +
    last_item_cache: false|true
    To specify whether or not pubsub should cache last items. Value is true or false. If not defined, pubsub do not cache last items. On systems with not so many nodes, caching last items speeds up pubsub and allows to raise user connection rate. The cost is memory usage, as every item is stored in memory. -
    {pep_mapping, [ {Key, Value}, ...]}
    +
    pep_mapping: {Key, Value}
    This allow to define a Key-Value list to choose defined node plugins on given PEP namespace. The following example will use node_tune instead of node_pep for every PEP node with tune namespace: -
      {mod_pubsub, [{pep_mapping, [{"http://jabber.org/protocol/tune", "tune"}]}]}
    +
    modules:
    +  ...
    +  mod_pubsub:
    +    pep_mapping:
    +      "http://jabber.org/protocol/tune": "tune"
    +  ...
     

    Example of configuration that uses flat nodes as default, and allows use of flat, nodetree and pep nodes: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_pubsub, [
    -                {access_createnode, pubsub_createnode},
    -                {plugins, ["flat", "hometree", "pep"]}
    -               ]},
    +  mod_pubsub:
    +    access_createnode: pubsub_createnode
    +    plugins:
    +      - "flat"
    +      - "hometree"
    +      - "pep"
       ...
    - ]}.
     

    Using ODBC database requires using mod_pubsub_odbc without option changes. Only flat, hometree and pep plugins supports ODBC. The following example shows previous configuration with ODBC usage: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_pubsub_odbc, [
    -                {access_createnode, pubsub_createnode},
    -                {plugins, ["flat", "hometree", "pep"]}
    -               ]},
    +  mod_pubsub_odbc:
    +    access_createnode: pubsub_createnode
    +    plugins:
    +      - "flat"
    +      - "hometree"
    +      - "pep"
       ...
    - ]}.
     

    -

    3.3.19  mod_register

    +

    3.3.19  mod_register

    This module adds support for In-Band Registration (XEP-0077). This protocol enables end users to use a XMPP client to:

    • @@ -3055,37 +3162,35 @@ Register a new account on the server.
    • Delete an existing account on the server.

    Options:

    -{access, AccessName}
    +access: AccessName
    Specify rules to restrict what usernames can be registered and unregistered. If a rule returns ‘deny’ on the requested username, registration and unregistration of that user name is denied. There are no restrictions by default. -
    {access_from, AccessName}
    By default, ejabberd +
    access_from: AccessName
    By default, ejabberd doesn’t allow to register new accounts from s2s or existing c2s sessions. You can change it by defining access rule in this option. Use with care: allowing registration from s2s leads to uncontrolled massive accounts creation by rogue users. -
    {captcha_protected, false|true}
    -Protect registrations with CAPTCHA (see section 3.1.8). The default is false. -
    {ip_access, [ {allow|deny, IPaddress}, ...]}
    +
    captcha_protected: false|true
    +Protect registrations with CAPTCHA (see section 3.1.9). The default is false. +
    ip_access: AccessName
    Define rules to allow or deny account registration depending -in the IP address of the XMPP client. -If there is no matching IP mask, the default rule is “allow”. -IPv6 addresses are supported, but not tested. -The default option value is an empty list: []. -
    {password_strength, Entropy}
    +on the IP address of the XMPP client. The AccessName should be +of type ip. The default value is all. +
    password_strength: Entropy
    This option sets the minimum informational entropy for passwords. The value Entropy is a number of bits of entropy. The recommended minimum is 32 bits. The default is 0, i.e. no checks are performed. -
    {welcome_message, {Subject, Body}}
    Set a welcome message that +
    welcome_message: {subject: Subject, body: Body}
    + Set a welcome message that is sent to each newly registered account. The first string is the subject, and the second string is the message body. -In the body you can set a newline with the characters: \n -
    {registration_watchers, [ JID, ...]}
    This option defines a +
    registration_watchers: [ JID, ...]
    This option defines a list of JIDs which will be notified each time a new account is registered. -
    {iqdisc, Discipline}
    This specifies +
    iqdisc: Discipline
    This specifies the processing discipline for In-Band Registration (jabber:iq:register) IQ queries (see section 3.3.2).

    This module reads also another option defined globally for the server: -{registration_timeout, Timeout}. +registration_timeout: Timeout. This option limits the frequency of registration from a given IP or username. So, a user that tries to register a new account from the same IP address or JID during this number of seconds after his previous registration @@ -3098,57 +3203,69 @@ Default value: 600 seconds.

    Examples:

    • Next example prohibits the registration of too short account names, and allows to create accounts only to clients of the local network: -
      {acl, shortname, {user_glob, "?"}}.
      -{acl, shortname, {user_glob, "??"}}.
      -%% The same using regexp:
      -%%{acl, shortname, {user_regexp, "^..?$"}}.
      +
      acl: 
      +  loopback:
      +    ip:
      +      - "127.0.0.0/8"
      +      - "::"
      +  shortname: 
      +    user_glob: 
      +      - "?"
      +      - "??"
      +    ## The same using regexp:
      +    ##user_regexp: "^..?$"
       
      -{access, register, [{deny, shortname},
      -                    {allow, all}]}.
      +access: 
      +  mynetworks: 
      +    loopback: allow
      +    all: deny
      +  register: 
      +    shortname: deny
      +    all: allow
       
      -{modules,
      - [
      -  ...
      -  {mod_register, [{access, register},
      -                  {ip_access, [{allow, "127.0.0.0/8"},
      -                               {deny, "0.0.0.0/0"}]}
      -  ]},
      -  ...
      - ]}.
      +modules: 
      +  mod_register: 
      +    ip_access: mynetworks
      +    access: register
       
    • This configuration prohibits usage of In-Band Registration to create or delete accounts, but allows existing accounts to change the password: -
      {access, register, [{deny, all}]}.
      +
      access:
      +  register:
      +    all: deny
       
      -{modules,
      - [
      +modules:
         ...
      -  {mod_register, [{access, register}]},
      +  mod_register:
      +    access: register
         ...
      - ]}.
       
    • This configuration disables all In-Band Registration functionality: create, delete accounts and change password: -
      {modules,
      - [
      +
      modules:
         ...
      -  %% {mod_register, [{access, register}]},
      +  ## mod_register:
      +  ##   access: register
         ...
      - ]}.
       
    • Define the welcome message and two registration watchers. Also define a registration timeout of one hour: -
      {registration_timeout, 3600}.
      -{modules,
      - [
      +
      registration_timeout: 3600
      +modules:
         ...
      -  {mod_register,
      -   [
      -    {welcome_message, {"Welcome!", "Hi.\nWelcome to this Jabber server.\n Check http://www.jabber.org\n\nBye"}},
      -    {registration_watchers, ["admin1@example.org", "boss@example.net"]}
      -   ]},
      +  mod_register:
      +    welcome_message:
      +      subject: "Welcome!"
      +      body: |-
      +        Hi.
      +        Welcome to this Jabber server.
      +        Check http://www.jabber.org
      +        
      +        Bye
      +    registration_watchers:
      +      - "admin1@example.org"
      +      - "boss@example.net"
         ...
      - ]}.
       

    -

    3.3.20  mod_register_web

    +

    3.3.20  mod_register_web

    This module provides a web page where people can:

    • Register a new account on the server. @@ -3157,46 +3274,46 @@ Register a new account on the server.

    This module supports CAPTCHA image to register a new account. To enable this feature, configure the options captcha_cmd and captcha_host.

    Options:

    -{registration_watchers, [ JID, ...]}
    This option defines a +registration_watchers: [ JID, ...]
    This option defines a list of JIDs which will be notified each time a new account is registered.

    This example configuration shows how to enable the module and the web handler: -

    {hosts, ["localhost", "example.org", "example.com"]}.
    +

    hosts: 
    +  - "localhost"
    +  - "example.org"
    +  - "example.com"
    +listen: 
    +  ...
    +  - 
    +    port: 5281
    +    module: ejabberd_http
    +    register: true
    +    certfile: "/etc/ejabberd/certificate.pem"
    +    tls: true
    +  ...
     
    -{listen, [
    +modules: 
       ...
    -  {5281, ejabberd_http, [
    -    tls,
    -    {certfile, "/etc/ejabberd/certificate.pem"},
    -    register
    -  ]},
    +  mod_register_web: {}
       ...
    -]}.
    -
    -{modules,
    - [
    -  ...
    -  {mod_register_web, []},
    -  ...
    - ]}.
     

    For example, the users of the host example.org can visit the page: https://example.org:5281/register/ It is important to include the last / character in the URL, otherwise the subpages URL will be incorrect.

    -

    3.3.21  mod_roster

    +

    3.3.21  mod_roster

    This module implements roster management as defined in RFC 3921: XMPP IM. It also supports Roster Versioning (XEP-0237).

    Options:

    -{iqdisc, Discipline}
    This specifies +iqdisc: Discipline
    This specifies the processing discipline for Roster Management (jabber:iq:roster) IQ queries (see section 3.3.2). -
    {db_type, mnesia|odbc}
    +
    db_type: internal|odbc
    Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2. -
    {versioning, false|true}
    Enables +
    versioning: false|true
    Enables Roster Versioning. This option is disabled by default. -
    {store_current_id, false|true}
    +
    store_current_id: false|true
    If this option is enabled, the current version number is stored on the database. If disabled, the version number is calculated on the fly each time. Enabling this option reduces the load for both ejabberd and the database. @@ -3206,44 +3323,43 @@ This option is disabled by default. Important: if you use mod_shared_roster or mod_shared_roster_ldap, you must disable this option.

    This example configuration enables Roster Versioning with storage of current id: -

    {modules,
    - [
    +

    modules:
       ...
    -  {mod_roster, [{versioning, true}, {store_current_id, true}]},
    +  mod_roster:
    +    versioning: true
    +    store_current_id: true
       ...
    - ]}.
     

    -

    3.3.22  mod_service_log

    +

    3.3.22  mod_service_log

    This module adds support for logging end user packets via a XMPP message auditing service such as Bandersnatch. All user packets are encapsulated in a <route/> element and sent to the specified service(s).

    Options:

    -{loggers, [Names, ...]}
    With this option a (list of) service(s) +loggers: [Names, ...]
    With this option a (list of) service(s) that will receive the packets can be specified.

    Examples:

    • To log all end user packets to the Bandersnatch service running on bandersnatch.example.com: -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_service_log, [{loggers, ["bandersnatch.example.com"]}]},
      +  mod_service_log:
      +    loggers: ["bandersnatch.example.com"]
         ...
      - ]}.
       
    • To log all end user packets to the Bandersnatch service running on bandersnatch.example.com and the backup service on bandersnatch.example.org: -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_service_log, [{loggers, ["bandersnatch.example.com",
      -                                "bandersnatch.example.org"]}]},
      +  mod_service_log:
      +    loggers:
      +      - "bandersnatch.example.com"
      +      - "bandersnatch.example.org"
         ...
      - ]}.
       

    -

    3.3.23  mod_shared_roster

    +

    3.3.23  mod_shared_roster

    This module enables you to create shared roster groups. This means that you can create groups of people that can see members from (other) groups in their rosters. The big advantages of this feature are that end users do not need to @@ -3253,7 +3369,7 @@ A shared roster group can have members from any XMPP server, but the presence will only be available from and to members of the same virtual host where the group is created.

    Options:

    -{db_type, mnesia|odbc}
    +db_type: internal|odbc
    Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2. @@ -3327,7 +3443,7 @@ roster groups as shown in the following table:
    ModuleFeatureDependencies
    mod_adhocAd-Hoc Commands (XEP-0050) 

    -

    3.3.24  mod_shared_roster_ldap

    +

    3.3.24  mod_shared_roster_ldap

    This module lets the server administrator automatically populate users’ rosters (contact lists) with entries based on users and groups defined in an LDAP-based directory.

    @@ -3438,7 +3554,7 @@ fresh after retrieval. 300 by default. See section 

    Connection parameters

    The module also accepts the connection parameters, all of which default to the -top-level parameter of the same name, if unspecified. See 3.2.5 +top-level parameter of the same name, if unspecified. See 3.2.2 for more information about them.

    Retrieving the roster

    When the module is called to retrieve the shared roster for a user, the following algorithm is used:

    1. @@ -3496,14 +3612,16 @@ information duplication – the group name is repeated in every member obje centralized, but distributed between member objects
    2. inefficiency – the list of unique group names has to be computed by iterating over all users
    3. This however seems to be a common DIT layout, so the module keeps supporting it. -You can use the following configuration…

        {mod_shared_roster_ldap,[
      -    {ldap_base, "ou=flat,dc=nodomain"},
      -    {ldap_rfilter, "(objectClass=inetOrgPerson)"},
      -    {ldap_groupattr, "ou"},
      -    {ldap_memberattr, "cn"},
      -    {ldap_filter,  "(objectClass=inetOrgPerson)"},
      -    {ldap_userdesc, "displayName"}
      -  ]},
      +You can use the following configuration…

      modules:
      +  ...
      +  mod_shared_roster_ldap:
      +    ldap_base: "ou=flat,dc=nodomain"
      +    ldap_rfilter: "(objectClass=inetOrgPerson)"
      +    ldap_groupattr: "ou"
      +    ldap_memberattr: "cn"
      +    ldap_filter: "(objectClass=inetOrgPerson)"
      +    ldap_userdesc: "displayName"
      +  ...
       

      …to be provided with a roster as shown in figure 3.2 upon connecting as user czesio.


      msrl-roster-flat.png @@ -3523,17 +3641,19 @@ They are shown separated into different subtrees, but it’s not a requirem

      If you use the following example module configuration with it: -

        {mod_shared_roster_ldap,[
      -    {ldap_base, "ou=deep,dc=nodomain"},
      -    {ldap_rfilter, "(objectClass=groupOfUniqueNames)"},
      -    {ldap_filter, ""},
      -    {ldap_gfilter, "(&(objectClass=groupOfUniqueNames)(cn=%g))"},
      -    {ldap_groupdesc, "description"},
      -    {ldap_memberattr, "uniqueMember"},
      -    {ldap_memberattr_format, "cn=%u,ou=people,ou=deep,dc=nodomain"},
      -    {ldap_ufilter, "(&(objectClass=inetOrgPerson)(cn=%u))"},
      -    {ldap_userdesc, "displayName"}
      -  ]},
      +

      modules: 
      +  ...
      +  mod_shared_roster_ldap: 
      +    ldap_base: "ou=deep,dc=nodomain"
      +    ldap_rfilter: "(objectClass=groupOfUniqueNames)"
      +    ldap_filter: ""
      +    ldap_gfilter: "(&(objectClass=groupOfUniqueNames)(cn=%g))"
      +    ldap_groupdesc: "description"
      +    ldap_memberattr: "uniqueMember"
      +    ldap_memberattr_format: "cn=%u,ou=people,ou=deep,dc=nodomain"
      +    ldap_ufilter: "(&(objectClass=inetOrgPerson)(cn=%u))"
      +    ldap_userdesc: "displayName"
      +  ...
       

      …and connect as user czesio, then ejabberd will provide you with the roster shown in figure 3.4.


      @@ -3544,14 +3664,14 @@ the roster shown in figure 3.4.


      -

      3.3.25  mod_sic

      +

      3.3.25  mod_sic

      This module adds support for Server IP Check (XEP-0279). This protocol enables a client to discover its external IP address.

      Options:

      -{iqdisc, Discipline}
      This specifies +iqdisc: Discipline
      This specifies the processing discipline for urn:xmpp:sic:0 IQ queries (see section 3.3.2).

      -

      3.3.26  mod_stats

      +

      3.3.26  mod_stats

      This module adds support for Statistics Gathering (XEP-0039). This protocol allows you to retrieve next statistics from your ejabberd deployment:

      • @@ -3561,7 +3681,7 @@ Total number of registered users on the current virtual host (users/total).
      • Total number of online users on all virtual hosts (users/all-hosts/online).

      Options:

      -{iqdisc, Discipline}
      This specifies +iqdisc: Discipline
      This specifies the processing discipline for Statistics Gathering (http://jabber.org/protocol/stats) IQ queries (see section 3.3.2).

      As there are only a small amount of clients (for example Tkabber) and software libraries with @@ -3583,44 +3703,44 @@ by sending: </query> </iq>

      -

      3.3.27  mod_time

      +

      3.3.27  mod_time

      This module features support for Entity Time (XEP-0202). By using this XEP, you are able to discover the time at another entity’s location.

      Options:

      -{iqdisc, Discipline}
      This specifies +iqdisc: Discipline
      This specifies the processing discipline for Entity Time (jabber:iq:time) IQ queries (see section 3.3.2).

      -

      3.3.28  mod_vcard

      +

      3.3.28  mod_vcard

      This module allows end users to store and retrieve their vCard, and to retrieve other users vCards, as defined in vcard-temp (XEP-0054). The module also implements an uncomplicated Jabber User Directory based on the vCards of these users. Moreover, it enables the server to send its vCard when queried.

      Options:

      -{host, HostName}
      This option defines the Jabber ID of the +host: HostName
      This option defines the Jabber ID of the service. If the host option is not specified, the Jabber ID will be the hostname of the virtual host with the prefix ‘vjud.’. The keyword "@HOST@" is replaced at start time with the real virtual host name. -
      {iqdisc, Discipline}
      This specifies +
      iqdisc: Discipline
      This specifies the processing discipline for vcard-temp IQ queries (see section 3.3.2). -
      {db_type, mnesia|odbc}
      +
      db_type: internal|odbc
      Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2. -
      {search, true|false}
      This option specifies whether the search +
      search: true|false
      This option specifies whether the search functionality is enabled or not If disabled, the option host will be ignored and the Jabber User Directory service will not appear in the Service Discovery item list. The default value is true. -
      {matches, infinity|Number}
      With this option, the number of reported +
      matches: infinity|Number
      With this option, the number of reported search results can be limited. If the option’s value is set to infinity, all search results are reported. The default value is 30. -
      {allow_return_all, false|true}
      This option enables +
      allow_return_all: false|true
      This option enables you to specify if search operations with empty input fields should return all users who added some information to their vCard. The default value is false. -
      {search_all_hosts, true|false}
      If this option is set +
      search_all_hosts, true|false
      If this option is set to true, search operations will apply to all virtual hosts. Otherwise only the current host will be searched. The default value is true. This option is available in mod_vcardwhen using Mnesia, but not when using ODBC storage. @@ -3629,30 +3749,28 @@ This option is available in mod_vcardwhen using Mnesia, but not when us In this first situation, search results are limited to twenty items, every user who added information to their vCard will be listed when people do an empty search, and only users from the current host will be returned: -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_vcard, [{search, true},
      -               {matches, 20},
      -               {allow_return_all, true},
      -               {search_all_hosts, false}]},
      +  mod_vcard:
      +    search: true
      +    matches: 20
      +    allow_return_all: true
      +    search_all_hosts: false
         ...
      - ]}.
       
    4. The second situation differs in a way that search results are not limited, and that all virtual hosts will be searched instead of only the current one: -
      {modules,
      - [
      +
      modules:
         ...
      -  {mod_vcard, [{search, true},
      -               {matches, infinity},
      -               {allow_return_all, true}]},
      +  mod_vcard:
      +    search: true
      +    matches: infinity
      +    allow_return_all: true
         ...
      - ]}.
       
    5. -

      3.3.29  mod_vcard_ldap

      +

      3.3.29  mod_vcard_ldap

      ejabberd can map LDAP attributes to vCard fields. This behaviour is implemented in the mod_vcard_ldap module. This module does not depend on the -authentication method (see 3.2.5).

      Usually ejabberd treats LDAP as a read-only storage: +authentication method (see 3.2.2).

      Usually ejabberd treats LDAP as a read-only storage: it is possible to consult data, but not possible to create accounts or edit vCard that is stored in LDAP. However, it is possible to change passwords if mod_register module is enabled @@ -3663,17 +3781,17 @@ meaning as the top-level LDAP parameters to set the authentication method: ldap_servers, ldap_port, ldap_rootdn, ldap_password, ldap_base, ldap_uids, ldap_deref_aliases and ldap_filter. -See section 3.2.5 for detailed information +See section 3.2.2 for detailed information about these options. If one of these options is not set, ejabberd will look for the top-level option with the same name.

      The second group of parameters consists of the following mod_vcard_ldap-specific options:

      -{host, HostName}
      This option defines the Jabber ID of the +host: HostName
      This option defines the Jabber ID of the service. If the host option is not specified, the Jabber ID will be the hostname of the virtual host with the prefix ‘vjud.’. The keyword "@HOST@" is replaced at start time with the real virtual host name. -
      {iqdisc, Discipline}
      This specifies +
      iqdisc: Discipline
      This specifies the processing discipline for vcard-temp IQ queries (see section 3.3.2).
      {search, true|false}
      This option specifies whether the search functionality is enabled (value: true) or disabled (value: @@ -3832,7 +3950,7 @@ searching his info in LDAP.

    6. ldap_vcard_map
    7. -

      3.3.30  mod_vcard_xupdate

      +

      3.3.30  mod_vcard_xupdate

      The user’s client can store an avatar in the user vCard. The vCard-Based Avatars protocol (XEP-0153) provides a method for clients to inform the contacts what is the avatar hash value. @@ -3847,22 +3965,22 @@ presence stanza rewrite. For this reason, enabling this module will introduce a computational overhead in servers with clients that change frequently their presence.

      Options:

      -{db_type, mnesia|odbc}
      +db_type: internal|odbc
      Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If odbc value is defined, make sure you have defined the database, see 3.2.

      -

      3.3.31  mod_version

      +

      3.3.31  mod_version

      This module implements Software Version (XEP-0092). Consequently, it answers ejabberd’s version when queried.

      Options:

      -{show_os, true|false}
      Should the operating system be revealed or not. +show_os: true|false
      Should the operating system be revealed or not. The default value is true. -
      {iqdisc, Discipline}
      This specifies +
      iqdisc: Discipline
      This specifies the processing discipline for Software Version (jabber:iq:version) IQ queries (see section 3.3.2).

      -

      Chapter 4  Managing an ejabberd Server

      -

      4.1  ejabberdctl

      With the ejabberdctl command line administration script +

      Chapter 4  Managing an ejabberd Server

      +

      4.1  ejabberdctl

      With the ejabberdctl command line administration script you can execute ejabberdctl commands (described in the next section, 4.1.1) and also many general ejabberd commands (described in section 4.2). This means you can start, stop and perform many other administrative tasks @@ -3874,7 +3992,7 @@ and other codes may be used for specific results. This can be used by other scripts to determine automatically if a command succeeded or failed, for example using: echo $?

      -

      4.1.1  ejabberdctl Commands

      When ejabberdctl is executed without any parameter, +

      4.1.1  ejabberdctl Commands

      When ejabberdctl is executed without any parameter, it displays the available options. If there isn’t an ejabberd server running, the available parameters are:

      @@ -3892,11 +4010,12 @@ and all the ejabberd commands available in that server (see mnesia
      Get information about the Mnesia database.

      The ejabberdctl script can be restricted to require authentication and execute some ejabberd commands; see 4.2.2. -Add the option to the file ejabberd.cfg. +Add the option to the file ejabberd.yml. In this example there is no restriction: -

      {ejabberdctl_access_commands, []}.
      +

      ejabberdctl_access_commands: []
       

      If account robot1@example.org is registered in ejabberd with password abcdef -and ejabberd.cfg contains this setting: +(which MD5 is E8B501798950FC58AAD83C8C14978E), +and ejabberd.yml contains this setting:

      {hosts, ["example.org"]}.
       {acl, bots, {user, "robot1", "example.org"}}.
       {access, ctlaccess, [{allow, bots}]}.
      @@ -3909,7 +4028,7 @@ robot1
       testuser1
       testuser2
       

      -

      4.1.2  Erlang Runtime System

      ejabberd is an Erlang/OTP application that runs inside an Erlang runtime system. +

      4.1.2  Erlang Runtime System

      ejabberd is an Erlang/OTP application that runs inside an Erlang runtime system. This system is configured using environment variables and command line parameters. The ejabberdctl administration script uses many of those possibilities. You can configure some of them with the file ejabberdctl.cfg, @@ -3991,7 +4110,7 @@ not “Simple Authentication and Security Layer”.

      Note that some characters need to be escaped when used in shell scripts, for instance " and {}. You can find other options in the Erlang manual page (erl -man erl).

      -

      4.2  ejabberd Commands

      An ejabberd command is an abstract function identified by a name, +

      4.2  ejabberd Commands

      An ejabberd command is an abstract function identified by a name, with a defined number and type of calling arguments and type of result that is registered in the ejabberd_commands service. Those commands can be defined in any Erlang module and executed using any valid frontend.

      ejabberd includes a frontend to execute ejabberd commands: the script ejabberdctl. @@ -3999,7 +4118,7 @@ Other known frontends that can be installed to execute ejabberd commands in diff ejabberd_xmlrpc (XML-RPC service), mod_rest (HTTP POST service), mod_shcommands (ejabberd WebAdmin page).

      -

      4.2.1  List of ejabberd Commands

      ejabberd includes a few ejabberd Commands by default. +

      4.2.1  List of ejabberd Commands

      ejabberd includes a few ejabberd Commands by default. When more modules are installed, new commands may be available in the frontends.

      The easiest way to get a list of the available commands, and get help for them is to use the ejabberdctl script:

      $ ejabberdctl help
      @@ -4053,7 +4172,7 @@ is very high.
       
      register user host password
      Register an account in that domain with the given password.
      unregister user host
      Unregister the given account.

      -

      4.2.2  Restrict Execution with AccessCommands

      The frontends can be configured to restrict access to certain commands. +

      4.2.2  Restrict Execution with AccessCommands

      The frontends can be configured to restrict access to certain commands. In that case, authentication information must be provided. In each frontend the AccessCommands option is defined in a different place. But in all cases the option syntax is the same: @@ -4097,10 +4216,10 @@ and the provided arguments do not contradict Arguments.

      As an example to u {_bot_reg_test, [register, unregister], [{host, "test.org"}]} ]

      -

      4.3  Web Admin

      +

      4.3  Web Admin

      The ejabberd Web Admin allows to administer most of ejabberd using a web browser.

      This feature is enabled by default: a ejabberd_http listener with the option web_admin (see -section 3.1.3) is included in the listening ports. Then you can open +section 3.1.4) is included in the listening ports. 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 @@ -4131,40 +4250,58 @@ URL). If you log in with ‘admin@example.com’ on
      http://example.org:5280/admin/server/example.com/ you can only administer the virtual host example.com. The account ‘reviewer@example.com’ can browse that vhost in read-only mode. -

      {acl, admin, {user, "admin", "example.net"}}.
      -{host_config, "example.com", [{acl, admin, {user, "admin", "example.com"}}]}.
      -{host_config, "example.com", [{acl, viewers, {user, "reviewer", "example.com"}}]}.
      +
      acl: 
      +  admin: 
      +    user: 
      +      - "admin": "example.net"
       
      -{access, configure, [{allow, admin}]}.
      -{access, webadmin_view, [{allow, viewers}]}.
      +host_config: 
      +  "example.com": 
      +    acl: 
      +      admin: 
      +        user: 
      +          - "admin": "example.com"
      +      viewers: 
      +        user: 
      +          - "reviewer": "example.com"
       
      -{hosts, ["example.org"]}.
      +access: 
      +  configure: 
      +    admin: allow
      +  webadmin_view: 
      +    viewers: allow
       
      -{listen,
      - [
      +hosts: 
      +  - "example.org"
      +
      +listen: 
         ...
      -  {5280, ejabberd_http, [http_poll, web_admin]},
      +  - 
      +    port: 5280
      +    module: ejabberd_http
      +    web_admin: true
      +    http_poll: true
         ...
      - ]}.
       
    8. For security reasons, you can serve the Web Admin on a secured connection, on a port differing from the HTTP Polling interface, and bind it to the internal LAN IP. The Web Admin will be accessible by pointing your web browser to https://192.168.1.1:5282/admin/: -
      -{hosts, ["example.org"]}.
      -
      -{listen,
      - [
      +
      hosts: 
      +  - "example.org"
      +listen: 
         ...
      -  {5280, ejabberd_http, [
      -                         http_poll
      -                        ]},
      -  {{5282, "192.168.1.1"}, ejabberd_http, [
      -                                          web_admin,
      -                                          tls, {certfile, "/usr/local/etc/server.pem"}
      -                                         ]},
      +  - 
      +    port: 5280
      +    module: ejabberd_http
      +    http_poll: true
      +  - 
      +    ip: "192.168.1.1"
      +    port: 5282
      +    module: ejabberd_http
      +    certfile: "/usr/local/etc/server.pem"
      +    tls: true
      +    web_admin: true
         ...
      - ]}.
       
    9. Certain pages in the ejabberd Web Admin contain a link to a related section in the ejabberd Installation and Operation Guide. In order to view such links, a copy in HTML format of the Guide must @@ -4174,13 +4311,13 @@ The file is searched by default in The directory of the documentation can be specified in the environment variable EJABBERD_DOC_PATH. See section 4.1.2.

      -

      4.4  Ad-hoc Commands

      If you enable mod_configure and mod_adhoc, +

      4.4  Ad-hoc Commands

      If you enable mod_configure and mod_adhoc, you can perform several administrative tasks in ejabberd with an XMPP client. The client must support Ad-Hoc Commands (XEP-0050), and you must login in the XMPP server with an account with proper privileges.

      -

      4.5  Change Computer Hostname

      ejabberd uses the distributed Mnesia database. +

      4.5  Change Computer Hostname

      ejabberd uses the distributed Mnesia database. Being distributed, Mnesia enforces consistency of its file, so it stores the name of the Erlang node in it (see section 5.4). The name of an Erlang node includes the hostname of the computer. @@ -4226,8 +4363,8 @@ mv /var/lib/ejabberd/*.* /var/lib/ejabberd/oldfiles/

    10. Check that the information of the old database is available: accounts, rosters... After you finish, remember to delete the temporary backup files from public directories.

    -

    Chapter 5  Securing ejabberd

    -

    5.1  Firewall Settings

    +

    Chapter 5  Securing ejabberd

    +

    5.1  Firewall Settings

    You need to take the following TCP ports in mind when configuring your firewall:


    @@ -4238,7 +4375,7 @@ After you finish, remember to delete the temporary backup files from public dire
    PortDescription
    port rangeUsed for connections between Erlang nodes. This range is configurable (see section 5.2).

    -

    5.2  epmd

    epmd (Erlang Port Mapper Daemon) +

    5.2  epmd

    epmd (Erlang Port Mapper Daemon) is a small name server included in Erlang/OTP and used by Erlang programs when establishing distributed Erlang communications. ejabberd needs epmd to use ejabberdctl and also when clustering ejabberd nodes. @@ -4251,8 +4388,7 @@ In order for this communication to work, epmd must be running and listening for name requests in the port 4369. You should block the port 4369 in the firewall in such a way that only the programs in your machine can access it. -or configure the option ERL_EPMD_ADDRESS in the file ejabberdctl.cfg -(this option works only in Erlang/OTP R14B03 or higher).

    If you build a cluster of several ejabberd instances, +or configure the option ERL_EPMD_ADDRESS in the file ejabberdctl.cfg.

    If you build a cluster of several ejabberd instances, each ejabberd instance is called an ejabberd node. Those ejabberd nodes use a special Erlang communication method to build the cluster, and EPMD is again needed listening in the port 4369. @@ -4269,7 +4405,7 @@ the network interface where the Erlang node will listen and accept connections. The Erlang command-line parameter used internally is, for example:

    erl ... -kernel inet_dist_use_interface "{127,0,0,1}"
     

    -

    5.3  Erlang Cookie

    The Erlang cookie is a string with numbers and letters. +

    5.3  Erlang Cookie

    The Erlang cookie is a string with numbers and letters. An Erlang node reads the cookie at startup from the command-line parameter -setcookie. If not indicated, the cookie is read from the cookie file $HOME/.erlang.cookie. If this file does not exist, it is created immediately with a random cookie. @@ -4283,7 +4419,7 @@ to prevent unauthorized access or intrusion to an Erlang node. The communication between Erlang nodes are not encrypted, so the cookie could be read sniffing the traffic on the network. The recommended way to secure the Erlang node is to block the port 4369.

    -

    5.4  Erlang Node Name

    An Erlang node may have a node name. +

    5.4  Erlang Node Name

    An Erlang node may have a node name. The name can be short (if indicated with the command-line parameter -sname) or long (if indicated with the parameter -name). Starting an Erlang node with -sname limits the communication between Erlang nodes to the LAN.

    Using the option -sname instead of -name is a simple method @@ -4292,10 +4428,10 @@ However, it is not ultimately effective to prevent access to the Erlang node, because it may be possible to fake the fact that you are on another network using a modified version of Erlang epmd. The recommended way to secure the Erlang node is to block the port 4369.

    -

    5.5  Securing Sensitive Files

    ejabberd stores sensitive data in the file system either in plain text or binary files. +

    5.5  Securing Sensitive Files

    ejabberd stores sensitive data in the file system either in plain text or binary files. The file system permissions should be set to only allow the proper user to read, write and execute those files and directories.

    -ejabberd configuration file: /etc/ejabberd/ejabberd.cfg
    +ejabberd configuration file: /etc/ejabberd/ejabberd.yml
    Contains the JID of administrators and passwords of external components. The backup files probably contain also this information, @@ -4312,9 +4448,9 @@ so it is preferable to secure the whole /var/lib/ejabberd/ directory.
    Erlang cookie file: /var/lib/ejabberd/.erlang.cookie
    See section 5.3.

    -

    Chapter 6  Clustering

    +

    Chapter 6  Clustering

    -

    6.1  How it Works

    +

    6.1  How it Works

    A XMPP domain is served by one or more ejabberd nodes. These nodes can be run on different machines that are connected via a network. They all must have the ability to connect to port 4369 of all another nodes, and must @@ -4328,29 +4464,29 @@ router,

  • session manager,
  • s2s manager.
  • -

    6.1.1  Router

    +

    6.1.1  Router

    This module is the main router of XMPP packets on each node. It routes them based on their destination’s domains. It uses a global routing table. The domain of the packet’s destination is searched in the routing table, and if it is found, the packet is routed to the 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 one of this server’s host names. If the destination JID has a non-empty user part, it is routed to the session manager, otherwise it is processed depending 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 resource a packet must be sent via a presence table. Then the packet is either routed to the appropriate c2s process, or stored in offline storage, or bounced back.

    -

    6.1.4  s2s Manager

    +

    6.1.4  s2s Manager

    This module routes packets to other XMPP servers. First, it checks if an opened s2s connection from the domain of the packet’s source to the domain of the packet’s destination exists. If that is the case, the s2s manager routes the packet to the process serving this connection, otherwise a new connection is opened.

    -

    6.2  Clustering Setup

    +

    6.2  Clustering Setup

    Suppose you already configured ejabberd on one machine named (first), and you need to setup another one to make an ejabberd cluster. Then do following steps:

    1. @@ -4388,30 +4524,29 @@ and ‘access’ options because they will be taken from enabled only on one machine in the cluster.

    You can repeat these steps for other machines supposed to serve this domain.

    -

    6.3  Service Load-Balancing

    +

    6.3  Service Load-Balancing

    -

    6.3.1  Domain Load-Balancing Algorithm

    +

    6.3.1  Domain Load-Balancing Algorithm

    ejabberd includes an algorithm to load balance the components that are plugged on an ejabberd cluster. It means that you can plug one or several instances of the same component on each ejabberd cluster and that the traffic will be automatically distributed.

    The default distribution algorithm try to deliver to a local instance of a component. If several local instances are available, one instance is chosen randomly. If no instance is available locally, one instance is chosen randomly among the remote component instances.

    If you need a different behaviour, you can change the load balancing behaviour with the option domain_balancing. The syntax of the option is the following: -

    {domain_balancing, "component.example.com", BalancingCriteria}.

    Several balancing criteria are available: +

    domain_balancing: BalancingCriteria

    Several balancing criteria are available:

    • destination: the full JID of the packet to attribute is used.
    • source: the full JID of the packet from attribute is used.
    • bare_destination: the bare JID (without resource) of the packet to attribute is used.
    • bare_source: the bare JID (without resource) of the packet from attribute is used.

    If the value corresponding to the criteria is the same, the same component instance in the cluster will be used.

    -

    6.3.2  Load-Balancing Buckets

    +

    6.3.2  Load-Balancing Buckets

    When there is a risk of failure for a given component, domain balancing can cause service trouble. If one component is failing the service will not work correctly unless the sessions are rebalanced.

    In this case, it is best to limit the problem to the sessions handled by the failing component. This is what the domain_balancing_component_number option does, making the load balancing algorithm not dynamic, but sticky on a fix number of component instances.

    The syntax is: -

    {domain_balancing_component_number, "component.example.com", Number}.

    -

    Chapter 7  Debugging

    +

    domain_balancing_component_number: Number

    +

    Chapter 7  Debugging

    -

    7.1  Log Files

    An ejabberd node writes two log files: +

    7.1  Log Files

    An ejabberd node writes two log files:

    ejabberd.log
    is the ejabberd service log, with the messages reported by ejabberd code
    erlang.log
    is the Erlang/OTP system log, with the messages reported by Erlang/OTP using SASL (System Architecture Support Libraries) -

    The option loglevel modifies the verbosity of the file ejabberd.log. The syntax is one of: +

    The option loglevel modifies the verbosity of the file ejabberd.log. The syntax:

    -{loglevel, Level}.
    The standard form to set a global log level. -
    {loglevel, {Level, [{Module, Level}, ...]}}.
    The given Erlang modules will be logged with specific log levels, all others will use the default log level. +loglevel: Level
    The standard form to set a global log level.

    The possible Level are:

    0
    No ejabberd log at all (not recommended) @@ -4422,39 +4557,41 @@ domain.

    -

    7.2  Debug Console

    The Debug Console is an Erlang shell attached to an already running ejabberd server. +

    7.2  Debug Console

    The Debug Console is an Erlang shell attached to an already running ejabberd server. With this Erlang shell, an experienced administrator can perform complex tasks.

    This shell gives complete control over the ejabberd server, so it is important to use it with extremely care. There are some simple and safe examples in the article Interconnecting Erlang Nodes

    To exit the shell, close the window or press the keys: control+c control+c.

    -

    7.3  Watchdog Alerts

    +

    7.3  Watchdog Alerts

    ejabberd includes a watchdog mechanism that may be useful to developers when troubleshooting a problem related to memory usage. If a process in the ejabberd server consumes more memory than the configured threshold, a message is sent to the XMPP accounts defined with the option watchdog_admins in the ejabberd configuration file.

    The syntax is: -

    {watchdog_admins, [JID, ...]}.

    The memory consumed is measured in words: +

    watchdog_admins: [JID, ...]

    The memory consumed is measured in words: a word on 32-bit architecture is 4 bytes, and a word on 64-bit architecture is 8 bytes. The threshold by default is 1000000 words. This value can be configured with the option watchdog_large_heap, or in a conversation with the watchdog alert bot.

    The syntax is: -

    {watchdog_large_heap, Number}.

    Example configuration: -

    {watchdog_admins, ["admin2@localhost", "admin2@example.org"]}.
    -{watchdog_large_heap, 30000000}.
    +

    watchdog_large_heap: Number

    Example configuration: +

    watchdog_admins:
    +  - "admin2@localhost"
    +  - "admin2@example.org"
    +watchdog_large_heap: 30000000
     

    To remove watchdog admins, remove them in the option. To remove all watchdog admins, set the option with an empty list: -

    {watchdog_admins, []}.
    +

    watchdog_admins: []
     

    -

    Appendix A  Internationalization and Localization

    +

    Appendix A  Internationalization and Localization

    The source code of ejabberd supports localization. The translators can edit the gettext .po files @@ -4489,9 +4626,9 @@ HTTP header ‘Accept-Language: ru’


    -

    Appendix B  Release Notes

    +

    Appendix B  Release Notes

    Release notes are available from ejabberd Home Page

    -

    Appendix C  Acknowledgements

    Thanks to all people who contributed to this guide: +

    Appendix C  Acknowledgements

    Thanks to all people who contributed to this guide:

    -

    Appendix D  Copyright Information

    Ejabberd Installation and Operation Guide.
    +

    Appendix D  Copyright Information

    Ejabberd Installation and Operation Guide.
    Copyright © 2003 — 2013 ProcessOne

    This document is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 diff --git a/doc/guide.tex b/doc/guide.tex index 1c3e0f023..08ceb78f6 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -109,15 +109,15 @@ %\ifthenelse{\boolean{modhttpbind}}{\input{mod_http_bind.tex}}{} %% Common options -\newcommand{\iqdiscitem}[1]{\titem{\{iqdisc, Discipline\}} \ind{options!iqdisc}This specifies +\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\}} \ind{options!host} This option defines the Jabber ID of the + \titem{host: HostName} \ind{options!host} This option defines the Jabber ID of the service. If the \texttt{host} option is not specified, the Jabber ID will be the hostname of the virtual host with the prefix `\jid{#1.}'. The keyword "@HOST@" is replaced at start time with the real virtual host name. } -\newcommand{\dbtype}{\titem{\{db\_type, mnesia|odbc\}} \ind{options!dbtype} +\newcommand{\dbtype}{\titem{db\_type: internal|odbc} \ind{options!dbtype} Define the type of storage where the module will create the tables and store user information. The default is to store in the internal Mnesia database. If \term{odbc} value is defined, make sure you have defined the database, see~\ref{database}. @@ -320,10 +320,9 @@ To compile \ejabberd{} on a `Unix-like' operating system, you need: \item GCC \item Libexpat 1.95 or higher \item Erlang/OTP R15B or higher. +\item Libyaml 1.4 or higher \item OpenSSL 0.9.8 or higher, for STARTTLS, SASL and SSL encryption. \item Zlib 1.2.3 or higher, for Stream Compression support (\xepref{0138}). Optional. -\item Erlang mysql library. Optional. For MySQL authentication or storage. See section \ref{compilemysql}. -\item Erlang pgsql library. Optional. For PostgreSQL authentication or storage. See section \ref{compilepgsql}. \item PAM library. Optional. For Pluggable Authentication Modules (PAM). See section \ref{pam}. \item GNU Iconv 1.8 or higher, for the IRC Transport (mod\_irc). Optional. Not needed on systems with GNU Libc. See section \ref{modirc}. \item ImageMagick's Convert program. Optional. For CAPTCHA challenges. See section \ref{captcha}. @@ -388,10 +387,10 @@ Some options that you may be interested in modifying: Enable the use of development tools. \titem{--enable-mysql} - Enable MySQL support (see section \ref{mysql}). + Enable MySQL support (see section \ref{odbc}). \titem{--enable-pgsql} - Enable PostgreSQL support (see section \ref{pgsql}). + Enable PostgreSQL support (see section \ref{odbc}). \titem{--enable-zlib} Enable Stream Compression (XEP-0138) using zlib. @@ -431,7 +430,7 @@ The files and directories created are, by default: \begin{description} \titem{/etc/ejabberd/} Configuration directory: \begin{description} - \titem{ejabberd.cfg} ejabberd configuration file + \titem{ejabberd.yml} ejabberd configuration file \titem{ejabberdctl.cfg} Configuration file of the administration script \titem{inetrc} Network DNS configuration file \end{description} @@ -583,7 +582,7 @@ We assume that we will try to put as much library as possible into \verb|C:\sdk\ configure.bat nmake -f Makefile.win32 \end{verbatim} -\item Edit the file \verb|ejabberd\src\ejabberd.cfg| and run +\item Edit the file \verb|ejabberd\src\ejabberd.yml| and run \begin{verbatim} werl -s ejabberd -name ejabberd \end{verbatim} @@ -608,8 +607,13 @@ ejabberdctl register admin1 example.org FgT5bk3 \end{enumerate} \item Edit the \ejabberd{} configuration file to give administration rights to the XMPP account you created: \begin{verbatim} -{acl, admin, {user, "admin1", "example.org"}}. -{access, configure, [{allow, admin}]}. +acl: + admin: + user: + - "admin1": "example.org" +access: + configure: + admin: allow \end{verbatim} You can grant administrative privileges to many XMPP accounts, and also to accounts in other XMPP servers. @@ -638,34 +642,56 @@ indicates you need to also update those tables. \makesection{basicconfig}{Basic Configuration} -The configuration file will be loaded the first time you start \ejabberd{}. The -content from this file will be parsed and stored in the internal \ejabberd{} database. Subsequently the -configuration will be loaded from the database and any commands in the -configuration file are appended to the entries in the database. +The configuration file will be loaded the first time you start \ejabberd{}. +The configuration file name MUST have ``.yml'' extension. This helps ejabberd +to differentiate between the new and legacy file formats (see section~\ref{oldconfig}). Note that \ejabberd{} never edits the configuration file. -So, the configuration changes done using the Web Admin -are stored in the database, but are not reflected in the configuration file. -If you want those changes to be use after \ejabberd{} restart, you can either -edit the configuration file, or remove all its content. -The configuration file contains a sequence of Erlang terms. Lines beginning with a -\term{`\%'} sign are ignored. Each term is a tuple of which the first element is -the name of an option, and any further elements are that option's values. If the -configuration file do not contain for instance the `hosts' option, the old -host name(s) stored in the database will be used. - - -You can override the old values stored in the database by adding next lines to -the beginning of the configuration file: +The configuration file is written in +\footahref{http://en.wikipedia.org/wiki/YAML}{YAML}. +However, different scalars are treated as different types: +\begin{itemize} +\item unquoted or single-quoted strings. The type is called \verb|atom()| + in this document. + Examples: \verb|dog|, \verb|'Jupiter'|, \verb|'3.14159'|, \verb|YELLOW|. +\item numeric literals. The type is called \verb|integer()|, \verb|float()| or, + if both are allowed, \verb|number()|. + Examples: \verb|3|, \verb|-45.0|, \verb|.0| +\item double-quoted or folded strings. The type is called \verb|string()|. + Examples of a double-quoted string: + \verb|"Lizzard"|, \verb|"orange"|, \verb|"3.14159"|. + Examples of a folded string: \begin{verbatim} -override_global. -override_local. -override_acls. +> Art thou not Romeo, + and a Montague? \end{verbatim} -With these lines the old global options (shared between all \ejabberd{} nodes in a -cluster), local options (which are specific for this particular \ejabberd{} node) -and ACLs will be removed before new ones are added. +\begin{verbatim} +| Neither, fair saint, + if either thee dislike. +\end{verbatim} +For associative arrays ("mappings") and lists you can use both outline +indentation and compact syntax (aka ``JSON style''). For example, the following is equivalent: +\begin{verbatim} +{param1: ["val1", "val2"], param2: ["val3", "val4"]} +\end{verbatim} +and +\begin{verbatim} +param1: + - "val1" + - "val2" +param2: + - "val3" + - "val4" +\end{verbatim} +Note that both styles are used in this document. +\end{itemize} + +\makesubsection{oldconfig}{Legacy Configuration File} +In previous \ejabberd{} version the configuration file should be written +in Erlang terms. The format is still supported, but it is highly recommended +to convert it to the new YAML format using \term{convert\_to\_yaml} command +from \term{ejabberdctl} (see~\ref{ejabberdctl} for details). \makesubsection{hostnames}{Host Names} \ind{options!hosts}\ind{host names} @@ -674,17 +700,20 @@ The option \option{hosts} defines a list containing one or more domains that \ejabberd{} will serve. The syntax is: -\esyntax{\{hosts, [HostName, ...]\}.} +\esyntax{[HostName]} Examples: \begin{itemize} \item Serving one domain: \begin{verbatim} -{hosts, ["example.org"]}. +hosts: ["example.org"] \end{verbatim} \item Serving three domains: \begin{verbatim} -{hosts, ["example.net", "example.com", "jabber.somesite.org"]}. +hosts: + - "example.net" + - "example.com" + - "jabber.somesite.org" \end{verbatim} \end{itemize} @@ -695,7 +724,7 @@ Options can be defined separately for every virtual host using the \term{host\_config} option. The syntax is: \ind{options!host\_config} -\esyntax{\{host\_config, HostName, [Option, ...]\}} +\esyntax{\{HostName: [Option, ...]\}} Examples: \begin{itemize} @@ -703,82 +732,89 @@ Examples: domain \jid{example.com} is using the \ind{LDAP}LDAP server running on the domain \jid{localhost} to perform authentication: \begin{verbatim} -{host_config, "example.net", [{auth_method, internal}]}. - -{host_config, "example.com", [{auth_method, ldap}, - {ldap_servers, ["localhost"]}, - {ldap_uids, [{"uid"}]}, - {ldap_rootdn, "dc=localdomain"}, - {ldap_rootdn, "dc=example,dc=com"}, - {ldap_password, ""}]}. +host_config: + "example.net" + auth_method: internal + "example.com": + auth_method: ldap + ldap_servers: + - "localhost" + ldap_uids: + - "uid" + ldap_rootdn: "dc=localdomain" + ldap_rootdn: "dc=example,dc=com" + ldap_password: "" \end{verbatim} -\item Domain \jid{example.net} is using \ind{ODBC}ODBC to perform authentication +\item Domain \jid{example.net} is using \ind{odbc}ODBC to perform authentication while domain \jid{example.com} is using the LDAP servers running on the domains \jid{localhost} and \jid{otherhost}: \begin{verbatim} -{host_config, "example.net", [{auth_method, odbc}, - {odbc_server, "DSN=ejabberd;UID=ejabberd;PWD=ejabberd"}]}. - -{host_config, "example.com", [{auth_method, ldap}, - {ldap_servers, ["localhost", "otherhost"]}, - {ldap_uids, [{"uid"}]}, - {ldap_rootdn, "dc=localdomain"}, - {ldap_rootdn, "dc=example,dc=com"}, - {ldap_password, ""}]}. +host_config: + "example.net": + auth_method: odbc + odbc_type: odbc + odbc_server: "DSN=ejabberd;UID=ejabberd;PWD=ejabberd" + "example.com": + auth_method: ldap + ldap_servers: + - "localhost" + - "otherhost" + ldap_uids: + - "uid" + ldap_rootdn: "dc=localdomain" + ldap_rootdn: "dc=example,dc=com" + ldap_password: "" \end{verbatim} \end{itemize} To define specific ejabberd modules in a virtual host, you can define the global \term{modules} option with the common modules, and later add specific modules to certain virtual hosts. -To accomplish that, instead of defining each option in \term{host\_config} with the general syntax -\esyntax{\{OptionName, OptionValue\}} -use this syntax: -\esyntax{\{\{add, OptionName\}, OptionValue\}} +To accomplish that, instead of defining each option in \term{host\_config} +use \term{append\_host\_config} with the same syntax. In this example three virtual hosts have some similar modules, but there are also other different modules for some specific virtual hosts: \begin{verbatim} -%% This ejabberd server has three vhosts: -{hosts, ["one.example.org", "two.example.org", "three.example.org"]}. +## This ejabberd server has three vhosts: +hosts: + - "one.example.org" + - "two.example.org" + - "three.example.org" -%% Configuration of modules that are common to all vhosts -{modules, - [ - {mod_roster, []}, - {mod_configure, []}, - {mod_disco, []}, - {mod_private, []}, - {mod_time, []}, - {mod_last, []}, - {mod_version, []} - ]}. +## Configuration of modules that are common to all vhosts +modules: + mod_roster: {} + mod_configure: {} + mod_disco: {} + mod_private: {} + mod_time: {} + mod_last: {} + mod_version: {} -%% Add some modules to vhost one: -{host_config, "one.example.org", - [{{add, modules}, [ - {mod_echo, [{host, "echo-service.one.example.org"}]} - {mod_http_bind, []}, - {mod_logxml, []} - ] - } - ]}. +## Add some modules to vhost one: +append_host_config: + "one.example.org": + modules: + mod_echo: + host: "echo-service.one.example.org" + mod_http_bind: {} + mod_logxml: {} -%% Add a module just to vhost two: -{host_config, "two.example.org", - [{{add, modules}, [ - {mod_echo, [{host, "mirror.two.example.org"}]} - ] - } - ]}. +## Add a module just to vhost two: +append_host_config: + "two.example.org": + modules: + mod_echo: + host: "mirror.two.example.org" \end{verbatim} \makesubsection{listened}{Listening Ports} \ind{options!listen} The option \option{listen} defines for which ports, addresses and network protocols \ejabberd{} -will listen and what services will be run on them. Each element of the list is a -tuple with the following elements: +will listen and what services will be run on them. Each element of the list is an +associative array with the following elements: \begin{itemize} \item Port number. Optionally also the IP address and/or a transport protocol. \item Listening module that serves this port. @@ -786,14 +822,20 @@ tuple with the following elements: \end{itemize} The option syntax is: -\esyntax{\{listen, [Listener, ...]\}.} - -To define a listener there are several syntax. -\esyntax{\{PortNumber, Module, [Option, ...]\}} -\esyntax{\{\{PortNumber, IPaddress\}, Module, [Option, ...]\}} -\esyntax{\{\{PortNumber, TransportProtocol\}, Module, [Option, ...]\}} -\esyntax{\{\{PortNumber, IPaddress, TransportProtocol\}, Module, [Option, ...]\}} - +\esyntax{[Listener, ...]} +Example: +\begin{verbatim} +listen: + - + port: 5222 + module: ejabberd_c2s + starttls: true + certfile: "/path/to/certfile.pem" + - + port: 5269 + module: ejabberd_s2s_in + transport: tcp +\end{verbatim} \makesubsubsection{listened-port}{Port Number, IP Address and Transport Protocol} @@ -801,8 +843,7 @@ The port number defines which port to listen for incoming connections. It can be a Jabber/XMPP standard port (see section \ref{firewall}) or any other valid port number. -The IP address can be represented with a string -or an Erlang tuple with decimal or hexadecimal numbers. +The IP address can be represented as a string. The socket will listen only in that network interface. It is possible to specify a generic address, so \ejabberd{} will listen in all addresses. @@ -815,9 +856,6 @@ Some example values for IP address: \item \verb|"::"| to listen in all IPv6 network interfaces \item \verb|"10.11.12.13"| is the IPv4 address \verb|10.11.12.13| \item \verb|"::FFFF:127.0.0.1"| is the IPv6 address \verb|::FFFF:127.0.0.1/128| -\item \verb|{10, 11, 12, 13}| is the IPv4 address \verb|10.11.12.13| -\item \verb|{0, 0, 0, 0, 0, 65535, 32512, 1}| is the IPv6 address \verb|::FFFF:127.0.0.1/128| -\item \verb|{16#fdca, 16#8ab6, 16#a243, 16#75ef, 0, 0, 0, 1}| is the IPv6 address \verb|FDCA:8AB6:A243:75EF::1/128| \end{itemize} The transport protocol can be \term{tcp} or \term{udp}. @@ -858,33 +896,33 @@ The available modules, their purpose and the options allowed by each one are: This is a detailed description of each option allowed by the listening modules: \begin{description} - \titem{\{access, AccessName\}} \ind{options!access}This option defines + \titem{access: AccessName} \ind{options!access}This option defines access to the port. The default value is \term{all}. - \titem{\{backlog, Value\}} \ind{options!backlog}The backlog value + \titem{backlog: Value} \ind{options!backlog}The backlog value defines the maximum length that the queue of pending connections may grow to. This should be increased if the server is going to handle lots of new incoming connections as they may be dropped if there is no space in the queue (and ejabberd was not able to accept them immediately). Default value is 5. - \titem{captcha} \ind{options!http-captcha} + \titem{captcha: true|false} \ind{options!http-captcha} Simple web page that allows a user to fill a CAPTCHA challenge (see section \ref{captcha}). - \titem{\{certfile, Path\}} Full path to a file containing the default SSL certificate. + \titem{certfile: Path} Full path to a file containing the default SSL certificate. To define a certificate file specific for a given domain, use the global option \term{domain\_certfile}. - \titem{\{default\_host, undefined|HostName\}} + \titem{default\_host: undefined|HostName\}} If the HTTP request received by ejabberd contains the HTTP header \term{Host} with an ambiguous virtual host that doesn't match any one defined in ejabberd (see \ref{hostnames}), then this configured HostName is set as the request Host. The default value of this option is: \term{undefined}. - \titem{\{hosts, [Hostname, ...], [HostOption, ...]\}} \ind{options!hosts} + \titem{hosts: \{Hostname: [HostOption, ...]\}}\ind{options!hosts} The external Jabber component that connects to this \term{ejabberd\_service} can serve one or more hostnames. As \term{HostOption} you can define options for the component; currently the only allowed option is the password required to the component - when attempt to connect to ejabberd: \poption{\{password, Secret\}}. + when attempt to connect to ejabberd: \poption{password: Secret}. Note that you cannot define in a single \term{ejabberd\_service} components of different services: add an \term{ejabberd\_service} for each service, as seen in an example below. - \titem{http\_bind} \ind{options!http\_bind}\ind{protocols!XEP-0206: HTTP Binding}\ind{JWChat}\ind{web-based XMPP client} + \titem{http\_bind: true|false} \ind{options!http\_bind}\ind{protocols!XEP-0206: HTTP Binding}\ind{JWChat}\ind{web-based XMPP client} This option enables HTTP Binding (\xepref{0124} and \xepref{0206}) support. HTTP Bind enables access via HTTP requests to \ejabberd{} from behind firewalls which do not allow outgoing sockets on port 5222. @@ -899,7 +937,7 @@ This is a detailed description of each option allowed by the listening modules: (check the tutorials to install JWChat with ejabberd and an \footahref{http://www.ejabberd.im/jwchat-localserver}{embedded local web server} or \footahref{http://www.ejabberd.im/jwchat-apache}{Apache}). - \titem{http\_poll} \ind{options!http\_poll}\ind{protocols!XEP-0025: HTTP Polling}\ind{JWChat}\ind{web-based XMPP client} + \titem{http\_poll: true|false} \ind{options!http\_poll}\ind{protocols!XEP-0025: HTTP Polling}\ind{JWChat}\ind{web-based XMPP client} This option enables HTTP Polling (\xepref{0025}) support. HTTP Polling enables access via HTTP requests to \ejabberd{} from behind firewalls which do not allow outgoing sockets on port 5222. @@ -913,9 +951,9 @@ This is a detailed description of each option allowed by the listening modules: The maximum period of time to keep a client session active without an incoming POST request can be configured with the global option \term{http\_poll\_timeout}. The default value is five minutes. - The option can be defined in \term{ejabberd.cfg}, expressing the time + The option can be defined in \term{ejabberd.yml}, expressing the time in seconds: \verb|{http_poll_timeout, 300}.| - \titem{\{max\_fsm\_queue, Size\}} + \titem{max\_fsm\_queue: Size} This option specifies the maximum number of elements in the queue of the FSM (Finite State Machine). Roughly speaking, each message in such queues represents one XML @@ -933,7 +971,7 @@ This is a detailed description of each option allowed by the listening modules: the globally configured value is used. The allowed values are integers and 'undefined'. Default value: 'undefined'. - \titem{\{max\_stanza\_size, Size\}} + \titem{max\_stanza\_size: Size} \ind{options!max\_stanza\_size}This option specifies an approximate maximum size in bytes of XML stanzas. Approximate, because it is calculated with the precision of one block of read @@ -942,12 +980,17 @@ This is a detailed description of each option allowed by the listening modules: connections and 131072 for s2s connections. s2s max stanza size must always much higher than c2s limit. Change this value with extreme care as it can cause unwanted disconnect if set too low. - \titem{\{request\_handlers, [ \{Path, Module\}, ...]\}} To define one or several handlers that will serve HTTP requests. - The Path is a list of strings; so the URIs that start with that Path will be served by Module. + \titem{request\_handlers: \{Path: Module\}} To define one or several handlers that will serve HTTP requests. + The Path is a string; so the URIs that start with that Path will be served by Module. For example, if you want \term{mod\_foo} to serve the URIs that start with \term{/a/b/}, and you also want \term{mod\_http\_bind} to serve the URIs \term{/http-bind/}, - use this option: \term{\{request\_handlers, [\{["a", "b"], mod\_foo\}, \{["http-bind"], mod\_http\_bind\}]\}} - \titem{\{service\_check\_from, true|false\}} + use this option: +\begin{verbatim} +request_handlers: + /"a"/"b": mod_foo + /"http-bind": mod_http_bind +\end{verbatim} + \titem{service\_check\_from: true|false} \ind{options!service\_check\_from} This option can be used with \term{ejabberd\_service} only. \xepref{0114} requires that the domain must match the hostname of the component. @@ -955,22 +998,25 @@ This is a detailed description of each option allowed by the listening modules: to send stanzas with any arbitrary domain in the 'from' attribute. Only use this option if you are completely sure about it. The default value is \term{true}, to be compliant with \xepref{0114}. - \titem{\{shaper, none|ShaperName\}} \ind{options!shaper}This option defines a + \titem{shaper: none|ShaperName} \ind{options!shaper}This option defines a shaper for the port (see section~\ref{shapers}). The default value is \term{none}. - \titem{\{shaper\_rule, none|ShaperRule\}} \ind{options!shaperrule}This option defines a + \titem{shaper\_rule: none|ShaperRule} \ind{options!shaperrule}This option defines a shaper rule for the \term{ejabberd\_service} (see section~\ref{shapers}). The recommended value is \term{fast}. - \titem{starttls} \ind{options!starttls}\ind{STARTTLS}This option + \titem{starttls: true|false} \ind{options!starttls}\ind{STARTTLS}This option specifies that STARTTLS encryption is available on connections to the port. You should also set the \option{certfile} option. You can define a certificate file for a specific domain using the global option \option{domain\_certfile}. - \titem{starttls\_required} \ind{options!starttls\_required}This option + \titem{starttls\_required: true|false} \ind{options!starttls\_required}This option specifies that STARTTLS encryption is required on connections to the port. No unencrypted connections will be allowed. You should also set the \option{certfile} option. You can define a certificate file for a specific domain using the global option \option{domain\_certfile}. - \titem{tls} \ind{options!tls}\ind{TLS}This option specifies that traffic on + \titem{timeout: Integer} \ind{options!timeout} + Timeout of the connections, expressed in milliseconds. + Default: 5000 + \titem{tls: true|false} \ind{options!tls}\ind{TLS}This option specifies that traffic on the port will be encrypted using SSL immediately after connecting. This was the traditional encryption method in the early Jabber software, commonly on port 5223 for client-to-server communications. @@ -980,56 +1026,53 @@ This is a detailed description of each option allowed by the listening modules: which can be enabled in \ejabberd{} with the option \term{starttls}. If this option is set, you should also set the \option{certfile} option. The option \term{tls} can also be used in \term{ejabberd\_http} to support HTTPS. - \titem{\{tls\_compression, true|false\}} + \titem{tls\_compression: true|false} Whether to enable or disable TLS compression. The default value is \term{true}. - \titem{\{trusted\_proxies, all | [IpString]\}} \ind{options!trusted\_proxies} + \titem{trusted\_proxies: all | [IpString]} \ind{options!trusted\_proxies} Specify what proxies are trusted when an HTTP request contains the header \term{X-Forwarded-For} You can specify \term{all} to allow all proxies, or specify a list of IPs in string format. The default value is: \term{["127.0.0.1"]} - \titem{web\_admin} \ind{options!web\_admin}\ind{web admin}This option + \titem{web\_admin: true|false} \ind{options!web\_admin}\ind{web admin}This option enables the Web Admin for \ejabberd{} administration which is available at \verb|http://server:port/admin/|. Login and password are the username and password of one of the registered users who are granted access by the `configure' access rule. - \titem{zlib} \ind{options!zlib}\ind{protocols!XEP-0138: Stream Compression}\ind{Zlib}This + \titem{zlib: true|false} \ind{options!zlib}\ind{protocols!XEP-0138: Stream Compression}\ind{Zlib}This option specifies that Zlib stream compression (as defined in \xepref{0138}) is available on connections to the port. \end{description} There are some additional global options that can be specified in the ejabberd configuration file (outside \term{listen}): \begin{description} - \titem{\{s2s\_use\_starttls, false|optional|required|required\_trusted\}} + \titem{s2s\_use\_starttls: false|optional|required|required\_trusted} \ind{options!s2s\_use\_starttls}\ind{STARTTLS}This option defines if s2s connections don't use STARTTLS encryption; if STARTTLS can be used optionally; if STARTTLS is required to establish the connection; or if STARTTLS is required and the remote certificate must be valid and trusted. The default value is to not use STARTTLS: \term{false}. - \titem{\{s2s\_certfile, Path\}} \ind{options!s2s\_certificate}Full path to a + \titem{s2s\_certfile: Path} \ind{options!s2s\_certificate}Full path to a file containing a SSL certificate. - \titem{\{domain\_certfile, Domain, Path\}} \ind{options!domain\_certfile} + \titem{domain\_certfile: Path} \ind{options!domain\_certfile} Full path to the file containing the SSL certificate for a specific domain. - \titem{\{outgoing\_s2s\_options, [Family, ...], Timeout\}} \ind{options!outgoing\_s2s\_options} - Specify which address families to try, in what order, and connect timeout in milliseconds. - By default it first tries connecting with IPv4, if that fails it tries using IPv6, - with a timeout of 10000 milliseconds. - \titem{\{s2s\_dns\_options, [ \{Property, Value\}, ...]\}} - \ind{options!s2s\_dns\_options}Define properties to use for DNS resolving. - Allowed Properties are: \term{timeout} in seconds which default value is \term{10} - and \term{retries} which default value is \term{2}. - \titem{\{s2s\_default\_policy, allow|deny\}} - The default policy for incoming and outgoing s2s connections to other XMPP servers. - The default value is \term{allow}. - \titem{\{\{s2s\_host, Host\}, allow|deny\}} - Defines if incoming and outgoing s2s connections with a specific remote host are allowed or denied. - This allows to restrict ejabberd to only establish s2s connections - with a small list of trusted servers, or to block some specific servers. - \titem{\{s2s\_max\_retry\_delay, Seconds\}} \ind{options!s2s\_max\_retry\_delay} + \titem{outgoing\_s2s\_families: [Family, ...]} \ind{options!outgoing\_s2s\_families} + Specify which address families to try, in what order. + By default it first tries connecting with IPv4, if that fails it tries using IPv6. + \titem{outgoing\_s2s\_timeout: Timeout} \ind{options!outgoing\_s2s\_timeout} + The timeout in milliseconds for outgoing S2S connection attempts. + \titem{s2s\_dns\_timeout: Timeout} \ind{options!s2s\_dns\_timeout} + The timeout in seconds for DNS resolving. The default value is \term{10}. + \titem{s2s\_dns\_retries: Number} \ind{options!s2s\_dns\_retries} + DNS resolving retries in seconds. The default value is \term{2}. + \titem{s2s\_policy: Access} \ind{options!s2s\_policy} + The policy for incoming and outgoing s2s connections to other XMPP servers. + The default value is \term{all}. + \titem{s2s\_max\_retry\_delay: Seconds} \ind{options!s2s\_max\_retry\_delay} The maximum allowed delay for retry to connect after a failed connection attempt. Specified in seconds. The default value is 300 seconds (5 minutes). - \titem{\{s2s\_tls\_compression, true|false\}} + \titem{s2s\_tls\_compression: true|false} Whether to enable or disable TLS compression for s2s connections. The default value is \term{true}. - \titem{\{max\_fsm\_queue, Size\}} + \titem{max\_fsm\_queue: Size} This option specifies the maximum number of elements in the queue of the FSM (Finite State Machine). Roughly speaking, each message in such queues represents one XML @@ -1047,7 +1090,7 @@ There are some additional global options that can be specified in the ejabberd c the globally configured value is used. The allowed values are integers and 'undefined'. Default value: 'undefined'. - \titem{\{route\_subdomains, local|s2s\}} + \titem{route\_subdomains: local|s2s} Defines if ejabberd must route stanzas directed to subdomains locally (compliant with \footahref{http://xmpp.org/rfcs/rfc3920.html\#rules.subdomain}{RFC 3920: XMPP Core}), or to foreign server using S2S (compliant with @@ -1070,40 +1113,60 @@ However, the c2s and s2s connections to the domain \term{example.com} use the fi section~\ref{webadmin}. The socket only listens connections to the IP address 127.0.0.1. \end{itemize} \begin{verbatim} -{hosts, ["example.com", "example.org", "example.net"]}. -{listen, - [ - {5222, ejabberd_c2s, [ - {access, c2s}, - {shaper, c2s_shaper}, - starttls, {certfile, "/etc/ejabberd/server.pem"}, - {max_stanza_size, 65536} - ]}, - {5223, ejabberd_c2s, [ - {access, c2s}, - {shaper, c2s_shaper}, - tls, {certfile, "/etc/ejabberd/server.pem"}, - {max_stanza_size, 65536} - ]}, - {{5269, "::"}, ejabberd_s2s_in, [ - {shaper, s2s_shaper}, - {max_stanza_size, 131072} - ]}, - {{3478, udp}, ejabberd_stun, []}, - {5280, ejabberd_http, [ - http_poll - ]}, - {{5281, "127.0.0.1"}, ejabberd_http, [ - web_admin, - http_bind, - tls, {certfile, "/etc/ejabberd/server.pem"}, - ]} - ] -}. -{s2s_use_starttls, optional}. -{s2s_certfile, "/etc/ejabberd/server.pem"}. -{domain_certfile, "example.com", "/etc/ejabberd/example_com.pem"}. -{outgoing_s2s_options, [ipv4, ipv6], 10000}. +hosts: + - "example.com" + - "example.org" + - "example.net" + +listen: + - + port: 5222 + module: ejabberd_c2s + access: c2s + shaper: c2s_shaper + starttls: true + certfile: "/etc/ejabberd/server.pem" + max_stanza_size: 65536 + - + port: 5223 + module: ejabberd_c2s + access: c2s + shaper: c2s_shaper + tls: true + certfile: "/etc/ejabberd/server.pem" + max_stanza_size: 65536 + - + port: 5269 + ip: "::" + module: ejabberd_s2s_in + shaper: s2s_shaper + max_stanza_size: 131072 + - + port: 3478 + transport: udp + module: ejabberd_stun + - + port: 5280 + module: ejabberd_http + http_poll: true + - + port: 5281 + ip: "127.0.0.1" + module: ejabberd_http + web_admin: true + http_bind: true + tls: true + certfile: "/etc/ejabberd/server.pem" + +s2s_use_starttls: optional +s2s_certfile: "/etc/ejabberd/server.pem" +host_config: + "example.com": + domain_certfile: "/etc/ejabberd/example_com.pem" +outgoing_s2s_families: + - ipv4 + - ipv6 +outgoing_s2s_timeout: 10000 \end{verbatim} In this example, the following configuration defines that: @@ -1145,59 +1208,117 @@ In this example, the following configuration defines that: \item The service custom has enabled the special option to avoiding checking the \term{from} attribute in the packets send by this component. The component can send packets in behalf of any users from the server, or even on behalf of any server. \end{itemize} \begin{verbatim} -{acl, blocked, {user, "bad"}}. -{access, c2s, [{deny, blocked}, - {allow, all}]}. -{shaper, normal, {maxrate, 1000}}. -{access, c2s_shaper, [{none, admin}, - {normal, all}]}. -{listen, - [{5222, ejabberd_c2s, [ - {access, c2s}, - {shaper, c2s_shaper} - ]}, - {{5223, {192, 168, 0, 1}}, ejabberd_c2s, [ - {access, c2s}, - ssl, {certfile, "/path/to/ssl.pem"} - ]}, - {{5223, {16#fdca, 16#8ab6, 16#a243, 16#75ef, 0, 0, 0, 1}}, - ejabberd_c2s, [ - {access, c2s}, - ssl, {certfile, "/path/to/ssl.pem"} - ]}, - {5269, ejabberd_s2s_in, []}, - {{5280, {0, 0, 0, 0}}, ejabberd_http, [ - http_poll, - web_admin - ]}, - {{5233, {127, 0, 0, 1}}, ejabberd_service, [ - {hosts, ["aim.example.org"], - [{password, "aimsecret"}]} - ]}, - {{5233, "::1"}, ejabberd_service, [ - {hosts, ["aim.example.org"], - [{password, "aimsecret"}]} - ]}, - {5234, ejabberd_service, [{hosts, ["icq.example.org", "sms.example.org"], - [{password, "jitsecret"}]}]}, - {5235, ejabberd_service, [{hosts, ["msn.example.org"], - [{password, "msnsecret"}]}]}, - {5236, ejabberd_service, [{hosts, ["yahoo.example.org"], - [{password, "yahoosecret"}]}]}, - {5237, ejabberd_service, [{hosts, ["gg.example.org"], - [{password, "ggsecret"}]}]}, - {5238, ejabberd_service, [{hosts, ["jmc.example.org"], - [{password, "jmcsecret"}]}]}, - {5239, ejabberd_service, [{hosts, ["custom.example.org"], - [{password, "customsecret"}]}, - {service_check_from, false}]} - ] -}. -{s2s_use_starttls, required_trusted}. -{s2s_certfile, "/path/to/ssl.pem"}. -{s2s_default_policy, deny}. -{{s2s_host,"jabber.example.org"}, allow}. -{{s2s_host,"example.com"}, allow}. +acl: + blocked: + user: "bad" + trusted_servers: + server: + - "example.com" + - "jabber.example.org" + xmlrpc_bot: + user: + - "xmlrpc-robot": "example.org" +shaper: + normal: 1000 +access: + c2s: + blocked: deny + all: allow + c2s_shaper: + admin: none + all: normal + xmlrpc_access: + xmlrpc_bot: allow + s2s_access: + trusted_servers: allow + all: deny +s2s_certfile: "/path/to/ssl.pem" +s2s_policy: s2s_access +s2s_use_starttls: required_trusted +listen: + - + port: 5222 + module: ejabberd_c2s + shaper: c2s_shaper + access: c2s + - + ip: "192.168.0.1" + port: 5223 + module: ejabberd_c2s + certfile: "/path/to/ssl.pem" + tls: true + access: c2s + - + ip: "FDCA:8AB6:A243:75EF::1" + port: 5223 + module: ejabberd_c2s + certfile: "/path/to/ssl.pem" + tls: true + access: c2s + - + port: 5269 + module: ejabberd_s2s_in + - + port: 5280 + module: ejabberd_http + web_admin: true + http_poll: true + - + port: 4560 + module: ejabberd_xmlrpc + - + ip: "127.0.0.1" + port: 5233 + module: ejabberd_service + hosts: + "aim.example.org": + password: "aimsecret" + - + ip: "::1" + port: 5233 + module: ejabberd_service + hosts: + "aim.example.org": + password: "aimsecret" + - + port: 5234 + module: ejabberd_service + hosts: + "icq.example.org": + password: "jitsecret" + "sms.example.org": + password: "jitsecret" + - + port: 5235 + module: ejabberd_service + hosts: + "msn.example.org": + password: "msnsecret" + - + port: 5236 + module: ejabberd_service + hosts: + "yahoo.example.org": + password: "yahoosecret" + - + port: 5237 + module: ejabberd_service + hosts: + "gg.example.org": + password: "ggsecret" + - + port: 5238 + module: ejabberd_service + hosts: + "jmc.example.org": + password: "jmcsecret" + - + port: 5239 + module: ejabberd_service + service_check_from: false + hosts: + "custom.example.org": + password: "customsecret" \end{verbatim} Note, that for services based in \ind{jabberd14}jabberd14 or \ind{WPJabber}WPJabber you have to make the transports log and do \ind{XDB}XDB by themselves: @@ -1237,15 +1358,14 @@ you have to make the transports log and do \ind{XDB}XDB by themselves: The option \option{auth\_method} defines the authentication methods that are used for user authentication. The syntax is: -\esyntax{\{auth\_method, [Method, ...]\}.} +\esyntax{[Method, ...]} The following authentication methods are supported by \ejabberd{}: \begin{itemize} \item internal (default) --- See section~\ref{internalauth}. \item external --- See section~\ref{extauth}. \item ldap --- See section~\ref{ldap}. -\item odbc --- See section~\ref{mysql}, \ref{pgsql}, - \ref{mssql} and \ref{odbc}. +\item odbc --- See section~\ref{odbc}. \item anonymous --- See section~\ref{saslanonymous}. \item pam --- See section~\ref{pam}. \end{itemize} @@ -1255,7 +1375,7 @@ Account creation is only supported by internal, external and odbc methods. The option \option{resource\_conflict} defines the action when a client attempts to login to an account with a resource that is already connected. The option syntax is: -\esyntax{\{resource\_conflict, setresource|closenew|closeold\}.} +\esyntax{resource\_conflict: setresource|closenew|closeold} The possible values match exactly the three possibilities described in \footahref{http://tools.ietf.org/html/rfc6120\#section-7.7.2.2}{XMPP Core: section 7.7.2.2}. The default value is \term{closeold}. @@ -1266,7 +1386,7 @@ The option \option{fqdn} allows you to define the Fully Qualified Domain Name of the machine, in case it isn't detected automatically. The FQDN is used to authenticate some clients that use the DIGEST-MD5 SASL mechanism. The option syntax is: -\esyntax{\{fqdn, undefined|FqdnString|[FqdnString]\}.} +\esyntax{fqdn: undefined|FqdnString|[FqdnString]} \makesubsubsection{internalauth}{Internal} \ind{internal authentication}\ind{Mnesia} @@ -1274,7 +1394,7 @@ The option syntax is: \ejabberd{} uses its internal Mnesia database as the default authentication method. The value \term{internal} will enable the internal authentication method. -The option \term{\{auth\_password\_format, plain|scram\}} +The option \term{auth\_password\_format: plain|scram} defines in what format the users passwords are stored: \begin{description} \titem{plain} @@ -1297,13 +1417,16 @@ Examples: \item To use internal authentication on \jid{example.org} and LDAP authentication on \jid{example.net}: \begin{verbatim} -{host_config, "example.org", [{auth_method, [internal]}]}. -{host_config, "example.net", [{auth_method, [ldap]}]}. +host_config: + "example.org": + auth_method: [internal] + "example.net": + auth_method: [ldap] \end{verbatim} \item To use internal authentication with hashed passwords on all virtual hosts: \begin{verbatim} -{auth_method, internal}. -{auth_password_format, scram}. +auth_method: internal +auth_password_format: scram \end{verbatim} \end{itemize} @@ -1321,15 +1444,15 @@ There are also \footahref{http://www.ejabberd.im/extauth}{several example authen These are the specific options: \begin{description} - \titem{\{extauth\_program, PathToScript\}} + \titem{extauth\_program: PathToScript} Indicate in this option the full path to the external authentication script. The script must be executable by ejabberd. - \titem{\{extauth\_instances, Integer\}} + \titem{extauth\_instances: Integer} Indicate how many instances of the script to run simultaneously to serve authentication in the virtual host. The default value is the minimum number: 1. - \titem{\{extauth\_cache, false|CacheTimeInteger\}} + \titem{extauth\_cache: false|CacheTimeInteger} The value \term{false} disables the caching feature, this is the default. The integer \term{0} (zero) enables caching for statistics, but doesn't use that cached information to authenticate users. If another integer value is set, caching is enabled both for statistics and for authentication: @@ -1343,10 +1466,10 @@ These are the specific options: This example sets external authentication, the extauth script, enables caching for 10 minutes, and starts three instances of the script for each virtual host defined in ejabberd: \begin{verbatim} -{auth_method, [external]}. -{extauth_program, "/etc/ejabberd/JabberAuth.class.php"}. -{extauth_cache, 600}. -{extauth_instances, 3}. +auth_method: [external] +extauth_program: "/etc/ejabberd/JabberAuth.class.php" +extauth_cache: 600 +extauth_instances: 3 \end{verbatim} @@ -1378,13 +1501,13 @@ options. Remember that you can use the \term{host\_config} option to set virtual host specific options (see section~\ref{virtualhost}). \begin{description} -\titem{\{allow\_multiple\_connections, false|true\}} This option is only used +\titem{allow\_multiple\_connections: false|true} This option is only used when the anonymous mode is enabled. Setting it to \term{true} means that the same username can be taken multiple times in anonymous login mode if different resource are used to connect. This option is only useful in very special occasions. The default value is \term{false}. -\titem{\{anonymous\_protocol, login\_anon | sasl\_anon | both\}} +\titem{anonymous\_protocol: login\_anon | sasl\_anon | both} \term{login\_anon} means that the anonymous login method will be used. \term{sasl\_anon} means that the SASL Anonymous method will be used. \term{both} means that SASL Anonymous and login anonymous are both enabled. @@ -1397,34 +1520,48 @@ Examples: \begin{itemize} \item To enable anonymous login on all virtual hosts: \begin{verbatim} -{auth_method, [anonymous]}. -{anonymous_protocol, login_anon}. +auth_method: [anonymous] +anonymous_protocol: login_anon \end{verbatim} \item Similar as previous example, but limited to \jid{public.example.org}: \begin{verbatim} -{host_config, "public.example.org", [{auth_method, [anonymous]}, - {anonymous_protocol, login_anon}]}. +host_config: + "public.example.org": + auth_method: [anonymous] + anonymous_protoco: login_anon \end{verbatim} \item To enable anonymous login and internal authentication on a virtual host: \begin{verbatim} -{host_config, "public.example.org", [{auth_method, [internal,anonymous]}, - {anonymous_protocol, login_anon}]}. +host_config: + "public.example.org": + auth_method: + - internal + - anonymous + anonymous_protocol: login_anon \end{verbatim} \item To enable SASL Anonymous on a virtual host: \begin{verbatim} -{host_config, "public.example.org", [{auth_method, [anonymous]}, - {anonymous_protocol, sasl_anon}]}. +host_config: + "public.example.org": + auth_method: [anonymous] + anonymous_protocol: sasl_anon \end{verbatim} \item To enable SASL Anonymous and anonymous login on a virtual host: \begin{verbatim} -{host_config, "public.example.org", [{auth_method, [anonymous]}, - {anonymous_protocol, both}]}. +host_config: + "public.example.org": + auth_method: [anonymous] + anonymous_protocol: both \end{verbatim} \item To enable SASL Anonymous, anonymous login, and internal authentication on a virtual host: \begin{verbatim} -{host_config, "public.example.org", [{auth_method, [internal,anonymous]}, - {anonymous_protocol, both}]}. +host_config: + "public.example.org": + auth_method: + - internal + - anonymous + anonymous_protocol: both \end{verbatim} \end{itemize} @@ -1445,10 +1582,10 @@ PAM authentication is disabled by default, so you have to configure and compile Options: \begin{description} -\titem{\{pam\_service, Name\}}\ind{options!pam\_service}This option defines the PAM service name. +\titem{pam\_service: Name}\ind{options!pam\_service}This option defines the PAM service name. Default is \term{"ejabberd"}. Refer to the PAM documentation of your operation system for more information. -\titem{\{pam\_userinfotype, username|jid\}}\ind{options!pam\_userinfotype} +\titem{pam\_userinfotype: username|jid}\ind{options!pam\_userinfotype} This option defines what type of information about the user ejabberd provides to the PAM service: only the username, or the user JID. Default is \term{username}. @@ -1456,8 +1593,8 @@ Default is \term{username}. Example: \begin{verbatim} -{auth_method, [pam]}. -{pam_service, "ejabberd"}. +auth_method: [pam] +pam_service: "ejabberd" \end{verbatim} Though it is quite easy to set up PAM support in \ejabberd{}, PAM itself introduces some @@ -1506,74 +1643,109 @@ then \term{/etc/nsswitch.conf} must be configured to use \term{winbind} as well. Access control in \ejabberd{} is performed via Access Control Lists (ACLs). The declarations of ACLs in the configuration file have the following syntax: -\esyntax{\{acl, ACLName, ACLValue\}.} +\esyntax{acl: \{ ACLName: \{ ACLType: ACLValue \} \}} -\term{ACLValue} can be one of the following: +\term{ACLType: ACLValue} can be one of the following: \begin{description} \titem{all} Matches all JIDs. Example: \begin{verbatim} -{acl, all, all}. +acl: + world: all \end{verbatim} -\titem{\{user, Username\}} Matches the user with the name +\titem{user: Username} Matches the user with the name \term{Username} at the first virtual host. Example: \begin{verbatim} -{acl, admin, {user, "yozhik"}}. +acl: + admin: + user: "yozhik" \end{verbatim} -\titem{\{user, Username, Server\}} Matches the user with the JID +\titem{user: \{Username: Server\}} Matches the user with the JID \term{Username@Server} and any resource. Example: \begin{verbatim} -{acl, admin, {user, "yozhik", "example.org"}}. +acl: + admin: + user: + "yozhik": "example.org" \end{verbatim} -\titem{\{server, Server\}} Matches any JID from server +\titem{server: Server} Matches any JID from server \term{Server}. Example: \begin{verbatim} -{acl, exampleorg, {server, "example.org"}}. +acl: + exampleorg: + server: "example.org" \end{verbatim} -\titem{\{resource, Resource\}} Matches any JID with a resource +\titem{resource: Resource} Matches any JID with a resource \term{Resource}. Example: \begin{verbatim} -{acl, mucklres, {resource, "muckl"}}. +acl: + mucklres: + resource: "muckl" \end{verbatim} -\titem{\{shared\_group, Groupname\}} Matches any member of a Shared Roster Group with name \term{Groupname} in the virtual host. Example: +\titem{shared\_group: Groupname} Matches any member of a Shared Roster Group with name \term{Groupname} in the virtual host. Example: \begin{verbatim} -{acl, techgroupmembers, {shared_group, "techteam"}}. +acl: + techgroupmembers: + shared_group: "techteam" \end{verbatim} -\titem{\{shared\_group, Groupname, Server\}} Matches any member of a Shared Roster Group with name \term{Groupname} in the virtual host \term{Server}. Example: +\titem{shared\_group: \{Groupname: Server\}} Matches any member of a Shared Roster Group with name \term{Groupname} in the virtual host \term{Server}. Example: \begin{verbatim} -{acl, techgroupmembers, {shared_group, "techteam", "example.org"}}. +acl: + techgroupmembers: + shared_group: + "techteam": "example.org" \end{verbatim} -\titem{\{user\_regexp, Regexp\}} Matches any local user with a name that +\titem{ip: Network} Matches any IP address from the \term{Network}. Example: +\begin{verbatim} +acl: + loopback: + ip: + - "127.0.0.0/8" + - "::" +\end{verbatim} +\titem{user\_regexp: Regexp} Matches any local user with a name that matches \term{Regexp} on local virtual hosts. Example: \begin{verbatim} -{acl, tests, {user_regexp, "^test[0-9]*$"}}. +acl: + tests: + user_regexp: "^test[0-9]*$" \end{verbatim} %$ -\titem{\{user\_regexp, Regexp, Server\}} Matches any user with a name +\titem{user\_regexp: \{Regexp: Server\}} Matches any user with a name that matches \term{Regexp} at server \term{Server}. Example: \begin{verbatim} -{acl, tests, {user_regexp, "^test", "example.org"}}. +acl: + tests: + user_regexp: + "^test": "example.org" \end{verbatim} -\titem{\{server\_regexp, Regexp\}} Matches any JID from the server that +\titem{server\_regexp: Regexp} Matches any JID from the server that matches \term{Regexp}. Example: \begin{verbatim} -{acl, icq, {server_regexp, "^icq\\."}}. +acl: + icq: + server_regexp: "^icq\\." \end{verbatim} -\titem{\{resource\_regexp, Regexp\}} Matches any JID with a resource that +\titem{resource\_regexp: Regexp} Matches any JID with a resource that matches \term{Regexp}. Example: \begin{verbatim} -{acl, icq, {resource_regexp, "^laptop\\."}}. +acl: + icq: + resource_regexp: "^laptop\\." \end{verbatim} -\titem{\{node\_regexp, UserRegexp, ServerRegexp\}} Matches any user +\titem{node\_regexp: \{UserRegexp: ServerRegexp\}} Matches any user with a name that matches \term{UserRegexp} at any server that matches \term{ServerRegexp}. Example: \begin{verbatim} -{acl, yozhik, {node_regexp, "^yozhik$", "^example.(com|org)$"}}. +acl: + yozhik: + node_regexp: + "^yozhik$": "^example.(com|org)$" \end{verbatim} -\titem{\{user\_glob, Glob\}} -\titem{\{user\_glob, Glob, Server\}} -\titem{\{server\_glob, Glob\}} -\titem{\{resource\_glob, Glob\}} -\titem{\{node\_glob, UserGlob, ServerGlob\}} This is the same as +\titem{user\_glob: Glob\}} +\titem{user\_glob: \{Glob: Server\}} +\titem{server\_glob: Glob} +\titem{resource\_glob: Glob} +\titem{node\_glob: \{UserGlob: ServerGlob\}} This is the same as above. However, it uses shell glob patterns instead of regexp. These patterns can have the following special characters: \begin{description} @@ -1597,7 +1769,7 @@ The following \term{ACLName} are pre-defined: An entry allowing or denying access to different services. The syntax is: -\esyntax{\{access, AccessName, [ \{allow|deny, ACLName\}, ...]\}.} +\esyntax{access: \{ AccessName: \{ ACLName: allow|deny \} \}} When a JID is checked to have access to \term{Accessname}, the server sequentially checks if that JID matches any of the ACLs that are named in the @@ -1612,9 +1784,12 @@ and the Access of a virtual host doesn't have effect. Example: \begin{verbatim} -{access, configure, [{allow, admin}]}. -{access, something, [{deny, badmans}, - {allow, all}]}. +access: + configure: + admin: allow + something + badmans: deny + all: allow \end{verbatim} The following \term{AccessName} are pre-defined: @@ -1635,11 +1810,14 @@ can be either a number, or \term{infinity}. The default value is \term{infinity}. The syntax is: -\esyntax{\{access, max\_user\_sessions, [ \{MaxNumber, ACLName\}, ...]\}.} +\esyntax{\{ max\_user\_sessions: \{ ACLName: MaxNumber \} \}} This example limits the number of sessions per user to 5 for all users, and to 10 for admins: \begin{verbatim} -{access, max_user_sessions, [{10, admin}, {5, all}]}. +access: + max_user_sessions: + admin: 10 + all: 5 \end{verbatim} \makesubsubsection{configmaxs2sconns}{Several connections to a remote XMPP server with ACL} @@ -1651,25 +1829,24 @@ The default value is \term{1}. There's also available the access \term{max\_s2s\_connections\_per\_node}. The syntax is: -\esyntax{\{access, max\_s2s\_connections, [ \{MaxNumber, ACLName\}, ...]\}.} +\esyntax{\{ max\_s2s\_connections: \{ ACLName: MaxNumber \} \}} Examples: \begin{itemize} \item Allow up to 3 connections with each remote server: \begin{verbatim} -{access, max_s2s_connections, [{3, all}]}. +access: + max_s2s_connections: + all: 3 \end{verbatim} \end{itemize} \makesubsection{shapers}{Shapers} -\ind{options!shaper}\ind{options!maxrate}\ind{shapers}\ind{maxrate}\ind{traffic speed} +\ind{options!shaper}\ind{shapers}\ind{traffic speed} Shapers enable you to limit connection traffic. The syntax is: -\esyntax{\{shaper, ShaperName, Kind\}.} -Currently only one kind of shaper called \term{maxrate} is available. It has the -following syntax: -\esyntax{\{maxrate, Rate\}} +\esyntax{shaper: \{ ShaperName: Rate \}} where \term{Rate} stands for the maximum allowed incoming rate in bytes per second. When a connection exceeds this limit, \ejabberd{} stops reading from the socket @@ -1680,12 +1857,14 @@ Examples: \item To define a shaper named `\term{normal}' with traffic speed limited to 1,000\,bytes/second: \begin{verbatim} -{shaper, normal, {maxrate, 1000}}. +shaper: + normal: 1000 \end{verbatim} \item To define a shaper named `\term{fast}' with traffic speed limited to 50,000\,bytes/second: \begin{verbatim} -{shaper, fast, {maxrate, 50000}}. +shaper: + fast: 50000 \end{verbatim} \end{itemize} @@ -1697,7 +1876,7 @@ can be seen by \XMPP{} clients. If a \XMPP{} client does not support \option{xml:lang}, the specified language is used. The option syntax is: -\esyntax{\{language, Language\}.} +\esyntax{language: Language} The default value is \term{en}. In order to take effect there must be a translation file @@ -1705,7 +1884,7 @@ In order to take effect there must be a translation file For example, to set Russian as default language: \begin{verbatim} -{language, "ru"}. +language: "ru" \end{verbatim} Appendix \ref{i18ni10n} provides more details about internationalization and localization. @@ -1723,10 +1902,10 @@ using ImageMagick's Convert program. The configurable options are: \begin{description} - \titem{\{captcha\_cmd, Path\}} + \titem{captcha\_cmd: Path} Full path to a script that generates the image. The default value disables the feature: \term{undefined} - \titem{\{captcha\_host, ProtocolHostPort\}} + \titem{captcha\_host: ProtocolHostPort} ProtocolHostPort is a string with the host, and optionally the Protocol and Port number. It must identify where ejabberd listens for CAPTCHA requests. The URL sent to the user is formed by: \term{Protocol://Host:Port/captcha/} @@ -1741,23 +1920,20 @@ See section \ref{listened-module}. Example configuration: \begin{verbatim} -{hosts, ["example.org"]}. +hosts: ["example.org"] -{captcha_cmd, "/lib/ejabberd/priv/bin/captcha.sh"}. -{captcha_host, "example.org:5280"}. -%% {captcha_host, "https://example.org:443"}. -%% {captcha_host, "http://example.com"}. +captcha_cmd: "/lib/ejabberd/priv/bin/captcha.sh" +captcha_host: "example.org:5280" +## captcha_host: "https://example.org:443" +## captcha_host: "http://example.com" -{listen, - [ +listen: + ... + - + port: 5280 + module: ejabberd_http + captcha: true ... - {5280, ejabberd_http, [ - captcha, - ... - ] - } - -]}. \end{verbatim} \makesubsection{stun}{STUN} @@ -1777,15 +1953,20 @@ functionality. Feel free to configure \term{udp} transport only. Example configuration: \begin{verbatim} -{listen, - [ +listen: ... - {{3478, udp}, ejabberd_stun, []}, - {3478, ejabberd_stun, []}, - {5349, ejabberd_stun, [{certfile, "/etc/ejabberd/server.pem"}]}, + - + port: 3478 + transport: udp + module: ejabberd_stun + - + port: 3478 + module: ejabberd_stun + - + port: 5349 + module: ejabberd_stun + certfile: "/etc/ejabberd/server.pem" ... - ] -}. \end{verbatim} You also need to configure DNS SRV records properly so clients can easily discover a @@ -1806,9 +1987,9 @@ _stuns._tcp IN SRV 0 0 5349 stun.example.com. The option \option{include\_config\_file} in a configuration file instructs \ejabberd{} to include other configuration files immediately. The basic syntax is: -\esyntax{\{include\_config\_file, Filename\}.} +\esyntax{include\_config\_file: [Filename]} It is possible to specify suboptions using the full syntax: -\esyntax{\{include\_config\_file, Filename, [Suboption, ...]\}.} +\esyntax{include\_config\_file: \{ Filename: [Suboption, ...] \}} The filename can be indicated either as an absolute path, or relative to the main \ejabberd{} configuration file. @@ -1817,37 +1998,51 @@ The file must exist and be readable. The allowed suboptions are: \begin{description} - \titem{\{disallow, [Optionname, ...]\}} Disallows the usage of those options in the included configuration file. + \titem{disallow: [Optionname, ...]} Disallows the usage of those options in the included configuration file. The options that match this criteria are not accepted. The default value is an empty list: \term{[]} - \titem{\{allow\_only, [Optionname, ...]\}} Allows only the usage of those options in the included configuration file. + \titem{allow\_only: [Optionname, ...]} Allows only the usage of those options in the included configuration file. The options that do not match this criteria are not accepted. The default value is: \term{all} \end{description} This is a basic example: \begin{verbatim} -{include_config_file, "/etc/ejabberd/additional.cfg"}. +include_config_file: "/etc/ejabberd/additional.yml" \end{verbatim} In this example, the included file is not allowed to contain a \term{listen} option. If such an option is present, the option will not be accepted. The file is in a subdirectory from where the main configuration file is. \begin{verbatim} -{include_config_file, "./example.org/additional_not_listen.cfg", [{disallow, [listen]}]}. +include_config_file: + "./example.org/additional_not_listen.yml": + disallow: [listen] \end{verbatim} -In this example, \term{ejabberd.cfg} defines some ACL and Access rules, +In this example, \term{ejabberd.yml} defines some ACL and Access rules, and later includes another file with additional rules: \begin{verbatim} -{acl, admin, {user, "admin", "localhost"}}. -{access, announce, [{allow, admin}]}. -{include_config_file, "/etc/ejabberd/acl_and_access.cfg", [{allow_only, [acl, access]}]}. +acl: + admin: + user: + - "admin": "localhost" +access: + announce: + admin: allow +include_config_file: + "/etc/ejabberd/acl_and_access.yml": + allow_only: + - acl + - access \end{verbatim} -and content of the file \term{acl\_and\_access.cfg} can be, for example: +and content of the file \term{acl\_and\_access.yml} can be, for example: \begin{verbatim} -{acl, admin, {user, "bob", "localhost"}}. -{acl, admin, {user, "jan", "localhost"}}. +acl: + admin: + user: + - "bob": "localhost" + - "jan": "localhost" \end{verbatim} @@ -1859,7 +2054,7 @@ it is possible to define a macro for a value and later use this macro when defining an option. A macro is defined with this syntax: -\esyntax{\{define\_macro, 'MACRO', Value\}.} +\esyntax{define\_macro: \{ 'MACRO': Value \}} The \term{MACRO} must be surrounded by single quotation marks, and all letters in uppercase; check the examples bellow. The \term{value} can be any valid arbitrary Erlang term. @@ -1875,65 +2070,53 @@ are defined in configuration files included before the usage. It isn't possible to use a macro in the definition of another macro. -There are two ways to use a macro: -\begin{description} - - \titem{'MACRO'} - You can put this instead of a value in an \ejabberd{} option, - and will be replaced with the \term{value} previously defined. - If the macro is not defined previously, - the program will crash and report an error. - - \titem{\{use\_macro, 'MACRO', Defaultvalue\}} - Use a macro even if it may not be defined. - If the macro is not defined previously, - the provided \term{defaultvalue} is used. - This usage behaves as if it were defined and used this way: -\begin{verbatim} -{define_macro, 'MACRO', Defaultvalue}. -'MACRO' -\end{verbatim} - -\end{description} - This example shows the basic usage of a macro: \begin{verbatim} -{define_macro, 'LOG_LEVEL_NUMBER', 5}. -{loglevel, 'LOG_LEVEL_NUMBER'}. +define_macro: + 'LOG_LEVEL_NUMBER': 5 +loglevel: 'LOG_LEVEL_NUMBER' \end{verbatim} -The resulting option interpreted by \ejabberd{} is: \term{\{loglevel, 5\}}. +The resulting option interpreted by \ejabberd{} is: \term{loglevel: 5}. This example shows that values can be any arbitrary Erlang term: \begin{verbatim} -{define_macro, 'USERBOB', {user, "bob", "localhost"}}. -{acl, admin, 'USERBOB'}. +define_macro: + 'USERBOB': + user: + - "bob": "localhost" +acl: + admin: 'USERBOB' +\end{verbatim} +The resulting option interpreted by \ejabberd{} is: +\begin{verbatim} +acl: + admin: + user: + - "bob": "localhost" \end{verbatim} -The resulting option interpreted by \ejabberd{} is: \term{\{acl, admin, \{user, "bob", "localhost"\}\}}. - This complex example: \begin{verbatim} -{define_macro, 'NUMBER_PORT_C2S', 5222}. -{define_macro, 'PORT_S2S_IN', {5269, ejabberd_s2s_in, []}}. -{listen, - [ - {'NUMBER_PORT_C2S', ejabberd_c2s, []}, - 'PORT_S2S_IN', - {{use_macro, 'NUMBER_PORT_HTTP', 5280}, ejabberd_http, []} - ] -}. +define_macro: + 'NUMBER_PORT_C2S': 5222 + 'NUMBER_PORT_HTTP': 5280 +listen: + - + port: 'NUMBER_PORT_C2S' + module: ejabberd_c2s + - + port: 'NUMBER_PORT_HTTP' + module: ejabberd_http \end{verbatim} produces this result after being interpreted: \begin{verbatim} -{listen, - [ - {5222, ejabberd_c2s, []}, - {5269, ejabberd_s2s_in, []}, - {5280, ejabberd_http, []} - ] -}. +listen: + - + port: 5222 + module: ejabberd_c2s + - + port: 5280 + module: ejabberd_http \end{verbatim} - - \makesection{database}{Database and LDAP Configuration} \ind{database} %TODO: this whole section is not yet 100% optimized @@ -1947,7 +2130,7 @@ different storage systems for modules, and so forth. The following databases are supported by \ejabberd{}: \begin{itemize} -\item \footahref{http://www.microsoft.com/sql/}{Microsoft SQL Server} +%%\item \footahref{http://www.microsoft.com/sql/}{Microsoft SQL Server} \item \footahref{http://www.erlang.org/doc/apps/mnesia/index.html}{Mnesia} \item \footahref{http://www.mysql.com/}{MySQL} \item \footahref{http://en.wikipedia.org/wiki/Open\_Database\_Connectivity}{Any ODBC compatible database} @@ -1965,372 +2148,72 @@ The following LDAP servers are tested with \ejabberd{}: \end{itemize} Important note about virtual hosting: -if you define several domains in ejabberd.cfg (see section \ref{hostnames}), +if you define several domains in ejabberd.yml (see section \ref{hostnames}), you probably want that each virtual host uses a different configuration of database, authentication and storage, so that usernames do not conflict and mix between different virtual hosts. For that purpose, the options described in the next sections must be set inside a \term{host\_config} for each vhost (see section \ref{virtualhost}). For example: \begin{verbatim} -{host_config, "public.example.org", [ - {odbc_server, {pgsql, "localhost", "database-public-example-org", "ejabberd", "password"}}, - {auth_method, [odbc]} -]}. +host_config: + "public.example.org": + odbc_type: pgsql + odbc_server: "localhost" + odbc_database: "database-public-example-org" + odbc_username: "ejabberd" + odbc_password: "password" + auth_method: [odbc] \end{verbatim} -\makesubsection{mysql}{MySQL} -\ind{MySQL}\ind{MySQL!schema} +\makesubsection{odbc}{ODBC}\ind{odbc} -There is a file \term{mysql.sql} in the directory \term{odbc}. -This file contains the \ejabberd{} schema for MySQL. At the end of the file -you can find information to update your database schema. - - -\makesubsubsection{compilemysql}{Driver Compilation} -\ind{MySQL!Driver Compilation} - -You can skip this step if you installed \ejabberd{} using a binary installer or -if the binary packages of \ejabberd{} you are using include support for ODBC. - -Use \term{--enable-mysql} configure option in order to build \ejabberd{} with -MySQL support: -\begin{verbatim} -./configure --enable-mysql && make install -\end{verbatim} - - -\makesubsubsection{mysqlcreatedb}{Create MySQL database} -\ind{MySQL!Create database} - -Before starting ejabberd, you need to create an ejabberd database in MySQL. -This assumes the MySQL server is already installed and you have root access to it. - -\begin{enumerate} -\item Create a new user 'ejabberd': -\begin{verbatim} -> mysql -h localhost -p -u root -S /tmp/mysql.sock -Enter password: -Welcome to the MySQL monitor. Commands end with ; or \g. -Your MySQL connection id is 2 to server version: 4.1.16-max - -Type 'help;' or '\h' for help. Type '\c' to clear the buffer. - -mysql> GRANT ALL ON ejabberd.* TO 'ejabberd'@'localhost'IDENTIFIED BY 'password'; -Query OK, 0 rows affected (0.00 sec) -\end{verbatim} - -\item Create a new database 'ejabberd': -\begin{verbatim} -> mysql -h localhost -p -u ejabberd -S /tmp/mysql.sock -Enter password: -Welcome to the MySQL monitor. Commands end with ; or \g. -Your MySQL connection id is 4 to server version: 4.1.16-max - -Type 'help;' or '\h' for help. Type '\c' to clear the buffer. - -mysql> CREATE DATABASE ejabberd; -Query OK, 1 row affected (0.00 sec) -\end{verbatim} - -\item Get the MySQL ejabberd schema file, usually called 'mysql.sql', -that you can find somewhere where ejabberd is installed. At the end -of the file you can find information to update your database schema. - -\item Import ejabberd database schema into the ejabberd database: -\begin{verbatim} -> mysql -D ejabberd -h localhost -p -u ejabberd -S /tmp/mysql.sock < mysql.sql -\end{verbatim} - -\item Check that the database structure has been correctly created: -\begin{verbatim} -> echo "show tables;" | mysql -D ejabberd -h localhost -p -u ejabberd -S /tmp/mysql.sock -Tables_in_ejabberd -last -privacy_default_list -privacy_list -privacy_list_data -private_storage -pubsub_item -pubsub_node -pubsub_node_option -pubsub_node_owner -pubsub_state -pubsub_subscription_opt -rostergroups -rosterusers -roster_version -spool -users -vcard -vcard_search -\end{verbatim} - -\end{enumerate} - - -\makesubsubsection{configuremysql}{Database Connection} -\ind{MySQL!Database Connection} - -The actual database access is defined in the option \term{odbc\_server}. Its -value is used to define if we want to use ODBC, or one of the two native +The actual database access is defined in the options with \term{odbc\_} prefix. The +values are used to define if we want to use ODBC, or one of the two native interface available, PostgreSQL or MySQL. -To use the native MySQL interface, you can pass a tuple of the following form as -parameter: -\esyntax{\{mysql, "Server", "Database", "Username", "Password"\}} +The following paramaters are available: +\begin{description} + \titem{odbc\_type: mysql | pgsql | odbc} The type of an ODBC connection. + The default is \term{odbc}. + \titem{odbc\_server: String} A hostname of the ODBC server. The default is + \term{``localhost''}. + \titem{odbc\_port: Port} The port where the ODBC server is accepting connections. + The option is only valid for \term{mysql} and \term{pgsql}. The default is + \term{3306} and \term{5432} respectively. + \titem{odbc\_database: String} The database name. The default is \term{``ejabberd''}. + The option is only valid for \term{mysql} and \term{pgsql}. + \titem{odbc\_username: String} The username. The default is \term{``ejabberd''}. + The option is only valid for \term{mysql} and \term{pgsql}. + \titem{odbc\_password: String} The password. The default is empty string. + The option is only valid for \term{mysql} and \term{pgsql}. + \titem{odbc\_pool\_size: N} By default \ejabberd{} opens 10 connections to + the database for each virtual host. You can change this number by using this option. + \titem{odbc\_keepalive\_interval: N} You can configure an interval to + make a dummy SQL request to keep alive the connections to the database. + The default value is 'undefined', so no keepalive requests are made. + Specify in seconds: for example 28800 means 8 hours. + \titem{odbc\_start\_interval: N} If the connection to the database fails, + \ejabberd{} waits 30 seconds before retrying. + You can modify this interval with this option. +\end{description} -\term{mysql} is a keyword that should be kept as is. For example: -\esyntax{\{odbc\_server, \{mysql, "localhost", "test", "root", "password"\}\}.} - -Optionally, it is possible to define the MySQL port to use. This -option is only useful, in very rare cases, when you are not running -MySQL with the default port setting. The \term{mysql} parameter -can thus take the following form: -\esyntax{\{mysql, "Server", Port, "Database", "Username", "Password"\}} - -The \term{Port} value should be an integer, without quotes. For example: -\esyntax{\{odbc\_server, \{mysql, "localhost", Port, "test", "root", "password"\}\}.} - -By default \ejabberd{} opens 10 connections to the database for each virtual host. -Use this option to modify the value: +Example of plain ODBC connection: \begin{verbatim} -{odbc_pool_size, 10}. +odbc_server: "DSN=database;UID=ejabberd;PWD=password" \end{verbatim} -You can configure an interval to make a dummy SQL request -to keep alive the connections to the database. -The default value is 'undefined', so no keepalive requests are made. -Specify in seconds: for example 28800 means 8 hours. +Example of MySQL connection: \begin{verbatim} -{odbc_keepalive_interval, undefined}. +odbc_type: mysql +odbc_server: "server.company.com" +odbc_port: 3306 # the default +odbc_database: "mydb" +odbc_username: "user1" +odbc_password: "**********" +odbc_pool_size: 5 \end{verbatim} -If the connection to the database fails, \ejabberd{} waits 30 seconds before retrying. -You can modify this interval with this option: -\begin{verbatim} -{odbc_start_interval, 30}. -\end{verbatim} - - -\makesubsubsection{mysqlauth}{Authentication} -\ind{MySQL!authentication} - -The option value name may be misleading, as the \term{auth\_method} name is used -for access to a relational database through ODBC, as well as through the native -MySQL interface. Anyway, the first configuration step is to define the odbc -\term{auth\_method}. For example: -\begin{verbatim} -{auth_method, [odbc]}. -\end{verbatim} - - -\makesubsubsection{mysqlstorage}{Storage} -\ind{MySQL!storage} - -MySQL also can be used to store information into from several \ejabberd{} -modules. See section~\ref{modoverview} to see which modules can be used with -relational databases like MySQL. To enable storage to your database, just make -sure that your database is running well (see previous sections), and add the -module option \term{\{db\_type, odbc\}}. - - -\makesubsection{mssql}{Microsoft SQL Server} -\ind{Microsoft SQL Server}\ind{Microsoft SQL Server!schema} - -There is a file \term{mssql.sql} in the directory \term{odbc}. -This file contains the \ejabberd{} schema for Microsoft SQL Server. At the end of the file -you can find information to update your database schema. - - -\makesubsubsection{compilemssql}{Driver Compilation} -\ind{Microsoft SQL Server!Driver Compilation} - -You can skip this step if you installed \ejabberd{} using a binary installer or -if the binary packages of \ejabberd{} you are using include support for ODBC. - -Use \term{--enable-mssql} configure option in order to build \ejabberd{} with -Microsoft SQL Server support: -\begin{verbatim} -./configure --enable-mssql && make install -\end{verbatim} - - -\makesubsubsection{configuremssql}{Database Connection} -\ind{Microsoft SQL Server!Database Connection} - -The configuration of Database Connection for a Microsoft SQL Server -is the same as the configuration for -ODBC compatible servers (see section~\ref{configureodbc}). - - -\begin{enumerate} -\item Install Microsoft SQL Server 2000. - -\item Open "SQL Server Enterprise Manager" to create and setup the database. Create a new database called 'ejabberd'. - -\item Use the "Query Analyzer" tool to run the database creation script. - -\item Create an ODBC datasource (from "Config Panel" -> "Data source (ODBC)"). The new ODBC datasource can be named ejabberd. - -\item Modify the config file to use your newly created MSSQL database: -The configuration of Authentication for a Microsoft SQL Server -is the same as the configuration for ODBC compatible servers (see section~\ref{odbcauth}). -\begin{verbatim} -% Comment Internal Authentication: -%{auth_method, internal}. -% Define ODBC authentication: -{auth_method, odbc}. -{odbc_server, "DSN=ejabberd;UID=sa;PWD=nimda"}. -Start ejabberd (from the "Start" menu, and from the console try creating a new user: -(ejabberd@home-68006dc09b)2> ejabberd_auth:try_register("admin", "localhost", "nimda"). -{atomic,ok} -\end{verbatim} - -\item Try connecting from a Jabber client, with your newly connected user. - -\item Check that the newly created user has been correctly added to your database using the MSSQL "Query Analyzer": -\begin{verbatim} -select * from [dbo].[users]; -\end{verbatim} - -\item Modify the config file to enable odbc storage in the modules you want. -See section~\ref{modoverview} to see which modules can be used with -relational databases like MySQL. To enable storage to your database, just make -sure that your database is running well (see previous sections), and add the -module option \term{\{db\_type, odbc\}}. - -\item Restart ejabberd -\end{enumerate} - - -\makesubsection{pgsql}{PostgreSQL} -\ind{PostgreSQL}\ind{PostgreSQL!schema} - -There is a file \term{pg.sql} in the directory \term{odbc}. -This file contains the \ejabberd{} schema for PostgreSQL. At the end of the file -you can find information to update your database schema. - - -\makesubsubsection{compilepgsql}{Driver Compilation} -\ind{PostgreSQL!Driver Compilation} - -You can skip this step if you installed \ejabberd{} using a binary installer or -if the binary packages of \ejabberd{} you are using include support for -PostgreSQL. - -Use \term{--enable-pgsql} configure option in order to build \ejabberd{} with -PostgreSQL support: -\begin{verbatim} -./configure --enable-pgsql && make install -\end{verbatim} - -\makesubsubsection{pgsqlcreatedb}{Create PostgreSQL database} -\ind{PgSQL!Create database} - -Before starting ejabberd, you need to create an ejabberd database in your PostgreSQL database. - - -\makesubsubsection{configurepgsql}{Database Connection} -\ind{PostgreSQL!Database Connection} - -The actual database access is defined in the option \term{odbc\_server}. Its -value is used to define if we want to use ODBC, or one of the two native -interface available, PostgreSQL or MySQL. - -To use the native PostgreSQL interface, you can pass a tuple of the following -form as parameter: -\esyntax{\{pgsql, "Server", "Database", "Username", "Password"\}} - -\term{pgsql} is a keyword that should be kept as is. For example: -\esyntax{\{odbc\_server, \{pgsql, "localhost", "database", "ejabberd", "password"\}\}.} - -Optionally, it is possible to define the PostgreSQL port to use. This -option is only useful, in very rare cases, when you are not running -PostgreSQL with the default port setting. The \term{pgsql} parameter -can thus take the following form: -\esyntax{\{pgsql, "Server", Port, "Database", "Username", "Password"\}} - -The \term{Port} value should be an integer, without quotes. For example: -\esyntax{\{odbc\_server, \{pgsql, "localhost", 5432, "database", "ejabberd", "password"\}\}.} - -By default \ejabberd{} opens 10 connections to the database for each virtual host. -Use this option to modify the value: -\begin{verbatim} -{odbc_pool_size, 10}. -\end{verbatim} - -You can configure an interval to make a dummy SQL request -to keep alive the connections to the database. -The default value is 'undefined', so no keepalive requests are made. -Specify in seconds: for example 28800 means 8 hours. -\begin{verbatim} -{odbc_keepalive_interval, undefined}. -\end{verbatim} - - -\makesubsubsection{pgsqlauth}{Authentication} -\ind{PostgreSQL!authentication} - -The option value name may be misleading, as the \term{auth\_method} name is used -for access to a relational database through ODBC, as well as through the native -PostgreSQL interface. Anyway, the first configuration step is to define the odbc -\term{auth\_method}. For example: -\begin{verbatim} -{auth_method, [odbc]}. -\end{verbatim} - - -\makesubsubsection{pgsqlstorage}{Storage} -\ind{PostgreSQL!storage} - -PostgreSQL also can be used to store information into from several \ejabberd{} -modules. See section~\ref{modoverview} to see which modules can be used with -relational databases like MySQL. To enable storage to your database, just make -sure that your database is running well (see previous sections), and add the -module option \term{\{db\_type, odbc\}}. - -\makesubsection{odbc}{ODBC Compatible} -\ind{databases!ODBC} - -\makesubsubsection{configureodbc}{Database Connection} -\ind{ODBC!Database Connection} - -The actual database access is defined in the option \term{odbc\_server}. Its -value is used to defined if we want to use ODBC, or one of the two native -interface available, PostgreSQL or MySQL. - -To use a relational database through ODBC, you can pass the ODBC connection -string as \term{odbc\_server} parameter. For example: -\begin{verbatim} -{odbc_server, "DSN=database;UID=ejabberd;PWD=password"}. -\end{verbatim} - -By default \ejabberd{} opens 10 connections to the database for each virtual host. -Use this option to modify the value: -\begin{verbatim} -{odbc_pool_size, 10}. -\end{verbatim} - -You can configure an interval to make a dummy SQL request -to keep alive the connections to the database. -The default value is 'undefined', so no keepalive requests are made. -Specify in seconds: for example 28800 means 8 hours. -\begin{verbatim} -{odbc_keepalive_interval, undefined}. -\end{verbatim} - - -\makesubsubsection{odbcauth}{Authentication} -\ind{ODBC!authentication} - -The first configuration step is to define the odbc \term{auth\_method}. For -example: -\begin{verbatim} -{auth_method, [odbc]}. -\end{verbatim} - - \makesubsubsection{odbcstorage}{Storage} \ind{ODBC!storage} @@ -2339,7 +2222,7 @@ several \ejabberd{} modules. See section~\ref{modoverview} to see which modules can be used with relational databases like MySQL. To enable storage to your database, just make sure that your database is running well (see previous sections), and add the -module option \term{\{db\_type, odbc\}}. +module option \term{db\_type: odbc}. \makesubsection{ldap}{LDAP} \ind{databases!LDAP} @@ -2362,47 +2245,48 @@ one for authentication and other for regular calls. Parameters: \begin{description} -\titem{\{ldap\_servers, [Servers, ...]\}} \ind{options!ldap\_server}List of IP addresses or DNS names of your +\titem{ldap\_servers: [Servers, ...]} \ind{options!ldap\_server}List of IP addresses or DNS names of your LDAP servers. This option is required. -\titem{\{ldap\_encrypt, none|tls\}} \ind{options!ldap\_encrypt}Type of connection encryption to the LDAP server. +\titem{ldap\_encrypt: none|tls} \ind{options!ldap\_encrypt}Type of connection encryption to the LDAP server. Allowed values are: \term{none}, \term{tls}. The value \term{tls} enables encryption by using LDAP over SSL. Note that STARTTLS encryption is not supported. The default value is: \term{none}. -\titem{\{ldap\_tls\_verify, false|soft|hard\}} \ind{options!ldap\_tls\_verify} +\titem{ldap\_tls\_verify: false|soft|hard} \ind{options!ldap\_tls\_verify} This option specifies whether to verify LDAP server certificate or not when TLS is enabled. When \term{hard} is enabled \ejabberd{} doesn't proceed if a certificate is invalid. When \term{soft} is enabled \ejabberd{} proceeds even if check fails. The default is \term{false} which means no checks are performed. -\titem{\{ldap\_tls\_cacertfile, Path\}} \ind{options!ldap\_tls\_cacertfile} +\titem{ldap\_tls\_cacertfile: Path} \ind{options!ldap\_tls\_cacertfile} Path to file containing PEM encoded CA certificates. This option is needed (and required) when TLS verification is enabled. -\titem{\{ldap\_tls\_depth, Number\}} \ind{options!ldap\_tls\_depth} +\titem{ldap\_tls\_depth: Number} \ind{options!ldap\_tls\_depth} Specifies the maximum verification depth when TLS verification is enabled, i.e. how far in a chain of certificates the verification process can proceed before the verification is considered to fail. Peer certificate = 0, CA certificate = 1, higher level CA certificate = 2, etc. The value 2 thus means that a chain can at most contain peer cert, CA cert, next CA cert, and an additional CA cert. The default value is 1. -\titem{\{ldap\_port, Number\}} \ind{options!ldap\_port}Port to connect to your LDAP server. +\titem{ldap\_port: Number} \ind{options!ldap\_port}Port to connect to your LDAP server. The default port is~389 if encryption is disabled; and 636 if encryption is enabled. If you configure a value, it is stored in \ejabberd{}'s database. Then, if you remove that value from the configuration file, the value previously stored in the database will be used instead of the default port. -\titem{\{ldap\_rootdn, RootDN\}} \ind{options!ldap\_rootdn}Bind DN. The default value +\titem{ldap\_rootdn: RootDN} \ind{options!ldap\_rootdn}Bind DN. The default value is~\term{""} which means `anonymous connection'. -\titem{\{ldap\_password, Password\}} \ind{options!ldap\_password}Bind password. The default +\titem{ldap\_password: Password} \ind{options!ldap\_password}Bind password. The default value is \term{""}. -\titem{\{ldap\_deref\_aliases, never|always|finding|searching\}} \ind{options!ldap\_deref\_aliases} Whether or not to dereference aliases. The default is \term{never}. +\titem{ldap\_deref\_aliases: never|always|finding|searching} \ind{options!ldap\_deref\_aliases} Whether or not to dereference aliases. The default is \term{never}. \end{description} Example: \begin{verbatim} -{auth_method, ldap}. -{ldap_servers, ["ldap.example.org"]}. -{ldap_port, 389}. -{ldap_rootdn, "cn=Manager,dc=domain,dc=org"}. -{ldap_password, "secret"}. +auth_method: [ldap] +ldap_servers: + - "ldap1.example.org" +ldap_port: 389 +ldap_rootdn: "cn=Manager,dc=domain,dc=org" +ldap_password: "**********" \end{verbatim} \makesubsubsection{ldapauth}{Authentication} @@ -2413,9 +2297,9 @@ Note that current LDAP implementation does not support SASL authentication. Available options are: \begin{description} -\titem{\{ldap\_base, Base\}}\ind{options!ldap\_base}LDAP base directory which stores +\titem{ldap\_base: Base}\ind{options!ldap\_base}LDAP base directory which stores users accounts. This option is required. - \titem{\{ldap\_uids, [ \{ldap\_uidattr\} | \{ldap\_uidattr, ldap\_uidattr\_format\}, ...]\}}\ind{options!ldap\_uids} + \titem{ldap\_uids: [ ldap\_uidattr | \{ldap\_uidattr: ldap\_uidattr\_format\} ]}\ind{options!ldap\_uids} LDAP attribute which holds a list of attributes to use as alternatives for getting the JID. The default attributes are \term{[\{"uid", "\%u"\}]}. The attributes are of the form: @@ -2432,7 +2316,7 @@ Available options are: user's part of a JID. For example, \term{"\%u@example.org"}. The default value is \term{"\%u"}. \end{description} - \titem{\{ldap\_filter, Filter\}}\ind{options!ldap\_filter}\ind{protocols!RFC 4515: + \titem{ldap\_filter: Filter}\ind{options!ldap\_filter}\ind{protocols!RFC 4515: LDAP String Representation of Search Filters} \footahref{http://tools.ietf.org/html/rfc4515}{RFC 4515} LDAP filter. The default Filter value is: \term{undefined}. Example: @@ -2440,7 +2324,7 @@ Available options are: not forget to close brackets and do not use superfluous whitespaces. Also you \emph{must not} use \option{ldap\_uidattr} attribute in filter because this attribute will be substituted in LDAP filter automatically. - \titem{\{ldap\_dn\_filter, \{ Filter, FilterAttrs \}\}}\ind{options!ldap\_dn\_filter} + \titem{ldap\_dn\_filter: \{ Filter: FilterAttrs \}}\ind{options!ldap\_dn\_filter} This filter is applied on the results returned by the main filter. This filter performs additional LDAP lookup to make the complete result. This is useful when you are unable to define all filter rules in \term{ldap\_filter}. You @@ -2452,7 +2336,8 @@ Available options are: \term{ldap\_dn\_filter} is undefined. Example: \begin{verbatim} -{ldap_dn_filter, {"(&(name=%s)(owner=%D)(user=%u@%d))", ["sn"]}}. +ldap_dn_filter: + "(&(name=%s)(owner=%D)(user=%u@%d))": ["sn"] \end{verbatim} Since this filter makes additional LDAP lookups, use it only in the last resort: try to define all filter rules in \term{ldap\_filter} if possible. @@ -2485,19 +2370,19 @@ and using the custom port 6123. Corresponding authentication section should looks like this: \begin{verbatim} -%% Authentication method -{auth_method, ldap}. -%% DNS name of our LDAP server -{ldap_servers, ["ldap.example.org"]}. -%% Bind to LDAP server as "cn=Manager,dc=example,dc=org" with password "secret" -{ldap_rootdn, "cn=Manager,dc=example,dc=org"}. -{ldap_password, "secret"}. -{ldap_encrypt, tls}. -{ldap_port, 6123}. -%% Define the user's base -{ldap_base, "ou=Users,dc=example,dc=org"}. -%% We want to authorize users from 'shadowAccount' object class only -{ldap_filter, "(objectClass=shadowAccount)"}. +## Authentication method +auth_method: [ldap] +## DNS name of our LDAP server +ldap_servers: ["ldap.example.org"] +## Bind to LDAP server as "cn=Manager,dc=example,dc=org" with password "secret" +ldap_rootdn: "cn=Manager,dc=example,dc=org" +ldap_password: "secret" +ldap_encrypt: tls +ldap_port: 6123 +## Define the user's base +ldap_base: "ou=Users,dc=example,dc=org" +## We want to authorize users from 'shadowAccount' object class only +ldap_filter: "(objectClass=shadowAccount)" \end{verbatim} Now we want to use users LDAP-info as their vCards. We have four attributes @@ -2506,48 +2391,45 @@ defined in our LDAP schema: \term{"mail"} --- email address, \term{"givenName"} Also we want users to search each other. Let's see how we can set it up: \begin{verbatim} -{modules, - [ +modules: ... - {mod_vcard_ldap, - [ - %% We use the same server and port, but want to bind anonymously because - %% our LDAP server accepts anonymous requests to - %% "ou=AddressBook,dc=example,dc=org" subtree. - {ldap_rootdn, ""}, - {ldap_password, ""}, - %% define the addressbook's base - {ldap_base, "ou=AddressBook,dc=example,dc=org"}, - %% uidattr: user's part of JID is located in the "mail" attribute - %% uidattr_format: common format for our emails - {ldap_uids, [{"mail", "%u@mail.example.org"}]}, - %% We have to define empty filter here, because entries in addressbook does not - %% belong to shadowAccount object class - {ldap_filter, ""}, - %% Now we want to define vCard pattern - {ldap_vcard_map, - [{"NICKNAME", "%u", []}, % just use user's part of JID as his nickname - {"GIVEN", "%s", ["givenName"]}, - {"FAMILY", "%s", ["sn"]}, - {"FN", "%s, %s", ["sn", "givenName"]}, % example: "Smith, John" - {"EMAIL", "%s", ["mail"]}, - {"BDAY", "%s", ["birthDay"]}]}, - %% Search form - {ldap_search_fields, - [{"User", "%u"}, - {"Name", "givenName"}, - {"Family Name", "sn"}, - {"Email", "mail"}, - {"Birthday", "birthDay"}]}, - %% vCard fields to be reported - %% Note that JID is always returned with search results - {ldap_search_reported, - [{"Full Name", "FN"}, - {"Nickname", "NICKNAME"}, - {"Birthday", "BDAY"}]} - ]}, + mod_vcard_ldap: + ## We use the same server and port, but want to bind anonymously because + ## our LDAP server accepts anonymous requests to + ## "ou=AddressBook,dc=example,dc=org" subtree. + ldap_rootdn: "" + ldap_password: "" + ## define the addressbook's base + ldap_base: "ou=AddressBook,dc=example,dc=org" + ## uidattr: user's part of JID is located in the "mail" attribute + ## uidattr_format: common format for our emails + ldap_uids: + "mail": "%u@mail.example.org" + ## We have to define empty filter here, because entries in addressbook does not + ## belong to shadowAccount object class + ldap_filter: "" + ## Now we want to define vCard pattern + ldap_vcard_map: + "NICKNAME": {"%u": []} # just use user's part of JID as his nickname + "GIVEN": {"%s": ["givenName"]} + "FAMILY": {"%s": ["sn"]} + "FN": {"%s, %s": ["sn", "givenName"]}, # example: "Smith, John" + "EMAIL": {"%s": ["mail"]} + "BDAY": {"%s": ["birthDay"]}]} + ## Search form + ldap_search_fields: + "User": "%u" + "Name": "givenName" + "Family Name": "sn" + "Email": "mail" + "Birthday": "birthDay" + ## vCard fields to be reported + ## Note that JID is always returned with search results + ldap_search_reported: + "Full Name": "FN" + "Nickname": "NICKNAME" + "Birthday": "BDAY" ... - ]}. \end{verbatim} Note that \modvcardldap{} module checks for the existence of the user before @@ -2561,53 +2443,50 @@ Active Directory is just an LDAP-server with predefined attributes. A sample configuration is shown below: \begin{verbatim} -{auth_method, ldap}. -{ldap_servers, ["office.org"]}. % List of LDAP servers -{ldap_base, "DC=office,DC=org"}. % Search base of LDAP directory -{ldap_rootdn, "CN=Administrator,CN=Users,DC=office,DC=org"}. % LDAP manager -{ldap_password, "*******"}. % Password to LDAP manager -{ldap_uids, [{"sAMAccountName"}]}. -{ldap_filter, "(memberOf=*)"}. +auth_method: [ldap] +ldap_servers: ["office.org"] # List of LDAP servers +ldap_base: "DC=office,DC=org" # Search base of LDAP directory +ldap_rootdn: "CN=Administrator,CN=Users,DC=office,DC=org" # LDAP manager +ldap_password: "*******" # Password to LDAP manager +ldap_uids: ["sAMAccountName"] +ldap_filter: "(memberOf=*)" -{modules, - [ +modules: ... - {mod_vcard_ldap, - [{ldap_vcard_map, - [{"NICKNAME", "%u", []}, - {"GIVEN", "%s", ["givenName"]}, - {"MIDDLE", "%s", ["initials"]}, - {"FAMILY", "%s", ["sn"]}, - {"FN", "%s", ["displayName"]}, - {"EMAIL", "%s", ["mail"]}, - {"ORGNAME", "%s", ["company"]}, - {"ORGUNIT", "%s", ["department"]}, - {"CTRY", "%s", ["c"]}, - {"LOCALITY", "%s", ["l"]}, - {"STREET", "%s", ["streetAddress"]}, - {"REGION", "%s", ["st"]}, - {"PCODE", "%s", ["postalCode"]}, - {"TITLE", "%s", ["title"]}, - {"URL", "%s", ["wWWHomePage"]}, - {"DESC", "%s", ["description"]}, - {"TEL", "%s", ["telephoneNumber"]}]}, - {ldap_search_fields, - [{"User", "%u"}, - {"Name", "givenName"}, - {"Family Name", "sn"}, - {"Email", "mail"}, - {"Company", "company"}, - {"Department", "department"}, - {"Role", "title"}, - {"Description", "description"}, - {"Phone", "telephoneNumber"}]}, - {ldap_search_reported, - [{"Full Name", "FN"}, - {"Nickname", "NICKNAME"}, - {"Email", "EMAIL"}]} - ]}, + mod_vcard_ldap: + ldap_vcard_map: + "NICKNAME": {"%u", []} + "GIVEN": {"%s", ["givenName"]} + "MIDDLE": {"%s", ["initials"]} + "FAMILY": {"%s", ["sn"]} + "FN": {"%s", ["displayName"]} + "EMAIL": {"%s", ["mail"]} + "ORGNAME": {"%s", ["company"]} + "ORGUNIT": {"%s", ["department"]} + "CTRY": {"%s", ["c"]} + "LOCALITY": {"%s", ["l"]} + "STREET": {"%s", ["streetAddress"]} + "REGION": {"%s", ["st"]} + "PCODE": {"%s", ["postalCode"]} + "TITLE": {"%s", ["title"]} + "URL": {"%s", ["wWWHomePage"]} + "DESC": {"%s", ["description"]} + "TEL": {"%s", ["telephoneNumber"]}]} + ldap_search_fields: + "User": "%u" + "Name": "givenName" + "Family Name": "sn" + "Email": "mail" + "Company": "company" + "Department": "department" + "Role": "title" + "Description": "description" + "Phone": "telephoneNumber" + ldap_search_reported: + "Full Name": "FN" + "Nickname": "NICKNAME" + "Email": "EMAIL" ... - ]}. \end{verbatim} @@ -2620,28 +2499,24 @@ element is the name of a module and the second is a list of options for that module. The syntax is: -\esyntax{\{modules, [ \{ModuleName, ModuleOptions\}, ...]\}.} +\esyntax{modules: \{ ModuleName: ModuleOptions \}} Examples: \begin{itemize} \item In this example only the module \modecho{} is loaded and no module options are specified between the square brackets: \begin{verbatim} -{modules, - [ - {mod_echo, []} - ]}. +modules: + mod_echo: {} \end{verbatim} \item In the second example the modules \modecho{}, \modtime{}, and \modversion{} are loaded without options. Remark that, besides the last entry, all entries end with a comma: \begin{verbatim} -{modules, - [ - {mod_echo, []}, - {mod_time, []}, - {mod_version, []} - ]}. +modules: + mod_echo: {} + mod_time: {} + mod_version: {} \end{verbatim} \end{itemize} @@ -2725,7 +2600,7 @@ to this server or to a user (e.\,g.\ to \jid{example.org} or to these queries. The syntax is: -\esyntax{\{iqdisc, Value\}} +\esyntax{iqdisc: Value} Possible \term{Value} are: \begin{description} @@ -2738,7 +2613,7 @@ Possible \term{Value} are: of IQ queries of a namespace with this discipline. In addition, the processing of this queue is done in parallel with that of other packets. This discipline is most recommended. -\titem{\{queues, N\}} N separate queues are created to process the +\titem{N} N separate queues are created to process the queries. The queries are thus processed in parallel, but in a controlled way. \titem{parallel} For every packet with this discipline a separate Erlang process @@ -2750,12 +2625,11 @@ Possible \term{Value} are: Example: \begin{verbatim} -{modules, - [ +modules: ... - {mod_time, [{iqdisc, no_queue}]}, + mod_time: + iqdisc: no_queue ... - ]}. \end{verbatim} \makesubsubsection{modhostoption}{\option{host}} @@ -2764,7 +2638,7 @@ Example: This option defines the Jabber ID of a service provided by an \ejabberd{} module. The syntax is: -\esyntax{\{host, HostName\}} +\esyntax{host: HostName} If you include the keyword "@HOST@" in the HostName, it is replaced at start time with the real virtual host string. @@ -2773,23 +2647,21 @@ This example configures the \ind{modules!\modecho{}}echo module to provide its echoing service in the Jabber ID \jid{mirror.example.org}: \begin{verbatim} -{modules, - [ +modules: ... - {mod_echo, [{host, "mirror.example.org"}]}, + mod_echo: + host: "mirror.example.org" ... - ]}. \end{verbatim} However, if there are several virtual hosts and this module is enabled in all of them, the "@HOST@" keyword must be used: \begin{verbatim} -{modules, - [ +modules: ... - {mod_echo, [{host, "mirror.@HOST@"}]}, + mod_echo: + host: "mirror.@HOST@" ... - ]}. \end{verbatim} \makesubsection{modannounce}{\modannounce{}} @@ -2832,7 +2704,7 @@ hosts in ejabberd. Options: \begin{description} \dbtype -\titem{\{access, AccessName\}} \ind{options!access}This option specifies who is allowed to +\titem{access: AccessName} \ind{options!access}This option specifies who is allowed to send announcements and to set the message of the day (by default, nobody is able to send such messages). \end{description} @@ -2841,32 +2713,38 @@ Examples: \begin{itemize} \item Only administrators can send announcements: \begin{verbatim} -{access, announce, [{allow, admin}]}. +access: + announce: + admin: allow -{modules, - [ +modules: ... - {mod_adhoc, []}, - {mod_announce, [{access, announce}]}, + mod_adhoc: {} + mod_announce: + access: announce ... - ]}. \end{verbatim} \item Administrators as well as the direction can send announcements: \begin{verbatim} -{acl, direction, {user, "big_boss", "example.org"}}. -{acl, direction, {user, "assistant", "example.org"}}. -{acl, admin, {user, "admin", "example.org"}}. +acl: + direction: + user: + "big_boss": "example.org" + "assistant": "example.org" + admin: + user: + "admin": "example.org" +access: + announce: + admin: allow + direction: allow -{access, announce, [{allow, admin}, - {allow, direction}]}. - -{modules, - [ +modules: ... - {mod_adhoc, []}, - {mod_announce, [{access, announce}]}, + mod_adhoc: {} + mod_announce: + access: announce ... - ]}. \end{verbatim} \end{itemize} @@ -2893,72 +2771,80 @@ Options: \begin{description} \iqdiscitem{Service Discovery (\ns{http://jabber.org/protocol/disco\#items} and \ns{http://jabber.org/protocol/disco\#info})} -\titem{\{extra\_domains, [Domain, ...]\}} \ind{options!extra\_domains}With this option, +\titem{extra\_domains: [Domain, ...]} \ind{options!extra\_domains}With this option, you can specify a list of extra domains that are added to the Service Discovery item list. -\titem{\{server\_info, [ \{Modules, Field, [Value, ...]\}, ... ]\}} \ind{options!server\_info} +\titem{server\_info: [ \{ modules: Modules, name: Name, urls: [URL, ...] \} ]} \ind{options!server\_info} Specify additional information about the server, as described in Contact Addresses for XMPP Services (\xepref{0157}). \term{Modules} can be the keyword `all', in which case the information is reported in all the services; or a list of \ejabberd{} modules, in which case the information is only specified for the services provided by those modules. - Any arbitrary \term{Field} and \term{Value} can be specified, not only contact addresses. + Any arbitrary \term{Name} and \term{URL} can be specified, not only contact addresses. \end{description} Examples: \begin{itemize} \item To serve a link to the Jabber User Directory on \jid{jabber.org}: \begin{verbatim} -{modules, - [ +modules: ... - {mod_disco, [{extra_domains, ["users.jabber.org"]}]}, + mod_disco: + extra_domains: ["users.jabber.org"] ... - ]}. \end{verbatim} \item To serve a link to the transports on another server: \begin{verbatim} -{modules, - [ +modules: ... - {mod_disco, [{extra_domains, ["icq.example.com", - "msn.example.com"]}]}, + mod_disco: + extra_domains: + - "icq.example.com" + - "msn.example.com" ... - ]}. \end{verbatim} \item To serve a link to a few friendly servers: \begin{verbatim} -{modules, - [ +modules: ... - {mod_disco, [{extra_domains, ["example.org", - "example.com"]}]}, + mod_disco: + extra_domains: + - "example.org" + - "example.com" ... - ]}. \end{verbatim} \item With this configuration, all services show abuse addresses, feedback address on the main server, and admin addresses for both the main server and the vJUD service: \begin{verbatim} -{modules, - [ +modules: ... - {mod_disco, [{server_info, [ - {all, - "abuse-addresses", - ["mailto:abuse@shakespeare.lit"]}, - {[mod_muc], - "Web chatroom logs", - ["http://www.example.org/muc-logs"]}, - {[mod_disco], - "feedback-addresses", - ["http://shakespeare.lit/feedback.php", "mailto:feedback@shakespeare.lit", "xmpp:feedback@shakespeare.lit"]}, - {[mod_disco, mod_vcard], - "admin-addresses", - ["mailto:xmpp@shakespeare.lit", "xmpp:admins@shakespeare.lit"]} - ]}]}, + mod_disco: + server_info: + - + modules: all + name: "abuse-addresses" + urls: ["mailto:abuse@shakespeare.lit"] + - + modules: [mod_muc] + name: "Web chatroom logs" + urls: ["http://www.example.org/muc-logs"] + - + modules: [mod_disco] + name: "feedback-addresses" + urls: + - "http://shakespeare.lit/feedback.php" + - "mailto:feedback@shakespeare.lit" + - "xmpp:feedback@shakespeare.lit" + - + modules: + - mod_disco + - mod_vcard + name: "admin-addresses" + urls: + - "mailto:xmpp@shakespeare.lit" + - "xmpp:admins@shakespeare.lit" ... - ]}. \end{verbatim} \end{itemize} @@ -2977,12 +2863,11 @@ Options: Example: Mirror, mirror, on the wall, who is the most beautiful of them all? \begin{verbatim} -{modules, - [ +modules: ... - {mod_echo, [{host, "mirror.example.org"}]}, + mod_echo: + host: "mirror.example.org" ... - ]}. \end{verbatim} \makesubsection{modhttpbind}{\modhttpbind{}} @@ -2995,26 +2880,22 @@ resource at which this service will be hosted. To use HTTP-Binding, enable the module: \begin{verbatim} -{modules, - [ +modules: ... - {mod_http_bind, []}, + mod_http_bind: {} ... -]}. \end{verbatim} and add \verb|http_bind| in the HTTP service. For example: \begin{verbatim} -{listen, - [ +listen: ... - {5280, ejabberd_http, [ - http_bind, - http_poll, - web_admin - ] - }, + - + port: 5280 + module: ejabberd_http + http_bind: true + http_poll: true + web_admin: true ... -]}. \end{verbatim} With this configuration, the module will serve the requests sent to \verb|http://example.org:5280/http-bind/| @@ -3025,17 +2906,16 @@ If you want to set the service in a different URI path or use a different module you can configure it manually using the option \verb|request_handlers|. For example: \begin{verbatim} -{listen, - [ +listen: ... - {5280, ejabberd_http, [ - {request_handlers, [{["http-bind"], mod_http_bind}]}, - http_poll, - web_admin - ] - }, + - + port: 5280 + module: ejabberd_http + request_handlers: + "/http-bind": mod_http_bind + http_poll: true + web_admin: true ... -]}. \end{verbatim} Options: @@ -3045,12 +2925,11 @@ Options: Default value is 30 seconds. For example, to set 50 seconds: \begin{verbatim} -{modules, - [ +modules: ... - {mod_http_bind, [ {max_inactivity, 50} ]}, + mod_http_bind: + max_inactivity: 50 ... -]}. \end{verbatim} \end{description} @@ -3062,25 +2941,25 @@ This simple module serves files from the local disk over HTTP. Options: \begin{description} - \titem{\{docroot, Path\}} \ind{options!docroot} + \titem{docroot: Path} \ind{options!docroot} Directory to serve the files. - \titem{\{accesslog, Path\}} \ind{options!accesslog} + \titem{accesslog: Path} \ind{options!accesslog} File to log accesses using an Apache-like format. No log will be recorded if this option is not specified. - \titem{\{directory\_indices, [Index, ...]\}} \ind{options!directoryindices} + \titem{directory\_indices: [Index, ...]} \ind{options!directoryindices} Indicate one or more directory index files, similarly to Apache's DirectoryIndex variable. When a web request hits a directory instead of a regular file, those directory indices are looked in order, and the first one found is returned. - \titem{\{custom\_headers, [ \{Name, Value\}, ...]\}} \ind{options!customheaders} + \titem{custom\_headers: \{Name: Value\}} \ind{options!customheaders} Indicate custom HTTP headers to be included in all responses. Default value is: \term{[]} - \titem{\{content\_types, [ \{Name, Type\}, ...]\}} \ind{options!contenttypes} + \titem{content\_types: \{Name: Type\}} \ind{options!contenttypes} Specify mappings of extension to content type. There are several content types already defined, with this option you can add new definitions, modify or delete existing ones. To delete an existing definition, simply define it with a value: `undefined'. - \titem{\{default\_content\_type, Type\}} \ind{options!defaultcontenttype} + \titem{default\_content\_type: Type} \ind{options!defaultcontenttype} Specify the content type to use for unknown extensions. Default value is `application/octet-stream'. \end{description} @@ -3092,44 +2971,36 @@ In this example a new content type \term{ogg} is defined, \term{png} is redefined, and \term{jpg} definition is deleted. To use this module you must enable it: \begin{verbatim} -{modules, - [ +modules: ... - {mod_http_fileserver, [ - {docroot, "/var/www"}, - {accesslog, "/var/log/ejabberd/access.log"}, - {directory_indices, ["index.html", "main.htm"]}, - {custom_headers, [{"X-Powered-By", "Erlang/OTP"}, - {"X-Fry", "It's a widely-believed fact!"} - ]}, - {content_types, [{".ogg", "audio/ogg"}, - {".png", "image/png"}, - {".jpg", undefined} - ]}, - {default_content_type, "text/html"} - ] - }, + mod_http_fileserver: + docroot: "/var/www" + accesslog: "/var/log/ejabberd/access.log" + directory_indices: + - "index.html" + - "main.htm" + custom_headers: + "X-Powered-By": "Erlang/OTP" + "X-Fry": "It's a widely-believed fact!" + content_types: + ".ogg": "audio/ogg" + ".png": "image/png" + ".jpg": undefined + default_content_type: "text/html" ... -]}. \end{verbatim} And define it as a handler in the HTTP service: \begin{verbatim} -{listen, - [ +listen: ... - {5280, ejabberd_http, [ - ... - {request_handlers, [ - ... - {["pub", "archive"], mod_http_fileserver}, - ... - ] - }, - ... - ] - }, + - + port: 5280 + module: ejabberd_http + request_handlers: + ... + "/pub/archive": mod_http_fileserver + ... ... -]}. \end{verbatim} \makesubsection{modirc}{\modirc{}} @@ -3163,9 +3034,9 @@ Options: \begin{description} \hostitem{irc} \dbtype -\titem{\{access, AccessName\}} \ind{options!access}This option can be used to specify who +\titem{access: AccessName} \ind{options!access}This option can be used to specify who may use the IRC transport (default value: \term{all}). -\titem{\{default\_encoding, Encoding\}} \ind{options!defaultencoding}Set the default IRC encoding. +\titem{default\_encoding: Encoding} \ind{options!defaultencoding}Set the default IRC encoding. Default value: \term{"iso8859-1"} \end{description} @@ -3175,30 +3046,35 @@ Examples: virtual host(s) with the prefix `\jid{irc.}'. Furthermore, anyone is able to use the transport. The default encoding is set to "iso8859-15". \begin{verbatim} -{modules, - [ +modules: ... - {mod_irc, [{access, all}, {default_encoding, "iso8859-15"}]}, + mod_irc: + access: all + default_encoding: "iso8859-15" ... - ]}. \end{verbatim} \item In next example the IRC transport is available with JIDs with prefix \jid{irc-t.net}. Moreover, the transport is only accessible to two users of \term{example.org}, and any user of \term{example.com}: \begin{verbatim} -{acl, paying_customers, {user, "customer1", "example.org"}}. -{acl, paying_customers, {user, "customer2", "example.org"}}. -{acl, paying_customers, {server, "example.com"}}. +acl: + paying_customers: + user: + - "customer1": "example.org" + - "customer2": "example.org" + server: "example.com" -{access, irc_users, [{allow, paying_customers}, {deny, all}]}. +access: + irc_users: + paying_customers: allow + all: deny -{modules, - [ +modules: ... - {mod_irc, [{access, irc_users}, - {host, "irc.example.net"}]}, + mod_irc: + access: irc_users + host: "irc.example.net" ... - ]}. \end{verbatim} \end{itemize} @@ -3249,15 +3125,15 @@ Module options: \begin{description} \hostitem{conference} \dbtype -\titem{\{access, AccessName\}} \ind{options!access}You can specify who is allowed to use +\titem{access: AccessName} \ind{options!access}You can specify who is allowed to use the Multi-User Chat service. By default everyone is allowed to use it. -\titem{\{access\_create, AccessName\}} \ind{options!access\_create}To configure who is +\titem{access\_create: AccessName} \ind{options!access\_create}To configure who is allowed to create new rooms at the Multi-User Chat service, this option can be used. By default any account in the local ejabberd server is allowed to create rooms. -\titem{\{access\_persistent, AccessName\}} \ind{options!access\_persistent}To configure who is +\titem{access\_persistent: AccessName} \ind{options!access\_persistent}To configure who is allowed to modify the 'persistent' room option. By default any account in the local ejabberd server is allowed to modify that option. -\titem{\{access\_admin, AccessName\}} \ind{options!access\_admin}This option specifies +\titem{access\_admin: AccessName} \ind{options!access\_admin}This option specifies who is allowed to administrate the Multi-User Chat service. The default value is \term{none}, which means that only the room creator can administer his room. @@ -3265,7 +3141,7 @@ Module options: and it will be shown in all active rooms as a service message. The administrators can send a groupchat message to the JID of an active room, and the message will be shown in the room as a service message. -\titem{\{history\_size, Size\}} \ind{options!history\_size}A small history of +\titem{history\_size: Size} \ind{options!history\_size}A small history of the current discussion is sent to users when they enter the room. With this option you can define the number of history messages to keep and send to users joining the room. The value is an @@ -3273,35 +3149,35 @@ Module options: and, as a result, nothing is kept in memory. The default value is \term{20}. This value is global and thus affects all rooms on the service. -\titem{\{max\_users, Number\}} \ind{options!max\_users} This option defines at +\titem{max\_users: Number} \ind{options!max\_users} This option defines at the service level, the maximum number of users allowed per room. It can be lowered in each room configuration but cannot be increased in individual room configuration. The default value is 200. -\titem{\{max\_users\_admin\_threshold, Number\}} +\titem{max\_users\_admin\_threshold: Number} \ind{options!max\_users\_admin\_threshold} This option defines the number of service admins or room owners allowed to enter the room when the maximum number of allowed occupants was reached. The default limit is 5. -\titem{\{max\_user\_conferences, Number\}} +\titem{max\_user\_conferences: Number} \ind{options!max\_user\_conferences} This option defines the maximum number of rooms that any given user can join. The default value is 10. This option is used to prevent possible abuses. Note that this is a soft limit: some users can sometimes join more conferences in cluster configurations. -\titem{\{max\_room\_id, Number\}} \ind{options!max\_room\_id} +\titem{max\_room\_id: Number} \ind{options!max\_room\_id} This option defines the maximum number of characters that Room ID can have when creating a new room. The default value is to not limit: infinite. -\titem{\{max\_room\_name, Number\}} \ind{options!max\_room\_name} +\titem{max\_room\_name: Number} \ind{options!max\_room\_name} This option defines the maximum number of characters that Room Name can have when configuring the room. The default value is to not limit: infinite. -\titem{\{max\_room\_desc, Number\}} \ind{options!max\_room\_desc} +\titem{max\_room\_desc: Number} \ind{options!max\_room\_desc} This option defines the maximum number of characters that Room Description can have when configuring the room. The default value is to not limit: infinite. -\titem{\{min\_message\_interval, Number\}} \ind{options!min\_message\_interval} +\titem{min\_message\_interval: Number} \ind{options!min\_message\_interval} This option defines the minimum interval between two messages send by an occupant in seconds. This option is global and valid for all rooms. A decimal value can be used. When this option is not defined, @@ -3311,7 +3187,7 @@ Module options: interval is 0.4 second. If an occupant tries to send messages faster, an error is send back explaining that the message has been discarded and describing the reason why the message is not acceptable. -\titem{\{min\_presence\_interval, Number\}} +\titem{min\_presence\_interval: Number} \ind{options!min\_presence\_interval} This option defines the minimum of time between presence changes coming from a given occupant in seconds. This option is global and valid for all rooms. A @@ -3323,41 +3199,41 @@ Module options: broadcasted to all occupants in the room after expiration of the interval delay. Intermediate presence packets are silently discarded. A good value for this option is 4 seconds. -\titem{\{default\_room\_options, [ \{OptionName, OptionValue\}, ...]\}} \ind{options!default\_room\_options} +\titem{default\_room\_options: \{OptionName: OptionValue\}} \ind{options!default\_room\_options} This module option allows to define the desired default room options. Note that the creator of a room can modify the options of his room at any time using an XMPP client with MUC capability. The available room options and the default values are: \begin{description} - \titem{\{allow\_change\_subj, true|false\}} Allow occupants to change the subject. - \titem{\{allow\_private\_messages, true|false\}} Occupants can send private messages to other occupants. - \titem{\{allow\_private\_messages\_from\_visitors, anyone|moderators|nobody\}} Visitors can send private messages to other occupants. - \titem{\{allow\_query\_users, true|false\}} Occupants can send IQ queries to other occupants. - \titem{\{allow\_user\_invites, false|true\}} Allow occupants to send invitations. - \titem{\{allow\_visitor\_nickchange, true|false\}} Allow visitors to + \titem{allow\_change\_subj: true|false} Allow occupants to change the subject. + \titem{allow\_private\_messages: true|false} Occupants can send private messages to other occupants. + \titem{allow\_private\_messages\_from\_visitors: anyone|moderators|nobody} Visitors can send private messages to other occupants. + \titem{allow\_query\_users: true|false} Occupants can send IQ queries to other occupants. + \titem{allow\_user\_invites: false|true} Allow occupants to send invitations. + \titem{allow\_visitor\_nickchange: true|false} Allow visitors to change nickname. - \titem{\{allow\_visitor\_status, true|false\}} Allow visitors to send + \titem{allow\_visitor\_status: true|false} Allow visitors to send status text in presence updates. If disallowed, the \term{status} text is stripped before broadcasting the presence update to all the room occupants. - \titem{\{anonymous, true|false\}} The room is anonymous: + \titem{anonymous: true|false} The room is anonymous: occupants don't see the real JIDs of other occupants. Note that the room moderators can always see the real JIDs of the occupants. - \titem{\{captcha\_protected, false\}} + \titem{captcha\_protected: false} When a user tries to join a room where he has no affiliation (not owner, admin or member), the room requires him to fill a CAPTCHA challenge (see section \ref{captcha}) in order to accept her join in the room. - \titem{\{logging, false|true\}} The public messages are logged using \term{mod\_muc\_log}. - \titem{\{max\_users, 200\}} Maximum number of occupants in the room. - \titem{\{members\_by\_default, true|false\}} The occupants that enter the room are participants by default, so they have 'voice'. - \titem{\{members\_only, false|true\}} Only members of the room can enter. - \titem{\{moderated, true|false\}} Only occupants with 'voice' can send public messages. - \titem{\{password, "roompass123"\}} Password of the room. You may want to enable the next option too. - \titem{\{password\_protected, false|true\}} The password is required to enter the room. - \titem{\{persistent, false|true\}} The room persists even if the last participant leaves. - \titem{\{public, true|false\}} The room is public in the list of the MUC service, so it can be discovered. - \titem{\{public\_list, true|false\}} The list of participants is public, without requiring to enter the room. - \titem{\{title, "Room Title"\}} A human-readable title of the room. + \titem{logging: false|true} The public messages are logged using \term{mod\_muc\_log}. + \titem{max\_users: 200} Maximum number of occupants in the room. + \titem{members\_by\_default: true|false} The occupants that enter the room are participants by default, so they have 'voice'. + \titem{members\_only: false|true} Only members of the room can enter. + \titem{moderated: true|false} Only occupants with 'voice' can send public messages. + \titem{password: "roompass123"} Password of the room. You may want to enable the next option too. + \titem{password\_protected: false|true} The password is required to enter the room. + \titem{persistent: false|true} The room persists even if the last participant leaves. + \titem{public: true|false} The room is public in the list of the MUC service, so it can be discovered. + \titem{public\_list: true|false} The list of participants is public, without requiring to enter the room. + \titem{title: "Room Title"} A human-readable title of the room. \end{description} All of those room options can be set to \term{true} or \term{false}, except \term{password} and \term{title} which are strings, @@ -3376,19 +3252,23 @@ Examples: it will be displayed in all active rooms. In this example the history feature is disabled. \begin{verbatim} -{acl, admin, {user, "admin", "example.org"}}. +acl: + admin: + user: + - "admin": "example.org" -{access, muc_admin, [{allow, admin}]}. +access: + muc_admin: + admin: allow -{modules, - [ +modules: ... - {mod_muc, [{access, all}, - {access_create, all}, - {access_admin, muc_admin}, - {history_size, 0}]}, + mod_muc: + access: all + access_create: all + access_admin: muc_admin + history_size: 0 ... - ]}. \end{verbatim} \item In the second example the Multi-User Chat service is only accessible by paying customers registered on our domains and on other servers. Of course @@ -3401,25 +3281,32 @@ Examples: \term{history\_size} option is used, this means that the feature is enabled and the default value of 20 history messages will be send to the users. \begin{verbatim} -{acl, paying_customers, {user, "customer1", "example.net"}}. -{acl, paying_customers, {user, "customer2", "example.com"}}. -{acl, paying_customers, {user, "customer3", "example.org"}}. -{acl, admin, {user, "admin", "example.org"}}. +acl: + paying_customers: + user: + - "customer1": "example.net" + - "customer2": "example.com" + - "customer3": "example.org" + admin: + user: + - "admin": "example.org" -{access, muc_admin, [{allow, admin}, - {deny, all}]}. -{access, muc_access, [{allow, paying_customers}, - {allow, admin}, - {deny, all}]}. +access: + muc_admin + admin: allow + all: deny + muc_access: + paying_customers: allow + admin: allow + all: deny -{modules, - [ +modules: ... - {mod_muc, [{access, muc_access}, - {access_create, muc_admin}, - {access_admin, muc_admin}]}, + mod_muc: + access: muc_access + access_create: muc_admin + access_admin: muc_admin ... - ]}. \end{verbatim} \item In the following example, MUC anti abuse options are used. An @@ -3430,38 +3317,34 @@ and Room Description to 300 characters. No ACLs are defined, but some user restriction could be added as well: \begin{verbatim} -{modules, - [ +modules: ... - {mod_muc, [{min_message_interval, 0.4}, - {min_presence_interval, 4}, - {max_room_id, 20}, - {max_room_name, 20}, - {max_room_desc, 300}]}, + mod_muc: + min_message_interval: 0.4 + min_presence_interval: 4 + max_room_id: 20 + max_room_name: 20 + max_room_desc: 300 ... - ]}. \end{verbatim} \item This example shows how to use \option{default\_room\_options} to make sure the newly created rooms have by default those options. \begin{verbatim} -{modules, - [ +modules: ... - {mod_muc, [{access, muc_access}, - {access_create, muc_admin}, - {default_room_options, - [ - {allow_change_subj, false}, - {allow_query_users, true}, - {allow_private_messages, true}, - {members_by_default, false}, - {title, "New chatroom"}, - {anonymous, false} - ]}, - {access_admin, muc_admin}]}, + mod_muc: + access: muc_access + access_create: muc_admin + default_room_options: + allow_change_subj: false + allow_query_users: true + allow_private_messages: true + members_by_default: false + title: "New chatroom" + anonymous: false + access_admin: muc_admin ... - ]}. \end{verbatim} \end{itemize} @@ -3494,54 +3377,54 @@ Features: Options: \begin{description} -\titem{\{access\_log, AccessName\}}\ind{options!access\_log} +\titem{access\_log: AccessName}\ind{options!access\_log} This option restricts which occupants are allowed to enable or disable room logging. The default value is \term{muc\_admin}. Note for this default setting you need to have an access rule for \term{muc\_admin} in order to take effect. -\titem{\{cssfile, false|URL\}}\ind{options!cssfile} +\titem{cssfile: false|URL}\ind{options!cssfile} With this option you can set whether the HTML files should have a custom CSS file or if they need to use the embedded CSS file. Allowed values are \term{false} and an URL to a CSS file. With the first value, HTML files will include the embedded CSS code. With the latter, you can specify the URL of the custom CSS file (for example: \term{"http://example.com/my.css"}). The default value is \term{false}. -\titem{\{dirname, room\_jid|room\_name\}}\ind{options!dirname} +\titem{dirname: room\_jid|room\_name}\ind{options!dirname} Allows to configure the name of the room directory. Allowed values are \term{room\_jid} and \term{room\_name}. With the first value, the room directory name will be the full room JID. With the latter, the room directory name will be only the room name, not including the MUC service name. The default value is \term{room\_jid}. -\titem{\{dirtype, subdirs|plain\}}\ind{options!dirtype} +\titem{dirtype: subdirs|plain}\ind{options!dirtype} The type of the created directories can be specified with this option. Allowed values are \term{subdirs} and \term{plain}. With the first value, subdirectories are created for each year and month. With the latter, the names of the log files contain the full date, and there are no subdirectories. The default value is \term{subdirs}. -\titem{\{file\_format, html|plaintext\}}\ind{options!file\_format} +\titem{file\_format: html|plaintext}\ind{options!file\_format} Define the format of the log files: \term{html} stores in HTML format, \term{plaintext} stores in plain text. The default value is \term{html}. -\titem{\{file\_permissions, \{Mode, Group\}\}}\ind{options!file\_permissions} +\titem{file\_permissions: \{mode: Mode, group: Group\}}\ind{options!file\_permissions} Define the permissions that must be used when creating the log files: the number of the mode, and the numeric id of the group that will own the files. The default value is \term{\{644, 33\}}. -\titem{\{outdir, Path\}}\ind{options!outdir} +\titem{outdir: Path}\ind{options!outdir} This option sets the full path to the directory in which the HTML files should be stored. Make sure the \ejabberd{} daemon user has write access on that directory. The default value is \term{"www/muc"}. -\titem{\{spam\_prevention true|false\}}\ind{options!spam\_prevention} +\titem{spam\_prevention: true|false}\ind{options!spam\_prevention} To prevent spam, the \term{spam\_prevention} option adds a special attribute to links that prevent their indexation by search engines. The default value is \term{true}, which mean that nofollow attributes will be added to user submitted links. -\titem{\{timezone, local|universal\}}\ind{options!timezone} +\titem{timezone: local|universal}\ind{options!timezone} The time zone for the logs is configurable with this option. Allowed values are \term{local} and \term{universal}. With the first value, the local time, as reported to Erlang by the operating system, will be used. With the latter, GMT/UTC time will be used. The default value is \term{local}. -\titem{\{top\_link, \{URL, Text\}\}}\ind{options!top\_link} +\titem{top\_link: \{URL: Text\}}\ind{options!top\_link} With this option you can customize the link on the top right corner of each log file. The default value is \term{\{"/", "Home"\}}. \end{description} @@ -3555,23 +3438,23 @@ Examples: time zone will be GMT/UTC. Finally, the top link will be \verb|Jabber.ru|. \begin{verbatim} -{access, muc, [{allow, all}]}. +access: + muc: + all: allow -{modules, - [ +modules: ... - {mod_muc_log, [ - {access_log, muc}, - {cssfile, "http://example.com/my.css"}, - {dirtype, plain}, - {dirname, room_jid}, - {outdir, "/var/www/muclogs"}, - {timezone, universal}, - {spam_prevention, true}, - {top_link, {"http://www.jabber.ru/", "Jabber.ru"}} - ]}, + mod_muc_log: + access_log: muc + cssfile: "http://example.com/my.css" + dirtype: plain + dirname: room_jid + outdir: "/var/www/muclogs" + timezone: universal + spam_prevention: true + top_link: + "http://www.jabber.ru/": "Jabber.ru" ... - ]}. \end{verbatim} \item In the second example only \jid{admin1@example.org} and \jid{admin2@example.net} can enable logging, and the embedded CSS file will be @@ -3580,26 +3463,28 @@ Examples: be stored in /var/www/muclogs, and the local time will be used. Finally, the top link will be the default \verb|Home|. \begin{verbatim} -{acl, admin, {user, "admin1", "example.org"}}. -{acl, admin, {user, "admin2", "example.net"}}. +acl: + admin: + user: + - "admin1": "example.org" + - "admin2": "example.net" +access: + muc_log: + admin: allow + all: deny -{access, muc_log, [{allow, admin}, - {deny, all}]}. - -{modules, - [ +modules: ... - {mod_muc_log, [ - {access_log, muc_log}, - {cssfile, false}, - {dirtype, subdirs}, - {dirtype, subdirs}, - {file_permissions, {644, 33}}, - {outdir, "/var/www/muclogs"}, - {timezone, local} - ]}, + mod_muc_log: + access_log: muc_log + cssfile: false + dirtype: subdirs + file_permissions: + mode: 644 + group: 33 + outdir: "/var/www/muclogs" + timezone: local ... - ]}. \end{verbatim} \end{itemize} @@ -3615,7 +3500,7 @@ online again. Thus it is very similar to how email works. Note that \begin{description} \dbtype - \titem{\{access\_max\_user\_messages, AccessName\}}\ind{options!access\_max\_user\_messages} + \titem{access\_max\_user\_messages: AccessName}\ind{options!access\_max\_user\_messages} This option defines which access rule will be enforced to limit the maximum number of offline messages that a user can have (quota). When a user has too many offline messages, any new messages that he receive are discarded, @@ -3629,19 +3514,27 @@ This example allows power users to have as much as 5000 offline messages, administrators up to 2000, and all the other users up to 100. \begin{verbatim} -{acl, admin, {user, "admin1", "localhost"}}. -{acl, admin, {user, "admin2", "example.org"}}. -{acl, poweruser, {user, "bob", "example.org"}}. -{acl, poweruser, {user, "jane", "example.org"}}. +acl: + admin: + user: + - "admin1": "localhost" + - "admin2": "example.org" + poweruser: + user: + - "bob": "example.org" + - "jane": "example.org" -{access, max_user_offline_messages, [ {5000, poweruser}, {2000, admin}, {100, all} ]}. +access: + max_user_offline_messages: + poweruser: 5000 + admin: 2000 + all: 100 -{modules, - [ +modules: ... - {mod_offline, [ {access_max_user_messages, max_user_offline_messages} ]}, + mod_offline: + access_max_user_messages: max_user_offline_messages ... - ]}. \end{verbatim} \makesubsection{modping}{\modping{}} @@ -3653,18 +3546,18 @@ ping requests, as defined in the protocol. Configuration options: \begin{description} - \titem{\{send\_pings, true|false\}}\ind{options!send\_pings} + \titem{send\_pings: true|false}\ind{options!send\_pings} If this option is set to \term{true}, the server sends pings to connected clients that are not active in a given interval \term{ping\_interval}. This is useful to keep client connections alive or checking availability. By default this option is disabled. % because it is mostly not needed and consumes resources. - \titem{\{ping\_interval, Seconds\}}\ind{options!ping\_interval} + \titem{ping\_interval: Seconds}\ind{options!ping\_interval} How often to send pings to connected clients, if the previous option is enabled. If a client connection does not send or receive any stanza in this interval, a ping request is sent to the client. The default value is 60 seconds. - \titem{\{timeout\_action, none|kill\}}\ind{options!timeout\_action} + \titem{timeout\_action: none|kill}\ind{options!timeout\_action} What to do when a client does not answer to a server ping request in less than 32 seconds. % Those 32 seconds are defined in ejabberd_local.erl: -define(IQ_TIMEOUT, 32000). The default is to do nothing. @@ -3674,12 +3567,13 @@ This example enables Ping responses, configures the module to send pings to client connections that are inactive for 4 minutes, and if a client does not answer to the ping in less than 32 seconds, its connection is closed: \begin{verbatim} -{modules, - [ +modules: ... - {mod_ping, [{send_pings, true}, {ping_interval, 240}, {timeout_action, kill}]}, + mod_ping: + send_pings: true + ping_interval: 240 + timeout_action: kill ... - ]}. \end{verbatim} \makesubsection{modprescounter}{\modprescounter{}} @@ -3691,7 +3585,7 @@ the exceeding stanzas are silently dropped, and warning is logged. Configuration options: \begin{description} - \titem{\{count, StanzaNumber\}}\ind{options!count} + \titem{count: StanzaNumber}\ind{options!count} The number of subscription presence stanzas (subscribe, unsubscribe, subscribed, unsubscribed) allowed for any direction (input or output) @@ -3699,7 +3593,7 @@ Configuration options: Please note that two users subscribing to each other usually generate 4 stanzas, so the recommended value is 4 or more. The default value is: 5. - \titem{\{interval, Seconds\}}\ind{options!interval} + \titem{interval: Seconds}\ind{options!interval} The time interval defined in seconds. The default value is 60. \end{description} @@ -3707,12 +3601,12 @@ Configuration options: This example enables the module, and allows up to 5 presence subscription stanzas to be sent or received by the users in 60 seconds: \begin{verbatim} -{modules, - [ +modules: ... - {mod_pres_counter, [{count, 5}, {interval, 60}]}, + mod_pres_counter: + count: 5 + interval: 60 ... - ]}. \end{verbatim} \makesubsection{modprivacy}{\modprivacy{}} @@ -3775,27 +3669,27 @@ XMPP clients. Options: \begin{description} \hostitem{proxy} -\titem{\{name, Text\}}\ind{options!name}Defines Service Discovery name of the service. +\titem{name: Text}\ind{options!name}Defines Service Discovery name of the service. Default is \term{"SOCKS5 Bytestreams"}. -\titem{\{ip, IPTuple\}}\ind{options!ip}This option specifies which network interface +\titem{ip: IP}\ind{options!ip}This option specifies which network interface to listen for. Default is an IP address of the service's DNS name, or, -if fails, \verb|{127,0,0,1}|. -\titem{\{port, Number\}}\ind{options!port}This option defines port to listen for +if fails, \verb|"127.0.0.1"|. +\titem{port: Number}\ind{options!port}This option defines port to listen for incoming connections. Default is~7777. -\titem{\{hostname, HostName\}}\ind{options!hostname}Defines a hostname advertised +\titem{hostname: HostName}\ind{options!hostname}Defines a hostname advertised by the service when establishing a session with clients. This is useful when you run the service behind a NAT. The default is the value of \term{ip} option. Examples: \term{"proxy.mydomain.org"}, \term{"200.150.100.50"}. Note that not all clients understand domain names in stream negotiation, so you should think twice before setting domain name in this option. -\titem{\{auth\_type, anonymous|plain\}}\ind{options!auth\_type}SOCKS5 authentication type. +\titem{auth\_type: anonymous|plain}\ind{options!auth\_type}SOCKS5 authentication type. Possible values are \term{anonymous} and \term{plain}. Default is \term{anonymous}. -\titem{\{access, AccessName\}}\ind{options!access}Defines ACL for file transfer initiators. +\titem{access: AccessName}\ind{options!access}Defines ACL for file transfer initiators. Default is \term{all}. -\titem{\{max\_connections, Number\}}\ind{options!max\_connections}Maximum number of +\titem{max\_connections: Number}\ind{options!max\_connections}Maximum number of active connections per file transfer initiator. No limit by default. -\titem{\{shaper, none|ShaperName\}}\ind{options!shaper}This option defines shaper for +\titem{shaper: none|ShaperName}\ind{options!shaper}This option defines shaper for the file transfer peers. Shaper with the maximum bandwidth will be selected. Default is \term{none}. \end{description} @@ -3804,34 +3698,43 @@ Examples: \begin{itemize} \item The simpliest configuration of the module: \begin{verbatim} -{modules, - [ +modules: ... - {mod_proxy65, []}, + mod_proxy65: {} ... - ]}. \end{verbatim} \item More complicated configuration. \begin{verbatim} -{acl, proxy_users, {server, "example.org"}}. -{access, proxy65_access, [{allow, proxy_users}, {deny, all}]}. +acl: + admin: + user: + - "admin": "example.org" + proxy_users: + server: + - "example.org" -{acl, admin, {user, "admin", "example.org"}}. -{shaper, proxyrate, {maxrate, 10240}}. %% 10 Kbytes/sec -{access, proxy65_shaper, [{none, admin}, {proxyrate, proxy_users}]}. +access: + proxy65_access: + proxy_users: allow + all: deny + proxy65_shaper: + admin: none + proxy_users: proxyrate -{modules, - [ +shaper: + proxyrate: 10240 + +modules: ... - {mod_proxy65, [{host, "proxy1.example.org"}, - {name, "File Transfer Proxy"}, - {ip, {200,150,100,1}}, - {port, 7778}, - {max_connections, 5}, - {access, proxy65_access}, - {shaper, proxy65_shaper}]}, + mod_proxy65: + host: "proxy1.example.org" + name: "File Transfer Proxy" + ip: "200.150.100.1" + port: 7778 + max_connections: 5 + access: proxy65_access + shaper: proxy65_shaper ... - ]}. \end{verbatim} \end{itemize} @@ -3849,20 +3752,20 @@ Options: \hostitem{pubsub} If you use \modpubsubodbc, please ensure the prefix contains only one dot, for example `\jid{pubsub.}', or `\jid{publish.}',. -\titem{\{access\_createnode, AccessName\}} \ind{options!access\_createnode} +\titem{access\_createnode: AccessName} \ind{options!access\_createnode} This option restricts which users are allowed to create pubsub nodes using ACL and ACCESS. By default any account in the local ejabberd server is allowed to create pubsub nodes. -\titem{\{max\_items\_node, MaxItems\}} \ind{options!max\_items\_node} +\titem{max\_items\_node: MaxItems} \ind{options!max\_items\_node} Define the maximum number of items that can be stored in a node. Default value is 10. -\titem{\{plugins, [ Plugin, ...]\}} \ind{options!plugins} +\titem{plugins: [ Plugin, ...]} \ind{options!plugins} To specify which pubsub node plugins to use. The first one in the list is used by default. If this option is not defined, the default plugins list is: \term{["flat"]}. PubSub clients can define which plugin to use when creating a node: add \term{type='plugin-name'} attribute to the \term{create} stanza element. -\titem{\{nodetree, Nodetree\}} \ind{options!nodetree} +\titem{nodetree: Nodetree} \ind{options!nodetree} To specify which nodetree to use. If not defined, the default pubsub nodetree is used: "tree". Only one nodetree can be used per host, and is shared by all node plugins. @@ -3880,21 +3783,26 @@ Options: The "dag" nodetree provides experimental support for PubSub Collection Nodes (\xepref{0248}). In that case you should also add "dag" node plugin as default, for example: - \term{\{plugins, ["dag","flat","hometree","pep"]\}} -\titem{\{ignore\_pep\_from\_offline, false|true\}} \ind{options!ignore\_pep\_from\_offline} + \term{plugins: ["dag","flat","hometree","pep"]} +\titem{ignore\_pep\_from\_offline: false|true} \ind{options!ignore\_pep\_from\_offline} To specify whether or not we should get last published PEP items from users in our roster which are offline when we connect. Value is true or false. If not defined, pubsub assumes true so we only get last items of online contacts. -\titem{\{last\_item\_cache, false|true\}} \ind{options!last\_item\_cache} +\titem{last\_item\_cache: false|true} \ind{options!last\_item\_cache} To specify whether or not pubsub should cache last items. Value is true or false. If not defined, pubsub do not cache last items. On systems with not so many nodes, caching last items speeds up pubsub and allows to raise user connection rate. The cost is memory usage, as every item is stored in memory. -\titem{\{pep\_mapping, [ \{Key, Value\}, ...]\}} \ind{pep\_mapping} +\titem{pep\_mapping: \{Key, Value\}} \ind{pep\_mapping} This allow to define a Key-Value list to choose defined node plugins on given PEP namespace. The following example will use node\_tune instead of node\_pep for every PEP node with tune namespace: \begin{verbatim} - {mod_pubsub, [{pep_mapping, [{"http://jabber.org/protocol/tune", "tune"}]}]} +modules: + ... + mod_pubsub: + pep_mapping: + "http://jabber.org/protocol/tune": "tune" + ... \end{verbatim} %\titem{served\_hosts} \ind{options!served\_hosts} % This option allows to create additional pubsub virtual hosts in a single module instance. @@ -3902,29 +3810,29 @@ Options: Example of configuration that uses flat nodes as default, and allows use of flat, nodetree and pep nodes: \begin{verbatim} -{modules, - [ +modules: ... - {mod_pubsub, [ - {access_createnode, pubsub_createnode}, - {plugins, ["flat", "hometree", "pep"]} - ]}, + mod_pubsub: + access_createnode: pubsub_createnode + plugins: + - "flat" + - "hometree" + - "pep" ... - ]}. \end{verbatim} Using ODBC database requires using mod\_pubsub\_odbc without option changes. Only flat, hometree and pep plugins supports ODBC. The following example shows previous configuration with ODBC usage: \begin{verbatim} -{modules, - [ +modules: ... - {mod_pubsub_odbc, [ - {access_createnode, pubsub_createnode}, - {plugins, ["flat", "hometree", "pep"]} - ]}, + mod_pubsub_odbc: + access_createnode: pubsub_createnode + plugins: + - "flat" + - "hometree" + - "pep" ... - ]}. \end{verbatim} \makesubsection{modregister}{\modregister{}} @@ -3941,38 +3849,36 @@ enables end users to use a \XMPP{} client to: Options: \begin{description} -\titem{\{access, AccessName\}} \ind{options!access} +\titem{access: AccessName} \ind{options!access} Specify rules to restrict what usernames can be registered and unregistered. If a rule returns `deny' on the requested username, registration and unregistration of that user name is denied. There are no restrictions by default. -\titem{\{access\_from, AccessName\}} \ind{options!access\_from}By default, \ejabberd{} +\titem{access\_from: AccessName} \ind{options!access\_from}By default, \ejabberd{} doesn't allow to register new accounts from s2s or existing c2s sessions. You can change it by defining access rule in this option. Use with care: allowing registration from s2s leads to uncontrolled massive accounts creation by rogue users. -\titem{\{captcha\_protected, false|true\}} \ind{options!captcha\_protected} +\titem{captcha\_protected: false|true} \ind{options!captcha\_protected} Protect registrations with CAPTCHA (see section \ref{captcha}). The default is \term{false}. -\titem{\{ip\_access, [ \{allow|deny, IPaddress\}, ...]\}} \ind{options!ip\_access} +\titem{ip\_access: AccessName} \ind{options!ip\_access} Define rules to allow or deny account registration depending - in the IP address of the XMPP client. - If there is no matching IP mask, the default rule is ``allow''. - IPv6 addresses are supported, but not tested. - The default option value is an empty list: \term{[]}. -\titem{\{password\_strength, Entropy\}} \ind{options!password\_strength} + on the IP address of the XMPP client. The \term{AccessName} should be + of type \term{ip}. The default value is \term{all}. +\titem{password\_strength: Entropy} \ind{options!password\_strength} This option sets the minimum informational entropy for passwords. The value \term{Entropy} is a number of bits of entropy. The recommended minimum is 32 bits. The default is 0, i.e. no checks are performed. -\titem{\{welcome\_message, \{Subject, Body\}\}} \ind{options!welcomem}Set a welcome message that +\titem{welcome\_message: \{subject: Subject, body: Body\}} + \ind{options!welcomem} Set a welcome message that is sent to each newly registered account. The first string is the subject, and the second string is the message body. - In the body you can set a newline with the characters: \verb|\n| -\titem{\{registration\_watchers, [ JID, ...]\}} \ind{options!rwatchers}This option defines a +\titem{registration\_watchers: [ JID, ...]} \ind{options!rwatchers}This option defines a list of JIDs which will be notified each time a new account is registered. \iqdiscitem{In-Band Registration (\ns{jabber:iq:register})} \end{description} This module reads also another option defined globally for the server: -\term{\{registration\_timeout, Timeout\}}. \ind{options!registratimeout} +\term{registration\_timeout: Timeout}. \ind{options!registratimeout} This option limits the frequency of registration from a given IP or username. So, a user that tries to register a new account from the same IP address or JID during this number of seconds after his previous registration @@ -3988,62 +3894,74 @@ Examples: \item Next example prohibits the registration of too short account names, and allows to create accounts only to clients of the local network: \begin{verbatim} -{acl, shortname, {user_glob, "?"}}. -{acl, shortname, {user_glob, "??"}}. -%% The same using regexp: -%%{acl, shortname, {user_regexp, "^..?$"}}. +acl: + loopback: + ip: + - "127.0.0.0/8" + - "::" + shortname: + user_glob: + - "?" + - "??" + ## The same using regexp: + ##user_regexp: "^..?$" -{access, register, [{deny, shortname}, - {allow, all}]}. +access: + mynetworks: + loopback: allow + all: deny + register: + shortname: deny + all: allow -{modules, - [ - ... - {mod_register, [{access, register}, - {ip_access, [{allow, "127.0.0.0/8"}, - {deny, "0.0.0.0/0"}]} - ]}, - ... - ]}. +modules: + mod_register: + ip_access: mynetworks + access: register \end{verbatim} \item This configuration prohibits usage of In-Band Registration to create or delete accounts, but allows existing accounts to change the password: \begin{verbatim} -{access, register, [{deny, all}]}. +access: + register: + all: deny -{modules, - [ +modules: ... - {mod_register, [{access, register}]}, + mod_register: + access: register ... - ]}. \end{verbatim} \item This configuration disables all In-Band Registration functionality: create, delete accounts and change password: \begin{verbatim} -{modules, - [ +modules: ... - %% {mod_register, [{access, register}]}, + ## mod_register: + ## access: register ... - ]}. \end{verbatim} \item Define the welcome message and two registration watchers. Also define a registration timeout of one hour: \begin{verbatim} -{registration_timeout, 3600}. -{modules, - [ +registration_timeout: 3600 +modules: ... - {mod_register, - [ - {welcome_message, {"Welcome!", "Hi.\nWelcome to this Jabber server.\n Check http://www.jabber.org\n\nBye"}}, - {registration_watchers, ["admin1@example.org", "boss@example.net"]} - ]}, + mod_register: + welcome_message: + subject: "Welcome!" + body: |- + Hi. + Welcome to this Jabber server. + Check http://www.jabber.org + + Bye + registration_watchers: + - "admin1@example.org" + - "boss@example.net" ... - ]}. \end{verbatim} \end{itemize} @@ -4062,30 +3980,30 @@ To enable this feature, configure the options captcha\_cmd and captcha\_host. Options: \begin{description} -\titem{\{registration\_watchers, [ JID, ...]\}} \ind{options!rwatchers}This option defines a +\titem{registration\_watchers: [ JID, ...]} \ind{options!rwatchers}This option defines a list of JIDs which will be notified each time a new account is registered. \end{description} This example configuration shows how to enable the module and the web handler: \begin{verbatim} -{hosts, ["localhost", "example.org", "example.com"]}. +hosts: + - "localhost" + - "example.org" + - "example.com" +listen: + ... + - + port: 5281 + module: ejabberd_http + register: true + certfile: "/etc/ejabberd/certificate.pem" + tls: true + ... -{listen, [ +modules: ... - {5281, ejabberd_http, [ - tls, - {certfile, "/etc/ejabberd/certificate.pem"}, - register - ]}, + mod_register_web: {} ... -]}. - -{modules, - [ - ... - {mod_register_web, []}, - ... - ]}. \end{verbatim} For example, the users of the host \term{example.org} can visit the page: @@ -4104,10 +4022,10 @@ Options: \begin{description} \iqdiscitem{Roster Management (\ns{jabber:iq:roster})} \dbtype - \titem{\{versioning, false|true\}} \ind{options!versioning}Enables + \titem{versioning: false|true} \ind{options!versioning}Enables Roster Versioning. This option is disabled by default. - \titem{\{store\_current\_id, false|true\}} \ind{options!storecurrentid} + \titem{store\_current\_id: false|true} \ind{options!storecurrentid} If this option is enabled, the current version number is stored on the database. If disabled, the version number is calculated on the fly each time. Enabling this option reduces the load for both ejabberd and the database. @@ -4120,12 +4038,12 @@ Options: This example configuration enables Roster Versioning with storage of current id: \begin{verbatim} -{modules, - [ +modules: ... - {mod_roster, [{versioning, true}, {store_current_id, true}]}, + mod_roster: + versioning: true + store_current_id: true ... - ]}. \end{verbatim} \makesubsection{modservicelog}{\modservicelog{}} @@ -4139,7 +4057,7 @@ service(s). Options: \begin{description} -\titem{\{loggers, [Names, ...]\}} \ind{options!loggers}With this option a (list of) service(s) +\titem{loggers: [Names, ...]} \ind{options!loggers}With this option a (list of) service(s) that will receive the packets can be specified. \end{description} @@ -4148,24 +4066,23 @@ Examples: \item To log all end user packets to the Bandersnatch service running on \jid{bandersnatch.example.com}: \begin{verbatim} -{modules, - [ +modules: ... - {mod_service_log, [{loggers, ["bandersnatch.example.com"]}]}, + mod_service_log: + loggers: ["bandersnatch.example.com"] ... - ]}. \end{verbatim} \item To log all end user packets to the Bandersnatch service running on \jid{bandersnatch.example.com} and the backup service on \jid{bandersnatch.example.org}: \begin{verbatim} -{modules, - [ +modules: ... - {mod_service_log, [{loggers, ["bandersnatch.example.com", - "bandersnatch.example.org"]}]}, + mod_service_log: + loggers: + - "bandersnatch.example.com" + - "bandersnatch.example.org" ... - ]}. \end{verbatim} \end{itemize} @@ -4572,14 +4489,16 @@ Such layout has a few downsides, including: This however seems to be a common DIT layout, so the module keeps supporting it. You can use the following configuration\ldots \begin{verbatim} - {mod_shared_roster_ldap,[ - {ldap_base, "ou=flat,dc=nodomain"}, - {ldap_rfilter, "(objectClass=inetOrgPerson)"}, - {ldap_groupattr, "ou"}, - {ldap_memberattr, "cn"}, - {ldap_filter, "(objectClass=inetOrgPerson)"}, - {ldap_userdesc, "displayName"} - ]}, +modules: + ... + mod_shared_roster_ldap: + ldap_base: "ou=flat,dc=nodomain" + ldap_rfilter: "(objectClass=inetOrgPerson)" + ldap_groupattr: "ou" + ldap_memberattr: "cn" + ldap_filter: "(objectClass=inetOrgPerson)" + ldap_userdesc: "displayName" + ... \end{verbatim} \ldots to be provided with a roster as shown in figure~\ref{fig:msrl-roster-flat} upon connecting as user {\tt czesio}. @@ -4605,17 +4524,19 @@ They are shown separated into different subtrees, but it's not a requirement. If you use the following example module configuration with it: \begin{verbatim} - {mod_shared_roster_ldap,[ - {ldap_base, "ou=deep,dc=nodomain"}, - {ldap_rfilter, "(objectClass=groupOfUniqueNames)"}, - {ldap_filter, ""}, - {ldap_gfilter, "(&(objectClass=groupOfUniqueNames)(cn=%g))"}, - {ldap_groupdesc, "description"}, - {ldap_memberattr, "uniqueMember"}, - {ldap_memberattr_format, "cn=%u,ou=people,ou=deep,dc=nodomain"}, - {ldap_ufilter, "(&(objectClass=inetOrgPerson)(cn=%u))"}, - {ldap_userdesc, "displayName"} - ]}, +modules: + ... + mod_shared_roster_ldap: + ldap_base: "ou=deep,dc=nodomain" + ldap_rfilter: "(objectClass=groupOfUniqueNames)" + ldap_filter: "" + ldap_gfilter: "(&(objectClass=groupOfUniqueNames)(cn=%g))" + ldap_groupdesc: "description" + ldap_memberattr: "uniqueMember" + ldap_memberattr_format: "cn=%u,ou=people,ou=deep,dc=nodomain" + ldap_ufilter: "(&(objectClass=inetOrgPerson)(cn=%u))" + ldap_userdesc: "displayName" + ... \end{verbatim} \ldots and connect as user {\tt czesio}, then \ejabberd{} will provide you with @@ -4705,19 +4626,19 @@ Options: \hostitem{vjud} \iqdiscitem{\ns{vcard-temp}} \dbtype -\titem{\{search, true|false\}}\ind{options!search}This option specifies whether the search +\titem{search: true|false}\ind{options!search}This option specifies whether the search functionality is enabled or not If disabled, the option \term{host} will be ignored and the \Jabber{} User Directory service will not appear in the Service Discovery item list. The default value is \term{true}. -\titem{\{matches, infinity|Number\}}\ind{options!matches}With this option, the number of reported +\titem{matches: infinity|Number}\ind{options!matches}With this option, the number of reported search results can be limited. If the option's value is set to \term{infinity}, all search results are reported. The default value is \term{30}. -\titem{\{allow\_return\_all, false|true\}}\ind{options!allow\_return\_all}This option enables +\titem{allow\_return\_all: false|true}\ind{options!allow\_return\_all}This option enables you to specify if search operations with empty input fields should return all users who added some information to their vCard. The default value is \term{false}. -\titem{\{search\_all\_hosts, true|false\}}\ind{options!search\_all\_hosts}If this option is set +\titem{search\_all\_hosts, true|false}\ind{options!search\_all\_hosts}If this option is set to \term{true}, search operations will apply to all virtual hosts. Otherwise only the current host will be searched. The default value is \term{true}. This option is available in \modvcard when using Mnesia, but not when using ODBC storage. @@ -4729,27 +4650,25 @@ Examples: every user who added information to their vCard will be listed when people do an empty search, and only users from the current host will be returned: \begin{verbatim} -{modules, - [ +modules: ... - {mod_vcard, [{search, true}, - {matches, 20}, - {allow_return_all, true}, - {search_all_hosts, false}]}, + mod_vcard: + search: true + matches: 20 + allow_return_all: true + search_all_hosts: false ... - ]}. \end{verbatim} \item The second situation differs in a way that search results are not limited, and that all virtual hosts will be searched instead of only the current one: \begin{verbatim} -{modules, - [ +modules: ... - {mod_vcard, [{search, true}, - {matches, infinity}, - {allow_return_all, true}]}, + mod_vcard: + search: true + matches: infinity + allow_return_all: true ... - ]}. \end{verbatim} \end{itemize} @@ -5006,7 +4925,7 @@ answers \ejabberd{}'s version when queried. Options: \begin{description} -\titem{\{show\_os, true|false\}}\ind{options!showos}Should the operating system be revealed or not. +\titem{show\_os: true|false}\ind{options!showos}Should the operating system be revealed or not. The default value is \term{true}. \iqdiscitem{Software Version (\ns{jabber:iq:version})} \end{description} @@ -5059,14 +4978,15 @@ The \term{ejabberdctl commands} are: The \term{ejabberdctl} script can be restricted to require authentication and execute some \term{ejabberd commands}; see \ref{accesscommands}. -Add the option to the file \term{ejabberd.cfg}. +Add the option to the file \term{ejabberd.yml}. In this example there is no restriction: \begin{verbatim} -{ejabberdctl_access_commands, []}. +ejabberdctl_access_commands: [] \end{verbatim} If account \term{robot1@example.org} is registered in \ejabberd{} with password \term{abcdef} -and \term{ejabberd.cfg} contains this setting: +(which MD5 is E8B501798950FC58AAD83C8C14978E), +and \term{ejabberd.yml} contains this setting: \begin{verbatim} {hosts, ["example.org"]}. {acl, bots, {user, "robot1", "example.org"}}. @@ -5353,42 +5273,60 @@ Example configurations: administer the virtual host \jid{example.com}. The account `\jid{reviewer@example.com}' can browse that vhost in read-only mode. \begin{verbatim} -{acl, admin, {user, "admin", "example.net"}}. -{host_config, "example.com", [{acl, admin, {user, "admin", "example.com"}}]}. -{host_config, "example.com", [{acl, viewers, {user, "reviewer", "example.com"}}]}. +acl: + admin: + user: + - "admin": "example.net" -{access, configure, [{allow, admin}]}. -{access, webadmin_view, [{allow, viewers}]}. +host_config: + "example.com": + acl: + admin: + user: + - "admin": "example.com" + viewers: + user: + - "reviewer": "example.com" -{hosts, ["example.org"]}. +access: + configure: + admin: allow + webadmin_view: + viewers: allow -{listen, - [ +hosts: + - "example.org" + +listen: ... - {5280, ejabberd_http, [http_poll, web_admin]}, + - + port: 5280 + module: ejabberd_http + web_admin: true + http_poll: true ... - ]}. \end{verbatim} \item For security reasons, you can serve the Web Admin on a secured connection, on a port differing from the HTTP Polling interface, and bind it to the internal LAN IP. The Web Admin will be accessible by pointing your web browser to \verb|https://192.168.1.1:5282/admin/|: \begin{verbatim} - -{hosts, ["example.org"]}. - -{listen, - [ +hosts: + - "example.org" +listen: ... - {5280, ejabberd_http, [ - http_poll - ]}, - {{5282, "192.168.1.1"}, ejabberd_http, [ - web_admin, - tls, {certfile, "/usr/local/etc/server.pem"} - ]}, + - + port: 5280 + module: ejabberd_http + http_poll: true + - + ip: "192.168.1.1" + port: 5282 + module: ejabberd_http + certfile: "/usr/local/etc/server.pem" + tls: true + web_admin: true ... - ]}. \end{verbatim} \end{itemize} @@ -5607,7 +5545,7 @@ The file system permissions should be set to only allow the proper user to read, write and execute those files and directories. \begin{description} - \titem{ejabberd configuration file: /etc/ejabberd/ejabberd.cfg} + \titem{ejabberd configuration file: /etc/ejabberd/ejabberd.yml} Contains the JID of administrators and passwords of external components. The backup files probably contain also this information, @@ -5783,7 +5721,7 @@ domain. The default distribution algorithm try to deliver to a local instance of a component. If several local instances are available, one instance is chosen randomly. If no instance is available locally, one instance is chosen randomly among the remote component instances. If you need a different behaviour, you can change the load balancing behaviour with the option \option{domain\_balancing}. The syntax of the option is the following: -\esyntax{\{domain\_balancing, "component.example.com", BalancingCriteria\}.} +\esyntax{domain\_balancing: BalancingCriteria} Several balancing criteria are available: \begin{itemize} @@ -5803,7 +5741,7 @@ When there is a risk of failure for a given component, domain balancing can caus In this case, it is best to limit the problem to the sessions handled by the failing component. This is what the \term{domain\_balancing\_component\_number} option does, making the load balancing algorithm not dynamic, but sticky on a fix number of component instances. The syntax is: -\esyntax{\{domain\_balancing\_component\_number, "component.example.com", Number\}.} +\esyntax{domain\_balancing\_component\_number: Number} @@ -5824,10 +5762,9 @@ An \ejabberd{} node writes two log files: \titem{erlang.log} is the Erlang/OTP system log, with the messages reported by Erlang/OTP using SASL (System Architecture Support Libraries) \end{description} -The option \term{loglevel} modifies the verbosity of the file ejabberd.log. The syntax is one of: +The option \term{loglevel} modifies the verbosity of the file ejabberd.log. The syntax: \begin{description} - \titem{\{loglevel, Level\}.} The standard form to set a global log level. - \titem{\{loglevel, \{Level, [\{Module, Level\}, ...]\}\}.} The given Erlang modules will be logged with specific log levels, all others will use the default log level. + \titem{loglevel: Level} The standard form to set a global log level. \end{description} The possible \term{Level} are: @@ -5841,7 +5778,7 @@ The possible \term{Level} are: \end{description} For example, the default configuration is: \begin{verbatim} -{loglevel, 4}. +loglevel: 4 \end{verbatim} The log files grow continually, so it is recommended to rotate them periodically. @@ -5876,7 +5813,7 @@ a message is sent to the XMPP accounts defined with the option \ind{options!watchdog\_admins} in the \ejabberd{} configuration file. The syntax is: -\esyntax{\{watchdog\_admins, [JID, ...]\}.} +\esyntax{watchdog\_admins: [JID, ...]} The memory consumed is measured in \term{words}: a word on 32-bit architecture is 4 bytes, @@ -5886,18 +5823,20 @@ This value can be configured with the option \term{watchdog\_large\_heap}, or in a conversation with the watchdog alert bot. The syntax is: -\esyntax{\{watchdog\_large\_heap, Number\}.} +\esyntax{watchdog\_large\_heap: Number} Example configuration: \begin{verbatim} -{watchdog_admins, ["admin2@localhost", "admin2@example.org"]}. -{watchdog_large_heap, 30000000}. +watchdog_admins: + - "admin2@localhost" + - "admin2@example.org" +watchdog_large_heap: 30000000 \end{verbatim} To remove watchdog admins, remove them in the option. To remove all watchdog admins, set the option with an empty list: \begin{verbatim} -{watchdog_admins, []}. +watchdog_admins: [] \end{verbatim} \appendix{} diff --git a/ejabberd.cfg.example b/ejabberd.cfg.example deleted file mode 100644 index d1d68feac..000000000 --- a/ejabberd.cfg.example +++ /dev/null @@ -1,609 +0,0 @@ -%%% -%%% ejabberd configuration file -%%% -%%%' - -%%% The parameters used in this configuration file are explained in more detail -%%% in the ejabberd Installation and Operation Guide. -%%% Please consult the Guide in case of doubts, it is included with -%%% your copy of ejabberd, and is also available online at -%%% http://www.process-one.net/en/ejabberd/docs/ - -%%% This configuration file contains Erlang terms. -%%% In case you want to understand the syntax, here are the concepts: -%%% -%%% - The character to comment a line is % -%%% -%%% - Each term ends in a dot, for example: -%%% override_global. -%%% -%%% - A tuple has a fixed definition, its elements are -%%% enclosed in {}, and separated with commas: -%%% {loglevel, 4}. -%%% -%%% - A list can have as many elements as you want, -%%% and is enclosed in [], for example: -%%% [http_poll, web_admin, tls] -%%% -%%% - A keyword of ejabberd is a word in lowercase. -%%% Strings are enclosed in "" and can contain spaces, dots, ... -%%% {language, "en"}. -%%% {ldap_rootdn, "dc=example,dc=com"}. -%%% -%%% - This term includes a tuple, a keyword, a list, and two strings: -%%% {hosts, ["jabber.example.net", "im.example.com"]}. -%%% - - -%%%. ======================= -%%%' OVERRIDE STORED OPTIONS - -%% -%% Override the old values stored in the database. -%% - -%% -%% Override global options (shared by all ejabberd nodes in a cluster). -%% -%%override_global. - -%% -%% Override local options (specific for this particular ejabberd node). -%% -%%override_local. - -%% -%% Remove the Access Control Lists before new ones are added. -%% -%%override_acls. - - -%%%. ========= -%%%' DEBUGGING - -%% -%% loglevel: Verbosity of log files generated by ejabberd. -%% 0: No ejabberd log at all (not recommended) -%% 1: Critical -%% 2: Error -%% 3: Warning -%% 4: Info -%% 5: Debug -%% -{loglevel, 4}. - -%% -%% watchdog_admins: Only useful for developers: if an ejabberd process -%% consumes a lot of memory, send live notifications to these XMPP -%% accounts. -%% -%%{watchdog_admins, ["bob@example.com"]}. - - -%%%. ================ -%%%' SERVED HOSTNAMES - -%% -%% hosts: Domains served by ejabberd. -%% You can define one or several, for example: -%% {hosts, ["example.net", "example.com", "example.org"]}. -%% -{hosts, ["localhost"]}. - -%% -%% route_subdomains: Delegate subdomains to other XMPP servers. -%% For example, if this ejabberd serves example.org and you want -%% to allow communication with an XMPP server called im.example.org. -%% -%%{route_subdomains, s2s}. - - -%%%. =============== -%%%' LISTENING PORTS - -%% -%% listen: The ports ejabberd will listen on, which service each is handled -%% by and what options to start it with. -%% -{listen, - [ - - {5222, ejabberd_c2s, [ - - %% - %% If TLS is compiled in and you installed a SSL - %% certificate, specify the full path to the - %% file and uncomment this line: - %% - %%{certfile, "/path/to/ssl.pem"}, starttls, - - {access, c2s}, - {shaper, c2s_shaper}, - {max_stanza_size, 65536} - ]}, - - %% - %% To enable the old SSL connection method on port 5223: - %% - %%{5223, ejabberd_c2s, [ - %% {access, c2s}, - %% {shaper, c2s_shaper}, - %% {certfile, "/path/to/ssl.pem"}, tls, - %% {max_stanza_size, 65536} - %% ]}, - - {5269, ejabberd_s2s_in, [ - {shaper, s2s_shaper}, - {max_stanza_size, 131072} - ]}, - - %% - %% ejabberd_service: Interact with external components (transports, ...) - %% - %%{8888, ejabberd_service, [ - %% {access, all}, - %% {shaper_rule, fast}, - %% {hosts, ["icq.example.org", "sms.example.org"], - %% [{password, "secret"}] - %% } - %% ]}, - - %% - %% ejabberd_stun: Handles STUN Binding requests - %% - %%{{3478, udp}, ejabberd_stun, []}, - - {5280, ejabberd_http, [ - %%{request_handlers, - %% [ - %% {["pub", "archive"], mod_http_fileserver} - %% ]}, - captcha, - http_bind, - http_poll, - %%register, - web_admin - ]} - - ]}. - -%% -%% s2s_use_starttls: Enable STARTTLS + Dialback for S2S connections. -%% Allowed values are: false optional required required_trusted -%% You must specify a certificate file. -%% -%%{s2s_use_starttls, optional}. - -%% -%% s2s_certfile: Specify a certificate file. -%% -%%{s2s_certfile, "/path/to/ssl.pem"}. - -%% -%% domain_certfile: Specify a different certificate for each served hostname. -%% -%%{domain_certfile, "example.org", "/path/to/example_org.pem"}. -%%{domain_certfile, "example.com", "/path/to/example_com.pem"}. - -%% -%% S2S whitelist or blacklist -%% -%% Default s2s policy for undefined hosts. -%% -%%{s2s_default_policy, allow}. - -%% -%% Allow or deny communication with specific servers. -%% -%%{{s2s_host, "goodhost.org"}, allow}. -%%{{s2s_host, "badhost.org"}, deny}. - -%% -%% Outgoing S2S options -%% -%% Preferred address families (which to try first) and connect timeout -%% in milliseconds. -%% -%%{outgoing_s2s_options, [ipv4, ipv6], 10000}. - - -%%%. ============== -%%%' AUTHENTICATION - -%% -%% auth_method: Method used to authenticate the users. -%% The default method is the internal. -%% If you want to use a different method, -%% comment this line and enable the correct ones. -%% -{auth_method, internal}. -%% -%% Store the plain passwords or hashed for SCRAM: -%%{auth_password_format, plain}. -%%{auth_password_format, scram}. -%% -%% Define the FQDN if ejabberd doesn't detect it: -%%{fqdn, "server3.example.com"}. - -%% -%% Authentication using external script -%% Make sure the script is executable by ejabberd. -%% -%%{auth_method, external}. -%%{extauth_program, "/path/to/authentication/script"}. - -%% -%% Authentication using ODBC -%% Remember to setup a database in the next section. -%% -%%{auth_method, odbc}. - -%% -%% Authentication using PAM -%% -%%{auth_method, pam}. -%%{pam_service, "pamservicename"}. - -%% -%% Authentication using LDAP -%% -%%{auth_method, ldap}. -%% -%% List of LDAP servers: -%%{ldap_servers, ["localhost"]}. -%% -%% Encryption of connection to LDAP servers: -%%{ldap_encrypt, none}. -%%{ldap_encrypt, tls}. -%% -%% Port to connect to on LDAP servers: -%%{ldap_port, 389}. -%%{ldap_port, 636}. -%% -%% LDAP manager: -%%{ldap_rootdn, "dc=example,dc=com"}. -%% -%% Password of LDAP manager: -%%{ldap_password, "******"}. -%% -%% Search base of LDAP directory: -%%{ldap_base, "dc=example,dc=com"}. -%% -%% LDAP attribute that holds user ID: -%%{ldap_uids, [{"mail", "%u@mail.example.org"}]}. -%% -%% LDAP filter: -%%{ldap_filter, "(objectClass=shadowAccount)"}. - -%% -%% Anonymous login support: -%% auth_method: anonymous -%% anonymous_protocol: sasl_anon | login_anon | both -%% allow_multiple_connections: true | false -%% -%%{host_config, "public.example.org", [{auth_method, anonymous}, -%% {allow_multiple_connections, false}, -%% {anonymous_protocol, sasl_anon}]}. -%% -%% To use both anonymous and internal authentication: -%% -%%{host_config, "public.example.org", [{auth_method, [internal, anonymous]}]}. - - -%%%. ============== -%%%' DATABASE SETUP - -%% ejabberd by default uses the internal Mnesia database, -%% so you do not necessarily need this section. -%% This section provides configuration examples in case -%% you want to use other database backends. -%% Please consult the ejabberd Guide for details on database creation. - -%% -%% MySQL server: -%% -%%{odbc_server, {mysql, "server", "database", "username", "password"}}. -%% -%% If you want to specify the port: -%%{odbc_server, {mysql, "server", 1234, "database", "username", "password"}}. - -%% -%% PostgreSQL server: -%% -%%{odbc_server, {pgsql, "server", "database", "username", "password"}}. -%% -%% If you want to specify the port: -%%{odbc_server, {pgsql, "server", 1234, "database", "username", "password"}}. -%% -%% If you use PostgreSQL, have a large database, and need a -%% faster but inexact replacement for "select count(*) from users" -%% -%%{pgsql_users_number_estimate, true}. - -%% -%% ODBC compatible or MSSQL server: -%% -%%{odbc_server, "DSN=ejabberd;UID=ejabberd;PWD=ejabberd"}. - -%% -%% Number of connections to open to the database for each virtual host -%% -%%{odbc_pool_size, 10}. - -%% -%% Interval to make a dummy SQL request to keep the connections to the -%% database alive. Specify in seconds: for example 28800 means 8 hours -%% -%%{odbc_keepalive_interval, undefined}. - - -%%%. =============== -%%%' TRAFFIC SHAPERS - -%% -%% The "normal" shaper limits traffic speed to 1000 B/s -%% -{shaper, normal, {maxrate, 1000}}. - -%% -%% The "fast" shaper limits traffic speed to 50000 B/s -%% -{shaper, fast, {maxrate, 50000}}. - -%% -%% This option specifies the maximum number of elements in the queue -%% of the FSM. Refer to the documentation for details. -%% -{max_fsm_queue, 1000}. - - -%%%. ==================== -%%%' ACCESS CONTROL LISTS - -%% -%% The 'admin' ACL grants administrative privileges to XMPP accounts. -%% You can put here as many accounts as you want. -%% -%%{acl, admin, {user, "aleksey", "localhost"}}. -%%{acl, admin, {user, "ermine", "example.org"}}. - -%% -%% Blocked users -%% -%%{acl, blocked, {user, "baduser", "example.org"}}. -%%{acl, blocked, {user, "test"}}. - -%% -%% Local users: don't modify this line. -%% -{acl, local, {user_regexp, ""}}. - -%% -%% More examples of ACLs -%% -%%{acl, jabberorg, {server, "jabber.org"}}. -%%{acl, aleksey, {user, "aleksey", "jabber.ru"}}. -%%{acl, test, {user_regexp, "^test"}}. -%%{acl, test, {user_glob, "test*"}}. - -%% -%% Define specific ACLs in a virtual host. -%% -%%{host_config, "localhost", -%% [ -%% {acl, admin, {user, "bob-local", "localhost"}} -%% ] -%%}. - - -%%%. ============ -%%%' ACCESS RULES - -%% Maximum number of simultaneous sessions allowed for a single user: -{access, max_user_sessions, [{10, all}]}. - -%% Maximum number of offline messages that users can have: -{access, max_user_offline_messages, [{5000, admin}, {100, all}]}. - -%% This rule allows access only for local users: -{access, local, [{allow, local}]}. - -%% Only non-blocked users can use c2s connections: -{access, c2s, [{deny, blocked}, - {allow, all}]}. - -%% For C2S connections, all users except admins use the "normal" shaper -{access, c2s_shaper, [{none, admin}, - {normal, all}]}. - -%% All S2S connections use the "fast" shaper -{access, s2s_shaper, [{fast, all}]}. - -%% Only admins can send announcement messages: -{access, announce, [{allow, admin}]}. - -%% Only admins can use the configuration interface: -{access, configure, [{allow, admin}]}. - -%% Admins of this server are also admins of the MUC service: -{access, muc_admin, [{allow, admin}]}. - -%% Only accounts of the local ejabberd server can create rooms: -{access, muc_create, [{allow, local}]}. - -%% All users are allowed to use the MUC service: -{access, muc, [{allow, all}]}. - -%% Only accounts on the local ejabberd server can create Pubsub nodes: -{access, pubsub_createnode, [{allow, local}]}. - -%% In-band registration allows registration of any possible username. -%% To disable in-band registration, replace 'allow' with 'deny'. -{access, register, [{allow, all}]}. - -%% By default the frequency of account registrations from the same IP -%% is limited to 1 account every 10 minutes. To disable, specify: infinity -%%{registration_timeout, 600}. - -%% -%% Define specific Access Rules in a virtual host. -%% -%%{host_config, "localhost", -%% [ -%% {access, c2s, [{allow, admin}, {deny, all}]}, -%% {access, register, [{deny, all}]} -%% ] -%%}. - - -%%%. ================ -%%%' DEFAULT LANGUAGE - -%% -%% language: Default language used for server messages. -%% -{language, "en"}. - -%% -%% Set a different default language in a virtual host. -%% -%%{host_config, "localhost", -%% [{language, "ru"}] -%%}. - - -%%%. ======= -%%%' CAPTCHA - -%% -%% Full path to a script that generates the image. -%% -%%{captcha_cmd, "/lib/ejabberd/priv/bin/captcha.sh"}. - -%% -%% Host for the URL and port where ejabberd listens for CAPTCHA requests. -%% -%%{captcha_host, "example.org:5280"}. - -%% -%% Limit CAPTCHA calls per minute for JID/IP to avoid DoS. -%% -%%{captcha_limit, 5}. - -%%%. ======= -%%%' MODULES - -%% -%% Modules enabled in all ejabberd virtual hosts. -%% -{modules, - [ - {mod_adhoc, []}, - {mod_announce, [{access, announce}]}, % recommends mod_adhoc - {mod_blocking,[]}, % requires mod_privacy - {mod_caps, []}, - {mod_configure,[]}, % requires mod_adhoc - {mod_disco, []}, - %%{mod_echo, [{host, "echo.localhost"}]}, - {mod_irc, []}, - {mod_http_bind, []}, - %%{mod_http_fileserver, [ - %% {docroot, "/var/www"}, - %% {accesslog, "/var/log/ejabberd/access.log"} - %% ]}, - {mod_last, []}, - {mod_muc, [ - %%{host, "conference.@HOST@"}, - {access, muc}, - {access_create, muc_create}, - {access_persistent, muc_create}, - {access_admin, muc_admin} - ]}, - %%{mod_muc_log,[]}, - {mod_offline, [{access_max_user_messages, max_user_offline_messages}]}, - {mod_ping, []}, - %%{mod_pres_counter,[{count, 5}, {interval, 60}]}, - {mod_privacy, []}, - {mod_private, []}, - %%{mod_proxy65,[]}, - {mod_pubsub, [ - {access_createnode, pubsub_createnode}, - {ignore_pep_from_offline, true}, % reduces resource comsumption, but XEP incompliant - %%{ignore_pep_from_offline, false}, % XEP compliant, but increases resource comsumption - {last_item_cache, false}, - {plugins, ["flat", "hometree", "pep"]} % pep requires mod_caps - ]}, - {mod_register, [ - %% - %% Protect In-Band account registrations with CAPTCHA. - %% - %%{captcha_protected, true}, - - %% - %% Set the minimum informational entropy for passwords. - %% - %%{password_strength, 32}, - - %% - %% After successful registration, the user receives - %% a message with this subject and body. - %% - {welcome_message, {"Welcome!", - "Hi.\nWelcome to this XMPP server."}}, - - %% - %% When a user registers, send a notification to - %% these XMPP accounts. - %% - %%{registration_watchers, ["admin1@example.org"]}, - - %% - %% Only clients in the server machine can register accounts - %% - {ip_access, [{allow, "127.0.0.0/8"}, - {deny, "0.0.0.0/0"}]}, - - %% - %% Local c2s or remote s2s users cannot register accounts - %% - %%{access_from, deny}, - - {access, register} - ]}, - %%{mod_register_web, [ - %% - %% When a user registers, send a notification to - %% these XMPP accounts. - %% - %%{registration_watchers, ["admin1@example.org"]} - %% ]}, - {mod_roster, []}, - %%{mod_service_log,[]}, - {mod_shared_roster,[]}, - {mod_stats, []}, - {mod_time, []}, - {mod_vcard, []}, - {mod_version, []} - ]}. - -%% -%% Enable modules with custom options in a specific virtual host -%% -%%{host_config, "localhost", -%% [{{add, modules}, -%% [ -%% {mod_echo, [{host, "mirror.localhost"}]} -%% ] -%% } -%% ]}. - - -%%%. -%%%' - -%%% $Id$ - -%%% Local Variables: -%%% mode: erlang -%%% End: -%%% vim: set filetype=erlang tabstop=8 foldmarker=%%%',%%%. foldmethod=marker: diff --git a/ejabberd.yml.example b/ejabberd.yml.example new file mode 100644 index 000000000..aa152e6ef --- /dev/null +++ b/ejabberd.yml.example @@ -0,0 +1,615 @@ +### +### ejabberd configuration file +### +### + +### The parameters used in this configuration file are explained in more detail +### in the ejabberd Installation and Operation Guide. +### Please consult the Guide in case of doubts, it is included with +### your copy of ejabberd, and is also available online at +### http://www.process-one.net/en/ejabberd/docs/ + +### The configuration file is written in YAML. +### Refer to http://en.wikipedia.org/wiki/YAML for the brief description. +### However, ejabberd treats different literals as different types: +### +### - unquoted or single-quoted strings. They are called "atoms". +### Example: dog, 'Jupiter', '3.14159', YELLOW +### +### - numeric literals. Example: 3, -45.0, .0 +### +### - quoted or folded strings. +### Examples of quoted string: "Lizzard", "orange". +### Example of folded string: +### > Art thou not Romeo, +### and a Montague? + +### ========= +### DEBUGGING + +## +## loglevel: Verbosity of log files generated by ejabberd. +## 0: No ejabberd log at all (not recommended) +## 1: Critical +## 2: Error +## 3: Warning +## 4: Info +## 5: Debug +## +loglevel: 4 + +## +## watchdog_admins: Only useful for developers: if an ejabberd process +## consumes a lot of memory, send live notifications to these XMPP +## accounts. +## +## watchdog_admins: +## - "bob@example.com" + + +### ================ +### SERVED HOSTNAMES + +## +## hosts: Domains served by ejabberd. +## You can define one or several, for example: +## hosts: +## - "example.net" +## - "example.com" +## - "example.org" +## +hosts: + - "localhost" + +## +## route_subdomains: Delegate subdomains to other XMPP servers. +## For example, if this ejabberd serves example.org and you want +## to allow communication with an XMPP server called im.example.org. +## +## route_subdomains: s2s + +### =============== +### LISTENING PORTS + +## +## listen: The ports ejabberd will listen on, which service each is handled +## by and what options to start it with. +## +listen: + - + port: 5222 + module: ejabberd_c2s + ## + ## If TLS is compiled in and you installed a SSL + ## certificate, specify the full path to the + ## file and uncomment this line: + ## + ## certfile: "/path/to/ssl.pem" + ## starttls: true + max_stanza_size: 65536 + shaper: c2s_shaper + access: c2s + - + port: 5269 + module: ejabberd_s2s_in + ## + ## ejabberd_service: Interact with external components (transports, ...) + ## + ## - + ## port: 8888 + ## module: ejabberd_service + ## access: all + ## shaper_rule: fast + ## ip: "127.0.0.1" + ## hosts: + ## "icq.example.org": + ## password: "secret" + ## "sms.example.org": + ## password: "secret" + + ## + ## ejabberd_stun: Handles STUN Binding requests + ## + ## - + ## port: 3478 + ## transport: udp + ## module: ejabberd_stun + + ## + ## To handle XML-RPC requests that provide admin credentials: + ## + ## - + ## port: 4560 + ## module: ejabberd_xmlrpc + - + port: 5280 + module: ejabberd_http + ## request_handlers: + ## "/pub/archive": mod_http_fileserver + web_admin: true + http_poll: true + http_bind: true + ## register: true + captcha: true + +## +## s2s_use_starttls: Enable STARTTLS + Dialback for S2S connections. +## Allowed values are: false optional required required_trusted +## You must specify a certificate file. +## +## s2s_use_starttls: optional + +## +## s2s_certfile: Specify a certificate file. +## +## s2s_certfile: "/path/to/ssl.pem" + +## +## domain_certfile: Specify a different certificate for each served hostname. +## +## host_config: +## "example.org": +## domain_certfile: "/path/to/example_org.pem" +## "example.com": +## domain_certfile: "/path/to/example_com.pem" + +## +## S2S whitelist or blacklist +## +## Default s2s policy for undefined hosts. +## +## s2s_policy: s2s_access + +## +## Outgoing S2S options +## +## Preferred address families (which to try first) and connect timeout +## in milliseconds. +## +## outgoing_s2s_families: +## - ipv4 +## - ipv6 +## outgoing_s2s_timeout: 10000 + +### ============== +### AUTHENTICATION + +## +## auth_method: Method used to authenticate the users. +## The default method is the internal. +## If you want to use a different method, +## comment this line and enable the correct ones. +## +auth_method: internal + +## +## Store the plain passwords or hashed for SCRAM: +## auth_password_format: plain +## auth_password_format: scram +## +## Define the FQDN if ejabberd doesn't detect it: +## fqdn: "server3.example.com" + +## +## Authentication using external script +## Make sure the script is executable by ejabberd. +## +## auth_method: external +## extauth_program: "/path/to/authentication/script" + +## +## Authentication using ODBC +## Remember to setup a database in the next section. +## +## auth_method: odbc + +## +## Authentication using PAM +## +## auth_method: pam +## pam_service: "pamservicename" + +## +## Authentication using LDAP +## +## auth_method: ldap +## +## List of LDAP servers: +## ldap_servers: +## - "localhost" +## +## Encryption of connection to LDAP servers: +## ldap_encrypt: none +## ldap_encrypt: tls +## +## Port to connect to on LDAP servers: +## ldap_port: 389 +## ldap_port: 636 +## +## LDAP manager: +## ldap_rootdn: "dc=example,dc=com" +## +## Password of LDAP manager: +## ldap_password: "******" +## +## Search base of LDAP directory: +## ldap_base: "dc=example,dc=com" +## +## LDAP attribute that holds user ID: +## ldap_uids: +## - "mail": "%u@mail.example.org" +## +## LDAP filter: +## ldap_filter: "(objectClass=shadowAccount)" + +## +## Anonymous login support: +## auth_method: anonymous +## anonymous_protocol: sasl_anon | login_anon | both +## allow_multiple_connections: true | false +## +## host_config: +## "public.example.org": +## auth_method: anonymous +## allow_multiple_connections: false +## anonymous_protocol: sasl_anon +## +## To use both anonymous and internal authentication: +## +## host_config: +## "public.example.org": +## auth_method: +## - internal +## - anonymous + +### ============== +### DATABASE SETUP + +## ejabberd by default uses the internal Mnesia database, +## so you do not necessarily need this section. +## This section provides configuration examples in case +## you want to use other database backends. +## Please consult the ejabberd Guide for details on database creation. + +## +## MySQL server: +## +## odbc_type: mysql +## odbc_server: "server" +## odbc_database: "database" +## odbc_username: "username" +## odbc_password: "password" +## +## If you want to specify the port: +## odbc_port: 1234 + +## +## PostgreSQL server: +## +## odbc_type: pgsql +## odbc_server: "server" +## odbc_database: "database" +## odbc_username: "username" +## odbc_password: "password" +## +## If you want to specify the port: +## odbc_port: 1234 +## +## If you use PostgreSQL, have a large database, and need a +## faster but inexact replacement for "select count(*) from users" +## +## pgsql_users_number_estimate: true + +## +## ODBC compatible or MSSQL server: +## +## odbc_type: odbc +## odbc_server: "DSN=ejabberd;UID=ejabberd;PWD=ejabberd" + +## +## Number of connections to open to the database for each virtual host +## +## odbc_pool_size: 10 + +## +## Interval to make a dummy SQL request to keep the connections to the +## database alive. Specify in seconds: for example 28800 means 8 hours +## +## odbc_keepalive_interval: undefined + +### =============== +### TRAFFIC SHAPERS + +shaper: + ## + ## The "normal" shaper limits traffic speed to 1000 B/s + ## + normal: 1000 + + ## + ## The "fast" shaper limits traffic speed to 50000 B/s + ## + fast: 50000 + +## +## This option specifies the maximum number of elements in the queue +## of the FSM. Refer to the documentation for details. +## +max_fsm_queue: 1000 + +###. ==================== +###' ACCESS CONTROL LISTS +acl: + ## + ## The 'admin' ACL grants administrative privileges to XMPP accounts. + ## You can put here as many accounts as you want. + ## + ## admin: + ## user: + ## - "aleksey": "localhost" + ## - "ermine": "example.org" + ## + ## Blocked users + ## + ## blocked: + ## user: + ## - "baduser": "example.org" + ## - "test": global + + ## Local users: don't modify this. + ## + local: + user_regexp: + - "": global + + ## + ## More examples of ACLs + ## + ## jabberorg: + ## server: + ## - "jabber.org" + ## aleksey: + ## user: + ## - "aleksey": "jabber.ru" + ## test: + ## user_regexp: + ## - "^test": global + ## user_glob: + ## - "test*": global + + ## + ## Loopback network + ## + loopback: + ip: + - "127.0.0.0/8" + + ## + ## Bad XMPP servers + ## + ## bad_servers: + ## server: + ## - "xmpp.zombie.org" + ## - "xmpp.spam.com" + +## +## Define specific ACLs in a virtual host. +## +## host_config: +## "localhost": +## acl: +## admin: +## user: +## - "bob-local": "localhost" + +### ============ +### ACCESS RULES +access: + ## Maximum number of simultaneous sessions allowed for a single user: + max_user_sessions: + all: 10 + ## Maximum number of offline messages that users can have: + max_user_offline_messages: + admin: 5000 + all: 100 + ## This rule allows access only for local users: + local: + local: allow + ## Only non-blocked users can use c2s connections: + c2s: + blocked: deny + all: allow + ## For C2S connections, all users except admins use the "normal" shaper + c2s_shaper: + admin: none + all: normal + ## All S2S connections use the "fast" shaper + s2s_shaper: + all: fast + ## Only admins can send announcement messages: + announce: + admin: allow + ## Only admins can use the configuration interface: + configure: + admin: allow + ## Admins of this server are also admins of the MUC service: + muc_admin: + admin: allow + ## Only accounts of the local ejabberd server can create rooms: + muc_create: + local: allow + ## All users are allowed to use the MUC service: + muc: + all: allow + ## Only accounts on the local ejabberd server can create Pubsub nodes: + pubsub_createnode: + local: allow + ## In-band registration allows registration of any possible username. + ## To disable in-band registration, replace 'allow' with 'deny'. + register: + all: allow + ## Only allow to register from localhost + trusted_network: + loopback: allow + ## Do not establish S2S connections with bad servers + ## s2s_access: + ## bad_servers: deny + ## all: allow + +## By default the frequency of account registrations from the same IP +## is limited to 1 account every 10 minutes. To disable, specify: infinity +## registration_timeout: 600 + +## +## Define specific Access Rules in a virtual host. +## +## host_config: +## "localhost": +## access: +## c2s: +## admin: allow +## all: deny +## register: +## all: deny + +### ================ +### DEFAULT LANGUAGE + +## +## language: Default language used for server messages. +## +language: "en" + +## +## Set a different default language in a virtual host. +## +## host_config: +## "localhost": +## language: "ru" + +### ======= +### CAPTCHA + +## +## Full path to a script that generates the image. +## +## captcha_cmd: "/lib/ejabberd/priv/bin/captcha.sh" + +## +## Host for the URL and port where ejabberd listens for CAPTCHA requests. +## +## captcha_host: "example.org:5280" + +## +## Limit CAPTCHA calls per minute for JID/IP to avoid DoS. +## +## captcha_limit: 5 + +### ======= +### MODULES + +## +## Modules enabled in all ejabberd virtual hosts. +## +modules: + mod_adhoc: {} + mod_announce: # recommends mod_adhoc + access: announce + mod_blocking: {} # requires mod_privacy + mod_caps: {} + mod_configure: {} # requires mod_adhoc + mod_disco: {} + ## mod_echo: {} + mod_irc: {} + mod_http_bind: {} + ## mod_http_fileserver: + ## docroot: "/var/www" + ## accesslog: "/var/log/ejabberd/access.log" + mod_last: {} + mod_muc: + ## host: "conference.@HOST@" + access: muc + access_create: muc_create + access_persistent: muc_create + access_admin: muc_admin + ## mod_muc_log: {} + mod_offline: + access_max_user_messages: max_user_offline_messages + mod_ping: {} + ## mod_pres_counter: + ## count: 5 + ## interval: 60 + mod_privacy: {} + mod_private: {} + ## mod_proxy65: {} + mod_pubsub: + access_createnode: pubsub_createnode + ## reduces resource comsumption, but XEP incompliant + ignore_pep_from_offline: true + ## XEP compliant, but increases resource comsumption + ## ignore_pep_from_offline: false + last_item_cache: false + plugins: + - "flat" + - "hometree" + - "pep" # pep requires mod_caps + mod_register: + ## + ## Protect In-Band account registrations with CAPTCHA. + ## + ## captcha_protected: true + + ## + ## Set the minimum informational entropy for passwords. + ## + ## password_strength: 32 + + ## + ## After successful registration, the user receives + ## a message with this subject and body. + ## + welcome_message: + subject: "Welcome!" + body: |- + Hi. + Welcome to this XMPP server. + + ## + ## When a user registers, send a notification to + ## these XMPP accounts. + ## + ## registration_watchers: + ## - "admin1@example.org" + + ## + ## Only clients in the server machine can register accounts + ## + ip_access: trusted_network + + ## + ## Local c2s or remote s2s users cannot register accounts + ## + ## access_from: deny + + access: register + mod_roster: {} + mod_shared_roster: {} + mod_stats: {} + mod_time: {} + mod_vcard: {} + mod_version: {} + +## +## Enable modules with custom options in a specific virtual host +## +## host_config: +## "localhost": +## add: +## modules: +## mod_echo: +## host: "mirror.localhost" + +### Local Variables: +### mode: yaml +### End: +### vim: set filetype=yaml tabstop=8 diff --git a/ejabberdctl.template b/ejabberdctl.template index b0f5a4b3f..e77196dfc 100755 --- a/ejabberdctl.template +++ b/ejabberdctl.template @@ -65,7 +65,7 @@ if [ -f "$EJABBERDCTL_CONFIG_PATH" ] ; then . "$EJABBERDCTL_CONFIG_PATH" fi if [ "$EJABBERD_CONFIG_PATH" = "" ] ; then - EJABBERD_CONFIG_PATH=$ETCDIR/ejabberd.cfg + EJABBERD_CONFIG_PATH=$ETCDIR/ejabberd.yml fi if [ "$LOGS_DIR" = "" ] ; then LOGS_DIR={{localstatedir}}/log/ejabberd diff --git a/rebar.config.script b/rebar.config.script index a814506e5..da838689d 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -56,6 +56,7 @@ Deps = [{p1_cache_tab, ".*", {git, "git://github.com/processone/cache_tab"}}, {p1_tls, ".*", {git, "git://github.com/processone/tls"}}, {p1_stringprep, ".*", {git, "git://github.com/processone/stringprep"}}, {p1_xml, ".*", {git, "git://github.com/processone/xml"}}, + {p1_yaml, ".*", {git, "git://github.com/processone/p1_yaml"}}, {xmlrpc, ".*", {git, "git://github.com/rds13/xmlrpc"}}], ConfigureCmd = fun(Pkg, Flags) -> diff --git a/rel/reltool.config.script b/rel/reltool.config.script index 517258660..ad647c74b 100644 --- a/rel/reltool.config.script +++ b/rel/reltool.config.script @@ -28,7 +28,7 @@ ConfiguredOTPApps = lists:flatmap( OTPApps = RequiredOTPApps ++ ConfiguredOTPApps, -DepRequiredApps = [p1_cache_tab, p1_tls, p1_stringprep, p1_xml, xmlrpc], +DepRequiredApps = [p1_cache_tab, p1_tls, p1_stringprep, p1_xml, p1_yaml, xmlrpc], DepConfiguredApps = lists:flatmap( fun({mysql, true}) -> [p1_mysql]; @@ -39,7 +39,7 @@ DepConfiguredApps = lists:flatmap( ({json, true}) -> [jiffy]; ({iconv, true}) -> [p1_iconv]; ({http, true}) -> [ibrowse, lhttpc]; - ({lager, true}) -> [lager]; + ({lager, true}) -> [lager, goldrush]; ({lager, false}) -> [p1_logger]; (_) -> [] end, Vars), @@ -89,7 +89,7 @@ Overlay = [ {template, "files/erl", "\{\{erts_vsn\}\}/bin/erl"}, {template, "../ejabberdctl.template", "bin/ejabberdctl"}, {copy, "../ejabberdctl.cfg.example", "etc/ejabberd/ejabberdctl.cfg"}, - {copy, "../ejabberd.cfg.example", "etc/ejabberd/ejabberd.cfg"}, + {copy, "../ejabberd.yml.example", "etc/ejabberd/ejabberd.yml"}, {copy, "../inetrc", "etc/ejabberd/inetrc"}, {copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"} ], diff --git a/src/acl.erl b/src/acl.erl index 1338e55b6..4c4523617 100644 --- a/src/acl.erl +++ b/src/acl.erl @@ -29,35 +29,38 @@ -author('alexey@process-one.net'). -export([start/0, to_record/3, add/3, add_list/3, - add_local/3, add_list_local/3, - match_rule/3, match_acl/3]). + add_local/3, add_list_local/3, load_from_config/0, + match_rule/3, match_acl/3, transform_options/1]). -include("ejabberd.hrl"). -include("logger.hrl"). -include("jlib.hrl"). -record(acl, {aclname, aclspec}). +-record(access, {name :: access_name(), + rules = [] :: [access_rule()]}). -type regexp() :: binary(). -type glob() :: binary(). +-type access_name() :: atom(). +-type access_rule() :: {atom(), any()}. +-type host() :: binary(). -type aclname() :: {atom(), binary() | global}. -type aclspec() :: all | none | - {user, binary()} | - {user, binary(), binary()} | + {user, {binary(), host()} | binary()} | {server, binary()} | {resource, binary()} | - {user_regexp, regexp()} | - {shared_group, binary()} | - {shared_group, binary(), binary()} | - {user_regexp, regexp(), binary()} | + {user_regexp, {regexp(), host()} | regexp()} | + {shared_group, {binary(), host()} | binary()} | + {user_regexp, {regexp(), host()} | regexp()} | {server_regexp, regexp()} | {resource_regexp, regexp()} | - {node_regexp, regexp(), regexp()} | - {user_glob, glob()} | - {user_glob, glob(), binary()} | + {node_regexp, {regexp(), regexp()}} | + {user_glob, {glob(), host()} | glob()} | {server_glob, glob()} | {resource_glob, glob()} | - {node_glob, glob(), glob()}. + {ip, {inet:ip_address(), integer()}} | + {node_glob, {glob(), glob()}}. -type acl() :: #acl{aclname :: aclname(), aclspec :: aclspec()}. @@ -65,12 +68,23 @@ -export_type([acl/0]). start() -> + case catch mnesia:table_info(acl, storage_type) of + disc_copies -> + mnesia:delete_table(acl); + _ -> + ok + end, mnesia:create_table(acl, - [{disc_copies, [node()]}, {type, bag}, + [{ram_copies, [node()]}, {type, bag}, {local_content, true}, {attributes, record_info(fields, acl)}]), + mnesia:create_table(access, + [{ram_copies, [node()]}, + {local_content, true}, + {attributes, record_info(fields, access)}]), mnesia:add_table_copy(acl, node(), ram_copies), - update_table(), + mnesia:add_table_copy(access, node(), ram_copies), + load_from_config(), ok. -spec to_record(binary(), atom(), aclspec()) -> acl(). @@ -82,7 +96,7 @@ to_record(Host, ACLName, ACLSpec) -> -spec add(binary(), aclname(), aclspec()) -> ok | {error, any()}. add(Host, ACLName, ACLSpec) -> - {ResL, BadNodes} = rpc:multicall(ejabberd_cluster:get_nodes(), + {ResL, BadNodes} = rpc:multicall(mnesia:system_info(running_db_nodes), ?MODULE, add_local, [Host, ACLName, ACLSpec]), case lists:keyfind(aborted, 1, ResL) of @@ -109,7 +123,7 @@ add_local(Host, ACLName, ACLSpec) -> -spec add_list(binary(), [acl()], boolean()) -> ok | {error, any()}. add_list(Host, ACLs, Clear) -> - {ResL, BadNodes} = rpc:multicall(ejabberd_cluster:get_nodes(), + {ResL, BadNodes} = rpc:multicall(mnesia:system_info(running_db_nodes), ?MODULE, add_list_local, [Host, ACLs, Clear]), case lists:keyfind(aborted, 1, ResL) of @@ -147,130 +161,196 @@ add_list_local(Host, ACLs, Clear) -> end, mnesia:transaction(F). -normalize(A) -> jlib:nodeprep(iolist_to_binary(A)). +-spec add_access(binary() | global, + access_name(), [access_rule()]) -> ok | {error, any()}. -normalize_spec({A, B}) -> {A, normalize(B)}; -normalize_spec({A, B, C}) -> - {A, normalize(B), normalize(C)}; -normalize_spec(all) -> all; -normalize_spec(none) -> none. +add_access(Host, Access, Rules) -> + case mnesia:transaction( + fun() -> + mnesia:write( + #access{name = {Access, Host}, + rules = Rules}) + end) of + {atomic, ok} -> + ok; + Err -> + {error, Err} + end. --spec match_rule(global | binary(), atom(), jid() | ljid()) -> any(). +-spec load_from_config() -> ok. -match_rule(global, Rule, JID) -> - case Rule of - all -> allow; - none -> deny; - _ -> - case ejabberd_config:get_global_option( - {access, Rule, global}, fun(V) -> V end) - of - undefined -> deny; - GACLs -> match_acls(GACLs, JID, global) - end - end; -match_rule(Host, Rule, JID) -> - case Rule of - all -> allow; - none -> deny; - _ -> - case ejabberd_config:get_global_option( - {access, Rule, global}, fun(V) -> V end) - of - undefined -> - case ejabberd_config:get_global_option( - {access, Rule, Host}, fun(V) -> V end) - of - undefined -> deny; - ACLs -> match_acls(ACLs, JID, Host) - end; - GACLs -> - case ejabberd_config:get_global_option( - {access, Rule, Host}, fun(V) -> V end) - of - undefined -> match_acls(GACLs, JID, Host); - ACLs -> - case lists:reverse(GACLs) of - [{allow, all} | Rest] -> - match_acls(lists:reverse(Rest) ++ - ACLs ++ [{allow, all}], - JID, Host); - _ -> match_acls(GACLs ++ ACLs, JID, Host) - end - end - end +load_from_config() -> + Hosts = [global|?MYHOSTS], + lists:foreach( + fun(Host) -> + ACLs = ejabberd_config:get_option( + {acl, Host}, fun(V) -> V end, []), + AccessRules = ejabberd_config:get_option( + {access, Host}, fun(V) -> V end, []), + lists:foreach( + fun({ACLName, SpecList}) -> + lists:foreach( + fun({ACLType, ACLSpecs}) when is_list(ACLSpecs) -> + lists:foreach( + fun(ACLSpec) -> + add(Host, ACLName, + {ACLType, ACLSpec}) + end, lists:flatten(ACLSpecs)); + ({ACLType, ACLSpecs}) -> + add(Host, ACLName, {ACLType, ACLSpecs}) + end, lists:flatten(SpecList)) + end, ACLs), + lists:foreach( + fun({Access, Rules}) -> + add_access(Host, Access, Rules) + end, AccessRules) + end, Hosts). + +b(S) -> + iolist_to_binary(S). + +nodeprep(S) -> + jlib:nodeprep(b(S)). + +nameprep(S) -> + jlib:nameprep(b(S)). + +resourceprep(S) -> + jlib:resourceprep(b(S)). + +normalize_spec(Spec) -> + case Spec of + all -> all; + none -> none; + {user, {U, S}} -> {user, {nodeprep(U), nameprep(S)}}; + {user, U} -> {user, nodeprep(U)}; + {shared_group, {G, H}} -> {shared_group, {b(G), nameprep(H)}}; + {shared_group, G} -> {shared_group, b(G)}; + {user_regexp, {UR, S}} -> {user_regexp, {b(UR), nameprep(S)}}; + {user_regexp, UR} -> {user_regexp, b(UR)}; + {node_regexp, {UR, SR}} -> {node_regexp, {b(UR), b(SR)}}; + {user_glob, {UR, S}} -> {user_glob, {b(UR), nameprep(S)}}; + {user_glob, UR} -> {user_glob, b(UR)}; + {node_glob, {UR, SR}} -> {node_glob, {b(UR), b(SR)}}; + {server, S} -> {server, nameprep(S)}; + {resource, R} -> {resource, resourceprep(R)}; + {server_regexp, SR} -> {server_regexp, b(SR)}; + {server_glob, S} -> {server_glob, b(S)}; + {resource_glob, R} -> {resource_glob, b(R)}; + {ip, S} -> + case parse_ip_netmask(b(S)) of + {ok, Net, Mask} -> + {ip, {Net, Mask}}; + error -> + ?INFO_MSG("Invalid network address: ~p", [S]), + none + end + end. + +-spec match_rule(global | binary(), access_name(), + jid() | ljid() | inet:ip_address()) -> any(). + +match_rule(_Host, all, _JID) -> + allow; +match_rule(_Host, none, _JID) -> + deny; +match_rule(Host, Access, JID) -> + GAccess = ets:lookup(access, {Access, global}), + LAccess = if Host /= global -> + ets:lookup(access, {Access, Host}); + true -> + [] + end, + case GAccess ++ LAccess of + [] -> + ?WARNING_MSG("Attempt to match against unspecified " + "access rule '~s' (scope: ~s)", + [Access, Host]), + deny; + AccessList -> + Rules = lists:flatmap( + fun(#access{rules = Rs}) -> + Rs + end, AccessList), + match_acls(Rules, JID, Host) end. match_acls([], _, _Host) -> deny; -match_acls([{Access, ACL} | ACLs], JID, Host) -> +match_acls([{ACL, Access} | ACLs], JID, Host) -> case match_acl(ACL, JID, Host) of true -> Access; _ -> match_acls(ACLs, JID, Host) end. --spec match_acl(atom(), jid() | ljid(), binary()) -> boolean(). +-spec match_acl(atom(), + jid() | ljid() | inet:ip_address(), + binary()) -> boolean(). +match_acl(all, _JID, _Host) -> + true; +match_acl(none, _JID, _Host) -> + false; +match_acl(ACL, IP, Host) when tuple_size(IP) == 4; + tuple_size(IP) == 8 -> + lists:any( + fun(#acl{aclspec = {ip, {Net, Mask}}}) -> + is_ip_match(IP, Net, Mask); + (_) -> + false + end, + ets:lookup(acl, {ACL, Host}) ++ + ets:lookup(acl, {ACL, global})); match_acl(ACL, JID, Host) -> - case ACL of - all -> true; - none -> false; - _ -> - {User, Server, Resource} = jlib:jid_tolower(JID), - lists:any(fun (#acl{aclspec = Spec}) -> - case Spec of - all -> true; - {user, U} -> - U == User andalso - (Host == Server orelse - Host == global andalso - lists:member(Server, ?MYHOSTS)); - {user, U, S} -> U == User andalso S == Server; - {server, S} -> S == Server; - {resource, R} -> R == Resource; - {user_regexp, UR} -> - (Host == Server orelse - Host == global andalso - lists:member(Server, ?MYHOSTS)) - andalso is_regexp_match(User, UR); - {shared_group, G} -> - Mod = loaded_shared_roster_module(Host), - Mod:is_user_in_group({User, Server}, G, Host); - {shared_group, G, H} -> - Mod = loaded_shared_roster_module(H), - Mod:is_user_in_group({User, Server}, G, H); - {user_regexp, UR, S} -> - S == Server andalso is_regexp_match(User, UR); - {server_regexp, SR} -> - is_regexp_match(Server, SR); - {resource_regexp, RR} -> - is_regexp_match(Resource, RR); - {node_regexp, UR, SR} -> - is_regexp_match(Server, SR) andalso - is_regexp_match(User, UR); - {user_glob, UR} -> - (Host == Server orelse - Host == global andalso - lists:member(Server, ?MYHOSTS)) - andalso is_glob_match(User, UR); - {user_glob, UR, S} -> - S == Server andalso is_glob_match(User, UR); - {server_glob, SR} -> is_glob_match(Server, SR); - {resource_glob, RR} -> - is_glob_match(Resource, RR); - {node_glob, UR, SR} -> - is_glob_match(Server, SR) andalso - is_glob_match(User, UR); - WrongSpec -> - ?ERROR_MSG("Wrong ACL expression: ~p~nCheck your " - "config file and reload it with the override_a" - "cls option enabled", - [WrongSpec]), - false - end - end, - ets:lookup(acl, {ACL, global}) ++ - ets:lookup(acl, {ACL, Host})) - end. + {User, Server, Resource} = jlib:jid_tolower(JID), + lists:any( + fun(#acl{aclspec = Spec}) -> + case Spec of + all -> true; + {user, {U, S}} -> U == User andalso S == Server; + {user, U} -> + U == User andalso + lists:member(Server, ?MYHOSTS); + {server, S} -> S == Server; + {resource, R} -> R == Resource; + {shared_group, {G, H}} -> + Mod = loaded_shared_roster_module(H), + Mod:is_user_in_group({User, Server}, G, H); + {shared_group, G} -> + Mod = loaded_shared_roster_module(Host), + Mod:is_user_in_group({User, Server}, G, Host); + {user_regexp, {UR, S}} -> + S == Server andalso is_regexp_match(User, UR); + {user_regexp, UR} -> + lists:member(Server, ?MYHOSTS) + andalso is_regexp_match(User, UR); + {server_regexp, SR} -> + is_regexp_match(Server, SR); + {resource_regexp, RR} -> + is_regexp_match(Resource, RR); + {node_regexp, {UR, SR}} -> + is_regexp_match(Server, SR) andalso + is_regexp_match(User, UR); + {user_glob, {UR, S}} -> + S == Server andalso is_glob_match(User, UR); + {user_glob, UR} -> + lists:member(Server, ?MYHOSTS) + andalso is_glob_match(User, UR); + {server_glob, SR} -> is_glob_match(Server, SR); + {resource_glob, RR} -> + is_glob_match(Resource, RR); + {node_glob, {UR, SR}} -> + is_glob_match(Server, SR) andalso + is_glob_match(User, UR); + WrongSpec -> + ?ERROR_MSG("Wrong ACL expression: ~p~nCheck your " + "config file and reload it with the override_a" + "cls option enabled", + [WrongSpec]), + false + end + end, + ets:lookup(acl, {ACL, Host}) ++ + ets:lookup(acl, {ACL, global})). is_regexp_match(String, RegExp) -> case ejabberd_regexp:run(String, RegExp) of @@ -286,34 +366,115 @@ is_glob_match(String, Glob) -> is_regexp_match(String, ejabberd_regexp:sh_to_awk(Glob)). +is_ip_match({_, _, _, _} = IP, {_, _, _, _} = Net, Mask) -> + IPInt = ip_to_integer(IP), + NetInt = ip_to_integer(Net), + M = bnot (1 bsl (32 - Mask) - 1), + IPInt band M =:= NetInt band M; +is_ip_match({_, _, _, _, _, _, _, _} = IP, + {_, _, _, _, _, _, _, _} = Net, Mask) -> + IPInt = ip_to_integer(IP), + NetInt = ip_to_integer(Net), + M = bnot (1 bsl (128 - Mask) - 1), + IPInt band M =:= NetInt band M; +is_ip_match(_, _, _) -> + false. + +ip_to_integer({IP1, IP2, IP3, IP4}) -> + IP1 bsl 8 bor IP2 bsl 8 bor IP3 bsl 8 bor IP4; +ip_to_integer({IP1, IP2, IP3, IP4, IP5, IP6, IP7, + IP8}) -> + IP1 bsl 16 bor IP2 bsl 16 bor IP3 bsl 16 bor IP4 bsl 16 + bor IP5 + bsl 16 + bor IP6 + bsl 16 + bor IP7 + bsl 16 + bor IP8. + loaded_shared_roster_module(Host) -> case gen_mod:is_loaded(Host, mod_shared_roster_ldap) of true -> mod_shared_roster_ldap; false -> mod_shared_roster end. -update_table() -> - Fields = record_info(fields, acl), - case mnesia:table_info(acl, attributes) of - Fields -> - ejabberd_config:convert_table_to_binary( - acl, Fields, bag, - fun(#acl{aclspec = Spec}) when is_tuple(Spec) -> - element(2, Spec); - (_) -> - '$next' - end, - fun(#acl{aclname = {ACLName, Host}, - aclspec = Spec} = R) -> - NewHost = if Host == global -> - Host; - true -> - iolist_to_binary(Host) - end, - R#acl{aclname = {ACLName, NewHost}, - aclspec = normalize_spec(Spec)} - end); - _ -> - ?INFO_MSG("Recreating acl table", []), - mnesia:transform_table(acl, ignore, Fields) +parse_ip_netmask(S) -> + case str:tokens(S, <<"/">>) of + [IPStr] -> + case inet_parse:address(binary_to_list(IPStr)) of + {ok, {_, _, _, _} = IP} -> {ok, IP, 32}; + {ok, {_, _, _, _, _, _, _, _} = IP} -> {ok, IP, 128}; + _ -> error + end; + [IPStr, MaskStr] -> + case catch jlib:binary_to_integer(MaskStr) of + Mask when is_integer(Mask), Mask >= 0 -> + case inet_parse:address(binary_to_list(IPStr)) of + {ok, {_, _, _, _} = IP} when Mask =< 32 -> + {ok, IP, Mask}; + {ok, {_, _, _, _, _, _, _, _} = IP} when Mask =< 128 -> + {ok, IP, Mask}; + _ -> error + end; + _ -> error + end; + _ -> error end. + +transform_options(Opts) -> + Opts1 = lists:foldl(fun transform_options/2, [], Opts), + {ACLOpts, Opts2} = lists:mapfoldl( + fun({acl, Os}, Acc) -> + {Os, Acc}; + (O, Acc) -> + {[], [O|Acc]} + end, [], Opts1), + {AccessOpts, Opts3} = lists:mapfoldl( + fun({access, Os}, Acc) -> + {Os, Acc}; + (O, Acc) -> + {[], [O|Acc]} + end, [], Opts2), + ACLOpts1 = ejabberd_config:collect_options(lists:flatten(ACLOpts)), + AccessOpts1 = case ejabberd_config:collect_options( + lists:flatten(AccessOpts)) of + [] -> []; + L1 -> [{access, L1}] + end, + ACLOpts2 = case lists:map( + fun({ACLName, Os}) -> + {ACLName, ejabberd_config:collect_options(Os)} + end, ACLOpts1) of + [] -> []; + L2 -> [{acl, L2}] + end, + ACLOpts2 ++ AccessOpts1 ++ Opts3. + +transform_options({acl, Name, Type}, Opts) -> + T = case Type of + all -> all; + none -> none; + {user, U} -> {user, [U]}; + {user, U, S} -> {user, [[{U, S}]]}; + {shared_group, G} -> {shared_group, [G]}; + {shared_group, G, H} -> {shared_group, [[{G, H}]]}; + {user_regexp, UR} -> {user_regexp, [UR]}; + {user_regexp, UR, S} -> {user_regexp, [[{UR, S}]]}; + {node_regexp, UR, SR} -> {node_regexp, [[{UR, SR}]]}; + {user_glob, UR} -> {user_glob, [UR]}; + {user_glob, UR, S} -> {user_glob, [[{UR, S}]]}; + {node_glob, UR, SR} -> {node_glob, [[{UR, SR}]]}; + {server, S} -> {server, [S]}; + {resource, R} -> {resource, [R]}; + {server_regexp, SR} -> {server_regexp, [SR]}; + {server_glob, S} -> {server_glob, [S]}; + {ip, S} -> {ip, [S]}; + {resource_glob, R} -> {resource_glob, [R]} + end, + [{acl, [{Name, [T]}]}|Opts]; +transform_options({access, Name, Rules}, Opts) -> + NewRules = [{ACL, Action} || {Action, ACL} <- Rules], + [{access, [{Name, NewRules}]}|Opts]; +transform_options(Opt, Opts) -> + [Opt|Opts]. diff --git a/src/cyrsasl_digest.erl b/src/cyrsasl_digest.erl index ecb50c159..3f7133943 100644 --- a/src/cyrsasl_digest.erl +++ b/src/cyrsasl_digest.erl @@ -204,11 +204,11 @@ get_local_fqdn() -> Str when is_binary(Str) -> Str; _ -> <<"unknown-fqdn, please configure fqdn " - "option in ejabberd.cfg!">> + "option in ejabberd.yml!">> end. get_local_fqdn2() -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( fqdn, fun iolist_to_binary/1) of ConfiguredFqdn when is_binary(ConfiguredFqdn) -> ConfiguredFqdn; diff --git a/src/ejabberd_admin.erl b/src/ejabberd_admin.erl index 5218d588a..a21331536 100644 --- a/src/ejabberd_admin.erl +++ b/src/ejabberd_admin.erl @@ -164,6 +164,12 @@ commands() -> module = ejd2odbc, function = export, args = [{host, string}, {file, string}], result = {res, rescode}}, + #ejabberd_commands{name = convert_to_yaml, tags = [config], + desc = "Convert the input file from Erlang to YAML format", + module = ejabberd_config, function = convert_to_yaml, + args = [{in, string}, {out, string}], + result = {res, rescode}}, + #ejabberd_commands{name = delete_expired_messages, tags = [purge], desc = "Delete expired offline messages from database", module = ?MODULE, function = delete_expired_messages, diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index ed67f0335..dba61b7d9 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -47,12 +47,14 @@ start(normal, _Args) -> db_init(), start(), translate:start(), - acl:start(), ejabberd_ctl:init(), ejabberd_commands:init(), ejabberd_admin:start(), gen_mod:start(), ejabberd_config:start(), + set_loglevel_from_config(), + acl:start(), + shaper:start(), connect_nodes(), Sup = ejabberd_sup:start_link(), ejabberd_rdbms:start(), @@ -119,7 +121,7 @@ db_init() -> start_modules() -> lists:foreach( fun(Host) -> - Modules = ejabberd_config:get_local_option( + Modules = ejabberd_config:get_option( {modules, Host}, fun(Mods) -> lists:map( @@ -137,7 +139,7 @@ start_modules() -> stop_modules() -> lists:foreach( fun(Host) -> - Modules = ejabberd_config:get_local_option( + Modules = ejabberd_config:get_option( {modules, Host}, fun(Mods) -> lists:map( @@ -152,7 +154,7 @@ stop_modules() -> end, ?MYHOSTS). connect_nodes() -> - Nodes = ejabberd_config:get_local_option( + Nodes = ejabberd_config:get_option( cluster_nodes, fun(Ns) -> true = lists:all(fun is_atom/1, Ns), @@ -212,9 +214,17 @@ delete_pid_file() -> file:delete(PidFilename) end. +set_loglevel_from_config() -> + Level = ejabberd_config:get_option( + loglevel, + fun(P) when P>=0, P=<5 -> P end, + 4), + ejabberd_logger:set(Level). + start_apps() -> ejabberd:start_app(sasl), ejabberd:start_app(ssl), + ejabberd:start_app(p1_yaml), ejabberd:start_app(p1_tls), ejabberd:start_app(p1_xml), ejabberd:start_app(p1_stringprep), diff --git a/src/ejabberd_auth.erl b/src/ejabberd_auth.erl index 7cc40ae1e..704c82cd4 100644 --- a/src/ejabberd_auth.erl +++ b/src/ejabberd_auth.erl @@ -423,7 +423,7 @@ auth_modules() -> %% Return the list of authenticated modules for a given host auth_modules(Server) -> LServer = jlib:nameprep(Server), - Methods = ejabberd_config:get_local_option( + Methods = ejabberd_config:get_option( {auth_method, LServer}, fun(V) when is_list(V) -> true = lists:all(fun is_atom/1, V), diff --git a/src/ejabberd_auth_anonymous.erl b/src/ejabberd_auth_anonymous.erl index d8101efc4..180e9d0df 100644 --- a/src/ejabberd_auth_anonymous.erl +++ b/src/ejabberd_auth_anonymous.erl @@ -104,7 +104,7 @@ is_login_anonymous_enabled(Host) -> %% Return the anonymous protocol to use: sasl_anon|login_anon|both %% defaults to login_anon anonymous_protocol(Host) -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( {anonymous_protocol, Host}, fun(sasl_anon) -> sasl_anon; (login_anon) -> login_anon; @@ -115,7 +115,7 @@ anonymous_protocol(Host) -> %% Return true if multiple connections have been allowed in the config file %% defaults to false allow_multiple_connections(Host) -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( {allow_multiple_connections, Host}, fun(V) when is_boolean(V) -> V end, false). diff --git a/src/ejabberd_auth_external.erl b/src/ejabberd_auth_external.erl index 2d1bb7cb9..514b551d7 100644 --- a/src/ejabberd_auth_external.erl +++ b/src/ejabberd_auth_external.erl @@ -48,7 +48,7 @@ %%% API %%%---------------------------------------------------------------------- start(Host) -> - Cmd = ejabberd_config:get_local_option( + Cmd = ejabberd_config:get_option( {extauth_program, Host}, fun(V) -> binary_to_list(iolist_to_binary(V)) @@ -171,7 +171,7 @@ remove_user(User, Server, Password) -> %% @spec (Host::string()) -> false | {true, CacheTime::integer()} get_cache_option(Host) -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( {extauth_cache, Host}, fun(I) when is_integer(I), I > 0 -> I end) of undefined -> false; diff --git a/src/ejabberd_auth_internal.erl b/src/ejabberd_auth_internal.erl index 5a6c1b10a..8d7d0a0dd 100644 --- a/src/ejabberd_auth_internal.erl +++ b/src/ejabberd_auth_internal.erl @@ -406,7 +406,7 @@ is_scrammed() -> is_option_scram() -> scram == - ejabberd_config:get_local_option({auth_password_format, ?MYNAME}, + ejabberd_config:get_option({auth_password_format, ?MYNAME}, fun(V) -> V end). maybe_alert_password_scrammed_without_option() -> diff --git a/src/ejabberd_auth_ldap.erl b/src/ejabberd_auth_ldap.erl index 1baf43887..1c1a4f313 100644 --- a/src/ejabberd_auth_ldap.erl +++ b/src/ejabberd_auth_ldap.erl @@ -369,8 +369,10 @@ parse_options(Host) -> {iolist_to_binary(U), iolist_to_binary(P)}; ({U}) -> + {iolist_to_binary(U)}; + (U) -> {iolist_to_binary(U)} - end, Us) + end, lists:flatten(Us)) end, [{<<"uid">>, <<"%u">>}]), UIDs = eldap_utils:uids_domain_subst(Host, UIDsTemp), SubFilter = eldap_utils:generate_subfilter(UIDs), diff --git a/src/ejabberd_auth_pam.erl b/src/ejabberd_auth_pam.erl index c81208494..8e744e2c4 100644 --- a/src/ejabberd_auth_pam.erl +++ b/src/ejabberd_auth_pam.erl @@ -107,13 +107,13 @@ store_type() -> external. %% Internal functions %%==================================================================== get_pam_service(Host) -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( {pam_service, Host}, fun iolist_to_binary/1, <<"ejabberd">>). get_pam_userinfotype(Host) -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( {pam_userinfotype, Host}, fun(username) -> username; (jid) -> jid diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 5e50d9bf9..610f22c24 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -47,7 +47,8 @@ del_aux_field/2, get_subscription/2, broadcast/4, - get_subscribed/1]). + get_subscribed/1, + transform_listen_option/2]). %% gen_fsm callbacks -export([init/1, @@ -233,11 +234,10 @@ init([{SockMod, Socket}, Opts]) -> {value, {_, XS}} -> XS; _ -> false end, - Zlib = lists:member(zlib, Opts), - StartTLS = lists:member(starttls, Opts), - StartTLSRequired = lists:member(starttls_required, - Opts), - TLSEnabled = lists:member(tls, Opts), + Zlib = proplists:get_bool(zlib, Opts), + StartTLS = proplists:get_bool(starttls, Opts), + StartTLSRequired = proplists:get_bool(starttls_required, Opts), + TLSEnabled = proplists:get_bool(tls, Opts), TLS = StartTLS orelse StartTLSRequired orelse TLSEnabled, TLSOpts1 = lists:filter(fun ({certfile, _}) -> true; @@ -682,7 +682,7 @@ wait_for_feature_request({xmlstreamelement, El}, when TLS == true, TLSEnabled == false, SockMod == gen_tcp -> TLSOpts = case - ejabberd_config:get_local_option( + ejabberd_config:get_option( {domain_certfile, StateData#state.server}, fun iolist_to_binary/1) of @@ -876,7 +876,7 @@ resource_conflict_action(U, S, R) -> R) of true -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( {resource_conflict, S}, fun(setresource) -> setresource; (closeold) -> closeold; @@ -2279,7 +2279,7 @@ fsm_limit_opts(Opts) -> case lists:keysearch(max_fsm_queue, 1, Opts) of {value, {_, N}} when is_integer(N) -> [{max_queue, N}]; _ -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( max_fsm_queue, fun(I) when is_integer(I), I > 0 -> I end) of undefined -> []; @@ -2377,3 +2377,6 @@ pack_string(String, Pack) -> {value, PackedString} -> {PackedString, Pack}; none -> {String, gb_trees:insert(String, String, Pack)} end. + +transform_listen_option(Opt, Opts) -> + [Opt|Opts]. diff --git a/src/ejabberd_c2s_config.erl b/src/ejabberd_c2s_config.erl index 4dbc48f38..2229e5ef1 100644 --- a/src/ejabberd_c2s_config.erl +++ b/src/ejabberd_c2s_config.erl @@ -34,7 +34,7 @@ %% Get first c2s configuration limitations to apply it to other c2s %% connectors. get_c2s_limits() -> - case ejabberd_config:get_local_option(listen, fun(V) -> V end) of + case ejabberd_config:get_option(listen, fun(V) -> V end) of undefined -> []; C2SFirstListen -> case lists:keysearch(ejabberd_c2s, 2, C2SFirstListen) of diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index 7442cf73c..e9a3ea3a9 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -504,7 +504,7 @@ do_create_image(Key) -> end. get_prog_name() -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( captcha_cmd, fun(FileName) -> F = iolist_to_binary(FileName), @@ -521,7 +521,7 @@ get_prog_name() -> end. get_url(Str) -> - CaptchaHost = ejabberd_config:get_local_option( + CaptchaHost = ejabberd_config:get_option( captcha_host, fun iolist_to_binary/1, <<"">>), @@ -549,7 +549,7 @@ get_transfer_protocol(PortString) -> get_captcha_transfer_protocol(PortListeners). get_port_listeners(PortNumber) -> - AllListeners = ejabberd_config:get_local_option(listen, fun(V) -> V end), + AllListeners = ejabberd_config:get_option(listen, fun(V) -> V end), lists:filter(fun ({{Port, _Ip, _Netp}, _Module1, _Opts1}) when Port == PortNumber -> @@ -579,7 +579,7 @@ get_captcha_transfer_protocol([_ | Listeners]) -> is_limited(undefined) -> false; is_limited(Limiter) -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( captcha_limit, fun(I) when is_integer(I), I > 0 -> I end) of undefined -> false; diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index b46603270..0551b49a5 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -27,16 +27,16 @@ -module(ejabberd_config). -author('alexey@process-one.net'). --export([start/0, load_file/1, +-export([start/0, load_file/1, read_file/1, add_global_option/2, add_local_option/2, get_global_option/2, get_local_option/2, get_global_option/3, get_local_option/3, - get_option/2, get_option/3, add_option/2]). --export([get_vh_by_auth_method/1]). --export([is_file_readable/1]). --export([get_version/0, get_myhosts/0, get_mylang/0]). --export([prepare_opt_val/4]). --export([convert_table_to_binary/5]). + get_option/2, get_option/3, add_option/2, + get_vh_by_auth_method/1, is_file_readable/1, + get_version/0, get_myhosts/0, get_mylang/0, + prepare_opt_val/4, convert_table_to_binary/5, + transform_options/1, collect_options/1, + convert_to_yaml/1, convert_to_yaml/2]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -53,21 +53,29 @@ start() -> + case catch mnesia:table_info(local_config, storage_type) of + disc_copies -> + mnesia:delete_table(local_config); + _ -> + ok + end, mnesia:create_table(local_config, - [{disc_copies, [node()]}, + [{ram_copies, [node()]}, {local_content, true}, {attributes, record_info(fields, local_config)}]), mnesia:add_table_copy(local_config, node(), ram_copies), Config = get_ejabberd_config_path(), - load_file(Config), + State = read_file(Config), %% This start time is used by mod_last: - add_option(node_start, now()), - ok. + {MegaSecs, Secs, _} = now(), + UnixTime = MegaSecs*1000000 + Secs, + State1 = set_option({node_start, global}, UnixTime, State), + set_opts(State1). %% @doc Get the filename of the ejabberd configuration file. -%% The filename can be specified with: erl -config "/path/to/ejabberd.cfg". +%% The filename can be specified with: erl -config "/path/to/ejabberd.yml". %% It can also be specified with the environtment variable EJABBERD_CONFIG_PATH. -%% If not specified, the default value 'ejabberd.cfg' is assumed. +%% If not specified, the default value 'ejabberd.yml' is assumed. %% @spec () -> string() get_ejabberd_config_path() -> case application:get_env(config) of @@ -81,16 +89,59 @@ get_ejabberd_config_path() -> end end. -%% @doc Load the ejabberd configuration file. +%% @doc Read the ejabberd configuration file. %% It also includes additional configuration files and replaces macros. %% This function will crash if finds some error in the configuration file. -%% @spec (File::string()) -> ok -load_file(File) -> - Terms = get_plain_terms_file(File), +%% @spec (File::string()) -> #state{}. +read_file(File) -> + read_file(File, [{replace_macros, true}, + {include_files, true}]). + +read_file(File, Opts) -> + Terms1 = get_plain_terms_file(File, Opts), + Terms_macros = case proplists:get_bool(replace_macros, Opts) of + true -> replace_macros(Terms1); + false -> Terms1 + end, + Terms = transform_terms(Terms_macros), State = lists:foldl(fun search_hosts/2, #state{}, Terms), - Terms_macros = replace_macros(Terms), - Res = lists:foldl(fun process_term/2, State, Terms_macros), - set_opts(Res). + {Head, Tail} = lists:partition( + fun({host_config, _}) -> false; + ({append_host_config, _}) -> false; + (_) -> true + end, Terms), + State1 = lists:foldl(fun process_term/2, State, Head ++ Tail), + State1#state{opts = compact(State1#state.opts)}. + +-spec load_file(string()) -> ok. + +load_file(File) -> + State = read_file(File), + set_opts(State). + +-spec convert_to_yaml(file:filename()) -> ok | {error, any()}. + +convert_to_yaml(File) -> + convert_to_yaml(File, stdout). + +-spec convert_to_yaml(file:filename(), + stdout | file:filename()) -> ok | {error, any()}. + +convert_to_yaml(File, Output) -> + State = read_file(File, [{include_files, false}]), + Opts = [{K, V} || #local_config{key = K, value = V} <- State#state.opts], + {GOpts, HOpts} = split_by_hosts(Opts), + NewOpts = GOpts ++ lists:map( + fun({Host, Opts1}) -> + {host_config, [{Host, Opts1}]} + end, HOpts), + Data = p1_yaml:encode(lists:reverse(NewOpts)), + case Output of + stdout -> + io:format("~s~n", [Data]); + FileName -> + file:write_file(FileName, Data) + end. %% @doc Read an ejabberd configuration file and return the terms. %% Input is an absolute or relative path to an ejabberd config file. @@ -99,22 +150,47 @@ load_file(File) -> %% and the terms in those files were included. %% @spec(string()) -> [term()] %% @spec(iolist()) -> [term()] -get_plain_terms_file(File) when is_binary(File) -> - get_plain_terms_file(binary_to_list(File)); -get_plain_terms_file(File1) -> +get_plain_terms_file(File) -> + get_plain_terms_file(File, [{include_files, true}]). + +get_plain_terms_file(File, Opts) when is_binary(File) -> + get_plain_terms_file(binary_to_list(File), Opts); +get_plain_terms_file(File1, Opts) -> File = get_absolute_path(File1), - case file:consult(File) of + case consult(File) of {ok, Terms} -> BinTerms = strings_to_binary(Terms), - include_config_files(BinTerms); - {error, {LineNumber, erl_parse, _ParseMessage} = Reason} -> - ExitText = describe_config_problem(File, Reason, LineNumber), - ?ERROR_MSG(ExitText, []), - exit_or_halt(ExitText); + case proplists:get_bool(include_files, Opts) of + true -> + include_config_files(BinTerms); + false -> + BinTerms + end; {error, Reason} -> - ExitText = describe_config_problem(File, Reason), - ?ERROR_MSG(ExitText, []), - exit_or_halt(ExitText) + ?ERROR_MSG(Reason, []), + exit_or_halt(Reason) + end. + +consult(File) -> + case filename:extension(File) of + ".yml" -> + case p1_yaml:decode_from_file(File, [plain_as_atom]) of + {ok, []} -> + {ok, []}; + {ok, [Document|_]} -> + {ok, Document}; + {error, Err} -> + {error, p1_yaml:format_error(Err)} + end; + _ -> + case file:consult(File) of + {ok, Terms} -> + {ok, Terms}; + {error, {LineNumber, erl_parse, _ParseMessage} = Reason} -> + {error, describe_config_problem(File, Reason, LineNumber)}; + {error, Reason} -> + {error, describe_config_problem(File, Reason)} + end end. %% @doc Convert configuration filename to absolute path. @@ -158,7 +234,7 @@ search_hosts(Term, State) -> add_hosts_to_option(Hosts, State) -> PrepHosts = normalize_hosts(Hosts), - add_option(hosts, PrepHosts, State#state{hosts = PrepHosts}). + set_option({hosts, global}, PrepHosts, State#state{hosts = PrepHosts}). normalize_hosts(Hosts) -> normalize_hosts(Hosts,[]). @@ -232,21 +308,37 @@ exit_or_halt(ExitText) -> %% @doc Include additional configuration files in the list of terms. %% @spec ([term()]) -> [term()] include_config_files(Terms) -> - include_config_files(Terms, []). + {FileOpts, Terms1} = + lists:mapfoldl( + fun({include_config_file, _} = T, Ts) -> + {[transform_include_option(T)], Ts}; + ({include_config_file, _, _} = T, Ts) -> + {[transform_include_option(T)], Ts}; + (T, Ts) -> + {[], [T|Ts]} + end, [], Terms), + Terms2 = lists:flatmap( + fun({File, Opts}) -> + include_config_file(File, Opts) + end, lists:flatten(FileOpts)), + Terms1 ++ Terms2. -include_config_files([], Res) -> - Res; -include_config_files([{include_config_file, Filename} | Terms], Res) -> - include_config_files([{include_config_file, Filename, []} | Terms], Res); -include_config_files([{include_config_file, Filename, Options} | Terms], Res) -> +transform_include_option({include_config_file, File}) when is_list(File) -> + case is_string(File) of + true -> {File, []}; + false -> File + end; +transform_include_option({include_config_file, Filename}) -> + {Filename, []}; +transform_include_option({include_config_file, Filename, Options}) -> + {Filename, Options}. + +include_config_file(Filename, Options) -> Included_terms = get_plain_terms_file(Filename), Disallow = proplists:get_value(disallow, Options, []), Included_terms2 = delete_disallowed(Disallow, Included_terms), Allow_only = proplists:get_value(allow_only, Options, all), - Included_terms3 = keep_only_allowed(Allow_only, Included_terms2), - include_config_files(Terms, Res ++ Included_terms3); -include_config_files([Term | Terms], Res) -> - include_config_files(Terms, Res ++ [Term]). + keep_only_allowed(Allow_only, Included_terms2). %% @doc Filter from the list of terms the disallowed. %% Returns a sublist of Terms without the ones which first element is @@ -308,12 +400,19 @@ split_terms_macros(Terms) -> fun(Term, {TOs, Ms}) -> case Term of {define_macro, Key, Value} -> - case is_atom(Key) and is_all_uppercase(Key) of + case is_correct_macro({Key, Value}) of true -> {TOs, Ms++[{Key, Value}]}; false -> exit({macro_not_properly_defined, Term}) end; + {define_macro, KeyVals} -> + case lists:all(fun is_correct_macro/1, KeyVals) of + true -> + {TOs, Ms ++ KeyVals}; + false -> + exit({macros_not_properly_defined, Term}) + end; Term -> {TOs ++ [Term], Ms} end @@ -321,6 +420,11 @@ split_terms_macros(Terms) -> {[], []}, Terms). +is_correct_macro({Key, _Val}) -> + is_atom(Key) and is_all_uppercase(Key); +is_correct_macro(_) -> + false. + %% @doc Recursively replace in Terms macro usages with the defined value. %% @spec (Terms, Macros) -> Terms %% Terms = [term()] @@ -328,7 +432,9 @@ split_terms_macros(Terms) -> replace([], _) -> []; replace([Term|Terms], Macros) -> - [replace_term(Term, Macros) | replace(Terms, Macros)]. + [replace_term(Term, Macros) | replace(Terms, Macros)]; +replace(Term, Macros) -> + replace_term(Term, Macros). replace_term(Key, Macros) when is_atom(Key) -> case is_all_uppercase(Key) of @@ -362,121 +468,65 @@ is_all_uppercase(Atom) -> process_term(Term, State) -> case Term of - override_global -> - State#state{override_global = true}; - override_local -> - State#state{override_local = true}; - override_acls -> - State#state{override_acls = true}; - {host_config, Host, Terms} -> - lists:foldl(fun(T, S) -> process_host_term(T, Host, S) end, - State, Terms); - {listen, Listeners} -> - Listeners2 = - lists:map( - fun({PortIP, Module, Opts}) -> - {Port, IPT, _, _, Proto, OptsClean} = - ejabberd_listener:parse_listener_portip(PortIP, Opts), - {{Port, IPT, Proto}, Module, OptsClean} - end, - Listeners), - add_option(listen, Listeners2, State); - {s2s_certfile, CertFile} -> - CertFileS = binary_to_list(CertFile), - case ejabberd_config:is_file_readable(CertFileS) of - true -> add_option(s2s_certfile, CertFile, State); - false -> - ErrorText = "There is a problem in the configuration: " - "the specified file is not readable: ", - throw({error, ErrorText ++ CertFileS}) - end; - {domain_certfile, Domain, CertFile} -> - CertFileS = binary_to_list(CertFile), - case ejabberd_config:is_file_readable(CertFileS) of - true -> add_option({domain_certfile, Domain}, CertFile, State); - false -> - ErrorText = "There is a problem in the configuration: " - "the specified file is not readable: ", - throw({error, ErrorText ++ CertFileS}) - end; - {loglevel, Loglevel} -> - ejabberd_logger:set(Loglevel), - State; + {host_config, HostTerms} -> + lists:foldl( + fun({Host, Terms}, AccState) -> + lists:foldl(fun(T, S) -> + process_host_term(T, Host, S, set) + end, AccState, Terms) + end, State, HostTerms); + {append_host_config, HostTerms} -> + lists:foldl( + fun({Host, Terms}, AccState) -> + lists:foldl(fun(T, S) -> + process_host_term(T, Host, S, append) + end, AccState, Terms) + end, State, HostTerms); _ -> - lists:foldl(fun(Host, S) -> process_host_term(Term, Host, S) end, - State, [global|State#state.hosts]) + process_host_term(Term, global, State, set) end. -process_host_term(Term, Host, State) -> +process_host_term(Term, Host, State, Action) -> case Term of - {acl, ACLName, ACLData} -> - State#state{opts = - [acl:to_record(Host, ACLName, ACLData) | State#state.opts]}; - {access, RuleName, Rules} -> - add_option({access, RuleName, Host}, Rules, State); - {shaper, Name, Data} -> - add_option({shaper, Name, Host}, Data, State); - {modules, Modules} -> - add_option({modules, Host}, replace_modules(Modules), State); + {modules, Modules} when Action == set -> + set_option({modules, Host}, replace_modules(Modules), State); + {modules, Modules} when Action == append -> + append_option({modules, Host}, replace_modules(Modules), State); {host, _} -> State; {hosts, _} -> State; - {Opt, Val} -> - add_option({Opt, Host}, Val, State) + {Opt, Val} when Action == set -> + set_option({Opt, Host}, Val, State); + {Opt, Val} when Action == append -> + append_option({Opt, Host}, Val, State); + Opt -> + ?WARNING_MSG("Ignore invalid (outdated?) option ~p", [Opt]), + State end. -add_option(Opt, Val, State) when is_atom(Opt) -> - add_option({Opt, global}, Val, State); -add_option(Opt, Val, State) -> - case Opt of - {{add, OptName}, Host} -> - State#state{opts = compact({OptName, Host}, Val, - State#state.opts, [])}; - _ -> - State#state{opts = [#local_config{key = Opt, value = Val} | - State#state.opts]} - end. - -compact({OptName, Host} = Opt, Val, [], Os) -> - ?WARNING_MSG("The option '~p' is defined for the host ~p using host_config " - "before the global '~p' option. This host_config option may get overwritten.", [OptName, Host, OptName]), - [#local_config{key = Opt, value = Val}] ++ Os; -%% Traverse the list of the options already parsed -compact(Opt, Val, [O | Os1], Os2) -> - case catch O#local_config.key of - %% If the key of a local_config matches the Opt that wants to be added - Opt -> - %% Then prepend the new value to the list of old values - Os2 ++ [#local_config{key = Opt, - value = Val++O#local_config.value} - ] ++ Os1; - _ -> - compact(Opt, Val, Os1, Os2++[O]) - end. +set_option(Opt, Val, State) -> + State#state{opts = [#local_config{key = Opt, value = Val} | + State#state.opts]}. +append_option({Opt, Host}, Val, State) -> + GlobalVals = lists:flatmap( + fun(#local_config{key = {O, global}, value = V}) + when O == Opt -> + if is_list(V) -> V; + true -> [V] + end; + (_) -> + [] + end, State#state.opts), + NewVal = if is_list(Val) -> Val ++ GlobalVals; + true -> [Val|GlobalVals] + end, + set_option({Opt, Host}, NewVal, State). set_opts(State) -> - Opts = lists:reverse(State#state.opts), + Opts = State#state.opts, F = fun() -> - if - State#state.override_local -> - Ksl = mnesia:all_keys(local_config), - lists:foreach(fun(K) -> - mnesia:delete({local_config, K}) - end, Ksl); - true -> - ok - end, - if - State#state.override_acls -> - Ksa = mnesia:all_keys(acl), - lists:foreach(fun(K) -> - mnesia:delete({acl, K}) - end, Ksa); - true -> - ok - end, lists:foreach(fun(R) -> mnesia:write(R) end, Opts) @@ -565,11 +615,22 @@ get_option(Opt, F) -> get_option(Opt, F, Default) when is_atom(Opt) -> get_option({Opt, global}, F, Default); get_option(Opt, F, Default) -> + case Opt of + {O, global} when is_atom(O) -> ok; + {O, H} when is_atom(O), is_binary(H) -> ok; + _ -> ?WARNING_MSG("Option ~p has invalid (outdated?) format. " + "This is likely a bug", [Opt]) + end, case ets:lookup(local_config, Opt) of [#local_config{value = Val}] -> prepare_opt_val(Opt, Val, F, Default); - _ -> - Default + _ -> + case Opt of + {Key, Host} when Host /= global -> + get_option({Key, global}, F, Default); + _ -> + Default + end end. -spec get_vh_by_auth_method(atom()) -> [binary()]. @@ -632,14 +693,14 @@ replace_modules(Modules) -> emit_deprecation_warning(Module, NewModule, DBType), NewOpts = [{db_type, DBType} | lists:keydelete(db_type, 1, Opts)], - {NewModule, NewOpts}; + {NewModule, transform_module_options(Module, NewOpts)}; NewModule -> if Module /= NewModule -> emit_deprecation_warning(Module, NewModule); true -> ok end, - {NewModule, Opts} + {NewModule, transform_module_options(Module, Opts)} end end, Modules). @@ -695,6 +756,142 @@ format_term(S) when is_list(S), S /= [] -> format_term(T) -> io_lib:format("~p", [binary_to_strings(T)]). +transform_terms(Terms) -> + %% We could check all ejabberd beams, but this + %% slows down start-up procedure :( + Mods = [mod_register, + mod_last, + ejabberd_s2s, + ejabberd_listener, + ejabberd_odbc_sup, + shaper, + ejabberd_s2s_out, + acl, + ejabberd_config], + collect_options(transform_terms(Mods, Terms)). + +transform_terms([Mod|Mods], Terms) -> + case catch Mod:transform_options(Terms) of + {'EXIT', _} = Err -> + ?ERROR_MSG("Failed to transform terms by ~p: ~p", [Mod, Err]), + transform_terms(Mods, Terms); + NewTerms -> + transform_terms(Mods, NewTerms) + end; +transform_terms([], NewTerms) -> + NewTerms. + +transform_module_options(Module, Opts) -> + Opts1 = gen_iq_handler:transform_module_options(Opts), + try + Module:transform_module_options(Opts1) + catch error:undef -> + Opts1 + end. + +compact(Cfg) -> + Opts = [{K, V} || #local_config{key = K, value = V} <- Cfg], + {GOpts, HOpts} = split_by_hosts(Opts), + [#local_config{key = {O, global}, value = V} || {O, V} <- GOpts] ++ + lists:flatmap( + fun({Host, OptVal}) -> + case lists:member(OptVal, GOpts) of + true -> + []; + false -> + [#local_config{key = {Opt, Host}, value = Val} + || {Opt, Val} <- OptVal] + end + end, lists:flatten(HOpts)). + +split_by_hosts(Opts) -> + Opts1 = orddict:to_list( + lists:foldl( + fun({{Opt, Host}, Val}, D) -> + orddict:append(Host, {Opt, Val}, D) + end, orddict:new(), Opts)), + case lists:keytake(global, 1, Opts1) of + {value, {global, GlobalOpts}, HostOpts} -> + {GlobalOpts, HostOpts}; + _ -> + {[], Opts1} + end. + +collect_options(Opts) -> + {D, InvalidOpts} = + lists:foldl( + fun({K, V}, {D, Os}) when is_list(V) -> + {orddict:append_list(K, V, D), Os}; + ({K, V}, {D, Os}) -> + {orddict:store(K, V, D), Os}; + (Opt, {D, Os}) -> + {D, [Opt|Os]} + end, {orddict:new(), []}, Opts), + InvalidOpts ++ orddict:to_list(D). + +transform_options(Opts) -> + Opts1 = lists:foldl(fun transform_options/2, [], Opts), + {HOpts, Opts2} = lists:mapfoldl( + fun({host_config, O}, Os) -> + {[O], Os}; + (O, Os) -> + {[], [O|Os]} + end, [], Opts1), + {AHOpts, Opts3} = lists:mapfoldl( + fun({append_host_config, O}, Os) -> + {[O], Os}; + (O, Os) -> + {[], [O|Os]} + end, [], Opts2), + HOpts1 = case collect_options(lists:flatten(HOpts)) of + [] -> + []; + HOs -> + [{host_config, + [{H, transform_terms(O)} || {H, O} <- HOs]}] + end, + AHOpts1 = case collect_options(lists:flatten(AHOpts)) of + [] -> + []; + AHOs -> + [{append_host_config, + [{H, transform_terms(O)} || {H, O} <- AHOs]}] + end, + HOpts1 ++ AHOpts1 ++ Opts3. + +transform_options({domain_certfile, Domain, CertFile}, Opts) -> + ?WARNING_MSG("Option 'domain_certfile' now should be defined " + "per virtual host or globally. The old format is " + "still supported but it is better to fix your config", []), + [{host_config, [{Domain, [{domain_certfile, CertFile}]}]}|Opts]; +transform_options(Opt, Opts) when Opt == override_global; + Opt == override_local; + Opt == override_acls -> + ?WARNING_MSG("Ignoring '~s' option which has no effect anymore", [Opt]), + Opts; +transform_options({host_config, Host, HOpts}, Opts) -> + {AddOpts, HOpts1} = + lists:mapfoldl( + fun({{add, Opt}, Val}, Os) -> + ?WARNING_MSG("Option 'add' is deprecated. " + "The option is still supported " + "but it is better to fix your config: " + "use 'append_host_config' instead.", []), + {[{Opt, Val}], Os}; + (O, Os) -> + {[], [O|Os]} + end, [], HOpts), + [{append_host_config, [{Host, lists:flatten(AddOpts)}]}, + {host_config, [{Host, HOpts1}]}|Opts]; +transform_options({define_macro, Macro, Val}, Opts) -> + [{define_macro, [{Macro, Val}]}|Opts]; +transform_options({include_config_file, _} = Opt, Opts) -> + [{include_config_file, [transform_include_option(Opt)]} | Opts]; +transform_options({include_config_file, _, _} = Opt, Opts) -> + [{include_config_file, [transform_include_option(Opt)]} | Opts]; +transform_options(Opt, Opts) -> + [Opt|Opts]. + -spec convert_table_to_binary(atom(), [atom()], atom(), fun(), fun()) -> ok. diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index 38b94ef4d..d3944e266 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -237,7 +237,7 @@ process2(Args, Auth, AccessCommands) -> end. get_accesscommands() -> - ejabberd_config:get_local_option(ejabberdctl_access_commands, + ejabberd_config:get_option(ejabberdctl_access_commands, fun(V) when is_list(V) -> V end, []). %%----------------------------- diff --git a/src/ejabberd_frontend_socket.erl b/src/ejabberd_frontend_socket.erl index adc7c2579..583396ec9 100644 --- a/src/ejabberd_frontend_socket.erl +++ b/src/ejabberd_frontend_socket.erl @@ -280,7 +280,7 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}. %%% Internal functions %%-------------------------------------------------------------------- check_starttls(SockMod, Socket, Receiver, Opts) -> - TLSEnabled = lists:member(tls, Opts), + TLSEnabled = proplists:get_bool(tls, Opts), TLSOpts = lists:filter(fun({certfile, _}) -> true; (_) -> false end, Opts), @@ -292,4 +292,3 @@ check_starttls(SockMod, Socket, Receiver, Opts) -> true -> {SockMod, Socket} end. - diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl index 899d50eb3..151a34ef4 100644 --- a/src/ejabberd_http.erl +++ b/src/ejabberd_http.erl @@ -30,7 +30,8 @@ %% External exports -export([start/2, start_link/2, become_controller/1, - socket_type/0, receive_headers/1, url_encode/1]). + socket_type/0, receive_headers/1, url_encode/1, + transform_listen_option/2]). %% Callbacks -export([init/2]). @@ -91,7 +92,7 @@ start_link(SockData, Opts) -> [SockData, Opts])}. init({SockMod, Socket}, Opts) -> - TLSEnabled = lists:member(tls, Opts), + TLSEnabled = proplists:get_bool(tls, Opts), TLSOpts1 = lists:filter(fun ({certfile, _}) -> true; (_) -> false end, @@ -133,12 +134,13 @@ init({SockMod, Socket}, Opts) -> true -> [{[<<"http-poll">>], ejabberd_http_poll}]; false -> [] end, - DefinedHandlers = case lists:keysearch(request_handlers, - 1, Opts) - of - {value, {request_handlers, H}} -> H; - false -> [] - end, + DefinedHandlers = gen_mod:get_opt( + request_handlers, Opts, + fun(Hs) -> + [{str:tokens( + iolist_to_binary(Path), <<"/">>), + Mod} || {Path, Mod} <- Hs] + end, []), RequestHandlers = DefinedHandlers ++ Captcha ++ Register ++ Admin ++ Bind ++ Poll, ?DEBUG("S: ~p~n", [RequestHandlers]), @@ -484,7 +486,7 @@ analyze_ip_xff(IP, [], _Host) -> IP; analyze_ip_xff({IPLast, Port}, XFF, Host) -> [ClientIP | ProxiesIPs] = str:tokens(XFF, <<", ">>) ++ [jlib:ip_to_list(IPLast)], - TrustedProxies = ejabberd_config:get_local_option( + TrustedProxies = ejabberd_config:get_option( {trusted_proxies, Host}, fun(TPs) -> [iolist_to_binary(TP) || TP <- TPs] @@ -834,3 +836,25 @@ normalize_path([_Parent, <<"..">>|Path], Norm) -> normalize_path(Path, Norm); normalize_path([Part | Path], Norm) -> normalize_path(Path, [Part|Norm]). + +transform_listen_option(captcha, Opts) -> + [{captcha, true}|Opts]; +transform_listen_option(register, Opts) -> + [{register, true}|Opts]; +transform_listen_option(web_admin, Opts) -> + [{web_admin, true}|Opts]; +transform_listen_option(http_bind, Opts) -> + [{http_bind, true}|Opts]; +transform_listen_option(http_poll, Opts) -> + [{http_poll, true}|Opts]; +transform_listen_option({request_handlers, Hs}, Opts) -> + Hs1 = lists:map( + fun({PList, Mod}) when is_list(PList) -> + Path = iolist_to_binary([[$/, P] || P <- PList]), + {Path, Mod}; + (Opt) -> + Opt + end, Hs), + [{request_handlers, Hs1} | Opts]; +transform_listen_option(Opt, Opts) -> + [Opt|Opts]. diff --git a/src/ejabberd_http_poll.erl b/src/ejabberd_http_poll.erl index f144aeb59..89933a595 100644 --- a/src/ejabberd_http_poll.erl +++ b/src/ejabberd_http_poll.erl @@ -205,7 +205,7 @@ get_human_html_xmlel() -> init([ID, Key, IP]) -> ?INFO_MSG("started: ~p", [{ID, Key, IP}]), Opts = ejabberd_c2s_config:get_c2s_limits(), - HTTPPollTimeout = ejabberd_config:get_local_option( + HTTPPollTimeout = ejabberd_config:get_option( {http_poll_timeout, ?MYNAME}, fun(I) when is_integer(I), I>0 -> I end, ?HTTP_POLL_TIMEOUT) * 1000, diff --git a/src/ejabberd_listener.erl b/src/ejabberd_listener.erl index be90cf92f..033eb0e0f 100644 --- a/src/ejabberd_listener.erl +++ b/src/ejabberd_listener.erl @@ -36,7 +36,8 @@ parse_listener_portip/2, add_listener/3, delete_listener/2, - validate_cfg/1 + transform_options/1, + validate_cfg/1 ]). -include("ejabberd.hrl"). @@ -55,7 +56,7 @@ init(_) -> {ok, {{one_for_one, 10, 1}, []}}. bind_tcp_ports() -> - case ejabberd_config:get_local_option(listen, fun validate_cfg/1) of + case ejabberd_config:get_option(listen, fun validate_cfg/1) of undefined -> ignore; Ls -> @@ -88,7 +89,7 @@ bind_tcp_port(PortIP, Module, RawOpts) -> end. start_listeners() -> - case ejabberd_config:get_local_option(listen, fun validate_cfg/1) of + case ejabberd_config:get_option(listen, fun validate_cfg/1) of undefined -> ignore; Ls -> @@ -267,7 +268,7 @@ strip_ip_option(Opts) -> Opts), case IPL of %% Only the first ip option is considered - [{ip, T1} | _] when is_tuple(T1) -> + [{ip, T1} | _] -> {T1, OptsNoIP}; [] -> {no_ip_option, OptsNoIP} @@ -364,7 +365,7 @@ start_listener_sup(Port, Module, Opts) -> supervisor:start_child(ejabberd_listeners, ChildSpec). stop_listeners() -> - Ports = ejabberd_config:get_local_option(listen, fun validate_cfg/1), + Ports = ejabberd_config:get_option(listen, fun validate_cfg/1), lists:foreach( fun({PortIpNetp, Module, _Opts}) -> delete_listener(PortIpNetp, Module) @@ -397,7 +398,7 @@ add_listener(PortIP, Module, Opts) -> PortIP1 = {Port, IPT, Proto}, case start_listener(PortIP1, Module, Opts) of {ok, _Pid} -> - Ports = case ejabberd_config:get_local_option( + Ports = case ejabberd_config:get_option( listen, fun validate_cfg/1) of undefined -> []; @@ -406,7 +407,8 @@ add_listener(PortIP, Module, Opts) -> end, Ports1 = lists:keydelete(PortIP1, 1, Ports), Ports2 = [{PortIP1, Module, Opts} | Ports1], - ejabberd_config:add_local_option(listen, Ports2), + Ports3 = lists:map(fun transform_option/1, Ports2), + ejabberd_config:add_option(listen, Ports3), ok; {error, {already_started, _Pid}} -> {error, {already_started, PortIP}}; @@ -428,7 +430,7 @@ delete_listener(PortIP, Module) -> delete_listener(PortIP, Module, Opts) -> {Port, IPT, _, _, Proto, _} = parse_listener_portip(PortIP, Opts), PortIP1 = {Port, IPT, Proto}, - Ports = case ejabberd_config:get_local_option( + Ports = case ejabberd_config:get_option( listen, fun validate_cfg/1) of undefined -> []; @@ -436,7 +438,8 @@ delete_listener(PortIP, Module, Opts) -> Ls end, Ports1 = lists:keydelete(PortIP1, 1, Ports), - ejabberd_config:add_local_option(listen, Ports1), + Ports2 = lists:map(fun transform_option/1, Ports1), + ejabberd_config:add_option(listen, Ports2), stop_listener(PortIP1, Module). @@ -541,6 +544,55 @@ format_error(Reason) -> -define(IS_PORT(P), (is_integer(P) and (P > 0) and (P =< 65535))). -define(IS_TRANSPORT(T), ((T == tcp) or (T == udp))). +transform_option({{Port, IP, Transport}, Mod, Opts}) -> + IPStr = if is_tuple(IP) -> + list_to_binary(inet_parse:ntoa(IP)); + true -> + IP + end, + Opts1 = lists:map( + fun({ip, IPT}) when is_tuple(IPT) -> + {ip, list_to_binary(inet_parse:ntoa(IP))}; + (tls) -> {tls, true}; + (ssl) -> {tls, true}; + (zlib) -> {zlib, true}; + (starttls) -> {starttls, true}; + (starttls_required) -> {starttls_required, true}; + (Opt) -> Opt + end, Opts), + Opts2 = lists:foldl( + fun(Opt, Acc) -> + try + Mod:transform_listen_option(Opt, Acc) + catch error:undef -> + Acc + end + end, [], Opts1), + TransportOpt = if Transport == tcp -> []; + true -> [{transport, Transport}] + end, + IPOpt = if IPStr == <<"0.0.0.0">> -> []; + true -> [{ip, IPStr}] + end, + IPOpt ++ TransportOpt ++ [{port, Port}, {module, Mod} | Opts2]; +transform_option({{Port, Transport}, Mod, Opts}) + when ?IS_TRANSPORT(Transport) -> + transform_option({{Port, {0,0,0,0}, Transport}, Mod, Opts}); +transform_option({{Port, IP}, Mod, Opts}) -> + transform_option({{Port, IP, tcp}, Mod, Opts}); +transform_option({Port, Mod, Opts}) -> + transform_option({{Port, {0,0,0,0}, tcp}, Mod, Opts}); +transform_option(Opt) -> + Opt. + +transform_options(Opts) -> + lists:foldl(fun transform_options/2, [], Opts). + +transform_options({listen, LOpts}, Opts) -> + [{listen, lists:map(fun transform_option/1, LOpts)} | Opts]; +transform_options(Opt, Opts) -> + [Opt|Opts]. + -type transport() :: udp | tcp. -type port_ip_transport() :: inet:port_number() | {inet:port_number(), transport()} | @@ -551,18 +603,21 @@ format_error(Reason) -> validate_cfg(L) -> lists:map( - fun({PortIPTransport, Mod1, Opts}) when is_atom(Mod1), is_list(Opts) -> - Mod = prepare_mod(Mod1), - case PortIPTransport of - Port when ?IS_PORT(Port) -> - {Port, Mod, Opts}; - {Port, Trans} when ?IS_PORT(Port) and ?IS_TRANSPORT(Trans) -> - {{Port, Trans}, Mod, Opts}; - {Port, IP} when ?IS_PORT(Port) -> - {{Port, prepare_ip(IP)}, Mod, Opts}; - {Port, IP, Trans} when ?IS_PORT(Port) and ?IS_TRANSPORT(Trans) -> - {{Port, prepare_ip(IP), Trans}, Mod, Opts} - end + fun(LOpts) -> + lists:foldl( + fun({port, Port}, {{_, IP, T}, Mod, Opts}) -> + true = ?IS_PORT(Port), + {{Port, IP, T}, Mod, Opts}; + ({ip, IP}, {{Port, _, T}, Mod, Opts}) -> + {{Port, prepare_ip(IP), T}, Mod, Opts}; + ({transport, T}, {{Port, IP, _}, Mod, Opts}) -> + true = ?IS_TRANSPORT(T), + {{Port, IP, T}, Mod, Opts}; + ({module, Mod}, {Port, _, Opts}) -> + {Port, prepare_mod(Mod), Opts}; + (Opt, {Port, Mod, Opts}) -> + {Port, Mod, [Opt|Opts]} + end, {{5222, {0,0,0,0}, tcp}, ejabberd_c2s, []}, LOpts) end, L). prepare_ip({A, B, C, D} = IP) @@ -583,5 +638,5 @@ prepare_mod(ejabberd_stun) -> prepare_mod(stun) -> ejabberd:start_app(p1_stun), stun; -prepare_mod(Mod) -> +prepare_mod(Mod) when is_atom(Mod) -> Mod. diff --git a/src/ejabberd_node_groups.erl b/src/ejabberd_node_groups.erl index 4e0335b97..eb39b7265 100644 --- a/src/ejabberd_node_groups.erl +++ b/src/ejabberd_node_groups.erl @@ -84,7 +84,12 @@ get_closest_node(Name) -> %%-------------------------------------------------------------------- init([]) -> {FE, BE} = - case ejabberd_config:get_local_option(node_type, fun(N) -> N end) of + case ejabberd_config:get_option( + node_type, + fun(frontend) -> frontend; + (backend) -> backend; + (generic) -> generic + end, generic) of frontend -> {true, false}; backend -> diff --git a/src/ejabberd_odbc.erl b/src/ejabberd_odbc.erl index 937805579..40a15a5ce 100644 --- a/src/ejabberd_odbc.erl +++ b/src/ejabberd_odbc.erl @@ -71,12 +71,12 @@ -define(TOP_LEVEL_TXN, 0). --define(MAX_TRANSACTION_RESTARTS, 10). - -define(PGSQL_PORT, 5432). -define(MYSQL_PORT, 3306). +-define(MAX_TRANSACTION_RESTARTS, 10). + -define(TRANSACTION_TIMEOUT, 60000). -define(KEEPALIVE_TIMEOUT, 60000). @@ -201,8 +201,8 @@ decode_term(Bin) -> %%% Callback functions from gen_fsm %%%---------------------------------------------------------------------- init([Host, StartInterval]) -> - case ejabberd_config:get_local_option( - {odbc_keepalive_interval, Host}, + case ejabberd_config:get_option( + {keepalive_interval, Host}, fun(I) when is_integer(I), I>0 -> I end) of undefined -> ok; @@ -573,39 +573,39 @@ log(Level, Format, Args) -> end. db_opts(Host) -> - case ejabberd_config:get_local_option( - {odbc_server, Host}, - fun({Type, Server, DB, User, Pass}) -> - {Type, - iolist_to_binary(Server), - case Type of - mysql -> ?MYSQL_PORT; - pgsql -> ?PGSQL_PORT - end, - iolist_to_binary(DB), - iolist_to_binary(User), - iolist_to_binary(Pass)}; - ({Type, Server, Port, DB, User, Pass}) - when ((Type == mysql) or (Type == pgsql)) - and (is_integer(Port) and ((Port > 0) - and (Port < 65536))) -> - {Type, - iolist_to_binary(Server), - Port, - iolist_to_binary(DB), - iolist_to_binary(User), - iolist_to_binary(Pass)}; - (S) -> - iolist_to_binary(S) - end, <<"localhost">>) of - {Type, Server, Port, DB, User, Pass} -> - [Type, Server, Port, DB, User, Pass]; - SQLServer -> - [odbc, SQLServer] + Type = ejabberd_config:get_option({odbc_type, Host}, + fun(mysql) -> mysql; + (pgsql) -> pgsql; + (odbc) -> odbc + end, odbc), + Server = ejabberd_config:get_option({odbc_server, Host}, + fun iolist_to_binary/1, + <<"localhost">>), + case Type of + odbc -> + [odbc, Server]; + _ -> + Port = ejabberd_config:get_option( + {port, Host}, + fun(P) when is_integer(P), P > 0, P < 65536 -> P end, + case Type of + mysql -> ?MYSQL_PORT; + pgsql -> ?PGSQL_PORT + end), + DB = ejabberd_config:get_option({odbc_database, Host}, + fun iolist_to_binary/1, + <<"ejabberd">>), + User = ejabberd_config:get_option({odbc_username, Host}, + fun iolist_to_binary/1, + <<"ejabberd">>), + Pass = ejabberd_config:get_option({odbc_password, Host}, + fun iolist_to_binary/1, + <<"">>), + [Type, Server, Port, DB, User, Pass] end. max_fsm_queue() -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( max_fsm_queue, fun(N) when is_integer(N), N > 0 -> N end). diff --git a/src/ejabberd_odbc_sup.erl b/src/ejabberd_odbc_sup.erl index 2ddc751f8..86b737948 100644 --- a/src/ejabberd_odbc_sup.erl +++ b/src/ejabberd_odbc_sup.erl @@ -30,11 +30,15 @@ %% API -export([start_link/1, init/1, add_pid/2, remove_pid/2, - get_pids/1, get_random_pid/1]). + get_pids/1, get_random_pid/1, transform_options/1]). -include("ejabberd.hrl"). -include("logger.hrl"). +-define(PGSQL_PORT, 5432). + +-define(MYSQL_PORT, 3306). + -define(DEFAULT_POOL_SIZE, 10). -define(DEFAULT_ODBC_START_INTERVAL, 30). @@ -56,11 +60,11 @@ start_link(Host) -> ?MODULE, [Host]). init([Host]) -> - PoolSize = ejabberd_config:get_local_option( + PoolSize = ejabberd_config:get_option( {odbc_pool_size, Host}, fun(I) when is_integer(I), I>0 -> I end, ?DEFAULT_POOL_SIZE), - StartInterval = ejabberd_config:get_local_option( + StartInterval = ejabberd_config:get_option( {odbc_start_interval, Host}, fun(I) when is_integer(I), I>0 -> I end, ?DEFAULT_ODBC_START_INTERVAL), @@ -93,3 +97,20 @@ remove_pid(Host, Pid) -> mnesia:delete_object(#sql_pool{host = Host, pid = Pid}) end, mnesia:ets(F). + +transform_options(Opts) -> + lists:foldl(fun transform_options/2, [], Opts). + +transform_options({odbc_server, {Type, Server, Port, DB, User, Pass}}, Opts) -> + [{odbc_type, Type}, + {odbc_server, Server}, + {odbc_port, Port}, + {odbc_database, DB}, + {odbc_username, User}, + {odbc_password, Pass}|Opts]; +transform_options({odbc_server, {mysql, Server, DB, User, Pass}}, Opts) -> + transform_options({odbc_server, {mysql, Server, ?MYSQL_PORT, DB, User, Pass}}, Opts); +transform_options({odbc_server, {pgsql, Server, DB, User, Pass}}, Opts) -> + transform_options({odbc_server, {pgsql, Server, ?PGSQL_PORT, DB, User, Pass}}, Opts); +transform_options(Opt, Opts) -> + [Opt|Opts]. diff --git a/src/ejabberd_rdbms.erl b/src/ejabberd_rdbms.erl index a7324e4ca..b5525de10 100644 --- a/src/ejabberd_rdbms.erl +++ b/src/ejabberd_rdbms.erl @@ -69,18 +69,16 @@ start_odbc(Host, App) -> start_odbc(Host, App) end. -%% Returns {true, App} if we have configured odbc_server for the given host +%% Returns {true, App} if we have configured odbc for the given host needs_odbc(Host) -> LHost = jlib:nameprep(Host), - case ejabberd_config:get_local_option( - {odbc_server, LHost}, fun(Res) -> Res end) of - {mysql, _, _, _, _} -> {true, p1_mysql}; - {pgsql, _, _, _, _} -> {true, p1_pgsql}; - {mysql, _, _, _, _, _} -> {true, p1_mysql}; - {pgsql, _, _, _, _, _} -> {true, p1_pgsql}; - S -> - case catch iolist_to_binary(S) of - {'EXIT', _} -> false; - _ -> true - end + case ejabberd_config:get_option({odbc_type, LHost}, + fun(mysql) -> mysql; + (pgsql) -> pgsql; + (odbc) -> odbc + end, undefined) of + mysql -> {true, p1_mysql}; + pgsql -> {true, p1_pgsql}; + odbc -> {true, odbc}; + undefined -> false end. diff --git a/src/ejabberd_router.erl b/src/ejabberd_router.erl index ea020a186..24f52d329 100644 --- a/src/ejabberd_router.erl +++ b/src/ejabberd_router.erl @@ -387,14 +387,10 @@ do_route(OrigFrom, OrigTo, OrigPacket) -> end. get_component_number(LDomain) -> - case - ejabberd_config:get_local_option({domain_balancing_component_number, - LDomain}, fun(D) -> D end) - of - N when is_integer(N), N > 1 -> N; - _ -> undefined - end. - + ejabberd_config:get_option( + {domain_balancing_component_number, LDomain}, + fun(N) when is_integer(N), N > 1 -> N end, + undefined). update_tables() -> case catch mnesia:table_info(route, attributes) of diff --git a/src/ejabberd_s2s.erl b/src/ejabberd_s2s.erl index 591d31da2..b13fdd58e 100644 --- a/src/ejabberd_s2s.erl +++ b/src/ejabberd_s2s.erl @@ -45,7 +45,7 @@ handle_info/2, terminate/2, code_change/3]). %% ejabberd API --export([get_info_s2s_connections/1]). +-export([get_info_s2s_connections/1, transform_options/1]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -461,12 +461,12 @@ needed_connections_number(Ls, MaxS2SConnectionsNumber, %% -------------------------------------------------------------------- is_service(From, To) -> LFromDomain = From#jid.lserver, - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( {route_subdomains, LFromDomain}, - fun(s2s) -> s2s end) of + fun(s2s) -> s2s; (local) -> local end, local) of s2s -> % bypass RFC 3920 10.3 false; - undefined -> + local -> Hosts = (?MYHOSTS), P = fun (ParentDomain) -> lists:member(ParentDomain, Hosts) @@ -548,34 +548,50 @@ allow_host2(MyServer, S2SHost) -> end. allow_host1(MyHost, S2SHost) -> - case ejabberd_config:get_local_option( - {{s2s_host, S2SHost}, MyHost}, - fun(deny) -> deny; (allow) -> allow end) - of - deny -> false; - allow -> true; - undefined -> - case ejabberd_config:get_local_option( - {s2s_default_policy, MyHost}, - fun(deny) -> deny; (allow) -> allow end) - of - deny -> false; - _ -> - case ejabberd_hooks:run_fold(s2s_allow_host, MyHost, - allow, [MyHost, S2SHost]) - of - deny -> false; - allow -> true; - _ -> true - end - end + Rule = ejabberd_config:get_option( + s2s_access, + fun(A) when is_atom(A) -> A end, + all), + JID = jlib:make_jid(<<"">>, S2SHost, <<"">>), + case acl:match_rule(MyHost, Rule, JID) of + deny -> false; + allow -> + case ejabberd_hooks:run_fold(s2s_allow_host, MyHost, + allow, [MyHost, S2SHost]) of + deny -> false; + allow -> true; + _ -> true + end end. +transform_options(Opts) -> + lists:foldl(fun transform_options/2, [], Opts). + +transform_options({{s2s_host, Host}, Action}, Opts) -> + ?WARNING_MSG("Option 's2s_host' is deprecated. " + "The option is still supported but it is better to " + "fix your config: use access rules instead.", []), + ACLName = jlib:binary_to_atom( + iolist_to_binary(["s2s_access_", Host])), + [{acl, ACLName, {server, Host}}, + {access, s2s, [{Action, ACLName}]}, + {s2s_access, s2s} | + Opts]; +transform_options({s2s_default_policy, Action}, Opts) -> + ?WARNING_MSG("Option 's2s_default_policy' is deprecated. " + "The option is still supported but it is better to " + "fix your config: " + "use 's2s_access' with an access rule.", []), + [{access, s2s, [{Action, all}]}, + {s2s_access, s2s} | + Opts]; +transform_options(Opt, Opts) -> + [Opt|Opts]. + %% Get information about S2S connections of the specified type. %% @spec (Type) -> [Info] %% where Type = in | out %% Info = [{InfoName::atom(), InfoValue::any()}] - get_info_s2s_connections(Type) -> ChildType = case Type of in -> ejabberd_s2s_in_sup; diff --git a/src/ejabberd_s2s_in.erl b/src/ejabberd_s2s_in.erl index 7692614ea..2ad335657 100644 --- a/src/ejabberd_s2s_in.erl +++ b/src/ejabberd_s2s_in.erl @@ -149,7 +149,7 @@ init([{SockMod, Socket}, Opts]) -> _ -> none end, {StartTLS, TLSRequired, TLSCertverify} = - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( s2s_use_starttls, fun(false) -> false; (true) -> true; @@ -171,7 +171,7 @@ init([{SockMod, Socket}, Opts]) -> required_trusted -> {true, true, true} end, - TLSOpts1 = case ejabberd_config:get_local_option( + TLSOpts1 = case ejabberd_config:get_option( s2s_certfile, fun iolist_to_binary/1) of undefined -> []; @@ -324,7 +324,7 @@ wait_for_feature_request({xmlstreamelement, El}, ?DEBUG("starttls", []), Socket = StateData#state.socket, TLSOpts1 = case - ejabberd_config:get_local_option( + ejabberd_config:get_option( {domain_certfile, StateData#state.server}, fun iolist_to_binary/1) of undefined -> StateData#state.tls_options; @@ -332,7 +332,7 @@ wait_for_feature_request({xmlstreamelement, El}, [{certfile, CertFile} | lists:keydelete(certfile, 1, StateData#state.tls_options)] end, - TLSOpts = case ejabberd_config:get_local_option( + TLSOpts = case ejabberd_config:get_option( {s2s_tls_compression, StateData#state.server}, fun(true) -> true; (false) -> false @@ -843,7 +843,7 @@ fsm_limit_opts(Opts) -> case lists:keysearch(max_fsm_queue, 1, Opts) of {value, {_, N}} when is_integer(N) -> [{max_queue, N}]; _ -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( max_fsm_queue, fun(I) when is_integer(I), I > 0 -> I end) of undefined -> []; diff --git a/src/ejabberd_s2s_out.erl b/src/ejabberd_s2s_out.erl index 1aaaa9998..f52a673e4 100644 --- a/src/ejabberd_s2s_out.erl +++ b/src/ejabberd_s2s_out.erl @@ -35,7 +35,8 @@ start_link/3, start_connection/1, terminate_if_waiting_delay/2, - stop_connection/1]). + stop_connection/1, + transform_options/1]). %% p1_fsm callbacks (same as gen_fsm) -export([init/1, @@ -161,7 +162,7 @@ init([From, Server, Type]) -> process_flag(trap_exit, true), ?DEBUG("started: ~p", [{From, Server, Type}]), {TLS, TLSRequired} = case - ejabberd_config:get_local_option( + ejabberd_config:get_option( s2s_use_starttls, fun(true) -> true; (false) -> false; @@ -184,13 +185,13 @@ init([From, Server, Type]) -> end, UseV10 = TLS, TLSOpts1 = case - ejabberd_config:get_local_option( + ejabberd_config:get_option( s2s_certfile, fun iolist_to_binary/1) of undefined -> [connect]; CertFile -> [{certfile, CertFile}, connect] end, - TLSOpts = case ejabberd_config:get_local_option( + TLSOpts = case ejabberd_config:get_option( {s2s_tls_compression, From}, fun(true) -> true; (false) -> false @@ -702,7 +703,7 @@ wait_for_starttls_proceed({xmlstreamelement, El}, [{StateData#state.myname, StateData#state.server}]), Socket = StateData#state.socket, TLSOpts = case - ejabberd_config:get_local_option( + ejabberd_config:get_option( {domain_certfile, StateData#state.myname}, fun iolist_to_binary/1) of @@ -1142,16 +1143,15 @@ get_addr_port(Server) -> end. srv_lookup(Server) -> - Options = case - ejabberd_config:get_local_option( - s2s_dns_options, fun(L) when is_list(L) -> L end) - of - undefined -> []; - L -> L - end, - TimeoutMs = timer:seconds(proplists:get_value(timeout, - Options, 10)), - Retries = proplists:get_value(retries, Options, 2), + TimeoutMs = timer:seconds( + ejabberd_config:get_option( + s2s_dns_timeout, + fun(I) when is_integer(I), I>=0 -> I end, + 10)), + Retries = ejabberd_config:get_option( + s2s_dns_retries, + fun(I) when is_integer(I), I>=0 -> I end, + 2), srv_lookup(binary_to_list(Server), TimeoutMs, Retries). %% XXX - this behaviour is suboptimal in the case that the domain @@ -1211,15 +1211,15 @@ get_addrs(Host, Family) -> end. outgoing_s2s_port() -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( outgoing_s2s_port, fun(I) when is_integer(I), I > 0, I =< 65536 -> I end, 5269). outgoing_s2s_families() -> - ejabberd_config:get_local_option( - outgoing_s2s_options, - fun({Families, _}) -> + ejabberd_config:get_option( + outgoing_s2s_families, + fun(Families) -> true = lists:all( fun(ipv4) -> true; (ipv6) -> true @@ -1228,14 +1228,43 @@ outgoing_s2s_families() -> end, [ipv4, ipv6]). outgoing_s2s_timeout() -> - ejabberd_config:get_local_option( - outgoing_s2s_options, - fun({_, TimeOut}) when is_integer(TimeOut), TimeOut > 0 -> + ejabberd_config:get_option( + outgoing_s2s_timeout, + fun(TimeOut) when is_integer(TimeOut), TimeOut > 0 -> TimeOut; - ({_, infinity}) -> + (infinity) -> infinity end, 10000). +transform_options(Opts) -> + lists:foldl(fun transform_options/2, [], Opts). + +transform_options({outgoing_s2s_options, Families, Timeout}, Opts) -> + ?WARNING_MSG("Option 'outgoing_s2s_options' is deprecated. " + "The option is still supported " + "but it is better to fix your config: " + "use 'outgoing_s2s_timeout' and " + "'outgoing_s2s_families' instead.", []), + [{outgoing_s2s_families, Families}, + {outgoing_s2s_timeout, Timeout} + | Opts]; +transform_options({s2s_dns_options, S2SDNSOpts}, AllOpts) -> + ?WARNING_MSG("Option 's2s_dns_options' is deprecated. " + "The option is still supported " + "but it is better to fix your config: " + "use 's2s_dns_timeout' and " + "'s2s_dns_retries' instead", []), + lists:foldr( + fun({timeout, T}, AccOpts) -> + [{s2s_dns_timeout, T}|AccOpts]; + ({retries, R}, AccOpts) -> + [{s2s_dns_retries, R}|AccOpts]; + (_, AccOpts) -> + AccOpts + end, AllOpts, S2SDNSOpts); +transform_options(Opt, Opts) -> + [Opt|Opts]. + %% Human readable S2S logging: Log only new outgoing connections as INFO %% Do not log dialback log_s2s_out(false, _, _, _) -> ok; @@ -1278,7 +1307,7 @@ wait_before_reconnect(StateData) -> queue = queue:new()}}. get_max_retry_delay() -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( s2s_max_retry_delay, fun(I) when is_integer(I), I > 0 -> I end) of undefined -> ?MAX_RETRY_DELAY; @@ -1295,7 +1324,7 @@ terminate_if_waiting_delay(From, To) -> Pids). fsm_limit_opts() -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( max_fsm_queue, fun(I) when is_integer(I), I > 0 -> I end) of undefined -> []; diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 49bea8950..35f7c187a 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -34,7 +34,7 @@ %% External exports -export([start/2, start_link/2, send_text/2, - send_element/2, socket_type/0]). + send_element/2, socket_type/0, transform_listen_option/2]). %% gen_fsm callbacks -export([init/1, wait_for_stream/2, @@ -124,29 +124,18 @@ init([{SockMod, Socket}, Opts]) -> {value, {_, A}} -> A; _ -> all end, - {Hosts, Password} = case lists:keysearch(hosts, 1, Opts) - of - {value, {_, Hs, HOpts}} -> - case lists:keysearch(password, 1, HOpts) of - {value, {_, P}} -> {Hs, P}; - _ -> - % TODO: generate error - false - end; - _ -> - case lists:keysearch(host, 1, Opts) of - {value, {_, H, HOpts}} -> - case lists:keysearch(password, 1, HOpts) of - {value, {_, P}} -> {[H], P}; - _ -> - % TODO: generate error - false - end; - _ -> - % TODO: generate error - false - end - end, + %% This should be improved probably + {Hosts, HostOpts} = case lists:keyfind(hosts, 1, Opts) of + {_, HOpts} -> + {[H || {H, _} <- HOpts], + lists:flatten( + [O || {_, O} <- HOpts])}; + _ -> + {[], []} + end, + Password = gen_mod:get_opt(password, HostOpts, + fun iolist_to_binary/1, + p1_sha:sha(crypto:rand_bytes(20))), Shaper = case lists:keysearch(shaper_rule, 1, Opts) of {value, {_, S}} -> S; _ -> none @@ -384,12 +373,30 @@ send_element(StateData, El) -> new_id() -> randoms:get_string(). +transform_listen_option({hosts, Hosts, O}, Opts) -> + case lists:keyfind(hosts, 1, Opts) of + {_, PrevHostOpts} -> + NewHostOpts = + lists:foldl( + fun(H, Acc) -> + dict:append_list(H, O, Acc) + end, dict:from_list(PrevHostOpts), Hosts), + [{hosts, dict:to_list(NewHostOpts)}| + lists:keydelete(hosts, 1, Opts)]; + _ -> + [{hosts, [{H, O} || H <- Hosts]}|Opts] + end; +transform_listen_option({host, Host, Os}, Opts) -> + transform_listen_option({hosts, [Host], Os}, Opts); +transform_listen_option(Opt, Opts) -> + [Opt|Opts]. + fsm_limit_opts(Opts) -> case lists:keysearch(max_fsm_queue, 1, Opts) of {value, {_, N}} when is_integer(N) -> [{max_queue, N}]; _ -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( max_fsm_queue, fun(I) when is_integer(I), I > 0 -> I end) of undefined -> []; diff --git a/src/ejabberd_system_monitor.erl b/src/ejabberd_system_monitor.erl index 2f5d1c330..92a41b9d8 100644 --- a/src/ejabberd_system_monitor.erl +++ b/src/ejabberd_system_monitor.erl @@ -53,7 +53,7 @@ %% Description: Starts the server %%-------------------------------------------------------------------- start_link() -> - LH = ejabberd_config:get_local_option( + LH = ejabberd_config:get_option( watchdog_large_heap, fun(I) when is_integer(I), I > 0 -> I end, 1000000), @@ -200,7 +200,7 @@ send_message(From, To, Body) -> [{xmlcdata, Body}]}]}). get_admin_jids() -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( watchdog_admins, fun(JIDs) -> [jlib:jid_tolower( diff --git a/src/ejabberd_web_admin.erl b/src/ejabberd_web_admin.erl index 8a2bacf15..4506455bd 100644 --- a/src/ejabberd_web_admin.erl +++ b/src/ejabberd_web_admin.erl @@ -827,14 +827,14 @@ process_admin(Host, {value, {_, String}} -> case parse_access_rule(String) of {ok, Rs} -> - ejabberd_config:add_global_option({access, Name, Host}, + ejabberd_config:add_option({access, Name, Host}, Rs), ok; _ -> error end; _ -> nothing end, - Rules = case ejabberd_config:get_global_option( + Rules = case ejabberd_config:get_option( {access, Name, Host}, fun(V) -> V end) of undefined -> []; @@ -1198,7 +1198,7 @@ access_parse_addnew(_AccessRules, Host, Query) -> case lists:keysearch(<<"namenew">>, 1, Query) of {value, {_, String}} when String /= <<"">> -> Name = jlib:binary_to_atom(String), - ejabberd_config:add_global_option({access, Name, Host}, + ejabberd_config:add_option({access, Name, Host}, []), ok end. diff --git a/src/eldap_utils.erl b/src/eldap_utils.erl index 6209802a8..a18a04ed6 100644 --- a/src/eldap_utils.erl +++ b/src/eldap_utils.erl @@ -182,7 +182,7 @@ get_opt({Key, Host}, Opts, F) -> get_opt({Key, Host}, Opts, F, Default) -> case gen_mod:get_opt(Key, Opts, F, undefined) of undefined -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( {Key, Host}, F, Default); Val -> Val diff --git a/src/extauth.erl b/src/extauth.erl index 23a409ce5..e57ac0b8d 100644 --- a/src/extauth.erl +++ b/src/extauth.erl @@ -106,7 +106,7 @@ random_instance(MaxNum) -> random:uniform(MaxNum) - 1. get_instances(Server) -> - ejabberd_config:get_local_option( + ejabberd_config:get_option( {extauth_instances, Server}, fun(V) when is_integer(V), V > 0 -> V diff --git a/src/gen_iq_handler.erl b/src/gen_iq_handler.erl index d53971fe4..628c1c90c 100644 --- a/src/gen_iq_handler.erl +++ b/src/gen_iq_handler.erl @@ -33,7 +33,7 @@ %% API -export([start_link/3, add_iq_handler/6, remove_iq_handler/3, stop_iq_handler/3, handle/7, - process_iq/6, check_type/1]). + process_iq/6, check_type/1, transform_module_options/1]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, @@ -46,7 +46,7 @@ -record(state, {host, module, function}). -type component() :: ejabberd_sm | ejabberd_local. --type type() :: no_queue | one_queue | {queues, pos_integer()} | parallel. +-type type() :: no_queue | one_queue | pos_integer() | parallel. -type opts() :: no_queue | {one_queue, pid()} | {queues, [pid()]} | parallel. %%==================================================================== @@ -71,7 +71,7 @@ add_iq_handler(Component, Host, NS, Module, Function, [Host, Module, Function]), Component:register_iq_handler(Host, NS, Module, Function, {one_queue, Pid}); - {queues, N} -> + N when is_integer(N) -> Pids = lists:map(fun (_) -> {ok, Pid} = supervisor:start_child(ejabberd_iq_sup, @@ -130,9 +130,19 @@ process_iq(_Host, Module, Function, From, To, IQ) -> check_type(no_queue) -> no_queue; check_type(one_queue) -> one_queue; -check_type({queues, N}) when is_integer(N), N>0 -> {queues, N}; +check_type(N) when is_integer(N), N>0 -> N; check_type(parallel) -> parallel. +-spec transform_module_options([{atom(), any()}]) -> [{atom(), any()}]. + +transform_module_options(Opts) -> + lists:map( + fun({iqdisc, {queues, N}}) -> + {iqdisc, N}; + (Opt) -> + Opt + end, Opts). + %%==================================================================== %% gen_server callbacks %%==================================================================== diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 5245dc65c..0b06529b5 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -64,13 +64,11 @@ start() -> -spec start_module(binary(), atom(), opts()) -> any(). start_module(Host, Module, Opts) -> - set_module_opts_mnesia(Host, Module, Opts), ets:insert(ejabberd_modules, #ejabberd_module{module_host = {Module, Host}, opts = Opts}), try Module:start(Host, Opts) catch Class:Reason -> - del_module_mnesia(Host, Module), ets:delete(ejabberd_modules, {Module, Host}), ErrorText = io_lib:format("Problem starting the module ~p for host " @@ -101,7 +99,7 @@ is_app_running(AppName) -> stop_module(Host, Module) -> case stop_module_keep_config(Host, Module) of error -> error; - ok -> del_module_mnesia(Host, Module) + ok -> ok end. %% @doc Stop the module in a host, but keep its configuration. @@ -232,25 +230,6 @@ loaded_modules_with_opts(Host) -> opts = '$2'}, [], [{{'$1', '$2'}}]}]). -set_module_opts_mnesia(Host, Module, Opts) -> - Modules = ejabberd_config:get_local_option( - {modules, Host}, - fun(Ls) when is_list(Ls) -> Ls end, - []), - Modules1 = lists:keydelete(Module, 1, Modules), - Modules2 = [{Module, Opts} | Modules1], - ejabberd_config:add_local_option({modules, Host}, - Modules2). - -del_module_mnesia(Host, Module) -> - Modules = ejabberd_config:get_local_option( - {modules, Host}, - fun(Ls) when is_list(Ls) -> Ls end, - []), - Modules1 = lists:keydelete(Module, 1, Modules), - ejabberd_config:add_local_option({modules, Host}, - Modules1). - -spec get_hosts(opts(), binary()) -> [binary()]. get_hosts(Opts, Prefix) -> diff --git a/src/mod_carboncopy.erl b/src/mod_carboncopy.erl index 9c2ab319b..087d090c8 100644 --- a/src/mod_carboncopy.erl +++ b/src/mod_carboncopy.erl @@ -3,7 +3,7 @@ %%% Author : Eric Cestari %%% Purpose : Message Carbons XEP-0280 0.8 %%% Created : 5 May 2008 by Mickael Remond -%%% Usage : Add the following line in modules section of ejabberd.cfg: +%%% Usage : Add the following line in modules section of ejabberd.yml: %%% {mod_carboncopy, []} %%% %%% diff --git a/src/mod_configure2.erl b/src/mod_configure2.erl index e3fbe82dc..375621441 100644 --- a/src/mod_configure2.erl +++ b/src/mod_configure2.erl @@ -129,7 +129,7 @@ process_get(#xmlel{name = <<"info">>}) -> children = []}}; process_get(#xmlel{name = <<"welcome-message">>, attrs = Attrs}) -> - {Subj, Body} = ejabberd_config:get_local_option( + {Subj, Body} = ejabberd_config:get_option( welcome_message, fun({Subj, Body}) -> {iolist_to_binary(Subj), @@ -145,7 +145,7 @@ process_get(#xmlel{name = <<"welcome-message">>, children = [{xmlcdata, Body}]}]}}; process_get(#xmlel{name = <<"registration-watchers">>, attrs = Attrs}) -> - SubEls = ejabberd_config:get_local_option( + SubEls = ejabberd_config:get_option( registration_watchers, fun(JIDs) when is_list(JIDs) -> lists:map( diff --git a/src/mod_disco.erl b/src/mod_disco.erl index d62251686..df3f320c7 100644 --- a/src/mod_disco.erl +++ b/src/mod_disco.erl @@ -36,7 +36,8 @@ process_sm_iq_items/3, process_sm_iq_info/3, get_sm_identity/5, get_sm_features/5, get_sm_items/5, get_info/5, register_feature/2, unregister_feature/2, - register_extra_domain/2, unregister_extra_domain/2]). + register_extra_domain/2, unregister_extra_domain/2, + transform_module_options/1]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -440,6 +441,22 @@ get_user_resources(User, Server) -> end, lists:sort(Rs)). +transform_module_options(Opts) -> + lists:map( + fun({server_info, Infos}) -> + NewInfos = lists:map( + fun({Modules, Name, URLs}) -> + [[{modules, Modules}, + {name, Name}, + {urls, URLs}]]; + (Opt) -> + Opt + end, Infos), + {server_info, NewInfos}; + (Opt) -> + Opt + end, Opts). + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Support for: XEP-0157 Contact Addresses for XMPP Services @@ -465,9 +482,17 @@ get_info(_A, Host, Mod, Node, _Lang) when Node == <<>> -> get_info(Acc, _, _, _Node, _) -> Acc. get_fields_xml(Host, Module) -> - Fields = gen_mod:get_module_opt(Host, ?MODULE, server_info, - fun(L) when is_list(L) -> L end, - []), + Fields = gen_mod:get_module_opt( + Host, ?MODULE, server_info, + fun(L) -> + lists:map( + fun(Opts) -> + Mods = proplists:get_value(modules, Opts, all), + Name = proplists:get_value(names, Opts, <<>>), + URLs = proplists:get_value(urls, Opts, []), + {Mods, Name, URLs} + end, lists:flatmap(L)) + end, []), Fields_good = lists:filter(fun ({Modules, _, _}) -> case Modules of all -> true; diff --git a/src/mod_last.erl b/src/mod_last.erl index 3ea86b350..6e35938d2 100644 --- a/src/mod_last.erl +++ b/src/mod_last.erl @@ -32,7 +32,8 @@ -export([start/2, stop/1, process_local_iq/3, export/1, process_sm_iq/3, on_presence_update/4, import/1, import/3, - store_last_info/4, get_last_info/2, remove_user/2]). + store_last_info/4, get_last_info/2, remove_user/2, + transform_options/1]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -101,18 +102,13 @@ process_local_iq(_From, _To, %% @doc Get the uptime of the ejabberd node, expressed in seconds. %% When ejabberd is starting, ejabberd_config:start/0 stores the datetime. get_node_uptime() -> - case ejabberd_config:get_local_option( + case ejabberd_config:get_option( node_start, - fun({MegaSecs, Secs, MicroSecs} = Now) - when is_integer(MegaSecs), MegaSecs >= 0, - is_integer(Secs), Secs >= 0, - is_integer(MicroSecs), MicroSecs >= 0 -> - Now - end) of + fun(S) when is_integer(S), S >= 0 -> S end) of undefined -> trunc(element(1, erlang:statistics(wall_clock)) / 1000); - StartNow -> - now_to_seconds(now()) - now_to_seconds(StartNow) + Now -> + now_to_seconds(now()) - Now end. now_to_seconds({MegaSecs, Secs, _MicroSecs}) -> @@ -319,3 +315,13 @@ import(_LServer, mnesia, #last_activity{} = LA) -> mnesia:dirty_write(LA); import(_, _, _) -> pass. + +transform_options(Opts) -> + lists:foldl(fun transform_options/2, [], Opts). + +transform_options({node_start, {_, _, _} = Now}, Opts) -> + ?WARNING_MSG("Old 'node_start' format detected. This is still supported " + "but it is better to fix your config.", []), + [{node_start, now_to_seconds(Now)}|Opts]; +transform_options(Opt, Opts) -> + [Opt|Opts]. diff --git a/src/mod_muc_log.erl b/src/mod_muc_log.erl index 97d992145..357d19216 100644 --- a/src/mod_muc_log.erl +++ b/src/mod_muc_log.erl @@ -33,7 +33,7 @@ -behaviour(gen_mod). %% API --export([start_link/2, start/2, stop/1, +-export([start_link/2, start/2, stop/1, transform_module_options/1, check_access_log/2, add_to_log/5]). %% gen_server callbacks @@ -111,6 +111,14 @@ check_access_log(Host, From) -> Res -> Res end. +transform_module_options(Opts) -> + lists:map( + fun({top_link, {S1, S2}}) -> + {top_link, [{S1, S2}]}; + (Opt) -> + Opt + end, Opts). + %%==================================================================== %% gen_server callbacks %%==================================================================== @@ -152,14 +160,14 @@ init([Host, Opts]) -> (universal) -> universal end, local), Top_link = gen_mod:get_opt(top_link, Opts, - fun({S1, S2}) -> + fun([{S1, S2}]) -> {iolist_to_binary(S1), iolist_to_binary(S2)} end, {<<"/">>, <<"Home">>}), NoFollow = gen_mod:get_opt(spam_prevention, Opts, fun(B) when is_boolean(B) -> B end, true), - Lang = ejabberd_config:get_local_option( + Lang = ejabberd_config:get_option( {language, Host}, fun iolist_to_binary/1, ?MYLANG), diff --git a/src/mod_proxy65.erl b/src/mod_proxy65.erl index 3e8354caf..85bec283b 100644 --- a/src/mod_proxy65.erl +++ b/src/mod_proxy65.erl @@ -33,7 +33,7 @@ -behaviour(supervisor). %% gen_mod callbacks. --export([start/2, stop/1]). +-export([start/2, stop/1, transform_module_options/1]). %% supervisor callbacks. -export([init/1]). @@ -64,6 +64,9 @@ start_link(Host, Opts) -> supervisor:start_link({local, Proc}, ?MODULE, [Host, Opts]). +transform_module_options(Opts) -> + mod_proxy65_service:transform_module_options(Opts). + init([Host, Opts]) -> Service = {mod_proxy65_service, {mod_proxy65_service, start_link, [Host, Opts]}, diff --git a/src/mod_proxy65_service.erl b/src/mod_proxy65_service.erl index 7d16e0f17..33d40b1cc 100644 --- a/src/mod_proxy65_service.erl +++ b/src/mod_proxy65_service.erl @@ -35,7 +35,7 @@ handle_cast/2, terminate/2, code_change/3]). %% API. --export([start_link/2, add_listener/2, +-export([start_link/2, add_listener/2, transform_module_options/1, delete_listener/1]). -include("ejabberd.hrl"). @@ -261,16 +261,15 @@ parse_options(ServerHost, Opts) -> Name = gen_mod:get_opt(name, Opts, fun iolist_to_binary/1, <<"SOCKS5 Bytestreams">>), IP = gen_mod:get_opt(ip, Opts, - fun(Addr) -> - jlib:ip_to_list(Addr), + fun(S) -> + {ok, Addr} = inet_parse:address( + binary_to_list( + iolist_to_binary(S))), Addr end, get_my_ip()), HostName = gen_mod:get_opt(hostname, Opts, - fun(Addr) when is_tuple(Addr) -> - jlib:ip_to_list(Addr); - (S) -> - iolist_to_binary(S) - end, jlib:ip_to_list(IP)), + fun iolist_to_binary/1, + jlib:ip_to_list(IP)), StreamAddr = [{<<"jid">>, MyHost}, {<<"host">>, HostName}, {<<"port">>, jlib:integer_to_binary(Port)}], @@ -278,6 +277,16 @@ parse_options(ServerHost, Opts) -> name = Name, port = Port, ip = IP, stream_addr = StreamAddr, acl = ACL}. +transform_module_options(Opts) -> + lists:map( + fun({ip, IP}) when is_tuple(IP) -> + {ip, jlib:ip_to_list(IP)}; + ({hostname, IP}) when is_tuple(IP) -> + {hostname, jlib:ip_to_list(IP)}; + (Opt) -> + Opt + end, Opts). + get_my_ip() -> {ok, MyHostName} = inet:gethostname(), case inet:getaddr(MyHostName, inet) of diff --git a/src/mod_proxy65_stream.erl b/src/mod_proxy65_stream.erl index 9b861f4db..b37dcc13a 100644 --- a/src/mod_proxy65_stream.erl +++ b/src/mod_proxy65_stream.erl @@ -279,10 +279,14 @@ select_auth_method(anonymous, AuthMethods) -> %% Obviously, we must use shaper with maximum rate. find_maxrate(Shaper, JID1, JID2, Host) -> - MaxRate1 = shaper:new(acl:match_rule(Host, Shaper, - JID1)), - MaxRate2 = shaper:new(acl:match_rule(Host, Shaper, - JID2)), + MaxRate1 = case acl:match_rule(Host, Shaper, JID1) of + deny -> none; + R1 -> shaper:new(R1) + end, + MaxRate2 = case acl:match_rule(Host, Shaper, JID2) of + deny -> none; + R2 -> shaper:new(R2) + end, if MaxRate1 == none; MaxRate2 == none -> none; true -> lists:max([MaxRate1, MaxRate2]) end. diff --git a/src/mod_register.erl b/src/mod_register.erl index 2b4e53de6..197927df0 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -32,7 +32,8 @@ -export([start/2, stop/1, stream_feature_register/2, unauthenticated_iq_register/4, try_register/5, - process_iq/3, send_registration_notifications/3]). + process_iq/3, send_registration_notifications/3, + transform_options/1, transform_module_options/1]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -418,7 +419,11 @@ try_register(User, Server, Password, SourceRaw, Lang) -> send_welcome_message(JID) -> Host = JID#jid.lserver, case gen_mod:get_module_opt(Host, ?MODULE, welcome_message, - fun({S, B}) -> + fun(Opts) -> + S = proplists:get_value( + subject, Opts, <<>>), + B = proplists:get_value( + body, Opts, <<>>), {iolist_to_binary(S), iolist_to_binary(B)} end, {<<"">>, <<"">>}) @@ -483,7 +488,7 @@ check_from(JID, Server) -> check_timeout(undefined) -> true; check_timeout(Source) -> - Timeout = ejabberd_config:get_local_option( + Timeout = ejabberd_config:get_option( registration_timeout, fun(TO) when is_integer(TO), TO > 0 -> TO; @@ -537,7 +542,7 @@ clean_treap(Treap, CleanPriority) -> remove_timeout(undefined) -> true; remove_timeout(Source) -> - Timeout = ejabberd_config:get_local_option( + Timeout = ejabberd_config:get_option( registration_timeout, fun(TO) when is_integer(TO), TO > 0 -> TO; @@ -604,6 +609,54 @@ is_strong_password(Server, Password) -> ejabberd_auth:entropy(Password) >= Entropy end. +transform_options(Opts) -> + Opts1 = transform_ip_access(Opts), + transform_module_options(Opts1). + +transform_ip_access(Opts) -> + try + {value, {modules, ModOpts}, Opts1} = lists:keytake(modules, 1, Opts), + {value, {?MODULE, RegOpts}, ModOpts1} = lists:keytake(?MODULE, 1, ModOpts), + {value, {ip_access, L}, RegOpts1} = lists:keytake(ip_access, 1, RegOpts), + true = is_list(L), + ?WARNING_MSG("Old 'ip_access' format detected. " + "The old format is still supported " + "but it is better to fix your config: " + "use access rules instead.", []), + ACLs = lists:flatmap( + fun({Action, S}) -> + ACLName = jlib:binary_to_atom( + iolist_to_binary( + ["ip_", S])), + [{Action, ACLName}, + {acl, ACLName, {ip, S}}] + end, L), + Access = {access, mod_register_networks, + [{Action, ACLName} || {Action, ACLName} <- ACLs]}, + [ACL || {acl, _, _} = ACL <- ACLs] ++ + [Access, + {modules, + [{mod_register, + [{ip_access, mod_register_networks}|RegOpts1]} + | ModOpts1]}|Opts1] + catch error:{badmatch, false} -> + Opts + end. + +transform_module_options(Opts) -> + lists:flatmap( + fun({welcome_message, {Subj, Body}}) -> + ?WARNING_MSG("Old 'welcome_message' format detected. " + "The old format is still supported " + "but it is better to fix your config: " + "change it to {welcome_message, " + "[{subject, Subject}, {body, Body}]}", + []), + [{welcome_message, [{subject, Subj}, {body, Body}]}]; + (Opt) -> + [Opt] + end, Opts). + %%% %%% ip_access management %%% @@ -614,75 +667,15 @@ may_remove_resource(From) -> From. get_ip_access(Host) -> gen_mod:get_module_opt(Host, ?MODULE, ip_access, - fun(IPAccess) -> - lists:flatmap( - fun({Access, S}) -> - {ok, IP, Mask} = - parse_ip_netmask( - iolist_to_binary(S)), - [{Access, IP, Mask}] - end, IPAccess) - end, []). + fun(A) when is_atom(A) -> A end, + all). -parse_ip_netmask(S) -> - case str:tokens(S, <<"/">>) of - [IPStr] -> - case inet_parse:address(binary_to_list(IPStr)) of - {ok, {_, _, _, _} = IP} -> {ok, IP, 32}; - {ok, {_, _, _, _, _, _, _, _} = IP} -> {ok, IP, 128}; - _ -> error - end; - [IPStr, MaskStr] -> - case catch jlib:binary_to_integer(MaskStr) of - Mask when is_integer(Mask), Mask >= 0 -> - case inet_parse:address(binary_to_list(IPStr)) of - {ok, {_, _, _, _} = IP} when Mask =< 32 -> - {ok, IP, Mask}; - {ok, {_, _, _, _, _, _, _, _} = IP} when Mask =< 128 -> - {ok, IP, Mask}; - _ -> error - end; - _ -> error - end; - _ -> error - end. - -check_ip_access(_Source, []) -> allow; check_ip_access({User, Server, Resource}, IPAccess) -> case ejabberd_sm:get_user_ip(User, Server, Resource) of - {IPAddress, _PortNumber} -> - check_ip_access(IPAddress, IPAccess); - _ -> true + {IPAddress, _PortNumber} -> + check_ip_access(IPAddress, IPAccess); + _ -> + deny end; -check_ip_access({_, _, _, _} = IP, - [{Access, {_, _, _, _} = Net, Mask} | IPAccess]) -> - IPInt = ip_to_integer(IP), - NetInt = ip_to_integer(Net), - M = bnot (1 bsl (32 - Mask) - 1), - if IPInt band M =:= NetInt band M -> Access; - true -> check_ip_access(IP, IPAccess) - end; -check_ip_access({_, _, _, _, _, _, _, _} = IP, - [{Access, {_, _, _, _, _, _, _, _} = Net, Mask} - | IPAccess]) -> - IPInt = ip_to_integer(IP), - NetInt = ip_to_integer(Net), - M = bnot (1 bsl (128 - Mask) - 1), - if IPInt band M =:= NetInt band M -> Access; - true -> check_ip_access(IP, IPAccess) - end; -check_ip_access(IP, [_ | IPAccess]) -> - check_ip_access(IP, IPAccess). - -ip_to_integer({IP1, IP2, IP3, IP4}) -> - IP1 bsl 8 bor IP2 bsl 8 bor IP3 bsl 8 bor IP4; -ip_to_integer({IP1, IP2, IP3, IP4, IP5, IP6, IP7, - IP8}) -> - IP1 bsl 16 bor IP2 bsl 16 bor IP3 bsl 16 bor IP4 bsl 16 - bor IP5 - bsl 16 - bor IP6 - bsl 16 - bor IP7 - bsl 16 - bor IP8. +check_ip_access(IPAddress, IPAccess) -> + acl:match_rule(global, IPAccess, IPAddress). diff --git a/src/mod_vcard_ldap.erl b/src/mod_vcard_ldap.erl index 7711353d2..1c96dd4a1 100644 --- a/src/mod_vcard_ldap.erl +++ b/src/mod_vcard_ldap.erl @@ -38,7 +38,7 @@ -export([start/2, start_link/2, stop/1, get_sm_features/5, process_local_iq/3, process_sm_iq/3, - remove_user/1, route/4]). + remove_user/1, route/4, transform_module_options/1]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -767,7 +767,7 @@ parse_options(Host, Opts) -> VCardMap = gen_mod:get_opt(ldap_vcard_map, Opts, fun(Ls) -> lists:map( - fun({S, P, L}) -> + fun({S, [{P, L}]}) -> {iolist_to_binary(S), iolist_to_binary(P), [iolist_to_binary(E) @@ -823,6 +823,20 @@ parse_options(Host, Opts) -> search_reported_attrs = SearchReportedAttrs, matches = Matches}. +transform_module_options(Opts) -> + lists:map( + fun({ldap_vcard_map, Map}) -> + NewMap = lists:map( + fun({Field, Pattern, Attrs}) -> + {Field, [{Pattern, Attrs}]}; + (Opt) -> + Opt + end, Map), + {ldap_vcard_map, NewMap}; + (Opt) -> + Opt + end, Opts). + check_filter(F) -> NewF = iolist_to_binary(F), {ok, _} = eldap_filter:parse(NewF), diff --git a/src/node_pep.erl b/src/node_pep.erl index f4b0bb38c..5635dee94 100644 --- a/src/node_pep.erl +++ b/src/node_pep.erl @@ -490,13 +490,11 @@ path_to_node(Path) -> node_flat:path_to_node(Path). %% Check that the mod_caps module is enabled in that Jabber Host %% If not, show a warning message in the ejabberd log file. complain_if_modcaps_disabled(ServerHost) -> - Modules = ejabberd_config:get_local_option({modules, ServerHost}, fun(Ms) when is_list(Ms) -> Ms end), - ModCaps = [mod_caps_enabled || {mod_caps, _Opts} <- Modules], - case ModCaps of - [] -> + case gen_mod:is_loaded(ServerHost, mod_caps) of + false -> ?WARNING_MSG("The PEP plugin is enabled in mod_pubsub " "of host ~p. This plugin requires mod_caps " "to be enabled, but it isn't.", [ServerHost]); - _ -> ok + true -> ok end. diff --git a/src/node_pep_odbc.erl b/src/node_pep_odbc.erl index 81cb7bc53..e4e1fafa9 100644 --- a/src/node_pep_odbc.erl +++ b/src/node_pep_odbc.erl @@ -433,7 +433,7 @@ path_to_node(Path) -> node_flat_odbc:path_to_node(Path). %% Check that the mod_caps module is enabled in that Jabber Host %% If not, show a warning message in the ejabberd log file. complain_if_modcaps_disabled(ServerHost) -> - Modules = ejabberd_config:get_local_option({modules, + Modules = ejabberd_config:get_option({modules, ServerHost}, fun(Ms) when is_list(Ms) -> Ms end), ModCaps = [mod_caps_enabled diff --git a/src/odbc_queries.erl b/src/odbc_queries.erl index 23b8e8da6..314b7cc13 100644 --- a/src/odbc_queries.erl +++ b/src/odbc_queries.erl @@ -219,13 +219,15 @@ list_users(LServer, [Prefix, Limit, Offset]))]). users_number(LServer) -> - case element(1, - ejabberd_config:get_local_option( - {odbc_server, LServer}, fun(V) -> V end)) - of + Type = ejabberd_config:get_option({odbc_type, LServer}, + fun(pgsql) -> pgsql; + (mysql) -> mysql; + (odbc) -> odbc + end, odbc), + case Type of pgsql -> case - ejabberd_config:get_local_option( + ejabberd_config:get_option( {pgsql_users_number_estimate, LServer}, fun(V) when is_boolean(V) -> V end, false) diff --git a/src/shaper.erl b/src/shaper.erl index 37c1a30c9..41e5f0626 100644 --- a/src/shaper.erl +++ b/src/shaper.erl @@ -28,7 +28,8 @@ -author('alexey@process-one.net'). --export([new/1, new1/1, update/2]). +-export([start/0, new/1, new1/1, update/2, + transform_options/1, load_from_config/0]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -37,32 +38,66 @@ lastrate = 0.0 :: float(), lasttime = 0 :: integer()}). --type maxrate() :: none | #maxrate{}. +-record(shaper, {name :: {atom(), global}, + maxrate :: integer()}). --type shaper() :: maxrate() | {maxrate(), integer()}. +-type shaper() :: none | #maxrate{}. -export_type([shaper/0]). --spec new(atom()) -> maxrate(). +-spec start() -> ok. +start() -> + mnesia:create_table(shaper, + [{ram_copies, [node()]}, + {local_content, true}, + {attributes, record_info(fields, shaper)}]), + mnesia:add_table_copy(shaper, node(), ram_copies), + load_from_config(), + ok. + +-spec load_from_config() -> ok | {error, any()}. + +load_from_config() -> + Shapers = ejabberd_config:get_option( + shaper, fun(V) -> V end, []), + case mnesia:transaction( + fun() -> + lists:foreach( + fun({Name, MaxRate}) -> + mnesia:write(#shaper{name = {Name, global}, + maxrate = MaxRate}) + end, Shapers) + end) of + {atomic, ok} -> + ok; + Err -> + {error, Err} + end. + +-spec new(atom()) -> shaper(). + +new(none) -> + none; new(Name) -> - Data = ejabberd_config:get_global_option( - {shaper, Name, global}, - fun({maxrate, R}) when is_integer(R), R>0 -> - {maxrate, R}; - (none) -> - none - end, none), - new1(Data). + MaxRate = case ets:lookup(shaper, {Name, global}) of + [#shaper{maxrate = R}] -> + R; + [] -> + ?WARNING_MSG("Attempt to initialize an " + "unspecified shaper '~s'", [Name]), + none + end, + new1(MaxRate). --spec new1(none | {maxrate, integer()}) -> maxrate(). +-spec new1(none | integer()) -> shaper(). new1(none) -> none; -new1({maxrate, MaxRate}) -> +new1(MaxRate) -> #maxrate{maxrate = MaxRate, lastrate = 0.0, lasttime = now_to_usec(now())}. --spec update(maxrate(), integer()) -> {maxrate(), integer()}. +-spec update(shaper(), integer()) -> {shaper(), integer()}. update(none, _Size) -> {none, 0}; update(#maxrate{} = State, Size) -> @@ -84,5 +119,15 @@ update(#maxrate{} = State, Size) -> lasttime = NextNow}, Pause}. +transform_options(Opts) -> + lists:foldl(fun transform_options/2, [], Opts). + +transform_options({shaper, Name, {maxrate, N}}, Opts) -> + [{shaper, [{Name, N}]}|Opts]; +transform_options({shaper, Name, none}, Opts) -> + [{shaper, [{Name, none}]}|Opts]; +transform_options(Opt, Opts) -> + [Opt|Opts]. + now_to_usec({MSec, Sec, USec}) -> (MSec * 1000000 + Sec) * 1000000 + USec. diff --git a/test/ejabberd_SUITE_data/ejabberd.yml b/test/ejabberd_SUITE_data/ejabberd.yml new file mode 100644 index 000000000..47cccb97c --- /dev/null +++ b/test/ejabberd_SUITE_data/ejabberd.yml @@ -0,0 +1,267 @@ +host_config: + "pgsql.localhost": + odbc_username: "ejabberd_test" + odbc_type: pgsql + odbc_server: "localhost" + odbc_port: 5432 + odbc_pool_size: 1 + odbc_password: "ejabberd_test" + odbc_database: "ejabberd_test" + auth_method: odbc + modules: + mod_announce: + db_type: odbc + mod_blocking: + db_type: odbc + mod_caps: + db_type: odbc + mod_last: + db_type: odbc + mod_muc: + db_type: odbc + mod_offline: + db_type: odbc + mod_privacy: + db_type: odbc + mod_private: + db_type: odbc + mod_pubsub_odbc: + access_createnode: pubsub_createnode + ignore_pep_from_offline: true + last_item_cache: false + plugins: + - "flat" + - "hometree" + - "pep" + mod_roster: + db_type: odbc + mod_mam: + db_type: odbc + mod_vcard: + db_type: odbc + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] +host_config: + "mysql.localhost": + odbc_username: "ejabberd_test" + odbc_type: mysql + odbc_server: "localhost" + odbc_port: 3306 + odbc_pool_size: 1 + odbc_password: "ejabberd_test" + odbc_database: "ejabberd_test" + auth_method: odbc + modules: + mod_announce: + db_type: odbc + mod_blocking: + db_type: odbc + mod_caps: + db_type: odbc + mod_last: + db_type: odbc + mod_muc: + db_type: odbc + mod_offline: + db_type: odbc + mod_privacy: + db_type: odbc + mod_private: + db_type: odbc + mod_pubsub_odbc: + access_createnode: pubsub_createnode + ignore_pep_from_offline: true + last_item_cache: false + plugins: + - "flat" + - "hometree" + - "pep" + mod_roster: + db_type: odbc + mod_mam: + db_type: odbc + mod_vcard: + db_type: odbc + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] +host_config: + "mnesia.localhost": + auth_method: internal + modules: + mod_announce: + db_type: internal + mod_blocking: + db_type: internal + mod_caps: + db_type: internal + mod_last: + db_type: internal + mod_muc: + db_type: internal + mod_offline: + db_type: internal + mod_privacy: + db_type: internal + mod_private: + db_type: internal + mod_pubsub: + access_createnode: pubsub_createnode + ignore_pep_from_offline: true + last_item_cache: false + plugins: + - "flat" + - "hometree" + - "pep" + mod_roster: + db_type: internal + mod_mam: + db_type: internal + mod_vcard: + db_type: internal + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] +host_config: + "localhost": + auth_method: internal +host_config: + "ldap.localhost": + ldap_servers: + - "localhost" + ldap_rootdn: "cn=admin,dc=localhost" + ldap_port: 1389 + ldap_password: "password" + ldap_base: "ou=users,dc=localhost" + auth_method: ldap + modules: + mod_vcard_ldap: [] + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] +host_config: + "extauth.localhost": + extauth_program: "python extauth.py" + auth_method: external +hosts: + - "localhost" + - "mnesia.localhost" + - "mysql.localhost" + - "pgsql.localhost" + - "extauth.localhost" + - "ldap.localhost" +access: + announce: + admin: allow + c2s: + blocked: deny + all: allow + c2s_shaper: + admin: none + all: normal + configure: + admin: allow + local: + local: allow + max_user_offline_messages: + admin: 5000 + all: 100 + max_user_sessions: + all: 10 + muc: + all: allow + muc_admin: + admin: allow + muc_create: + local: allow + pubsub_createnode: + local: allow + register: + all: allow + s2s_shaper: + all: fast +acl: + local: + user_regexp: + - [] +define_macro: + CERTFILE: "cert.pem" +language: "en" +listen: + - + port: 5222 + module: ejabberd_c2s + max_stanza_size: 65536 + certfile: CERTFILE + zlib: true + starttls: true + shaper: c2s_shaper + access: c2s + - + port: 5269 + module: ejabberd_s2s_in + - + port: 5280 + module: ejabberd_http + captcha: true +loglevel: 4 +max_fsm_queue: 1000 +modules: + mod_adhoc: [] + mod_configure: [] + mod_disco: [] + mod_ping: [] + mod_proxy65: [] + mod_register: + welcome_message: + subject: "Welcome!" + body: "Hi. +Welcome to this XMPP server." + mod_stats: [] + mod_time: [] + mod_version: [] +registration_timeout: infinity +shaper: + fast: 50000 + normal: 1000 \ No newline at end of file diff --git a/test/suite.erl b/test/suite.erl index cbb4ca227..8104df75e 100644 --- a/test/suite.erl +++ b/test/suite.erl @@ -21,7 +21,7 @@ init_config(Config) -> PrivDir = proplists:get_value(priv_dir, Config), [_, _|Tail] = lists:reverse(filename:split(DataDir)), BaseDir = filename:join(lists:reverse(Tail)), - ConfigPath = filename:join([DataDir, "ejabberd.cfg"]), + ConfigPath = filename:join([DataDir, "ejabberd.yml"]), LogPath = filename:join([PrivDir, "ejabberd.log"]), SASLPath = filename:join([PrivDir, "sasl.log"]), MnesiaDir = filename:join([PrivDir, "mnesia"]),