25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

* doc/guide.tex: Updated

* src/ejabberd_s2s_out.erl: Added support for IPv6 and
"_jabber-server.tcp" lookups

* src/jlib.erl (string_to_jid1): Bugfix

* src/ejabberd_config.erl: Now possible to specify path to config
file in command line

SVN Revision: 149
This commit is contained in:
Alexey Shchepin 2003-10-12 18:21:16 +00:00
parent 146d464f96
commit 5c0ba6e337
7 changed files with 104 additions and 48 deletions

View File

@ -1,3 +1,15 @@
2003-10-12 Alexey Shchepin <alexey@sevcom.net>
* doc/guide.tex: Updated
* src/ejabberd_s2s_out.erl: Added support for IPv6 and
"_jabber-server.tcp" lookups
* src/jlib.erl (string_to_jid1): Bugfix
* src/ejabberd_config.erl: Now possible to specify path to config
file in command line
2003-10-11 Alexey Shchepin <alexey@sevcom.net> 2003-10-11 Alexey Shchepin <alexey@sevcom.net>
* doc/guide.tex: Updated * doc/guide.tex: Updated

View File

@ -113,8 +113,8 @@ server. It is writen mostly in Erlang.<BR>
<BR> <BR>
The main features of <TT>ejabberd</TT> is: The main features of <TT>ejabberd</TT> is:
<UL><LI> <UL><LI>
Works on most of popular platforms: *nix (tested on Linux and FreeBSD) Works on most of popular platforms: *nix (tested on Linux, FreeBSD and
and Win32 NetBSD) and Win32
<LI>Distributed: You can run <TT>ejabberd</TT> on a cluster of machines and all of <LI>Distributed: You can run <TT>ejabberd</TT> on a cluster of machines and all of
them will serve one Jabber domain. them will serve one Jabber domain.
<LI>Fault-tolerance: You can setup an <TT>ejabberd</TT> cluster so that all the <LI>Fault-tolerance: You can setup an <TT>ejabberd</TT> cluster so that all the
@ -247,16 +247,31 @@ Windows distribution of Erlang emulator.<BR>
<H3><A NAME="htoc10">2.4</A>&nbsp;&nbsp;Starting</H3><!--SEC END --> <H3><A NAME="htoc10">2.4</A>&nbsp;&nbsp;Starting</H3><!--SEC END -->
<A NAME="sec:starting"></A> <A NAME="sec:starting"></A>
... To use more than 1024 connections, you will need to set environment To start <TT>ejabberd</TT>, use the following command:
variable <TT>ERL_MAX_PORTS</TT>: <PRE>
erl -name ejabberd -s ejabberd
</PRE>or
<PRE>
erl -sname ejabberd -s ejabberd
</PRE>In second case Erlang node will be identified using only first part of host
name, i.&nbsp;e. other Erlang nodes not inside this domain can't contact this node.<BR>
<BR>
To specify path to config file, use command like this:
<PRE>
erl -sname ejabberd -s ejabberd -ejabberd config \"/etc/ejabberd/ejabberd.cfg\"
</PRE>
To use more than 1024 connections, you will need to set environment variable
<CODE>ERL_MAX_PORTS</CODE>:
<PRE> <PRE>
export ERL_MAX_PORTS=32000 export ERL_MAX_PORTS=32000
</PRE>Note that with this value <TT>ejabberd</TT> will use more memory (approximately 6MB </PRE>Note that with this value <TT>ejabberd</TT> will use more memory (approximately 6MB
more)... more).<BR>
<BR>
To reduce memory usage, you can set environment variable
<CODE>ERL_FULLSWEEP_AFTER</CODE>:
<PRE> <PRE>
erl -name ejabberd -s ejabberd export ERL_FULLSWEEP_AFTER=0
</PRE> </PRE>But in this case <TT>ejabberd</TT> can start to work slower.<BR>
TBD<BR>
<BR> <BR>
<!--TOC section Configuration--> <!--TOC section Configuration-->
@ -415,18 +430,21 @@ Port number;
</UL> </UL>
Currently three modules are implemented: Currently three modules are implemented:
<DL COMPACT=compact><DT> <DL COMPACT=compact><DT>
<B><TT>ejabberd_c2s</TT></B><DD> This module serves C2S connections.<BR> <CODE><B>ejabberd_c2s</B></CODE><DD> This module serves C2S connections.<BR>
<BR> <BR>
The following options are defined: The following options are defined:
<DL COMPACT=compact><DT> <DL COMPACT=compact><DT>
<B><TT>{access, &lt;access rule&gt;}</TT></B><DD> This option defines access of users <CODE><B>{access, &lt;access rule&gt;}</B></CODE><DD> This option defines access of users
to this C2S port. Default value is ``<TT>all</TT>''. to this C2S port. Default value is ``<TT>all</TT>''.
<DT><B><TT>{shaper, &lt;access rule&gt;}</TT></B><DD> This option is like previous, but <DT><CODE><B>{shaper, &lt;access rule&gt;}</B></CODE><DD> This option is like previous, but
use shapers instead of ``<TT>allow</TT>'' and ``<TT>deny</TT>''. Default use shapers instead of ``<TT>allow</TT>'' and ``<TT>deny</TT>''. Default
value is ``<TT>none</TT>''. value is ``<TT>none</TT>''.
<DT><CODE><B>{ssl, SSLOpts}</B></CODE><DD> This option defines that traffic on this port
will be encrypted using SSL. SSL options are the same as described by
``<CODE>erl -man ssl</CODE>'' command
</DL> </DL>
<DT><B><TT>ejabberd_s2s_in</TT></B><DD> This module serves incoming S2S connections. <DT><CODE><B>ejabberd_s2s_in</B></CODE><DD> This module serves incoming S2S connections.
<DT><B><TT>ejabberd_service</TT></B><DD> This module serves connections from Jabber <DT><CODE><B>ejabberd_service</B></CODE><DD> This module serves connections from Jabber
services (i.&nbsp;e. that use the <TT>jabber:component:accept</TT> namespace). services (i.&nbsp;e. that use the <TT>jabber:component:accept</TT> namespace).
</DL> </DL>
For example, the following configuration defines that C2S connections are For example, the following configuration defines that C2S connections are

