]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_s2s_in.erl: Fixed "id" attribute processing
authorAlexey Shchepin <alexey@process-one.net>
Wed, 3 Sep 2003 17:49:42 +0000 (17:49 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Wed, 3 Sep 2003 17:49:42 +0000 (17:49 +0000)
* src/ejabberd_s2s_out.erl: Likewise

* src/ejabberd_c2s.erl: Added sending of empty <stream:features/>
element after opening of authentificated stream

SVN Revision: 135

ChangeLog
TODO
src/ejabberd_c2s.erl
src/ejabberd_s2s_in.erl
src/ejabberd_s2s_out.erl

index f7fd224ee3d9478441541cbb9dc7d96f34299695..0275a27c994e5a420da915275146d5a1cd3067b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-09-03  Alexey Shchepin  <alexey@sevcom.net>
+
+       * src/ejabberd_s2s_in.erl: Fixed "id" attribute processing
+       * src/ejabberd_s2s_out.erl: Likewise
+
+       * src/ejabberd_c2s.erl: Added sending of empty <stream:features/>
+       element after opening of authentificated stream
+
 2003-09-02  Alexey Shchepin  <alexey@sevcom.net>
 
        * src/ejabberd_s2s_in.erl: Temporary hack for "id" attribute
 
 2003-07-05  Alexey Shchepin  <alexey@sevcom.net>
 
-       * src/jlib.hrl: Added pub/sub nemaspaces
+       * src/jlib.hrl: Added pub/sub namespaces
 
 2003-07-03  Alexey Shchepin  <alexey@sevcom.net>
 
 
 2003-05-08  Alexey Shchepin  <alexey@sevcom.net>
 
-       * src/mod_muc/mod_muc.erl: Denied using of empty nick
+       * src/mod_muc/mod_muc.erl: Denied usage of empty nick
 
 2003-05-07  Alexey Shchepin  <alexey@sevcom.net>
 
diff --git a/TODO b/TODO
index 9f555aa883f3fc93ed6dc972c74688af89461fd7..e2256dac7ce2615199956237532073d2e4169421 100644 (file)
--- a/TODO
+++ b/TODO
@@ -8,7 +8,8 @@ admin interface
        backup management
 
 S2S:
-       * rewrite S2S key validation
+       rewrite S2S key validation
+       check "id" attributes in db:verify packets
 
 more correctly work with SRV DNS records (priority, weight, etc...)
 TLS
index 3199f3585a9942a506a80002cc532621d7fb6b6f..f4b6a3513fd28060ecddb51ce287aa114be6ea9b 100644 (file)
@@ -133,13 +133,15 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
                                            ?MYNAME,
                                            " version='1.0'"]),
                    send_text(StateData, Header),
