]> granicus.if.org Git - ejabberd/commitdiff
*** empty log message ***
authorAlexey Shchepin <alexey@process-one.net>
Wed, 29 Jan 2003 17:12:23 +0000 (17:12 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Wed, 29 Jan 2003 17:12:23 +0000 (17:12 +0000)
SVN Revision: 53

17 files changed:
TODO
src/Makefile
src/acl.erl
src/ejabberd.cfg
src/ejabberd_auth.erl
src/ejabberd_c2s.erl
src/ejabberd_local.erl
src/ejabberd_s2s_out.erl
src/ejabberd_sm.erl
src/gen_iq_handler.erl
src/mod_configure.erl
src/mod_disco.erl
src/mod_offline.erl
src/mod_private.erl
src/mod_stats.erl
src/mod_time.erl
src/mod_version.erl

diff --git a/TODO b/TODO
index e3f828c9fe2b437f65bf51d2cb0b4b036d0f6fcf..a87f73c348e383756e781e1f2251705a01af5958 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,8 +4,8 @@ admin interface
        backup management
 S2S timeouts
 rewrite S2S key validation
-iq:browse(?)
+iq:browse (?)
 SRV DNS records
 karma
 SSL
-JEP-62,63
\ No newline at end of file
+JEP-62,63 (?)
index 2cc96509ca01e0a8f644f5cf3a057b43f2e53061..8f3c17bce1ae9de41d2aa0ceb90f8502625e5026 100644 (file)
@@ -11,7 +11,6 @@ ERLSHLIBS = expat_erl.so
 
 all:   $(ERLSHLIBS)
        erl -s make all report -noinput -s erlang halt
-       etags *.erl
 
 $(ERLSHLIBS):  %.so:   %.c
                        gcc -Wall $(INCLUDES) $(LIBDIRS) \
@@ -26,3 +25,7 @@ clean:
 
 Makefile.inc:
        ./configure
+
+TAGS:
+       etags *.erl
+
index 375f694908cff30a1848ebb20f82c7f4ca532f87..2c8a8e7cae9f37025bc035ec12f76247659b5e42 100644 (file)
 
 -include("ejabberd.hrl").
 
+-record(acl, {aclname, aclspec}).
+
 start() ->
-    ets:new(acls, [bag, named_table, public]),
+    %ets:new(acls, [bag, named_table, public]),
+    mnesia:create_table(acl,
+                       [{disc_copies, [node()]},
+                        {type, bag},
+                        {attributes, record_info(fields, acl)}]),
+    mnesia:add_table_copy(acl, node(), ram_copies),
     ok.
 
 
-add(ACLName, ACLData) ->
-    ets:insert(acls, {ACLName, ACLData}).
+add(ACLName, ACLSpec) ->
+    F = fun() ->
+               mnesia:write(#acl{aclname = ACLName, aclspec = ACLSpec})
+       end,
+    mnesia:transaction(F).
+    %ets:insert(acls, {ACLName, ACLData}).
 
 match_rule(Rule, JID) ->
     case ejabberd_config:get_global_option({access, Rule}) of
@@ -42,7 +53,7 @@ match_acls([{Access, ACL} | ACLs], JID) ->
 
 match_acl(ACL, JID) ->
     {User, Server, Resource} = jlib:jid_tolower(JID),
-    lists:any(fun({_, Spec}) ->
+    lists:any(fun(#acl{aclspec = Spec}) ->
                      case Spec of
                          all ->
                              true;
@@ -53,4 +64,4 @@ match_acl(ACL, JID) ->
                          {server, S} ->
                              S == Server
                      end
-             end, ets:lookup(acls, ACL)).
+             end, ets:lookup(acl, ACL)).
index a949a7cf8d3e176eee3bdae72d64700f15836a34..6d4f3551b3e25dc231e95fe2e1edaa365f73abb9 100644 (file)
@@ -21,6 +21,9 @@
           {8888, ejabberd_service, start, ["asd.e.localhost", "asdqwe"]}
          ]}.
 
+% This value (5569) is only for debugging, must be 5269
+{outgoing_s2s_port, 5569}.
+
 {modules, [
            {mod_register,  []},
            {mod_roster,    []},
index d280a42924de69a66db45e009a550a63e92bb21e..b977103c463f37c110348437aa1d36dc45df323a 100644 (file)
@@ -185,17 +185,11 @@ get_password_s(User) ->
 
 is_user_exists(User) ->
     LUser = jlib:tolower(User),
-    F = fun() ->
-               case mnesia:read({passwd, LUser}) of
-                   [] ->
-                       false;
-                   [_] ->
-                       true
-               end
-        end,
-    case mnesia:transaction(F) of
-       {atomic, Res} ->
-           Res;
+    case catch mnesia:dirty_read({passwd, LUser}) of
+       [] ->
+           false;
+       [_] ->
+           true;
        _ ->
            false
     end.
index c1f7ebc5d0d95fb080cb6eca6a94aeb0163e992b..8c66d3262dd93cefa9e3de91ab41328000619305 100644 (file)
@@ -286,12 +286,14 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
                ?DEBUG("broadcast!!!!!!!!!!!~n~p~n", [Els]),
                NewSt = case Els of
                            [{item, IJID, ISubscription}] ->
-                               roster_change(IJID, ISubscription,
-                                             StateData);
+                               {false, Attrs,
+                                roster_change(IJID, ISubscription,
+                                              StateData)};
+                           [{exit, Reason}] ->
+                               {exit, Attrs, Reason};
                            _ ->
-                               StateData
-                       end,
-               {false, Attrs, NewSt};
+                               {false, Attrs, StateData}
+                       end;
            "iq" ->
                IQ = jlib:iq_query_info(Packet),
                case IQ of
@@ -310,16 +312,19 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
            _ ->
                {true, Attrs, StateData}
        end,
-    if Pass ->
+    if
+       Pass == exit ->
+           {stop, normal, StateData};
+       Pass ->
            Attrs2 = jlib:replace_from_to_attrs(jlib:jid_to_string(From),
                                                jlib:jid_to_string(To),
                                                NewAttrs),
            Text = xml:element_to_string({xmlelement, Name, Attrs2, Els}),
-           send_text(StateData#state.sender, Text);
-       true ->
-           ok
-    end,
-    {next_state, StateName, NewState}.
+           send_text(StateData#state.sender, Text),
+           {next_state, StateName, NewState};
+       true ->
+           {next_state, StateName, NewState}
+    end.
 
 %%----------------------------------------------------------------------
 %% Func: terminate/3
index c567cbfa603f04398e7be09115f95a28cb80a566..e0415b0d209b26893095604f10fdcb4e52ec4ea5 100644 (file)
@@ -13,7 +13,9 @@
 -export([start/0, init/0]).
 
 -export([register_iq_handler/3,
-        register_iq_handler/4]).
+        register_iq_handler/4,
+        unregister_iq_handler/1
+       ]).
 
 -include("ejabberd.hrl").
 
@@ -41,6 +43,18 @@ loop(State) ->
        {register_iq_handler, XMLNS, Module, Function, Opts} ->
            ets:insert(State#state.iqtable, {XMLNS, Module, Function, Opts}),
            mod_disco:register_feature(XMLNS),
+           loop(State);
+       {unregister_iq_handler, XMLNS} ->
+           case ets:lookup(State#state.iqtable, XMLNS) of
+               [{_, Module, Function, Opts}] ->
+                   gen_iq_handler:stop_iq_handler(Module, Function, Opts);
+               _ ->
+                   ok
+           end,
+           ets:delete(State#state.iqtable, XMLNS),
+           mod_disco:unregister_feature(XMLNS),
+           loop(State);
+       _ ->
            loop(State)
     end.
 
@@ -117,3 +131,7 @@ register_iq_handler(XMLNS, Module, Fun) ->
 
 register_iq_handler(XMLNS, Module, Fun, Opts) ->
     ejabberd_local ! {register_iq_handler, XMLNS, Module, Fun, Opts}.
+
+unregister_iq_handler(XMLNS) ->
+    ejabberd_local ! {unregister_iq_handler, XMLNS}.
+
index 799e9da4156d9d1aabfc5a7a4463abaed2b2a08b..aaa3356fda31816a1698fb64e4a9f5f7bf5fc025 100644 (file)
@@ -97,7 +97,8 @@ init([From, Server, Type]) ->
 %%          {stop, Reason, NewStateData}                         
 %%----------------------------------------------------------------------
 open_socket(init, StateData) ->
-    case gen_tcp:connect(StateData#state.server, 5569,
+    case gen_tcp:connect(StateData#state.server,
+                        ejabberd_config:get_local_option(outgoing_s2s_port),
                         [binary, {packet, 0}]) of
        {ok, Socket} ->
            XMLStreamPid = xml_stream:start(self()),
index a6c5efa0a153acdae3bb386e32139dc70851a112..8860dcf5d4863f25ec70d88836841f902deb17fa 100644 (file)
@@ -17,7 +17,9 @@
         dirty_get_sessions_list/0,
         dirty_get_my_sessions_list/0,
         register_iq_handler/3,
-        register_iq_handler/4]).
+        register_iq_handler/4,
+        unregister_iq_handler/1
+       ]).
 
 -include_lib("mnemosyne/include/mnemosyne.hrl").
 -include("ejabberd.hrl").
@@ -77,6 +79,16 @@ loop() ->
        {register_iq_handler, XMLNS, Module, Function, Opts} ->
            ets:insert(sm_iqtable, {XMLNS, Module, Function, Opts}),
            loop();
+       {unregister_iq_handler, XMLNS} ->
+           case ets:lookup(sm_iqtable, XMLNS) of
+               [{_, Module, Function, Opts}] ->
+                   gen_iq_handler:stop_iq_handler(Module, Function, Opts);
+               _ ->
+                   ok
+           end,
+           ets:delete(sm_iqtable, XMLNS),
+           mod_disco:unregister_feature(XMLNS),
+           loop();
        _ ->
            loop()
     end.
@@ -389,3 +401,6 @@ register_iq_handler(XMLNS, Module, Fun) ->
 register_iq_handler(XMLNS, Module, Fun, Opts) ->
     ejabberd_sm ! {register_iq_handler, XMLNS, Module, Fun, Opts}.
 
+unregister_iq_handler(XMLNS) ->
+    ejabberd_sm ! {unregister_iq_handler, XMLNS}.
+
index 6140610851ae631b9120dc0e8f09910ed8f130fe..3bdeeee4cbc3ff6212c1a3da4b1c8adb2f207479 100644 (file)
@@ -12,6 +12,8 @@
 
 -export([start/0,
         add_iq_handler/5,
+        remove_iq_handler/2,
+        stop_iq_handler/3,
         handle/6,
         process_iq/5,
         queue_init/2]).
@@ -33,6 +35,17 @@ add_iq_handler(Component, NS, Module, Function, Type) ->
            Component:register_iq_handler(NS, Module, Function, parallel)
     end.
 
+remove_iq_handler(Component, NS) ->
+    Component:unregister_iq_handler(NS).
+
+stop_iq_handler(Module, Function, Opts) ->
+    case Opts of
+       {one_queue, Pid} ->
+           exit(Pid, kill);
+       _ ->
+           ok
+    end.
+
 handle(Module, Function, Opts, From, To, IQ) ->
     case Opts of
        no_queue ->
index 6e6b7f903d6dc007aa53a74ca7b13bc69748f827..fe89a2ded81f28b80c4cb093ce054c61c1fc5b51 100644 (file)
@@ -13,6 +13,7 @@
 -behaviour(gen_mod).
 
 -export([start/1,
+        stop/0,
         process_local_iq/3,
         process_sm_iq/3]).
 
@@ -28,6 +29,10 @@ start(Opts) ->
                                  ?MODULE, process_sm_iq, IQDisc),
     ok.
 
+stop() ->
+    gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_XDATA),
+    gen_iq_handler:remove_iq_handler(ejabberd_sm, ?NS_XDATA).
+
 
 process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
     case acl:match_rule(configure, From) of
@@ -240,7 +245,7 @@ get_form(["config", "acls"], Lang) ->
                         end,
                         string:tokens(
                           lists:flatten(io_lib:format("~p",
-                                                      [ets:tab2list(acls)])),
+                                                      [ets:tab2list(acl)])),
                           "\n"))
                %{xmlelement, "value", [], [{xmlcdata, ?MYNAME}]}
              }
