]> granicus.if.org Git - ejabberd/commitdiff
*** empty log message ***
authorAlexey Shchepin <alexey@process-one.net>
Thu, 6 Feb 2003 19:09:22 +0000 (19:09 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Thu, 6 Feb 2003 19:09:22 +0000 (19:09 +0000)
SVN Revision: 62

TODO
doc/guide.html
doc/guide.tex
src/ejabberd.app
src/ejabberd.cfg
src/ejabberd.erl
src/ejabberd_c2s.erl
src/ejabberd_listener.erl
src/ejabberd_s2s_in.erl
src/ejabberd_service.erl
src/mod_configure.erl

diff --git a/TODO b/TODO
index 6d2ba9e303d9efb09807aa79482dd7d081fa5bfb..d571ae66018faf6741dd65b1b8acfff74b0350b2 100644 (file)
--- a/TODO
+++ b/TODO
@@ -5,9 +5,10 @@ admin interface
 S2S timeouts
 rewrite S2S key validation
 iq:browse (?)
-SRV DNS records
+more correctly work  with SRV DNS records (priority, weight, etc...)
 karma
 SSL
+SASL
 JEP-62,63 (?)
 make roster set work in one transaction
 
index e4bcb91a7099b039de54c5da1257857dfe46efa0..1da6a5bf5061dd1a6d0a8b790a3a217df9780033 100644 (file)
@@ -178,23 +178,23 @@ Declaration of ACL in config file have following syntax:
 <DT><TT>{user_regexp, &lt;regexp&gt;}</TT><DD> Matches local user with name that
  mathes <TT>&lt;regexp&gt;</TT>. Example:
 <PRE>
-{acl, tests, {user, "test.*"}}.
+{acl, tests, {user, "^test[0-9]*$"}}.
 </PRE>
 <DT><TT>{user_regexp, &lt;regexp&gt;, &lt;server&gt;}</TT><DD> Matches user with name
  that mathes <TT>&lt;regexp&gt;</TT> and from server <TT>&lt;server&gt;</TT>. Example:
 <PRE>
-{acl, tests, {user, "test.*", "localhost"}}.
+{acl, tests, {user, "^test", "localhost"}}.
 </PRE>
 <DT><TT>{server_regexp, &lt;regexp&gt;}</TT><DD> Matches any JID from server that
  matches <TT>&lt;regexp&gt;</TT>. Example:
 <PRE>
-{acl, icq, {server, "icq.*"}}.
+{acl, icq, {server, "^icq\\."}}.
 </PRE>
 <DT><TT>{node_regexp, &lt;user_regexp&gt;, &lt;server_regexp&gt;}</TT><DD> Matches user
  with name that mathes <TT>&lt;user_regexp&gt;</TT> and from server that matches
  <TT>&lt;server_regexp&gt;</TT>. Example:
 <PRE>
-{acl, aleksey, {node_regexp, "aleksey.*", "jabber.(ru|org)"}}.
+{acl, aleksey, {node_regexp, "^aleksey", "^jabber.(ru|org)$"}}.
 </PRE>
 <DT><TT>{user_glob, &lt;glob&gt;}</TT><DD>
 
@@ -357,7 +357,7 @@ correctly only after restart)
 <DIV ALIGN=center><HR WIDTH="80%" SIZE=2></DIV></DIV></BLOCKQUOTE><!--TOC paragraph Node <TT>config/acls</TT>-->
 
 <H5> Node <TT>config/acls</TT></H5><!--SEC END -->
-Via <TT>jabber:x:data</TT> queries to this node possible edit ACLs list. (See
+Via <TT>jabber:x:data</TT> queries to this node possible to edit ACLs list. (See
 figure&nbsp;<A HREF="#fig:acls">2</A>)
 <BLOCKQUOTE><DIV ALIGN=center><DIV ALIGN=center><HR WIDTH="80%" SIZE=2></DIV>
  [acls editing window]
@@ -369,8 +369,7 @@ figure&nbsp;<A HREF="#fig:acls">2</A>)
 <DIV ALIGN=center><HR WIDTH="80%" SIZE=2></DIV></DIV></BLOCKQUOTE><!--TOC paragraph Node <TT>config/access</TT>-->
 
 <H5> Node <TT>config/access</TT></H5><!--SEC END -->
