mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Attach IP metadata to every stanza received from stream
This commit is contained in:
parent
0b304731c5
commit
6fd89f5fe0
@ -428,22 +428,24 @@ handle_unauthenticated_packet(Pkt, #{lserver := LServer} = State) ->
|
||||
handle_authenticated_packet(Pkt, #{lserver := LServer} = State) when not ?is_stanza(Pkt) ->
|
||||
ejabberd_hooks:run_fold(c2s_authenticated_packet,
|
||||
LServer, State, [Pkt]);
|
||||
handle_authenticated_packet(Pkt, #{lserver := LServer, jid := JID} = State) ->
|
||||
handle_authenticated_packet(Pkt, #{lserver := LServer, jid := JID,
|
||||
ip := {IP, _}} = State) ->
|
||||
Pkt1 = xmpp:put_meta(Pkt, ip, IP),
|
||||
State1 = ejabberd_hooks:run_fold(c2s_authenticated_packet,
|
||||
LServer, State, [Pkt]),
|
||||
LServer, State, [Pkt1]),
|
||||
#jid{luser = LUser} = JID,
|
||||
{Pkt1, State2} = ejabberd_hooks:run_fold(
|
||||
user_send_packet, LServer, {Pkt, State1}, []),
|
||||
case Pkt1 of
|
||||
{Pkt2, State2} = ejabberd_hooks:run_fold(
|
||||
user_send_packet, LServer, {Pkt1, State1}, []),
|
||||
case Pkt2 of
|
||||
drop ->
|
||||
State2;
|
||||
#presence{to = #jid{luser = LUser, lserver = LServer,
|
||||
lresource = <<"">>}} ->
|
||||
process_self_presence(State2, Pkt1);
|
||||
process_self_presence(State2, Pkt2);
|
||||
#presence{} ->
|
||||
process_presence_out(State2, Pkt1);
|
||||
process_presence_out(State2, Pkt2);
|
||||
_ ->
|
||||
check_privacy_then_route(State2, Pkt1)
|
||||
check_privacy_then_route(State2, Pkt2)
|
||||
end.
|
||||
|
||||
handle_cdata(Data, #{lserver := LServer} = State) ->
|
||||
|
@ -200,7 +200,8 @@ handle_unauthenticated_packet(Pkt, #{server_host := LServer} = State) ->
|
||||
|
||||
handle_authenticated_packet(Pkt, #{server_host := LServer} = State) when not ?is_stanza(Pkt) ->
|
||||
ejabberd_hooks:run_fold(s2s_in_authenticated_packet, LServer, State, [Pkt]);
|
||||
handle_authenticated_packet(Pkt, State) ->
|
||||
handle_authenticated_packet(Pkt0, #{ip := {IP, _}} = State) ->
|
||||
Pkt = xmpp:put_meta(Pkt0, ip, IP),
|
||||
From = xmpp:get_from(Pkt),
|
||||
To = xmpp:get_to(Pkt),
|
||||
case check_from_to(From, To, State) of
|
||||
|
@ -184,7 +184,9 @@ handle_auth_failure(_, Mech, Reason,
|
||||
Reason]),
|
||||
State.
|
||||
|
||||
handle_authenticated_packet(Pkt, #{lang := Lang} = State) when ?is_stanza(Pkt) ->
|
||||
handle_authenticated_packet(Pkt0, #{ip := {IP, _}, lang := Lang} = State)
|
||||
when ?is_stanza(Pkt0) ->
|
||||
Pkt = xmpp:put_meta(Pkt0, ip, IP),
|
||||
From = xmpp:get_from(Pkt),
|
||||
case check_from(From, State) of
|
||||
true ->
|
||||
|
Loading…
Reference in New Issue
Block a user