@@ -379,6 +384,9 @@ set_form(["config", "remusers"], Lang, XData) ->
       fun({Var, Vals}) ->
              case Vals of
                  ["1"] ->
+                     ejabberd_sm ! {route, {"", "", ""}, {Var, "", ""},
+                                    {xmlelement, "broadcast", [],
+                                     [{exit, "User removed"}]}},
                      catch ejabberd_auth:remove_user(Var),
                      catch mod_roster:remove_user(Var),
                      catch mod_offline:remove_user(Var),
index 705780a5ccf6300e1be08a2f2f989975dd4e321b..474eb2ac87f96d07003bba3f20d3734d1f46a1f9 100644 (file)
 -behaviour(gen_mod).
 
 -export([start/1,
+        stop/0,
         process_local_iq_items/3,
         process_local_iq_info/3,
         process_sm_iq_items/3,
         process_sm_iq_info/3,
-        register_feature/1]).
+        register_feature/1,
+        unregister_feature/1]).
 
 -include("ejabberd.hrl").
 -include("namespaces.hrl").
@@ -41,10 +43,21 @@ start(Opts) ->
     register_feature("presence-invisible"),
     ok.
 
+stop() ->
+    gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_DISCO_ITEMS),
+    gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_DISCO_INFO),
+    gen_iq_handler:remove_iq_handler(ejabberd_sm, ?NS_DISCO_ITEMS),
+    gen_iq_handler:remove_iq_handler(ejabberd_sm, ?NS_DISCO_INFO).
+
+
 register_feature(Feature) ->
     catch ets:new(disco_features, [named_table, ordered_set, public]),
     ets:insert(disco_features, {Feature}).
 
