⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x1740.htm

📁 Its a xmpp protocol book
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<HTML
><HEAD
><TITLE
>A Tour of jabber.xml</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"><LINK
REL="HOME"
TITLE="Programming Jabber"
HREF="book1.htm"><LINK
REL="UP"
TITLE="Server Architecture and Configuration"
HREF="c1223.htm"><LINK
REL="PREVIOUS"
TITLE="Server Configuration"
HREF="x1581.htm"><LINK
REL="NEXT"
TITLE="Managing the Configuration"
HREF="x3305.htm"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Programming Jabber</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x1581.htm"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 4. Server Architecture and Configuration</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x3305.htm"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="JABTDG-CH-4-SECT-4.3"
>A Tour of <TT
CLASS="FILENAME"
>jabber.xml</TT
></A
></H1
><P
>Now we know what patterns to look out for, we're well prepared to dive
into a <TT
CLASS="FILENAME"
>jabber.xml</TT
> configuration file. As an example,
we'll take one that's very similar to the default
<TT
CLASS="FILENAME"
>jabber.xml</TT
> installed with 
version 1.4.1 of
Jabber, but we'll plug in some extra components: the
Conferencing component and a local JUD component. </P
><P
>The entire configuration content, with comment lines dividing up
each section, can be found in <A
HREF="a10211.htm"
>Appendix A</A
>.
It's definitely worth turning briefly to have a look at the XML
before continuing, to get a feel for how the configuration is 
laid out.</P
><P
>In order to deal with it without going crazy, let's break down the
XML into manageable chunks.
We'll build configuration diagrams for each of the top-level tags
that are children of the root tag
<TT
CLASS="LITERAL"
>&#60;jabber/&#62;</TT
>.
The opening tags for each of these chunks are as follows:</P
><P
></P
><UL
><LI
><P
><TT
CLASS="LITERAL"
>&#60;service id="sessions"&#62;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>&#60;xdb id="xdb"&#62;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>&#60;service id="c2s"&#62;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>&#60;log id="elogger"&#62;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>&#60;log id="rlogger"&#62;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>&#60;service id="dnsrv"&#62;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>&#60;service id="s2s"&#62;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>&#60;service id="conf"&#62;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>&#60;io&#62;</TT
></P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>&#60;pidfile&#62;</TT
></P
></LI
></UL
><P
>Most of these should be recognisable by now, but there are two chunks that
we haven't come across yet:
<TT
CLASS="LITERAL"
>&#60;io&#62;</TT
> and
<TT
CLASS="LITERAL"
>&#60;pidfile&#62;</TT
>.
These aren't components but nevertheless are part of the configuration
for <B
CLASS="COMMAND"
>jabberd</B
>; there are also the two 
<I
CLASS="EMPHASIS"
>Logging</I
> component instances that we have not paid
much attention to until now.</P
><P
><A
HREF="x1740.htm#JABTDG-CH-4-FIG-4.4"
>Figure 4-4</A
> provides an overview of how the
Jabber server is configured. It represents the contents of the
<TT
CLASS="FILENAME"
>jabber.xml</TT
> configuration file in 
<A
HREF="a10211.htm"
>Appendix A</A
> in diagram form. </P
><DIV
CLASS="FIGURE"
><A
NAME="JABTDG-CH-4-FIG-4.4"
></A
><P
><B
>Figure 4-4. Configuration file in diagram form</B
></P
><PRE
CLASS="SCREEN"
>&#13;+----------+                         +-----+
| sessions |                         | xdb |
+----------+-------------------+     +-----+------------------------+
|                      service |     |                          xdb | 
|--&#62; host    yak               |     |--&#62; host    *                 |
|--&#62; load    jsm.so            |     |--&#62; load    xdb_file.so       |
|--&#62; config  filter, vCard,    |     |--&#62; config  spool             |
|            register, welcome |     +------------------------------+
|            ...               |
+------------------------------+     +---------+
                                     | elogger |
