25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-30 16:36:29 +01:00

* 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

SVN Revision: 135
This commit is contained in:
Alexey Shchepin 2003-09-03 17:49:42 +00:00
parent dc80fa1562
commit de6b2a2996
5 changed files with 35 additions and 41 deletions

View File

@ -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> 2003-09-02 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_s2s_in.erl: Temporary hack for "id" attribute * src/ejabberd_s2s_in.erl: Temporary hack for "id" attribute
@ -111,7 +119,7 @@
2003-07-05 Alexey Shchepin <alexey@sevcom.net> 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-07-03 Alexey Shchepin <alexey@sevcom.net>
@ -221,7 +229,7 @@
2003-05-08 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> 2003-05-07 Alexey Shchepin <alexey@sevcom.net>

3
TODO
View File

@ -8,7 +8,8 @@ admin interface
backup management backup management
S2S: 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...) more correctly work with SRV DNS records (priority, weight, etc...)
TLS TLS

View File

@ -133,13 +133,15 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
?MYNAME, ?MYNAME,
" version='1.0'"]), " version='1.0'"]),
send_text(StateData, Header), send_text(StateData, Header),
SASLState = cyrsasl:server_new("jabber", ?MYNAME, "", []), case StateData#state.authentificated of
Mechs = lists:map(fun(S) -> false ->
SASLState =
cyrsasl:server_new("jabber", ?MYNAME, "", []),
Mechs = lists:map(
fun(S) ->
{xmlelement, "mechanism", [], {xmlelement, "mechanism", [],
[{xmlcdata, S}]} [{xmlcdata, S}]}
end, cyrsasl:listmech()), end, cyrsasl:listmech()),
case StateData#state.authentificated of
false ->
send_element(StateData, send_element(StateData,
{xmlelement, "stream:features", [], {xmlelement, "stream:features", [],
[{xmlelement, "mechanisms", [{xmlelement, "mechanisms",
@ -148,6 +150,9 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
{next_state, wait_for_sasl_auth, {next_state, wait_for_sasl_auth,
StateData#state{sasl_state = SASLState}}; StateData#state{sasl_state = SASLState}};
_ -> _ ->
send_element(
StateData,
{xmlelement, "stream:features", [], []}),
{next_state, wait_for_session, StateData} {next_state, wait_for_session, StateData}
end; end;
_ -> _ ->

View File

@ -42,12 +42,12 @@
-endif. -endif.
-define(STREAM_HEADER, -define(STREAM_HEADER,
"<?xml version='1.0'?>" ("<?xml version='1.0'?>"
"<stream:stream " "<stream:stream "
"xmlns:stream='http://etherx.jabber.org/streams' " "xmlns:stream='http://etherx.jabber.org/streams' "
"xmlns='jabber:server' " "xmlns='jabber:server' "
"xmlns:db='jabber:server:dialback' " "xmlns:db='jabber:server:dialback' "
"id='todo'>" "id='" ++ StateData#state.streamid ++ "'>")
). ).
-define(STREAM_TRAILER, "</stream:stream>"). -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 case lists:member(To, ejabberd_router:dirty_get_all_domains()) of
true -> true ->
ejabberd_s2s_out:start(To, From, ejabberd_s2s_out:start(To, From,
{verify, self(), Key}), {verify, self(),
Key, StateData#state.streamid}),
{next_state, {next_state,
wait_for_verification, wait_for_verification,
StateData#state{myname = To, StateData#state{myname = To,

View File

@ -88,8 +88,8 @@ init([From, Server, Type]) ->
{New, Verify} = case Type of {New, Verify} = case Type of
{new, Key} -> {new, Key} ->
{Key, false}; {Key, false};
{verify, Pid, Key} -> {verify, Pid, Key, SID} ->
{false, {Pid, Key}} {false, {Pid, Key, SID}}
end, end,
{ok, open_socket, #state{queue = queue:new(), {ok, open_socket, #state{queue = queue:new(),
myname = From, myname = From,
@ -162,13 +162,13 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
case StateData#state.verify of case StateData#state.verify of
false -> false ->
ok; ok;
{Pid, Key2} -> {Pid, Key2, SID} ->
send_element(StateData#state.socket, send_element(StateData#state.socket,
{xmlelement, {xmlelement,
"db:verify", "db:verify",
[{"from", StateData#state.myname}, [{"from", StateData#state.myname},
{"to", StateData#state.server}, {"to", StateData#state.server},
{"id", "todo"}], {"id", SID}],
[{xmlcdata, Key2}]}) [{xmlcdata, Key2}]})
end, end,
{next_state, wait_for_validation, {next_state, wait_for_validation,
@ -208,7 +208,7 @@ wait_for_validation({xmlstreamelement, El}, StateData) ->
case StateData#state.verify of case StateData#state.verify of
false -> false ->
{next_state, wait_for_validation, StateData, ?S2STIMEOUT}; {next_state, wait_for_validation, StateData, ?S2STIMEOUT};
{Pid, Key} -> {Pid, _Key, _SID} ->
case Type of case Type of
"valid" -> "valid" ->
gen_fsm:send_event(Pid, valid); gen_fsm:send_event(Pid, valid);
@ -242,7 +242,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
{verify, VTo, VFrom, VId, VType} -> {verify, VTo, VFrom, VId, VType} ->
?INFO_MSG("recv verify: ~p", [{VFrom, VTo, VId, VType}]), ?INFO_MSG("recv verify: ~p", [{VFrom, VTo, VId, VType}]),
case StateData#state.verify of case StateData#state.verify of
{VPid, VKey} -> {VPid, _VKey, _SID} ->
case VType of case VType of
"valid" -> "valid" ->
gen_fsm:send_event(VPid, valid); gen_fsm:send_event(VPid, valid);
@ -255,27 +255,6 @@ stream_established({xmlstreamelement, El}, StateData) ->
_ -> _ ->
ok ok
end, 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}; {next_state, stream_established, StateData, ?S2STIMEOUT};
stream_established({xmlstreamend, Name}, StateData) -> stream_established({xmlstreamend, Name}, StateData) ->