+unregister_feature(Feature) ->
+    catch ets:new(disco_features, [named_table, ordered_set, public]),
+    ets:delete(disco_features, Feature).
+
 process_local_iq_items(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
     Lang = xml:get_tag_attr_s("xml:lang", SubEl),
     case Type of
index b5e84cad052ed2cc335cbed318b7099974309514..63391cfc4cfe2454f6abf1cce327041058278303 100644 (file)
@@ -12,6 +12,7 @@
 -behaviour(gen_mod).
 
 -export([start/1,
+        stop/0,
         store_packet/3,
         resend_offline_messages/1,
         remove_user/1]).
@@ -27,6 +28,9 @@ start(_) ->
                         {type, bag},
                         {attributes, record_info(fields, offline_msg)}]).
 
+stop() ->
+    % TODO: maybe throw error that this module can't be removed?
+    ok.
 
 store_packet(From, To, Packet) ->
     case check_event(From, To, Packet) of
index ef0bc21afcac5692ee2a0bdb0436bef7a3af68c8..eb14f804ca581b38e88c5ebc74c3374372fa971d 100644 (file)
@@ -13,6 +13,7 @@
 -behaviour(gen_mod).
 
 -export([start/1,
+        stop/0,
         process_local_iq/3]).
 
 -include("ejabberd.hrl").