View File

@ -62,8 +62,8 @@ server. It is writen mostly in Erlang.
The main features of \ejabberd{} is: The main features of \ejabberd{} is:
\begin{itemize} \begin{itemize}
\item Works on most of popular platforms: *nix (tested on Linux and FreeBSD) \item Works on most of popular platforms: *nix (tested on Linux, FreeBSD and
and Win32 NetBSD) and Win32
\item Distributed: You can run \ejabberd{} on a cluster of machines and all of \item Distributed: You can run \ejabberd{} on a cluster of machines and all of
them will serve one Jabber domain. them will serve one Jabber domain.
\item Fault-tolerance: You can setup an \ejabberd{} cluster so that all the \item Fault-tolerance: You can setup an \ejabberd{} cluster so that all the
@ -201,19 +201,40 @@ Windows distribution of Erlang emulator.
\subsection{Starting} \subsection{Starting}
\label{sec:starting} \label{sec:starting}
\ldots{} To use more than 1024 connections, you will need to set environment To start \ejabberd{}, use the following command:
variable \texttt{ERL\_MAX\_PORTS}: \begin{verbatim}
erl -name ejabberd -s ejabberd
\end{verbatim}
or
\begin{verbatim}
erl -sname ejabberd -s ejabberd
\end{verbatim}
In second case Erlang node will be identified using only first part of host
name, i.\,e. other Erlang nodes not inside this domain can't contact this node.
To specify path to config file, use command like this:
\begin{verbatim}
erl -sname ejabberd -s ejabberd -ejabberd config \"/etc/ejabberd/ejabberd.cfg\"
\end{verbatim}
To use more than 1024 connections, you will need to set environment variable
\verb|ERL_MAX_PORTS|:
\begin{verbatim} \begin{verbatim}
export ERL_MAX_PORTS=32000 export ERL_MAX_PORTS=32000
\end{verbatim} \end{verbatim}
Note that with this value \ejabberd{} will use more memory (approximately 6MB Note that with this value \ejabberd{} will use more memory (approximately 6MB
more)\ldots{} more).
To reduce memory usage, you can set environment variable
\verb|ERL_FULLSWEEP_AFTER|:
\begin{verbatim} \begin{verbatim}
erl -name ejabberd -s ejabberd export ERL_FULLSWEEP_AFTER=0
\end{verbatim} \end{verbatim}
But in this case \ejabberd{} can start to work slower.
TBD
\section{Configuration} \section{Configuration}
\label{sec:configuration} \label{sec:configuration}
@ -395,18 +416,21 @@ runned on them. Each element of list is a tuple with following elements:
Currently three modules are implemented: Currently three modules are implemented:
\begin{description} \begin{description}
\item[\texttt{ejabberd\_c2s}] This module serves C2S connections. \item[\verb|ejabberd_c2s|] This module serves C2S connections.
The following options are defined: The following options are defined:
\begin{description} \begin{description}
\item[\texttt{\{access, <access rule>\}}] This option defines access of users \item[\verb|{access, <access rule>}|] This option defines access of users
to this C2S port. Default value is ``\texttt{all}''. to this C2S port. Default value is ``\texttt{all}''.
\item[\texttt{\{shaper, <access rule>\}}] This option is like previous, but \item[\verb|{shaper, <access rule>}|] This option is like previous, but
use shapers instead of ``\texttt{allow}'' and ``\texttt{deny}''. Default use shapers instead of ``\texttt{allow}'' and ``\texttt{deny}''. Default
value is ``\texttt{none}''. value is ``\texttt{none}''.
\item[\verb|{ssl, SSLOpts}|] This option defines that traffic on this port
will be encrypted using SSL. SSL options are the same as described by
``\verb|erl -man ssl|'' command
\end{description} \end{description}
\item[\texttt{ejabberd\_s2s\_in}] This module serves incoming S2S connections. \item[\verb|ejabberd_s2s_in|] This module serves incoming S2S connections.
\item[\texttt{ejabberd\_service}] This module serves connections from \Jabber{} \item[\verb|ejabberd_service|] This module serves connections from \Jabber{}
services (i.\,e.\ that use the \texttt{jabber:component:accept} namespace). services (i.\,e.\ that use the \texttt{jabber:component:accept} namespace).
\end{description} \end{description}

