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

📄 x1581.htm

📁 Its a xmpp protocol book
💻 HTM
📖 第 1 页 / 共 2 页
字号:
>"none specified."</I
>
So what happens now?  Well, a host filter is usually one or more 
<TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
> tags containing
hostnames to which the component instance will "answer". It's a way of
specifying that packets destined for a certain hostname will be received
by that component instance. </P
><P
>However, if there are no 
<TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
> tags specified
as in this c2s example, then the component instance's identification
is taken as the hostname specification. In other words, the
<TT
CLASS="LITERAL"
>&#60;service id="c2s"&#62;</TT
> declaration 
in this example, coupled with the
lack of any explicit <TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
>
tag, <I
CLASS="EMPHASIS"
>implies</I
> a host filter of "c2s".
This component instance wants to receive all packets with 
addresses that have "c2s" as the hostname. It's the equivalent of this
host filter specification:</P
><P
><PRE
CLASS="SCREEN"
>&#60;host&#62;c2s&#60;/host&#62;</PRE
></P
><TABLE
CLASS="SIDEBAR"
BORDER="1"
CELLPADDING="5"
><TR
><TD
><DIV
CLASS="SIDEBAR"
><A
NAME="AEN1667"
></A
><P
><B
>Packets and Hostnames</B
></P
><P
>Each packet travelling within the Jabber universe has a destination address,
which at the very least contains a hostname specification. This hostname
can be a "real" hostname in the DNS sense, or it can be a Jabber-internal
hostname, such as '<TT
CLASS="LITERAL"
>jud.yak</TT
>'.</P
><P
>When you send a packet, such as a 
<TT
CLASS="LITERAL"
>&#60;message/&#62;</TT
> element from your Jabber
client, you're sending it as an XML fragment within the context of the
<TT
CLASS="LITERAL"
>jabber:client</TT
>
XML stream running between your client and the Jabber server. Apart from the
initial activity to connect to the Jabber server's listening socket, there's no
hostname resolution on the client's part&mdash;the hostname in the recipient
address is just specified as an attribute (<TT
CLASS="OPTION"
>to</TT
>) of the 
<TT
CLASS="LITERAL"
>&#60;message/&#62;</TT
>
tag <I
CLASS="EMPHASIS"
>inside</I
> the stream. </P
><P
>Once a packet reaches the Jabber server, <B
CLASS="COMMAND"
>jabberd</B
> will
try to deliver it to its destination. In doing so it will check an 
internal list of component instances derived from the configuration file
specified at startup, and work out which instance (or instances; more than
one may have registered to receive packets destined for the same hostname)
should receive it.</P
><P
>If no matching instance can be found (i.e., there are
no instances filtering for the hostname specified in the packet's destination
address) then the Jabber server will assume it's for a non-local destination
and attempt to resolve the hostname into
an IP address using the <I
CLASS="EMPHASIS"
>Hostname Resolution</I
> component
and send it on using the <I
CLASS="EMPHASIS"
>Server (to Server) Connections</I
>
component.</P
></DIV
></TD
></TR
></TABLE
><DIV
CLASS="SECT4"
><H4
CLASS="SECT4"
><A
NAME="JABTDG-CH-4-SECT-4.2.2.3.1"
>The <TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
> tag</A
></H4
><P
>There is some degree of flexibility in how you specify a hostname in the
<TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
>
tag.</P
><P
>You can specify an absolute hostname like this:</P
><P
><PRE
CLASS="SCREEN"
>&#60;host&#62;conference.yak&#60;/host&#62;</PRE
></P
><P
>You can specify more than one hostname like this:</P
><P
><PRE
CLASS="SCREEN"
>&#60;host&#62;conference.yak&#60;/host&#62;
&#60;host&#62;talk.yak&#60;/host&#62;</PRE
></P
><P
>For example, if this pair of 
<TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
>
tags appeared in an instance specification for the 
<I
CLASS="EMPHASIS"
>Conferencing</I
> component, you could address the 
component instance using either hostname. </P
><P
>You can use a wildcard character to specify all hostnames within 
a domain, for example:</P
><P
><PRE
CLASS="SCREEN"
>&#60;host&#62;*.pipetree.com&#60;/host&#62;</PRE
></P
><P
>will match on all hosts with the domain name <TT
CLASS="FILENAME"
>pipetree.com</TT
>.</P
><P
>If you want the component instance to receive packets regardless of the
hostname, you can specify an empty tag thus:</P
><P
><PRE
CLASS="SCREEN"
>&#60;host/&#62;</PRE
></P
></DIV
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="JABTDG-CH-4-SECT-4.2.2.4"
>Component connection method</A
></H3
><P
>What is the component? Where do we load it from, or how does it connect
to the Jabber backbone? There is a
<I
CLASS="EMPHASIS"
>component connection method</I
>
(see <A
HREF="x1234.htm#JABTDG-CH-4-SECT-4.1.3"
>the section called <I
>Component Connection Methods</I
></A
> earlier in this Chapter)
specified in each of the component instance definitions. In our example
of the c2s component instance, we see that the 
<I
CLASS="EMPHASIS"
>library load</I
> method is being used to load the
<TT
CLASS="FILENAME"
>./pthsock/pthsock_client.so</TT
> shared object library,
and that the component registration routine
<TT
CLASS="FUNCTION"
>pthsock_client()</TT
> should be called once loading is 
complete:</P
><P
><PRE
CLASS="SCREEN"
>&#60;load&#62;
  &#60;pthsock_client&#62;./pthsock/pthsock_client.so&#60;/pthsock_client&#62;