@@ -28,6 +29,9 @@ start(Opts) ->
     gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_PRIVATE,
                                  ?MODULE, process_local_iq, IQDisc).
 
+stop() ->
+    gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_PRIVATE).
+
 
 process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
     {User, Server, _} = From,
index e0787ce113fcb42819ef535f60a7b0bf0026b3c7..ff5b65369fd27e78fe972237fa865346cc44142f 100644 (file)
@@ -13,6 +13,7 @@
 -behaviour(gen_mod).
 
 -export([start/1,
+        stop/0,
         process_local_iq/3]).
 
 -include("namespaces.hrl").
@@ -22,6 +23,9 @@ start(Opts) ->
     gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_STATS,
                                  ?MODULE, process_local_iq, IQDisc).
 
+stop() ->
+    gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_STATS).
+
 
 process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
     Lang = xml:get_tag_attr_s("xml:lang", SubEl),
@@ -77,7 +81,11 @@ get_local_stats(["running nodes", _], []) ->
     {result,
      [?STAT("time/uptime"),
       ?STAT("time/cputime"),
-      ?STAT("users/online")
+      ?STAT("users/online"),
+      ?STAT("transactions/commited"),
+      ?STAT("transactions/aborted"),
+      ?STAT("transactions/restarted"),
+      ?STAT("transactions/logged")
      ]};
 
 get_local_stats(["running nodes", ENode], Names) ->
