mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Make option 'validate_stream' global
This commit is contained in:
parent
a0d3fb3b23
commit
e9a78d0de7
@ -710,7 +710,7 @@ bounce_receivers(State, _Reason) ->
|
||||
State, Receivers ++ ShapedReceivers).
|
||||
|
||||
bounce_els_from_obuf(State) ->
|
||||
Opts = ejabberd_config:codec_options(State#state.host),
|
||||
Opts = ejabberd_config:codec_options(),
|
||||
p1_queue:foreach(
|
||||
fun({xmlstreamelement, El}) ->
|
||||
try xmpp:decode(El, ?NS_CLIENT, Opts) of
|
||||
|
@ -442,7 +442,7 @@ handle_stream_start(StreamStart, #{lserver := LServer} = State) ->
|
||||
send(State#{lserver => ejabberd_config:get_myname()}, xmpp:serr_host_unknown());
|
||||
true ->
|
||||
State1 = change_shaper(State),
|
||||
Opts = ejabberd_config:codec_options(LServer),
|
||||
Opts = ejabberd_config:codec_options(),
|
||||
State2 = State1#{codec_options => Opts},
|
||||
ejabberd_hooks:run_fold(
|
||||
c2s_stream_started, LServer, State2, [StreamStart])
|
||||
|
@ -31,7 +31,7 @@
|
||||
-export([get_myname/0, get_uri/0, get_copyright/0]).
|
||||
-export([get_shared_key/0, get_node_start/0]).
|
||||
-export([fsm_limit_opts/1]).
|
||||
-export([codec_options/1]).
|
||||
-export([codec_options/0]).
|
||||
-export([default_db/2, default_db/3, default_ram_db/2, default_ram_db/3]).
|
||||
-export([beams/1, validators/1, globals/0, may_hide_data/1]).
|
||||
-export([dump/0, dump/1, convert_to_yaml/1, convert_to_yaml/2]).
|
||||
@ -218,9 +218,9 @@ fsm_limit_opts(Opts) ->
|
||||
end
|
||||
end.
|
||||
|
||||
-spec codec_options(binary() | global) -> [xmpp:decode_option()].
|
||||
codec_options(Host) ->
|
||||
case get_option({validate_stream, Host}) of
|
||||
-spec codec_options() -> [xmpp:decode_option()].
|
||||
codec_options() ->
|
||||
case get_option(validate_stream) of
|
||||
true -> [];
|
||||
false -> [ignore_els]
|
||||
end.
|
||||
|
@ -156,7 +156,7 @@
|
||||
-export([sql_username/0, sql_username/1]).
|
||||
-export([trusted_proxies/0, trusted_proxies/1]).
|
||||
-export([use_cache/0, use_cache/1]).
|
||||
-export([validate_stream/0, validate_stream/1]).
|
||||
-export([validate_stream/0]).
|
||||
-export([version/0]).
|
||||
-export([websocket_origin/0]).
|
||||
-export([websocket_ping_interval/0]).
|
||||
@ -1040,10 +1040,7 @@ use_cache(Host) ->
|
||||
|
||||
-spec validate_stream() -> boolean().
|
||||
validate_stream() ->
|
||||
validate_stream(global).
|
||||
-spec validate_stream(global | binary()) -> boolean().
|
||||
validate_stream(Host) ->
|
||||
ejabberd_config:get_option({validate_stream, Host}).
|
||||
ejabberd_config:get_option({validate_stream, global}).
|
||||
|
||||
-spec version() -> binary().
|
||||
version() ->
|
||||
|
@ -711,6 +711,7 @@ globals() ->
|
||||
sm_cache_life_time,
|
||||
sm_cache_missed,
|
||||
sm_cache_size,
|
||||
validate_stream,
|
||||
version,
|
||||
websocket_origin,
|
||||
websocket_ping_interval,
|
||||
|
@ -164,7 +164,7 @@ handle_stream_start(_StreamStart, #{lserver := LServer} = State) ->
|
||||
send(State, xmpp:serr_host_unknown());
|
||||
true ->
|
||||
ServerHost = ejabberd_router:host_of_route(LServer),
|
||||
Opts = ejabberd_config:codec_options(LServer),
|
||||
Opts = ejabberd_config:codec_options(),
|
||||
State#{server_host => ServerHost, codec_options => Opts}
|
||||
end.
|
||||
|
||||
|
@ -133,7 +133,7 @@ handle_stream_start(_StreamStart,
|
||||
HostOpts
|
||||
end
|
||||
end,
|
||||
CodecOpts = ejabberd_config:codec_options(global),
|
||||
CodecOpts = ejabberd_config:codec_options(),
|
||||
State#{host_opts => NewHostOpts, codec_options => CodecOpts}
|
||||
end.
|
||||
|
||||
|
@ -1496,7 +1496,7 @@ send_stanza(FromString, ToString, Stanza) ->
|
||||
#xmlel{} = El = fxml_stream:parse_element(Stanza),
|
||||
From = jid:decode(FromString),
|
||||
To = jid:decode(ToString),
|
||||
CodecOpts = ejabberd_config:codec_options(From#jid.lserver),
|
||||
CodecOpts = ejabberd_config:codec_options(),
|
||||
Pkt = xmpp:decode(El, ?NS_CLIENT, CodecOpts),
|
||||
ejabberd_router:route(xmpp:set_from_to(Pkt, From, To))
|
||||
catch _:{xmpp_codec, Why} ->
|
||||
|
@ -708,7 +708,7 @@ send_motd({#presence{type = available},
|
||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||
case get_motd(Mod, LServer) of
|
||||
{ok, Packet} ->
|
||||
CodecOpts = ejabberd_config:codec_options(LServer),
|
||||
CodecOpts = ejabberd_config:codec_options(),
|
||||
try xmpp:decode(Packet, ?NS_CLIENT, CodecOpts) of
|
||||
Msg ->
|
||||
case is_motd_user(Mod, LUser, LServer) of
|
||||
@ -800,7 +800,7 @@ get_stored_motd(LServer) ->
|
||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||
case get_motd(Mod, LServer) of
|
||||
{ok, Packet} ->
|
||||
CodecOpts = ejabberd_config:codec_options(LServer),
|
||||
CodecOpts = ejabberd_config:codec_options(),
|
||||
try xmpp:decode(Packet, ?NS_CLIENT, CodecOpts) of
|
||||
#message{body = Body, subject = Subject} ->
|
||||
{xmpp:get_text(Subject), xmpp:get_text(Body)}
|
||||
|
@ -267,7 +267,7 @@ process_iq(#iq{to = To, lang = Lang, sub_els = [SubEl]} = IQ, Type) ->
|
||||
process_iq_result(#iq{from = From, to = To, id = ID, lang = Lang} = IQ,
|
||||
#iq{type = result} = ResIQ) ->
|
||||
try
|
||||
CodecOpts = ejabberd_config:codec_options(To#jid.lserver),
|
||||
CodecOpts = ejabberd_config:codec_options(),
|
||||
#delegation{forwarded = #forwarded{sub_els = [SubEl]}} =
|
||||
xmpp:get_subtag(ResIQ, #delegation{}),
|
||||
case xmpp:decode(SubEl, ?NS_CLIENT, CodecOpts) of
|
||||
|
@ -1218,8 +1218,7 @@ wrap_as_mucsub(Message, Requester, ReqServer) ->
|
||||
msg_to_el(#archive_msg{timestamp = TS, packet = El, nick = Nick,
|
||||
peer = Peer, id = ID},
|
||||
MsgType, JidRequestor, #jid{lserver = LServer} = JidArchive) ->
|
||||
CodecOpts = ejabberd_config:codec_options(
|
||||
ejabberd_router:host_of_route(LServer)),
|
||||
CodecOpts = ejabberd_config:codec_options(),
|
||||
try xmpp:decode(El, ?NS_CLIENT, CodecOpts) of
|
||||
Pkt1 ->
|
||||
Pkt2 = case MsgType of
|
||||
|
@ -689,7 +689,7 @@ get_offline_els(LUser, LServer) ->
|
||||
-spec offline_msg_to_route(binary(), #offline_msg{}) ->
|
||||
{route, message()} | error.
|
||||
offline_msg_to_route(LServer, #offline_msg{from = From, to = To} = R) ->
|
||||
CodecOpts = ejabberd_config:codec_options(LServer),
|
||||
CodecOpts = ejabberd_config:codec_options(),
|
||||
try xmpp:decode(R#offline_msg.packet, ?NS_CLIENT, CodecOpts) of
|
||||
Pkt ->
|
||||
Pkt1 = xmpp:set_from_to(Pkt, From, To),
|
||||
@ -715,7 +715,7 @@ read_messages(LUser, LServer) ->
|
||||
-spec read_db_messages(binary(), binary()) -> [{binary(), message()}].
|
||||
read_db_messages(LUser, LServer) ->
|
||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||
CodecOpts = ejabberd_config:codec_options(LServer),
|
||||
CodecOpts = ejabberd_config:codec_options(),
|
||||
lists:flatmap(
|
||||
fun({Seq, From, To, TS, El}) ->
|
||||
Node = integer_to_binary(Seq),
|
||||
|
@ -281,7 +281,7 @@ get_permissions(ServerHost) ->
|
||||
forward_message(#message{to = To} = Msg) ->
|
||||
ServerHost = To#jid.lserver,
|
||||
Lang = xmpp:get_lang(Msg),
|
||||
CodecOpts = ejabberd_config:codec_options(ServerHost),
|
||||
CodecOpts = ejabberd_config:codec_options(),
|
||||
try xmpp:try_subtag(Msg, #privilege{}) of
|
||||
#privilege{forwarded = #forwarded{sub_els = [SubEl]}} ->
|
||||
try xmpp:decode(SubEl, ?NS_CLIENT, CodecOpts) of
|
||||
|
Loading…
Reference in New Issue
Block a user