&#60;/load&#62;</PRE
></P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="JABTDG-CH-4-SECT-4.2.2.5"
>Custom configuration</A
></H3
><P
>Once we've dealt with the (optional or implied)
<TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
>
tag hostname filters, and the component connection method, all
that is left is the custom configuration for the component instance 
itself. This will look different for different components, but there
is still a pattern that you can recognize. The configuration always appears
in a "wrapper" tag that, like the 
<TT
CLASS="LITERAL"
>&#60;host/&#62;</TT
>
and
<TT
CLASS="LITERAL"
>&#60;load/&#62;</TT
>
tags above, appears as an immediate child of the component type tag
(that's 
<TT
CLASS="LITERAL"
>&#60;service/&#62;</TT
>
in our c2s example):</P
><P
><PRE
CLASS="SCREEN"
>&#60;service id="c2s"&#62;
  ...
<TT
CLASS="USERINPUT"
><B
>  &#60;pthcsock xmlns='jabber:config:pth-csock'&#62;
     ... [configuration here] ...
  &#60;/pthcsock&#62;</B
></TT
>
&#60;/service&#62;</PRE
></P
><P
>There are two things to note here:</P
><P
></P
><UL
><LI
><P
>The tag name
(<TT
CLASS="LITERAL"
>&#60;pthcsock/&#62;</TT
>)</P
></LI
><LI
><P
>The namespace declaration
(<TT
CLASS="LITERAL"
>xmlns='jabber:config:pth-csock'</TT
>)</P
></LI
></UL
><P
>To put it bluntly, one is important, the other isn't. The name of the
tag enclosing the instance's configuration&mdash;"pthcsock" is not important. 
There must be a name (otherwise it wouldn't be valid XML) but it might
as well be "banana" for all the effect it would have. So as it might as
well be "banana," it might as well be something meaningful&mdash;hence
"pthcsock."</P
><P
>The important part of the configuration wrapper tag is the namespace
declaration:</P
><P
><PRE
CLASS="SCREEN"
>xmlns="jabber:config:pth-csock"</PRE
></P
><P
>because that is what the component actually uses to search for and retrieve
the configuration.</P
><P
>As for the actual configuration elements for the c2s component instance 
that we see here (
<TT
CLASS="LITERAL"
>&#60;authtime/&#62;</TT
> and
<TT
CLASS="LITERAL"
>&#60;karma/&#62;</TT
>),
we'll take a look at them in the next section.</P
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x1234.htm"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.htm"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x1740.htm"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>An Overview of the Server Architecture</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c1223.htm"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>A Tour of <TT
CLASS="FILENAME"
>jabber.xml</TT
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

⌨️ 快捷键说明

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