@@ -159,6 +167,39 @@ get_node_stat(Node, Name) when Name == "users/online" ->
        Users ->
            ?STATVAL(integer_to_list(length(Users)), "users")
     end;
+
+get_node_stat(Node, Name) when Name == "transactions/commited" ->
+    case catch rpc:call(Node, mnesia, system_info, [transaction_commits]) of
+       {badrpc, Reason} ->
+           ?STATERR("500", "Internal Server Error");
+       Transactions ->
+           ?STATVAL(integer_to_list(Transactions), "transactions")
+    end;
+
+get_node_stat(Node, Name) when Name == "transactions/aborted" ->
+    case catch rpc:call(Node, mnesia, system_info, [transaction_failures]) of
+       {badrpc, Reason} ->
+           ?STATERR("500", "Internal Server Error");
+       Transactions ->
+           ?STATVAL(integer_to_list(Transactions), "transactions")
+    end;
+
+get_node_stat(Node, Name) when Name == "transactions/restarted" ->
+    case catch rpc:call(Node, mnesia, system_info, [transaction_restarts]) of
+       {badrpc, Reason} ->
+           ?STATERR("500", "Internal Server Error");
+       Transactions ->
+           ?STATVAL(integer_to_list(Transactions), "transactions")
+    end;
+
+get_node_stat(Node, Name) when Name == "transactions/logged" ->
+    case catch rpc:call(Node, mnesia, system_info, [transaction_log_writes]) of
+       {badrpc, Reason} ->
+           ?STATERR("500", "Internal Server Error");
+       Transactions ->
+           ?STATVAL(integer_to_list(Transactions), "transactions")
+    end;
+
 get_node_stat(_, Name) ->
     ?STATERR("404", "Not Found").
 
index 7837c83c38c712e2c5e9e7e28d3ac5214c51454b..a9959398f80199fa6472d70a8a1ea3078f296051 100644 (file)
@@ -13,6 +13,7 @@
 -behaviour(gen_mod).
 
 -export([start/1,
+        stop/0,
         process_local_iq/3]).
 
 -include("ejabberd.hrl").
@@ -24,6 +25,8 @@ start(Opts) ->
     gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_TIME,
                                  ?MODULE, process_local_iq, IQDisc).
 
+stop() ->
+    gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_TIME).
 
 process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
     case Type of
index 0789c295402b17d69476219ae7bd1f0274854bd2..a00d4a08a3d32388cad05522cc2316453a18c36a 100644 (file)
@@ -13,6 +13,7 @@
 -behaviour(gen_mod).
 
 -export([start/1,
+        stop/0,
         process_local_iq/3]).
 
 -include("ejabberd.hrl").
@@ -25,6 +26,8 @@ start(Opts) ->
     gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_VERSION,
                                  ?MODULE, process_local_iq, IQDisc).
 
+stop() ->
+    gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_VERSION).
 
 
 process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->