View File

@ -14,7 +14,7 @@
% Another examples of ACLs: % Another examples of ACLs:
%{acl, jabberorg, {server, "jabber.org"}}. %{acl, jabberorg, {server, "jabber.org"}}.
%{acl, aleksey, {user, "aleksey", "jabber.ru"}}. %{acl, aleksey, {user, "aleksey", "jabber.ru"}}.
%{acl, test, {user_regexp, "^test"}}. %{acl, test, {user_regexp, "^test"}}.
%{acl, test, {user_glob, "test*"}}. %{acl, test, {user_glob, "test*"}}.

View File

@ -34,7 +34,11 @@ start() ->
{local_content, true}, {local_content, true},
{attributes, record_info(fields, local_config)}]), {attributes, record_info(fields, local_config)}]),
mnesia:add_table_copy(local_config, node(), ram_copies), mnesia:add_table_copy(local_config, node(), ram_copies),
load_file(?CONFIG_PATH). Config = case application:get_env(config) of
{ok, Path} -> Path;
undefined -> ?CONFIG_PATH
end,
load_file(Config).
load_file(File) -> load_file(File) ->
@ -43,7 +47,7 @@ load_file(File) ->
Res = lists:foldl(fun process_term/2, #state{}, Terms), Res = lists:foldl(fun process_term/2, #state{}, Terms),
set_opts(Res); set_opts(Res);
{error, Reason} -> {error, Reason} ->
?ERROR_MSG("~p", [Reason]), ?ERROR_MSG("Can't load config file ~p: ~p", [File, Reason]),
exit(file:format_error(Reason)) exit(file:format_error(Reason))
end. end.

View File

@ -107,9 +107,16 @@ init([From, Server, Type]) ->
open_socket(init, StateData) -> open_socket(init, StateData) ->
{Addr, Port} = get_addr_port(StateData#state.server), {Addr, Port} = get_addr_port(StateData#state.server),
?DEBUG("s2s_out: connecting to ~s:~p~n", [Addr, Port]), ?DEBUG("s2s_out: connecting to ~s:~p~n", [Addr, Port]),
case gen_tcp:connect(Addr, Res = case gen_tcp:connect(Addr, Port,
Port, [binary, {packet, 0}]) of
[binary, {packet, 0}]) of {ok, _Socket} = R -> R;
{error, Reason1} ->
?DEBUG("s2s_out: connect return ~p~n", [Reason1]),
gen_tcp:connect(Addr, Port,
[binary, {packet, 0},
{tcp_module, inet6_tcp}])
end,
case Res of
{ok, Socket} -> {ok, Socket} ->
XMLStreamPid = xml_stream:start(self()), XMLStreamPid = xml_stream:start(self()),
send_text(Socket, io_lib:format(?STREAM_HEADER, send_text(Socket, io_lib:format(?STREAM_HEADER,
@ -120,11 +127,8 @@ open_socket(init, StateData) ->
streamid = new_id()}, streamid = new_id()},
?S2STIMEOUT}; ?S2STIMEOUT};
{error, Reason} -> {error, Reason} ->
?DEBUG("s2s_out: connect return ~p~n", [Reason]), ?DEBUG("s2s_out: inet6 connect return ~p~n", [Reason]),
Error = case Reason of Error = ?ERR_REMOTE_SERVER_NOT_FOUND,
timeout -> ?ERR_REMOTE_SERVER_TIMEOUT;
_ -> ?ERR_REMOTE_SERVER_NOT_FOUND
end,
bounce_messages(Error), bounce_messages(Error),
{stop, normal, StateData} {stop, normal, StateData}
end. end.
@ -439,7 +443,12 @@ is_verify_res(_) ->
-include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet.hrl").
get_addr_port(Server) -> get_addr_port(Server) ->
case inet_res:getbyname("_jabber._tcp." ++ Server, srv) of Res = case inet_res:getbyname("_jabber-server._tcp." ++ Server, srv) of
{error, _Reason} ->
inet_res:getbyname("_jabber._tcp." ++ Server, srv);
{ok, _HEnt} = R -> R
end,
case Res of
{error, Reason} -> {error, Reason} ->
?DEBUG("srv lookup of '~s' failed: ~p~n", [Server, Reason]), ?DEBUG("srv lookup of '~s' failed: ~p~n", [Server, Reason]),
{Server, ejabberd_config:get_local_option(outgoing_s2s_port)}; {Server, ejabberd_config:get_local_option(outgoing_s2s_port)};

View File

@ -171,17 +171,6 @@ string_to_jid1([$/ | J], "") ->
error; error;
string_to_jid1([$/ | J], N) -> string_to_jid1([$/ | J], N) ->
string_to_jid3(J, "", lists:reverse(N), ""); string_to_jid3(J, "", lists:reverse(N), "");
string_to_jid1([C | J], N)
when (C =< 32) or
(C == $") or
(C == $&) or
(C == $') or
(C == $:) or
(C == $<) or
(C == $>) or
(C == 127)
->
error;
string_to_jid1([C | J], N) -> string_to_jid1([C | J], N) ->
string_to_jid1(J, [C | N]); string_to_jid1(J, [C | N]);
string_to_jid1([], "") -> string_to_jid1([], "") ->