25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Update xmpp to make us present both sasl1 and sasl2 with from in initial stanza

This commit is contained in:
Paweł Chmielowski 2023-11-22 18:34:18 +01:00
parent 9c7e91a1e9
commit 48f0d9c15e
4 changed files with 17 additions and 14 deletions

View File

@ -114,7 +114,7 @@ defmodule Ejabberd.MixProject do
{:p1_utils, "~> 1.0"},
{:pkix, "~> 1.0"},
{:stringprep, ">= 1.0.26"},
{:xmpp, git: "https://github.com/processone/xmpp.git", ref: "dcb701e6800d827f8806c0d049aaf103cd724e2b", override: true},
{:xmpp, git: "https://github.com/processone/xmpp.git", ref: "2b0c95c807fc8f5862bc4301e0b7451a0617348e", override: true},
{:yconf, "~> 1.0"}]
++ cond_deps()
end

View File

@ -77,7 +77,7 @@
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.29"}}},
{if_var_true, stun,
{stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.2.10"}}}},
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "dcb701e6800d827f8806c0d049aaf103cd724e2b"}},
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "2b0c95c807fc8f5862bc4301e0b7451a0617348e"}},
{yconf, ".*", {git, "https://github.com/processone/yconf", {tag, "1.0.15"}}}
]}.

View File

@ -216,7 +216,7 @@ open_session(#{user := U, server := S, resource := R,
end,
Info = [{ip, IP}, {conn, Conn}, {auth_module, AuthModule}],
case State of
#{bind2_tag := Tag} ->
#{bind2_session_id := Tag} ->
ejabberd_sm:open_session(SID, U, S, R, Prio, Info, Tag);
_ ->
ejabberd_sm:open_session(SID, U, S, R, Prio, Info)

View File

@ -149,8 +149,8 @@ route(Packet) ->
end.
-spec open_session(sid(), binary(), binary(), binary(), prio(), info(), binary() | undefined) -> ok.
-spec open_session(sid(), binary(), binary(), binary(), prio(), info(),
{binary(), binary()} | undefined) -> ok.
open_session(SID, User, Server, Resource, Priority, Info, Bind2Tag) ->
set_session(SID, User, Server, Resource, Priority, Info),
check_for_sessions_to_replace(User, Server, Resource, Bind2Tag),
@ -459,7 +459,7 @@ c2s_handle_info(#{lang := Lang} = State, replaced) ->
State1 = State#{replaced => true},
Err = xmpp:serr_conflict(?T("Replaced by new connection"), Lang),
{stop, ejabberd_c2s:send(State1, Err)};
c2s_handle_info(#{lang := Lang, bind2_tag := Tag} = State,
c2s_handle_info(#{lang := Lang, bind2_session_id := {Tag, _}} = State,
{replaced_with_bind_tag, Bind2Tag}) when Tag == Bind2Tag ->
State1 = State#{replaced => true},
Err = xmpp:serr_conflict(?T("Replaced by new connection"), Lang),
@ -840,8 +840,8 @@ clean_session_list([S1, S2 | Rest], Res) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% On new session, check if some existing connections need to be replace
-spec check_for_sessions_to_replace(binary(), binary(), binary(), binary() | undefined)
-> ok | replaced.
-spec check_for_sessions_to_replace(binary(), binary(), binary(),
{binary(), binary()} | undefined) -> ok | replaced.
check_for_sessions_to_replace(User, Server, Resource, Bind2Tag) ->
LUser = jid:nodeprep(User),
LServer = jid:nameprep(Server),
@ -849,7 +849,8 @@ check_for_sessions_to_replace(User, Server, Resource, Bind2Tag) ->
check_existing_resources(LUser, LServer, LResource, Bind2Tag),
check_max_sessions(LUser, LServer).
-spec check_existing_resources(binary(), binary(), binary(), binary() | undefined) -> ok.
-spec check_existing_resources(binary(), binary(), binary(),
{binary(), binary()} | undefined) -> ok.
check_existing_resources(LUser, LServer, LResource, undefined) ->
Mod = get_sm_backend(LServer),
Ss = get_sessions(Mod, LUser, LServer, LResource),
@ -863,14 +864,16 @@ check_existing_resources(LUser, LServer, LResource, undefined) ->
end,
SIDs)
end;
check_existing_resources(LUser, LServer, _LResource, Bind2Tag) ->
check_existing_resources(LUser, LServer, LResource, {Tag, Hash}) ->
Mod = get_sm_backend(LServer),
Ss = get_sessions(Mod, LUser, LServer),
Len = size(Bind2Tag),
lists:foreach(
fun(#session{sid = {_, Pid}, usr = {_, _, <<Tag:Len/binary, ".", _/binary>>}})
when Pid /= self(), Tag == Bind2Tag ->
ejabberd_c2s:route(Pid, {replaced_with_bind_tag, Bind2Tag});
fun(#session{sid = {_, Pid}, usr = {_, _, Res}})
when Pid /= self(), Res == LResource ->
ejabberd_c2s:route(Pid, replaced);
(#session{sid = {_, Pid}, usr = {_, _, Res}})
when Pid /= self(), binary_part(Res, size(Res), -size(Hash)) == Hash ->
ejabberd_c2s:route(Pid, {replaced_with_bind_tag, Tag});
(_) ->
ok
end, Ss).