+-----+                              +---------+--------------------+
| c2s |                              |                          log |
+-----+------------------------+     |--&#62; host    *                 |
|                      service |     |--&#62; logtype *                 |
|--&#62; host    (c2s)             |     |--&#62; format  ...               |
|--&#62; load    pth_client.so     |     |--&#62; file    ...               |
|--&#62; config  authtime, ip,     |     |--&#62; stderr                    |
|            karma             |     +------------------------------+
+------------------------------+
                                     +---------+
+-------+                            | rlogger |
| dnsrv |                            +---------+--------------------+
+-------+----------------------+     |                          log |
|                      service |     |--&#62; host    *                 |
|--&#62; host    *                 |     |--&#62; logtype record            |
|--&#62; load    dnsrv.so          |     |--&#62; format  ...               |
|--&#62; config  resend            |     |--&#62; file    ...               |
+------------------------------+     +------------------------------+

+------+                             +-----+
| conf |                             | s2s |
+------+-----------------------+     +-----+------------------------+
|                      service |     |                      service |
|--&#62; host    conference.yak    |     |--&#62; host    (s2s)             |
|--&#62; load    conference.so     |     |--&#62; load    dialback.so       |
|--&#62; config  public, vCard,    |     |--&#62; config  legacy, ip, karma |
|            history, notice   |     +------------------------------+
|            room              |
+------------------------------+     +----+
                                     | io |
+-----+                              +----+--------------+
| jud |                              |--&#62; rate   ...     |
+-----+------------------------+     |--&#62; karma  ...     |
|                      service |     |--&#62; ssl    ...     |
|--&#62; host    jud.yak           |     |--&#62; allow  ...     |
|--&#62; load    jud.so            |     |--&#62; deny   ...     |
|--&#62; config  vCard             |     +-------------------+
+------------------------------+
                                     +---------+
                                     | pidfile |
                                     +---------+---------+
                                     |--&#62; jabber.pid     |
                                     +-------------------+