-Via <TT>jabber:x:data</TT> queries to this node possible edit access rules.
-<B>Not work yet</B>.<BR>
+Via <TT>jabber:x:data</TT> queries to this node possible to edit access rules.<BR>
 <BR>
 <!--TOC paragraph Node <TT>config/remusers</TT>-->
 
index 46ecc96dcebed56780af80c3bacff5415689efe8..f9a3e5eb5fa58c0aace52697337eb9ad2b4eb982 100644 (file)
@@ -218,27 +218,29 @@ Declaration of ACL in config file have following syntax:
 \item[\texttt{\{user\_regexp, <regexp>\}}] Matches local user with name that
   mathes \texttt{<regexp>}.  Example:
 \begin{verbatim}
-{acl, tests, {user, "test.*"}}.
+{acl, tests, {user, "^test[0-9]*$"}}.
 \end{verbatim}
+%$
 
 \item[\texttt{\{user\_regexp, <regexp>, <server>\}}] Matches user with name
   that mathes \texttt{<regexp>} and from server \texttt{<server>}.  Example:
 \begin{verbatim}
-{acl, tests, {user, "test.*", "localhost"}}.
+{acl, tests, {user, "^test", "localhost"}}.
 \end{verbatim}
 
 \item[\texttt{\{server\_regexp, <regexp>\}}] Matches any JID from server that
   matches \texttt{<regexp>}.  Example:
 \begin{verbatim}
-{acl, icq, {server, "icq.*"}}.
+{acl, icq, {server, "^icq\\."}}.
 \end{verbatim}
 
 \item[\texttt{\{node\_regexp, <user\_regexp>, <server\_regexp>\}}] Matches user
   with name that mathes \texttt{<user\_regexp>} and from server that matches
   \texttt{<server\_regexp>}.  Example:
 \begin{verbatim}
-{acl, aleksey, {node_regexp, "aleksey.*", "jabber.(ru|org)"}}.
+{acl, aleksey, {node_regexp, "^aleksey", "^jabber.(ru|org)$"}}.
 \end{verbatim}
+%$
 
 \item[\texttt{\{user\_glob, <glob>\}}]
 \item[\texttt{\{user\_glob, <glob>, <server>\}}]
@@ -400,7 +402,7 @@ correctly only after restart)
 
 \paragraph{Node \texttt{config/acls}}
 
-Via \ns{jabber:x:data} queries to this node possible edit ACLs list.  (See
+Via \ns{jabber:x:data} queries to this node possible to edit ACLs list.  (See
 figure~\ref{fig:acls})
 \begin{figure}[htbp]
   \centering
@@ -412,8 +414,8 @@ figure~\ref{fig:acls})
 
 \paragraph{Node \texttt{config/access}}
 
-Via \ns{jabber:x:data} queries to this node possible edit access rules.
-\textbf{Not work yet}.
+Via \ns{jabber:x:data} queries to this node possible to edit access rules.
+
 
 \paragraph{Node \texttt{config/remusers}}
 
index a90fbaeb45e1f9abe8197cbef3a45619e83bc6bb..894141e54889b3bb9b2ff00afe74f0b2f425ce04 100644 (file)
@@ -43,7 +43,7 @@
                ejabberd_mod_roster,
                ejabberd_listeners
               ]},
-  {applications, [kernel, stdlib, mnesia]},
+  {applications, [kernel, stdlib, mnesia, crypto, ssl]},
   {env, []},
   {mod, {ejabberd_app, []}}]}.
 
