Changeset View
Changeset View
Standalone View
Standalone View
source/tools/lobbybots/mod_ipstamp/src/mod_ipstamp.erl
%% Copyright (C) 2018 Wildfire Games. | %% Copyright (C) 2019 Wildfire Games. | ||||
%% This file is part of 0 A.D. | %% This file is part of 0 A.D. | ||||
%% | %% | ||||
%% 0 A.D. is free software: you can redistribute it and/or modify | %% 0 A.D. is free software: you can redistribute it and/or modify | ||||
%% it under the terms of the GNU General Public License as published by | %% it under the terms of the GNU General Public License as published by | ||||
%% the Free Software Foundation, either version 2 of the License, or | %% the Free Software Foundation, either version 2 of the License, or | ||||
%% (at your option) any later version. | %% (at your option) any later version. | ||||
%% | %% | ||||
%% 0 A.D. is distributed in the hope that it will be useful, | %% 0 A.D. is distributed in the hope that it will be useful, | ||||
%% but WITHOUT ANY WARRANTY; without even the implied warranty of | %% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
%% GNU General Public License for more details. | %% GNU General Public License for more details. | ||||
%% | %% | ||||
%% You should have received a copy of the GNU General Public License | %% You should have received a copy of the GNU General Public License | ||||
%% along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | %% along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
-module(mod_ipstamp). | -module(mod_ipstamp). | ||||
-behaviour(gen_mod). | -behaviour(gen_mod). | ||||
-include("ejabberd.hrl"). | |||||
-include("logger.hrl"). | -include("logger.hrl"). | ||||
-include("xmpp.hrl"). | -include("xmpp.hrl"). | ||||
-export([start/2, | -export([start/2, | ||||
stop/1, | stop/1, | ||||
depends/2, | depends/2, | ||||
mod_opt_type/1, | mod_options/1, | ||||
reload/3, | reload/3, | ||||
on_filter_packet/1]). | on_filter_packet/1]). | ||||
start(_Host, _Opts) -> | start(_Host, _Opts) -> | ||||
ejabberd_hooks:add(filter_packet, global, ?MODULE, on_filter_packet, 50). | ejabberd_hooks:add(filter_packet, global, ?MODULE, on_filter_packet, 50). | ||||
stop(_Host) -> | stop(_Host) -> | ||||
ejabberd_hooks:delete(filter_packet, global, ?MODULE, on_filter_packet, 50). | ejabberd_hooks:delete(filter_packet, global, ?MODULE, on_filter_packet, 50). | ||||
depends(_Host, _Opts) -> []. | depends(_Host, _Opts) -> []. | ||||
mod_opt_type(_) -> []. | mod_options(_) -> []. | ||||
elexis: https://docs.ejabberd.im/developer/guide/ | |||||
Done Inline Actionsnew in ejabberd 18.03 elexis: new in ejabberd 18.03 | |||||
reload(_Host, _NewOpts, _OldOpts) -> ok. | reload(_Host, _NewOpts, _OldOpts) -> ok. | ||||
-spec on_filter_packet(Input :: iq()) -> iq() | drop. | -spec on_filter_packet(Input :: iq()) -> iq() | drop. | ||||
on_filter_packet(#iq{type = set, to = To, sub_els = [SubEl]} = Input) -> | on_filter_packet(#iq{type = set, to = To, sub_els = [SubEl]} = Input) -> | ||||
% We only want to do something for the bots | % We only want to do something for the bots | ||||
case acl:match_rule(global, ipbots, To) of | case acl:match_rule(global, ipbots, To) of | ||||
allow -> | allow -> | ||||
Show All 24 Lines |
Wildfire Games · Phabricator
https://docs.ejabberd.im/developer/guide/