&#13;</PRE
></DIV
><P
>We can see that the bulk of the Jabber server functionality described
here is in the form of components. Let's take each of these components
one by one and have a closer look.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="JABTDG-CH-4-SECT-4.3.1"
>Component instance: <I
CLASS="EMPHASIS"
>sessions</I
></A
></H2
><P
>The <I
CLASS="EMPHASIS"
>sessions</I
> component, described by the configuration
XML shown in <A
HREF="x1740.htm#JABTDG-CH-4-EX-8"
>Example 4-8</A
> and shown in diagram form
in <A
HREF="x1740.htm#JABTDG-CH-4-FIG-4.5"
>Figure 4-5</A
>, provides Session Management
features for users (the word "users" is employed in the widest possible
sense&mdash;a user could be a person or a script) connecting with Jabber
clients - through XML streams identified 
with the <TT
CLASS="LITERAL"
>jabber:client</TT
> stream namespace.</P
><DIV
CLASS="FIGURE"
><A
NAME="JABTDG-CH-4-FIG-4.5"
></A
><P
><B
>Figure 4-5. Diagram view of <I
CLASS="EMPHASIS"
>sessions</I
> component instance</B
></P
><PRE
CLASS="SCREEN"
>+----------+                      
| sessions |                     
+----------+-------------------+ 
|                      service |
|--&#62; host    yak               |  
|--&#62; load    jsm.so            | 
|--&#62; config  filter, vCard,    | 
|            register, welcome | 
|            ...               |
+------------------------------+ </PRE
></DIV
><P
>It also provides the services that give Jabber its IM capabilities&mdash;
services such as roster management, message filtering, store-and-forward
("offline") message handling, and so on. These IM services are loaded
individually as part of the component connection phase.</P
><DIV
CLASS="EXAMPLE"
><A
NAME="JABTDG-CH-4-EX-8"
></A
><P
><B
>Example 4-8. <TT
CLASS="FILENAME"
>jabber.xml</TT
> configuration for the <I
CLASS="EMPHASIS"
>sessions</I
> component instance</B
></P
><P
><PRE
CLASS="SCREEN"
>&#60;service id="sessions"&#62;

  &#60;host&#62;&#60;jabberd:cmdline flag="h"&#62;yak&#60;/jabberd:cmdline&#62;&#60;/host&#62;

  &#60;jsm xmlns="jabber:config:jsm"&#62;
    &#60;filter&#62;
        &#60;default/&#62;
        &#60;max_size&#62;100&#60;/max_size&#62;
        &#60;allow&#62;
            &#60;conditions&#62;
                &#60;ns/&#62;
                &#60;unavailable/&#62;
                &#60;from/&#62;
                &#60;resource/&#62;
                &#60;subject/&#62;
                &#60;body/&#62;
                &#60;show/&#62;
                &#60;type/&#62;
                &#60;roster/&#62;
                &#60;group/&#62;
            &#60;/conditions&#62;
            &#60;actions&#62;
                &#60;error/&#62;
                &#60;offline/&#62;
                &#60;forward/&#62;
                &#60;reply/&#62;
                &#60;continue/&#62;
                &#60;settype/&#62;
            &#60;/actions&#62;
        &#60;/allow&#62;
    &#60;/filter&#62;
    &#60;vCard&#62;
      &#60;FN&#62;Jabber Server on yak&#60;/FN&#62;
      &#60;DESC&#62;A Jabber Server!&#60;/DESC&#62;
      &#60;URL&#62;http://yak/&#60;/URL&#62;
    &#60;/vCard&#62;
    &#60;register notify="yes"&#62;
      &#60;instructions&#62;Choose a userid and password to register.&#60;/instructions&#62;
      &#60;name/&#62;
      &#60;email/&#62;
    &#60;/register&#62;
    &#60;welcome&#62;
      &#60;subject&#62;Welcome!&#60;/subject&#62;
      &#60;body&#62;Welcome to the Jabber server on yak&#60;/body&#62;
    &#60;/welcome&#62;
    &#60;!--
    &#60;admin&#62;
      &#60;read&#62;support@yak&#60;/read&#62;
      &#60;write&#62;admin@yak&#60;/write&#62;
      &#60;reply&#62;
        &#60;subject&#62;Auto Reply&#60;/subject&#62;
        &#60;body&#62;This is a special administrative address.&#60;/body&#62;
      &#60;/reply&#62;
    &#60;/admin&#62;
    --&#62;
    &#60;update&#62;&#60;jabberd:cmdline flag="h"&#62;yak&#60;/jabberd:cmdline&#62;&#60;/update&#62;
    &#60;vcard2jud/&#62;
    &#60;browse&#62;
      &#60;service type="jud" jid="jud.yak" name="yak User Directory"&#62;
        &#60;ns&#62;jabber:iq:search&#60;/ns&#62;
        &#60;ns&#62;jabber:iq:register&#60;/ns&#62;
      &#60;/service&#62;
      &#60;conference type="public" jid="conference.yak" name="yak Conferencing"/&#62;
    &#60;/browse&#62;

  &#60;/jsm&#62;

  &#60;load main="jsm"&#62;
    &#60;jsm&#62;./jsm/jsm.so&#60;/jsm&#62;
    &#60;mod_echo&#62;./jsm/jsm.so&#60;/mod_echo&#62;
    &#60;mod_roster&#62;./jsm/jsm.so&#60;/mod_roster&#62;
    &#60;mod_time&#62;./jsm/jsm.so&#60;/mod_time&#62;
    &#60;mod_vcard&#62;./jsm/jsm.so&#60;/mod_vcard&#62;
    &#60;mod_last&#62;./jsm/jsm.so&#60;/mod_last&#62;
    &#60;mod_version&#62;./jsm/jsm.so&#60;/mod_version&#62;
    &#60;mod_announce&#62;./jsm/jsm.so&#60;/mod_announce&#62;
    &#60;mod_agents&#62;./jsm/jsm.so&#60;/mod_agents&#62;
    &#60;mod_browse&#62;./jsm/jsm.so&#60;/mod_browse&#62;
    &#60;mod_admin&#62;./jsm/jsm.so&#60;/mod_admin&#62;
    &#60;mod_filter&#62;./jsm/jsm.so&#60;/mod_filter&#62;
    &#60;mod_offline&#62;./jsm/jsm.so&#60;/mod_offline&#62;
    &#60;mod_presence&#62;./jsm/jsm.so&#60;/mod_presence&#62;
    &#60;mod_auth_plain&#62;./jsm/jsm.so&#60;/mod_auth_plain&#62;
    &#60;mod_auth_digest&#62;./jsm/jsm.so&#60;/mod_auth_digest&#62;
    &#60;mod_auth_0k&#62;./jsm/jsm.so&#60;/mod_auth_0k&#62;
    &#60;mod_log&#62;./jsm/jsm.so&#60;/mod_log&#62;
    &#60;mod_register&#62;./jsm/jsm.so&#60;/mod_register&#62;
    &#60;mod_xml&#62;./jsm/jsm.so&#60;/mod_xml&#62;
  &#60;/load&#62;