index 6cc428f357c20b96852ef451c9f783ae124b0d60..c91c7113942c19816518a7e37050032f3d2d1c65 100644 (file)
@@ -29,6 +29,8 @@ override_acls.
 {host, "e.localhost"}.
 
 {listen, [{5522, ejabberd_c2s,     start, [{access, c2s}]},
+         %{5523, ejabberd_c2s,     start,
+         % [{access, c2s}, {ssl, [{certfile, "./ssl.pem"}]}]},
           {5269, ejabberd_s2s_in,  start, []},
           {8888, ejabberd_service, start,
           [{host, "asd.e.localhost", [{password, "asdqwe"}]}]}
index ef3b85c15f63f0b6d80b48c1d9d7acdcc52dcfe7..c34430fc3b0b2cd02660ff33d8583ae042363fdb 100644 (file)
@@ -14,6 +14,8 @@
 
 start() ->
     application:start(mnesia),
+    application:start(crypto),
+    application:start(ssl),
     application:start(ejabberd).
 
 stop() ->
index 2fa3e1d2e98e255d29997b63b839f46a7c87a3cb..13e7cc169b78d77506a56575c32ff59bc3de125e 100644 (file)
@@ -13,7 +13,7 @@
 -behaviour(gen_fsm).
 
 %% External exports
--export([start/2, receiver/2, sender/1, send_text/2, send_element/2]).
+-export([start/2, receiver/3, sender/2, send_text/2, send_element/2]).
 
 %% gen_fsm callbacks
 -export([init/1, wait_for_stream/2, wait_for_auth/2, session_established/2,
@@ -61,8 +61,8 @@
 %%%----------------------------------------------------------------------
 %%% API
 %%%----------------------------------------------------------------------
-start(Socket, Opts) ->
-    gen_fsm:start(ejabberd_c2s, [Socket, Opts], ?FSMOPTS).
+start(SockData, Opts) ->
+    gen_fsm:start(ejabberd_c2s, [SockData, Opts], ?FSMOPTS).
 
 %%%----------------------------------------------------------------------
 %%% Callback functions from gen_fsm
@@ -75,9 +75,9 @@ start(Socket, Opts) ->
 %%          ignore                              |
 %%          {stop, StopReason}                   
 %%----------------------------------------------------------------------
-init([Socket, Opts]) ->
-    SenderPid = spawn(?MODULE, sender, [Socket]),
-    ReceiverPid = spawn(?MODULE, receiver, [Socket, self()]),
+init([{SockMod, Socket}, Opts]) ->
+    SenderPid = spawn(?MODULE, sender, [Socket, SockMod]),
+    ReceiverPid = spawn(?MODULE, receiver, [Socket, SockMod, self()]),
     Access = case lists:keysearch(access, 1, Opts) of
                 {value, {_, A}} ->
                     A;
@@ -367,28 +367,28 @@ terminate(Reason, StateName, StateData) ->
 %%% Internal functions
 %%%----------------------------------------------------------------------
 
-receiver(Socket, C2SPid) ->
+receiver(Socket, SockMod, C2SPid) ->
     XMLStreamPid = xml_stream:start(C2SPid),
-    receiver(Socket, C2SPid, XMLStreamPid).
+    receiver(Socket, SockMod, C2SPid, XMLStreamPid).
 
-receiver(Socket, C2SPid, XMLStreamPid) ->
-    case gen_tcp:recv(Socket, 0) of
+receiver(Socket, SockMod, C2SPid, XMLStreamPid) ->
+    case SockMod:recv(Socket, 0) of
         {ok, Text} ->
            xml_stream:send_text(XMLStreamPid, Text),
-           receiver(Socket, C2SPid, XMLStreamPid);
+           receiver(Socket, SockMod, C2SPid, XMLStreamPid);
         {error, Reason} ->
            exit(XMLStreamPid, closed),
            gen_fsm:send_event(C2SPid, closed),
            ok
     end.
 
-sender(Socket) ->
+sender(Socket, SockMod) ->
     receive
        {send_text, Text} ->
-           gen_tcp:send(Socket,Text),
-           sender(Socket);
+           SockMod:send(Socket,Text),
+           sender(Socket, SockMod);
        close ->
-           gen_tcp:close(Socket),
+           SockMod:close(Socket),
            ok
     end.
 
index 3ed030c7b9df43015d5d56dedd6d6b25eb971d74..004ddba38ea1ad6180d469951a27c65dca23af54 100644 (file)
 -author('alexey@sevcom.net').
 -vsn('$Revision$ ').
 
--export([start_link/0, init/1, start/4, init/4]).
+-export([start_link/0, init/1, start/4,
+        init/4,
+        init_ssl/5
+       ]).
 
 start_link() ->
     supervisor:start_link({local, ejabberd_listeners}, ?MODULE, []).
@@ -25,7 +28,7 @@ init(_) ->
                  lists:map(
                    fun({Port, Module, Fun, Opts}) ->
                            {Port,
-                            {?MODULE, start, [Port, Module, Fun, [Opts]]},
+                            {?MODULE, start, [Port, Module, Fun, Opts]},
                             permanent,
                             brutal_kill,
                             worker,
@@ -34,22 +37,45 @@ init(_) ->
     end.
 
 
-start(Port, Module, Fun, Args) ->
-    {ok, spawn_link(?MODULE, init, [Port, Module, Fun, Args])}.
+start(Port, Module, Fun, Opts) ->
+    case lists:keysearch(ssl, 1, Opts) of
+       {value, {ssl, SSLOpts}} ->
+           {ok, spawn_link(?MODULE, init_ssl,
+                           [Port, Module, Fun, Opts, SSLOpts])};
+       _ ->
+           {ok, spawn_link(?MODULE, init, [Port, Module, Fun, Opts])}
+    end.
 
-init(Port, Module, Fun, Args) ->
+init(Port, Module, Fun, Opts) ->
     {ok, ListenSocket} = gen_tcp:listen(Port, [binary,
                                               {packet, 0}, 
                                               {active, false},
                                               {reuseaddr, true}]),
-    accept(ListenSocket, Module, Fun, Args).
+    accept(ListenSocket, Module, Fun, Opts).
 
-accept(ListenSocket, Module, Fun, Args) ->
+accept(ListenSocket, Module, Fun, Opts) ->
     case gen_tcp:accept(ListenSocket) of
        {ok,Socket} ->
-           apply(Module, Fun, [Socket] ++ Args),
-           %ejabberd_c2s:start(Socket),
-           accept(ListenSocket, Module, Fun, Args)
+           apply(Module, Fun, [{gen_tcp, Socket}, Opts]),
+           accept(ListenSocket, Module, Fun, Opts)
+    end.
+
+
+init_ssl(Port, Module, Fun, Opts, SSLOpts) ->
+    {ok, ListenSocket} = ssl:listen(Port, [binary,
+                                          {packet, 0}, 
+                                          {active, false},
+                                          {nodelay, true},
+                                          {backlog, 0},
+                                          {cachetimout, 0} |
+                                          SSLOpts]),
+    accept_ssl(ListenSocket, Module, Fun, Opts).
+
+accept_ssl(ListenSocket, Module, Fun, Opts) ->
+    case ssl:accept(ListenSocket) of
+       {ok,Socket} ->
+           apply(Module, Fun, [{ssl, Socket}, Opts]),
+           accept_ssl(ListenSocket, Module, Fun, Opts)
     end.
 
 
index 38803054956b76bfc56d1fd73a47e6a317a6941b..2f25c267bb9c8e10de057a371586ead5ecc75876 100644 (file)
@@ -65,8 +65,8 @@
 %%%----------------------------------------------------------------------
 %%% API
 %%%----------------------------------------------------------------------
-start(Socket, Opts) ->
-    gen_fsm:start(ejabberd_s2s_in, [Socket], ?FSMOPTS).
+start(SockData, Opts) ->
+    gen_fsm:start(ejabberd_s2s_in, [SockData], ?FSMOPTS).
 
 %%%----------------------------------------------------------------------
 %%% Callback functions from gen_fsm
@@ -79,7 +79,7 @@ start(Socket, Opts) ->
 %%          ignore                              |
 %%          {stop, StopReason}                   
 %%----------------------------------------------------------------------
-init([Socket]) ->
+init([{SockMod, Socket}]) ->
     ReceiverPid = spawn(?MODULE, receiver, [Socket, self()]),
     {ok, wait_for_stream, #state{socket = Socket,
                                 receiver = ReceiverPid,
index 78e7a9c9a3ba77b187fbf5070ca3eb2d8c371a59..455885f504c3b665703aebcb0b96501e717b26fa 100644 (file)
@@ -63,8 +63,8 @@
 %%%----------------------------------------------------------------------
 %%% API
 %%%----------------------------------------------------------------------
-start(Socket, Opts) ->
-    gen_fsm:start(ejabberd_service, [Socket, Opts], ?FSMOPTS).
+start(SockData, Opts) ->
+    gen_fsm:start(ejabberd_service, [SockData, Opts], ?FSMOPTS).
 
 %%%----------------------------------------------------------------------
 %%% Callback functions from gen_fsm
@@ -77,7 +77,7 @@ start(Socket, Opts) ->
 %%          ignore                              |
 %%          {stop, StopReason}                   
 %%----------------------------------------------------------------------
-init([Socket, Opts]) ->
+init([{SockMod, Socket}, Opts]) ->
     {Host, Password} =
        case lists:keysearch(host, 1, Opts) of
            {value, {_, H, HOpts}} ->
index 7e62bff998f327b89120d6b63c82695f06671ede..3f6c09a08d787e8b719f6f6b0e72bccb5c523593 100644 (file)
@@ -283,7 +283,36 @@ get_form(["config", "acls"], Lang) ->
                           lists:flatten(io_lib:format("~p.",
                                                       [ets:tab2list(acl)])),
                           "\n"))
-               %{xmlelement, "value", [], [{xmlcdata, ?MYNAME}]}
+             }
+            ]};
+
+get_form(["config", "access"], Lang) ->
+    {result, [{xmlelement, "title", [],
+              [{xmlcdata,
+                translate:translate(
+                  Lang, "Access Configuration")}]},
+             %{xmlelement, "instructions", [],
+             % [{xmlcdata,
+             %   translate:translate(
+             %     Lang, "")}]},
+             {xmlelement, "field", [{"type", "text-multi"},
+                                    {"label",
+                                     translate:translate(
+                                       Lang, "Access Rules")},
+                                    {"var", "access"}],
+              lists:map(fun(S) ->
+                                {xmlelement, "value", [], [{xmlcdata, S}]}
+                        end,
+                        string:tokens(
+                          lists:flatten(
+                            io_lib:format(
+                              "~p.",
+                              [ets:select(config,
+                                          [{{config, {access, '$1'}, '$2'},
+                                            [],
+                                            [{{access, '$1', '$2'}}]}])
+                              ])),
+                          "\n"))
              }
             ]};
 
@@ -447,25 +476,71 @@ set_form(["config", "hostname"], Lang, XData) ->
 set_form(["config", "acls"], Lang, XData) ->
     case lists:keysearch("acls", 1, XData) of
        {value, {_, Strings}} ->
-                   String = lists:foldl(fun(S, Res) ->
-                                                Res ++ S ++ "\n"
-                                        end, "", Strings),
-                   case erl_scan:string(String) of
-                       {ok, Tokens, _} ->
-                           case erl_parse:parse_term(Tokens) of
-                               {ok, ACLs} ->
-                                   case acl:add_list(ACLs, true) of
-                                       ok ->
-                                           {result, []};
-                                       _ ->
-                                           {error, "406", "Not Acceptable"}
-                                   end;
+           String = lists:foldl(fun(S, Res) ->
+                                        Res ++ S ++ "\n"
+                                end, "", Strings),
+           case erl_scan:string(String) of
+               {ok, Tokens, _} ->
+                   case erl_parse:parse_term(Tokens) of
+                       {ok, ACLs} ->
+                           case acl:add_list(ACLs, true) of
+                               ok ->
+                                   {result, []};
                                _ ->
                                    {error, "406", "Not Acceptable"}
                            end;
                        _ ->
                            {error, "406", "Not Acceptable"}
                    end;
+               _ ->
+                   {error, "406", "Not Acceptable"}
+           end;
+       _ ->
+           {error, "406", "Not Acceptable"}
+    end;
+
+set_form(["config", "access"], Lang, XData) ->
+    SetAccess =
+       fun(Rs) ->
+               mnesia:transaction(
+                 fun() ->
+                         Os = mnesia:select(config,
+                                            [{{config, {access, '$1'}, '$2'},
+                                              [],
+                                              ['$_']}]),
+                         lists:foreach(fun(O) ->
+                                               mnesia:delete_object(O)
+                                       end, Os),
+                         lists:foreach(
+                           fun({access, Name, Rules}) ->
+                                   mnesia:write({config,
+                                                 {access, Name},
+                                                 Rules})
+                           end, Rs)
+                 end)
+       end,
+    case lists:keysearch("access", 1, XData) of
+       {value, {_, Strings}} ->
+           String = lists:foldl(fun(S, Res) ->
+                                        Res ++ S ++ "\n"
+                                end, "", Strings),
+           case erl_scan:string(String) of
+               {ok, Tokens, _} ->
+                   case erl_parse:parse_term(Tokens) of
+                       {ok, Rs} ->
+                           case SetAccess(Rs) of
+                               {atomic, _} ->
+                                   {result, []};
+                               E ->
+                                   io:format("A: ~p~n", [E]),
+                                   {error, "406", "Not Acceptable"}
+                           end;
+                       _ ->
+                           {error, "406", "Not Acceptable"}
+                   end;
+               _ ->
+                   {error, "406", "Not Acceptable"}
+           end;
        _ ->
            {error, "406", "Not Acceptable"}
     end;