-                   SASLState = cyrsasl:server_new("jabber", ?MYNAME, "", []),
-                   Mechs = lists:map(fun(S) ->
+                   case StateData#state.authentificated of
+                       false ->
+                           SASLState =
+                               cyrsasl:server_new("jabber", ?MYNAME, "", []),
+                           Mechs = lists:map(
+                                     fun(S) ->
                                              {xmlelement, "mechanism", [],
                                               [{xmlcdata, S}]}
                                      end, cyrsasl:listmech()),
-                   case StateData#state.authentificated of
-                       false ->
                            send_element(StateData,
                                         {xmlelement, "stream:features", [],
                                          [{xmlelement, "mechanisms",
@@ -148,6 +150,9 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
                            {next_state, wait_for_sasl_auth,
                             StateData#state{sasl_state = SASLState}};
                        _ ->
+                           send_element(
+                             StateData,
+                             {xmlelement, "stream:features", [], []}),
                            {next_state, wait_for_session, StateData}
                    end;
                _ ->
index 97a67e3ebb141ad9cc02e686b8a660dbed60d535..38f95a747106e953830a54161d73bf3751ab4815 100644 (file)
 -endif.
 
 -define(STREAM_HEADER,
-       "<?xml version='1.0'?>"
-       "<stream:stream "
-       "xmlns:stream='http://etherx.jabber.org/streams' "
-       "xmlns='jabber:server' "
-       "xmlns:db='jabber:server:dialback' "
-       "id='todo'>"
+       ("<?xml version='1.0'?>"
+        "<stream:stream "
+        "xmlns:stream='http://etherx.jabber.org/streams' "
+        "xmlns='jabber:server' "
+        "xmlns:db='jabber:server:dialback' "
+        "id='" ++ StateData#state.streamid ++ "'>")
        ).
 
 -define(STREAM_TRAILER, "</stream:stream>").
@@ -139,7 +139,8 @@ wait_for_key({xmlstreamelement, El}, StateData) ->
            case lists:member(To, ejabberd_router:dirty_get_all_domains()) of
                true ->
                    ejabberd_s2s_out:start(To, From,
-                                          {verify, self(), Key}),
+                                          {verify, self(),
+                                           Key, StateData#state.streamid}),
                    {next_state,
                     wait_for_verification,
                     StateData#state{myname = To,
index 4313354f16f1125c60aa9e749f4e7930133375a8..16c76fea83bf4627e3e4692817a78719b651fb16 100644 (file)
@@ -88,8 +88,8 @@ init([From, Server, Type]) ->
     {New, Verify} = case Type of
                        {new, Key} ->
                            {Key, false};
-                       {verify, Pid, Key} ->
-                           {false, {Pid, Key}}
+                       {verify, Pid, Key, SID} ->
+                           {false, {Pid, Key, SID}}
                    end,
     {ok, open_socket, #state{queue = queue:new(),
                             myname = From,
@@ -162,13 +162,13 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
            case StateData#state.verify of
                false ->
                    ok;
-               {Pid, Key2} ->
+               {Pid, Key2, SID} ->
                    send_element(StateData#state.socket,
                                 {xmlelement,
                                  "db:verify",
                                  [{"from", StateData#state.myname},
                                   {"to", StateData#state.server},
-                                  {"id", "todo"}],
+                                  {"id", SID}],
                                  [{xmlcdata, Key2}]})
            end,
            {next_state, wait_for_validation,
@@ -208,7 +208,7 @@ wait_for_validation({xmlstreamelement, El}, StateData) ->
            case StateData#state.verify of
                false ->
                    {next_state, wait_for_validation, StateData, ?S2STIMEOUT};
-               {Pid, Key} ->
+               {Pid, _Key, _SID} ->
                    case Type of
                        "valid" ->
                            gen_fsm:send_event(Pid, valid);
@@ -242,7 +242,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
        {verify, VTo, VFrom, VId, VType} ->
            ?INFO_MSG("recv verify: ~p", [{VFrom, VTo, VId, VType}]),
            case StateData#state.verify of
-               {VPid, VKey} ->
+               {VPid, _VKey, _SID} ->
                    case VType of
                        "valid" ->
                            gen_fsm:send_event(VPid, valid);
@@ -255,27 +255,6 @@ stream_established({xmlstreamelement, El}, StateData) ->
        _ ->
            ok
     end,
-    %{xmlelement, Name, Attrs, Els} = El,
-    %From = xml:get_attr_s("from", Attrs),
-    %FromJID1 = jlib:string_to_jid(From),
-    %FromJID = case FromJID1 of
-    %            {Node, Server, Resource} ->
-    %                if Server == StateData#state.server -> FromJID1;
-    %                   true -> error
-    %                end;
-    %            _ -> error
-    %          end,
-    %To = xml:get_attr_s("to", Attrs),
-    %ToJID = case To of
-    %          "" -> error;
-    %          _ -> jlib:string_to_jid(To)
-    %        end,
-    %if ((Name == "iq") or (Name == "message") or (Name == "presence")) and
-    %   (ToJID /= error) and (FromJID /= error) ->
-    %        ejabberd_router:route(FromJID, ToJID, El);
-    %   true ->
-    %        error
-    %end,
     {next_state, stream_established, StateData, ?S2STIMEOUT};
 
 stream_established({xmlstreamend, Name}, StateData) ->