&#60;/service&#62;</PRE
></P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="JABTDG-CH-4-SECT-4.3.1.1"
>Component type and identification</A
></H3
><P
>The opening tag:</P
><P
><PRE
CLASS="SCREEN"
>&#60;service id="sessions"&#62;</PRE
></P
><P
>identifies this component instance to the backbone as a service type
component and gives it a name ("sessions") that can be used for 
internal addressing 
and to distinguish it from other component instances. </P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="JABTDG-CH-4-SECT-4.3.1.2"
>Host filter</A
></H3
><P
>Assuming that our hostname isn't "sessions," it's just as well that
we have a 
<TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
>
specification in this component instance description:</P
><P
><PRE
CLASS="SCREEN"
>&#60;host&#62;&#60;jabberd:cmdline flag="h"&#62;yak&#60;/jabberd:cmdline&#62;&#60;/host&#62;</PRE
></P
><P
>which means that this session management component instance will
handle packets addressed to the host "yak." 

<A
NAME="JABTDG-CH-4-FOOTNOTE-7"
HREF="#FTN.JABTDG-CH-4-FOOTNOTE-7"
>[1]</A
>

The 
<TT
CLASS="LITERAL"
>&#60;jabberd:cmdline flag="h"&#62; ... &#60;/jabberd:cmdline&#62;</TT
>
wrapper around the hostname means that this value ("yak") can be overridden
by specifying a switch <TT
CLASS="OPTION"
>-h &#60;hostname&#62;</TT
> when 
<B
CLASS="COMMAND"
>jabberd</B
>
is invoked, as is described in <A
HREF="c813.htm"
>Chapter 3</A
>.
If you're sure you'll never want
to override the hostname setting here, this
<TT
CLASS="LITERAL"
>&#60;jabberd:cmdline/&#62;</TT
> wrapper can
safely be removed from the configuration, to leave:</P
><P
><PRE
CLASS="SCREEN"
>&#60;host&#62;yak&#60;/host&#62;</PRE
></P
><P
>As described earlier, you can specify more than one hostname - use a 
<TT
CLASS="LITERAL"
>&#60;host&#62;...&#60;/host&#62;</TT
>
pair for each one. This will effectively give you a virtual server effect
where Jabber will respond to different hostnames. This is useful in situations 
such as deployment in an ISP where a single host serves multiple domains.
The client data stored on the server (such as rosters, offline messages,
and so on) is stored by the xdb component by hostname, so that a separate
directory in the spool area will be used for each specified hostname. </P
><P
>For example, if you specified the two hosts:</P
><P
><PRE
CLASS="SCREEN"
>&#60;host&#62;a-domain.com&#60;/host&#62;
&#60;host&#62;b-domain.com&#60;/host&#62;</PRE
></P
><P

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -