diff options
293 files changed, 3362 insertions, 3002 deletions
diff --git a/ejabberd.yml.example b/ejabberd.yml.example index ceea11e52..fc8555265 100644 --- a/ejabberd.yml.example +++ b/ejabberd.yml.example @@ -524,6 +524,40 @@ access_rules: ## - ip: "XXX.XXX.XXX.XXX/32" ## - allow +## =============== +## API PERMISSIONS +## =============== +## +## This section allows you to define who and using what method +## can execute commands offered by ejabberd. +## +## By default "console commands" section allow executing all commands +## issued using ejabberdctl command, and "admin access" section allows +## users in admin acl to execute all commands except start and stop +## with any available access method (ejabberdctl, http-api, xmlrpc +## depending what is enabled on server). +## +## Remember to not remove "console commands" section when doing modifications +## or ejabberdctl will not be able to execute commands! +## +## +## api_permissions: +## "console commands": +## from: +## - ejabberd_ctl +## who: all +## what: "*" +## "admin access": +## who: +## - admin +## - oauth: +## - scope: "ejabberd:admin" +## - admin +## what: +## - "*" +## - "!stop" +## - "!start" + ## By default the frequency of account registrations from the same IP ## is limited to 1 account every 10 minutes. To disable, specify: infinity ## registration_timeout: 600 diff --git a/include/adhoc.hrl b/include/adhoc.hrl index bd1bfaa6f..d5ec14e48 100644 --- a/include/adhoc.hrl +++ b/include/adhoc.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/bosh.hrl b/include/bosh.hrl index 9cdfd98d8..6468efac4 100644 --- a/include/bosh.hrl +++ b/include/bosh.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/ejabberd.hrl b/include/ejabberd.hrl index ddf41f094..419e91d0e 100644 --- a/include/ejabberd.hrl +++ b/include/ejabberd.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -39,7 +39,7 @@ -define(EJABBERD_URI, <<"http://www.process-one.net/en/ejabberd/">>). --define(COPYRIGHT, "Copyright (c) 2002-2016 ProcessOne"). +-define(COPYRIGHT, "Copyright (c) 2002-2017 ProcessOne"). %%-define(DBGFSM, true). diff --git a/include/ejabberd_commands.hrl b/include/ejabberd_commands.hrl index 199be890e..5d14b2787 100644 --- a/include/ejabberd_commands.hrl +++ b/include/ejabberd_commands.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/ejabberd_config.hrl b/include/ejabberd_config.hrl index 2d6889313..80dd5613b 100644 --- a/include/ejabberd_config.hrl +++ b/include/ejabberd_config.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/ejabberd_ctl.hrl b/include/ejabberd_ctl.hrl index 3951129e7..dc73b3a1a 100644 --- a/include/ejabberd_ctl.hrl +++ b/include/ejabberd_ctl.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/ejabberd_http.hrl b/include/ejabberd_http.hrl index 25209f76c..8f6510183 100644 --- a/include/ejabberd_http.hrl +++ b/include/ejabberd_http.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/ejabberd_oauth.hrl b/include/ejabberd_oauth.hrl index 6b5a9bcc8..2e36d069b 100644 --- a/include/ejabberd_oauth.hrl +++ b/include/ejabberd_oauth.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/ejabberd_sm.hrl b/include/ejabberd_sm.hrl index f86ab1c15..0591dd09e 100644 --- a/include/ejabberd_sm.hrl +++ b/include/ejabberd_sm.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -ifndef(EJABBERD_SM_HRL). -define(EJABBERD_SM_HRL, true). diff --git a/include/ejabberd_sql_pt.hrl b/include/ejabberd_sql_pt.hrl index f1a3dba3f..8e5e5c38c 100644 --- a/include/ejabberd_sql_pt.hrl +++ b/include/ejabberd_sql_pt.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/ejabberd_web_admin.hrl b/include/ejabberd_web_admin.hrl index 33ff3a451..61221db7e 100644 --- a/include/ejabberd_web_admin.hrl +++ b/include/ejabberd_web_admin.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/eldap.hrl b/include/eldap.hrl index 6dfc894a8..5ec1f9c88 100644 --- a/include/eldap.hrl +++ b/include/eldap.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/http_bind.hrl b/include/http_bind.hrl index cd8512f0e..e950e28f4 100644 --- a/include/http_bind.hrl +++ b/include/http_bind.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/jlib.hrl b/include/jlib.hrl index 5a3c1634e..6f0972f81 100644 --- a/include/jlib.hrl +++ b/include/jlib.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/logger.hrl b/include/logger.hrl index df0776863..0916c5841 100644 --- a/include/logger.hrl +++ b/include/logger.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -17,6 +17,7 @@ %%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. %%% %%%---------------------------------------------------------------------- + -define(PRINT(Format, Args), io:format(Format, Args)). -compile([{parse_transform, lager_transform}]). diff --git a/include/mod_announce.hrl b/include/mod_announce.hrl index 83d72aaf1..e209942c6 100644 --- a/include/mod_announce.hrl +++ b/include/mod_announce.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -record(motd, {server = <<"">> :: binary(), packet = #xmlel{} :: xmlel()}). diff --git a/include/mod_caps.hrl b/include/mod_caps.hrl index 067df9490..5730bab71 100644 --- a/include/mod_caps.hrl +++ b/include/mod_caps.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -record(caps_features, {node_pair = {<<"">>, <<"">>} :: {binary(), binary()}, features = [] :: [binary()] | pos_integer() diff --git a/include/mod_carboncopy.hrl b/include/mod_carboncopy.hrl index df69938e8..b58a5044e 100644 --- a/include/mod_carboncopy.hrl +++ b/include/mod_carboncopy.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -type matchspec_atom() :: '_' | '$1' | '$2' | '$3'. -record(carboncopy, {us :: {binary(), binary()} | matchspec_atom(), resource :: binary() | matchspec_atom(), diff --git a/include/mod_irc.hrl b/include/mod_irc.hrl index b9696a88b..23b9d84e2 100644 --- a/include/mod_irc.hrl +++ b/include/mod_irc.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -type conn_param() :: {binary(), binary(), inet:port_number(), binary()} | {binary(), binary(), inet:port_number()} | {binary(), binary()} | diff --git a/include/mod_last.hrl b/include/mod_last.hrl index 494bf7b0c..e6df97771 100644 --- a/include/mod_last.hrl +++ b/include/mod_last.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -record(last_activity, {us = {<<"">>, <<"">>} :: {binary(), binary()}, timestamp = 0 :: non_neg_integer(), status = <<"">> :: binary()}). diff --git a/include/mod_mam.hrl b/include/mod_mam.hrl index a2b92fca5..452f404ed 100644 --- a/include/mod_mam.hrl +++ b/include/mod_mam.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -record(archive_msg, {us = {<<"">>, <<"">>} :: {binary(), binary()} | '$2', id = <<>> :: binary() | '_', diff --git a/include/mod_muc.hrl b/include/mod_muc.hrl index b2cdb9544..ef66e2c2b 100644 --- a/include/mod_muc.hrl +++ b/include/mod_muc.hrl @@ -1,7 +1,6 @@ %%%---------------------------------------------------------------------- -%%% File : mod_muc.hrl %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/mod_muc_room.hrl b/include/mod_muc_room.hrl index 4fbd1466e..010dc6e99 100644 --- a/include/mod_muc_room.hrl +++ b/include/mod_muc_room.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/mod_offline.hrl b/include/mod_offline.hrl index cc644c4c2..682e361f2 100644 --- a/include/mod_offline.hrl +++ b/include/mod_offline.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -record(offline_msg, {us = {<<"">>, <<"">>} :: {binary(), binary()}, timestamp = p1_time_compat:timestamp() :: erlang:timestamp() | '_', diff --git a/include/mod_privacy.hrl b/include/mod_privacy.hrl index dbd19a081..b628a5e1e 100644 --- a/include/mod_privacy.hrl +++ b/include/mod_privacy.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/mod_private.hrl b/include/mod_private.hrl index d833af35f..aa41f4350 100644 --- a/include/mod_private.hrl +++ b/include/mod_private.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -record(private_storage, {usns = {<<"">>, <<"">>, <<"">>} :: {binary(), binary(), binary() | '$1' | '_'}, diff --git a/include/mod_proxy65.hrl b/include/mod_proxy65.hrl index 1d8ceb3c6..ae0f77785 100644 --- a/include/mod_proxy65.hrl +++ b/include/mod_proxy65.hrl @@ -2,7 +2,7 @@ %%% RFC 1928 constants. %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/mod_roster.hrl b/include/mod_roster.hrl index 818508703..4bd1897a5 100644 --- a/include/mod_roster.hrl +++ b/include/mod_roster.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/include/mod_shared_roster.hrl b/include/mod_shared_roster.hrl index 1f96b3034..52cf7d733 100644 --- a/include/mod_shared_roster.hrl +++ b/include/mod_shared_roster.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -record(sr_group, {group_host = {<<"">>, <<"">>} :: {'$1' | binary(), '$2' | binary()}, opts = [] :: list() | '_' | '$2'}). diff --git a/include/mod_vcard.hrl b/include/mod_vcard.hrl index 3bd62b2eb..5b7c39998 100644 --- a/include/mod_vcard.hrl +++ b/include/mod_vcard.hrl @@ -1,3 +1,23 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -record(vcard_search, {us, user, luser, fn, lfn, family, lfamily, given, lgiven, middle, lmiddle, nickname, lnickname, bday, diff --git a/include/mod_vcard_xupdate.hrl b/include/mod_vcard_xupdate.hrl index 8634597aa..505797219 100644 --- a/include/mod_vcard_xupdate.hrl +++ b/include/mod_vcard_xupdate.hrl @@ -1,2 +1,22 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -record(vcard_xupdate, {us = {<<>>, <<>>} :: {binary(), binary()}, hash = <<>> :: binary()}). diff --git a/include/pubsub.hrl b/include/pubsub.hrl index a05807247..f20fa4b7b 100644 --- a/include/pubsub.hrl +++ b/include/pubsub.hrl @@ -1,27 +1,22 @@ -%%% ==================================================================== -%%% ``The contents of this file are subject to the Erlang Public License, -%%% Version 1.1, (the "License"); you may not use this file except in -%%% compliance with the License. You should have received a copy of the -%%% Erlang Public License along with this software. If not, it can be -%%% retrieved via the world wide web at http://www.erlang.org/. -%%% +%%%---------------------------------------------------------------------- %%% -%%% Software distributed under the License is distributed on an "AS IS" -%%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%%% the License for the specific language governing rights and limitations -%%% under the License. -%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% -%%% The Initial Developer of the Original Code is ProcessOne. -%%% Portions created by ProcessOne are Copyright 2006-2016, ProcessOne -%%% All Rights Reserved.'' -%%% This software is copyright 2006-2016, ProcessOne. +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. %%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. %%% -%%% copyright 2006-2016 ProcessOne +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. %%% -%%% This file contains pubsub types definition. -%%% ==================================================================== +%%%---------------------------------------------------------------------- -include("ejabberd.hrl"). @@ -176,3 +171,9 @@ creation ,% :: {erlang:timestamp(), jlib:ljid()}, payload % :: mod_pubsub:payload() }). + +-record(pubsub_orphan, +{ + nodeid ,% :: mod_pubsub:nodeIdx(), + items = [] % :: list() +}). @@ -3,7 +3,7 @@ defmodule Ejabberd.Mixfile do def project do [app: :ejabberd, - version: "16.11.0", + version: "17.01.0", description: description, elixir: "~> 1.3", elixirc_paths: ["lib"], @@ -34,7 +34,7 @@ defmodule Ejabberd.Mixfile do defp erlc_options do # Use our own includes + includes from all dependencies - includes = ["include"] ++ Path.wildcard("deps/*/include") + includes = ["include"] ++ deps_include(["fast_xml", "xmpp"]) [:debug_info, {:d, :ELIXIR_ENABLED}] ++ Enum.map(includes, fn(path) -> {:i, path} end) end @@ -51,14 +51,15 @@ defmodule Ejabberd.Mixfile do {:esip, "~> 1.0"}, {:jiffy, "~> 0.14.7"}, {:p1_oauth2, "~> 0.6.1"}, - {:exrm, "~> 1.0.0", only: :dev}, - # relx is used by exrm. Lock version as for now, ejabberd doesn not compile fine with - # version 3.20: - {:relx, "~> 3.21", only: :dev}, + {:distillery, "~> 1.0"}, {:ex_doc, ">= 0.0.0", only: :dev}] ++ cond_deps end + defp deps_include(deps) do + Enum.map(deps, fn dep -> "deps/#{dep}/include" end) + end + defp cond_deps do for {:true, dep} <- [{config(:mysql), {:p1_mysql, "~> 1.0"}}, {config(:pgsql), {:p1_pgsql, "~> 1.1"}}, @@ -1,16 +1,12 @@ -%{"bbmustache": {:hex, :bbmustache, "1.0.4", "7ba94f971c5afd7b6617918a4bb74705e36cab36eb84b19b6a1b7ee06427aa38", [:rebar], []}, - "cache_tab": {:hex, :cache_tab, "1.0.5", "022da45aa10c2ccfdc804e69af36e3be1717c7579f3578767a29bd8ceb3b3c92", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, - "cf": {:hex, :cf, "0.2.2", "7f2913fff90abcabd0f489896cfeb0b0674f6c8df6c10b17a83175448029896c", [:rebar3], []}, +%{"cache_tab": {:hex, :cache_tab, "1.0.5", "022da45aa10c2ccfdc804e69af36e3be1717c7579f3578767a29bd8ceb3b3c92", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, + "distillery": {:hex, :distillery, "1.0.0", "a866a72bf2a3a5f078f5a249017ed951acda88a760d200512f91f585d74db1ec", [:mix], []}, "earmark": {:hex, :earmark, "1.0.3", "89bdbaf2aca8bbb5c97d8b3b55c5dd0cff517ecc78d417e87f1d0982e514557b", [:mix], []}, - "erlware_commons": {:hex, :erlware_commons, "0.22.0", "051bed79a34e66678c1cbeebc7b66360c827d081a0c5e2528878011e31ddcdca", [:rebar3], [{:cf, "0.2.2", [hex: :cf, optional: false]}]}, "esip": {:hex, :esip, "1.0.9", "256259792c07d2f888d56e89031b0d064ff795c395fdca11ee3aab912c56d9de", [:rebar3], [{:fast_tls, "1.0.8", [hex: :fast_tls, optional: false]}, {:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}, {:stun, "1.0.8", [hex: :stun, optional: false]}]}, - "ex_doc": {:hex, :ex_doc, "0.14.4", "a0a79a6896075814f4bc6802b74ccbed6549f47cc5ab34c71eaee2303170b8ef", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]}, - "exrm": {:hex, :exrm, "1.0.8", "5aa8990cdfe300282828b02cefdc339e235f7916388ce99f9a1f926a9271a45d", [:mix], [{:relx, "~> 3.5", [hex: :relx, optional: false]}]}, + "ex_doc": {:hex, :ex_doc, "0.14.5", "c0433c8117e948404d93ca69411dd575ec6be39b47802e81ca8d91017a0cf83c", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]}, "ezlib": {:hex, :ezlib, "1.0.1", "add8b2770a1a70c174aaea082b4a8668c0c7fdb03ee6cc81c6c68d3a6c3d767d", [:rebar3], []}, "fast_tls": {:hex, :fast_tls, "1.0.8", "697dc84ab958aed36924d8d9df9a463103ddc92f53283bbd930c9015f05ecf0a", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, "fast_xml": {:hex, :fast_xml, "1.1.18", "5cad4f35fa50070d38ef7cbb64975c6a8750e92b976f49e5bb88819f47451e69", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, "fast_yaml": {:hex, :fast_yaml, "1.0.7", "c1fc7995c8422bb4dc2a3502f6432054d6c16fde86f259f50080bb1d09fc5e50", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, - "getopt": {:hex, :getopt, "0.8.2", "b17556db683000ba50370b16c0619df1337e7af7ecbf7d64fbf8d1d6bce3109b", [:rebar], []}, "goldrush": {:hex, :goldrush, "0.1.8", "2024ba375ceea47e27ea70e14d2c483b2d8610101b4e852ef7f89163cdb6e649", [:rebar3], []}, "iconv": {:hex, :iconv, "1.0.3", "f5c159f7e0ad2a3b55c6b5528ce71d7926f206df2f9bf83201a77cf1bc91c6f0", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, "jiffy": {:hex, :jiffy, "0.14.7", "9f33b893edd6041ceae03bc1e50b412e858cc80b46f3d7535a7a9940a79a1c37", [:make, :rebar], []}, @@ -18,8 +14,6 @@ "p1_mysql": {:hex, :p1_mysql, "1.0.1", "d2be1cfc71bb4f1391090b62b74c3f5cb8e7a45b0076b8cb290cd6b2856c581b", [:rebar3], []}, "p1_oauth2": {:hex, :p1_oauth2, "0.6.1", "4e021250cc198c538b097393671a41e7cebf463c248980320e038fe0316eb56b", [:rebar3], []}, "p1_utils": {:hex, :p1_utils, "1.0.6", "ef0951ddf38e92b7e479af4b8dc950df76af8c1030432ef68b7fd7ad17c436fe", [:rebar3], []}, - "providers": {:hex, :providers, "1.6.0", "db0e2f9043ae60c0155205fcd238d68516331d0e5146155e33d1e79dc452964a", [:rebar3], [{:getopt, "0.8.2", [hex: :getopt, optional: false]}]}, - "relx": {:hex, :relx, "3.22.0", "ff7e2b5924b754a63ba1a46ba8c1901a2d6ae1418982e189cfed5937dace18da", [:rebar3], [{:bbmustache, "1.0.4", [hex: :bbmustache, optional: false]}, {:cf, "0.2.2", [hex: :cf, optional: false]}, {:erlware_commons, "0.22.0", [hex: :erlware_commons, optional: false]}, {:getopt, "0.8.2", [hex: :getopt, optional: false]}, {:providers, "1.6.0", [hex: :providers, optional: false]}]}, "stringprep": {:hex, :stringprep, "1.0.7", "f709c7ee3697ae9d2becbbbba1dcea47e0f583e313b4eb7d0ced2163c595ee12", [:rebar3], [{:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, "stun": {:hex, :stun, "1.0.8", "cfe6df914b12227ca0920e5e3d5b1203331c6662d0948859357c84d2c87a0411", [:rebar3], [{:fast_tls, "1.0.8", [hex: :fast_tls, optional: false]}, {:p1_utils, "1.0.6", [hex: :p1_utils, optional: false]}]}, - "xmpp": {:hex, :xmpp, "1.1.3", "c55fbc629243caa5947c26c2e8eaab0584cecc3ece0a13d7723dc283ecd3aa78", [:rebar3], [{:fast_xml, "1.1.18", [hex: :fast_xml, optional: false]}, {:stringprep, "1.0.7", [hex: :stringprep, optional: false]}]}} + "xmpp": {:hex, :xmpp, "1.1.4", "fa9c890a779c57699d870e2e0966e4b6a66e92de19d0263a54df26f1be6ae046", [:rebar3], [{:fast_xml, "1.1.18", [hex: :fast_xml, optional: false]}, {:stringprep, "1.0.7", [hex: :stringprep, optional: false]}]}} diff --git a/rebar.config b/rebar.config index 85d8c1059..cc04c86d0 100644 --- a/rebar.config +++ b/rebar.config @@ -1,35 +1,46 @@ -%------------------------------------------------------------------- -%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2013-2016, Evgeniy Khramtsov -%%% @doc +%%%---------------------------------------------------------------------- %%% -%%% @end -%%% Created : 1 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- {deps, [{lager, ".*", {git, "https://github.com/basho/lager", {tag, "3.2.1"}}}, {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.6"}}}, - {cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.5"}}}, - {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.8"}}}, + {cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.6"}}}, + {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.10"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.7"}}}, - {fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.18"}}}, - {xmpp, ".*", {git, "https://github.com/processone/xmpp", "47d6e8b071c52e0fc07a02fd0bfbc3deae290abd"}}, - {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.8"}}}, - {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.9"}}}, - {fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.7"}}}, + {fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.19"}}}, + {xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "1.1.6"}}}, + {stun, ".*", {git, "https://github.com/processone/stun", {tag, "1.0.9"}}}, + {esip, ".*", {git, "https://github.com/processone/esip", {tag, "1.0.10"}}}, + {fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.8"}}}, {jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}}, {p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.1"}}}, {luerl, ".*", {git, "https://github.com/rvirding/luerl", {tag, "v0.2"}}}, {if_var_true, mysql, {p1_mysql, ".*", {git, "https://github.com/processone/p1_mysql", {tag, "1.0.2"}}}}, {if_var_true, pgsql, {p1_pgsql, ".*", {git, "https://github.com/processone/p1_pgsql", - {tag, "1.1.1"}}}}, + {tag, "1.1.2"}}}}, {if_var_true, sqlite, {sqlite3, ".*", {git, "https://github.com/processone/erlang-sqlite3", {tag, "1.1.5"}}}}, {if_var_true, pam, {p1_pam, ".*", {git, "https://github.com/processone/epam", {tag, "1.0.0"}}}}, {if_var_true, zlib, {ezlib, ".*", {git, "https://github.com/processone/ezlib", - {tag, "1.0.1"}}}}, + {tag, "1.0.2"}}}}, {if_var_true, riak, {riakc, ".*", {git, "https://github.com/basho/riak-erlang-client", {tag, "2.4.1"}}}}, %% Elixir support, needed to run tests diff --git a/rebar.config.script b/rebar.config.script index 34e0c328e..1576a1777 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -1,11 +1,22 @@ -%%%------------------------------------------------------------------- -%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2013-2016, Evgeniy Khramtsov -%%% @doc +%%%---------------------------------------------------------------------- %%% -%%% @end -%%% Created : 1 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) -> {OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of diff --git a/rel/reltool.config.script b/rel/reltool.config.script index d84c202a3..2a8566d54 100644 --- a/rel/reltool.config.script +++ b/rel/reltool.config.script @@ -1,6 +1,6 @@ %%%------------------------------------------------------------------- %%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2013-2016, Evgeniy Khramtsov +%%% @copyright (C) 2013-2017, Evgeniy Khramtsov %%% @doc %%% %%% @end diff --git a/sql/lite.sql b/sql/lite.sql index aacea11e7..81579e079 100644 --- a/sql/lite.sql +++ b/sql/lite.sql @@ -1,5 +1,5 @@ -- --- ejabberd, Copyright (C) 2002-2016 ProcessOne +-- ejabberd, Copyright (C) 2002-2017 ProcessOne -- -- This program is free software; you can redistribute it and/or -- modify it under the terms of the GNU General Public License as diff --git a/sql/mssql.sql b/sql/mssql.sql index 0dfaa7161..7925fd92d 100644 --- a/sql/mssql.sql +++ b/sql/mssql.sql @@ -1,5 +1,5 @@ --
--- ejabberd, Copyright (C) 2002-2015 ProcessOne
+-- ejabberd, Copyright (C) 2002-2017 ProcessOne
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
diff --git a/sql/mysql.sql b/sql/mysql.sql index 3d253c574..84901ffd5 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -1,5 +1,5 @@ -- --- ejabberd, Copyright (C) 2002-2016 ProcessOne +-- ejabberd, Copyright (C) 2002-2017 ProcessOne -- -- This program is free software; you can redistribute it and/or -- modify it under the terms of the GNU General Public License as diff --git a/sql/pg.sql b/sql/pg.sql index 3d7de4285..9fba94b30 100644 --- a/sql/pg.sql +++ b/sql/pg.sql @@ -1,5 +1,5 @@ -- --- ejabberd, Copyright (C) 2002-2016 ProcessOne +-- ejabberd, Copyright (C) 2002-2017 ProcessOne -- -- This program is free software; you can redistribute it and/or -- modify it under the terms of the GNU General Public License as @@ -10,7 +10,7 @@ -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- General Public License for more details. --- +-- -- You should have received a copy of the GNU General Public License along -- with this program; if not, write to the Free Software Foundation, Inc., -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. diff --git a/src/acl.erl b/src/acl.erl index e00aaa5d3..ee2d8ecfa 100644 --- a/src/acl.erl +++ b/src/acl.erl @@ -5,7 +5,7 @@ %%% Created : 18 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/cyrsasl.erl b/src/cyrsasl.erl index 5c7eb7edb..014df7e80 100644 --- a/src/cyrsasl.erl +++ b/src/cyrsasl.erl @@ -5,7 +5,7 @@ %%% Created : 8 Mar 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -111,8 +111,8 @@ format_error(Mech, Reason) -> PasswordType :: password_type()) -> any(). register_mechanism(Mechanism, Module, PasswordType) -> - ets:insert(sasl_mechanism, - #sasl_mechanism{mechanism = Mechanism, module = Module, + ets:insert(sasl_mechanism, + #sasl_mechanism{mechanism = Mechanism, module = Module, password_type = PasswordType}). check_credentials(_State, Props) -> @@ -127,17 +127,17 @@ check_credentials(_State, Props) -> listmech(Host) -> ets:select(sasl_mechanism, - [{#sasl_mechanism{mechanism = '$1', - password_type = '$2', _ = '_'}, - case catch ejabberd_auth:store_type(Host) of - external -> [{'==', '$2', plain}]; - scram -> [{'/=', '$2', digest}]; - {'EXIT', {undef, [{Module, store_type, []} | _]}} -> - ?WARNING_MSG("~p doesn't implement the function store_type/0", - [Module]), - []; - _Else -> [] - end, + [{#sasl_mechanism{mechanism = '$1', + password_type = '$2', _ = '_'}, + case catch ejabberd_auth:store_type(Host) of + external -> [{'==', '$2', plain}]; + scram -> [{'/=', '$2', digest}]; + {'EXIT', {undef, [{Module, store_type, []} | _]}} -> + ?WARNING_MSG("~p doesn't implement the function store_type/0", + [Module]), + []; + _Else -> [] + end, ['$1']}]). -spec server_new(binary(), binary(), binary(), term(), diff --git a/src/cyrsasl_anonymous.erl b/src/cyrsasl_anonymous.erl index cad9cdf93..75ae9bd8f 100644 --- a/src/cyrsasl_anonymous.erl +++ b/src/cyrsasl_anonymous.erl @@ -6,7 +6,7 @@ %%% Created : 23 Aug 2005 by Magnus Henoch <henoch@dtek.chalmers.se> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/cyrsasl_digest.erl b/src/cyrsasl_digest.erl index 39055f2b1..fa5c5338b 100644 --- a/src/cyrsasl_digest.erl +++ b/src/cyrsasl_digest.erl @@ -5,7 +5,7 @@ %%% Created : 11 Mar 2003 by Alexey Shchepin <alexey@sevcom.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/cyrsasl_oauth.erl b/src/cyrsasl_oauth.erl index be7e9a68d..d53b791e9 100644 --- a/src/cyrsasl_oauth.erl +++ b/src/cyrsasl_oauth.erl @@ -5,7 +5,7 @@ %%% Created : 17 Sep 2015 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/cyrsasl_plain.erl b/src/cyrsasl_plain.erl index bbac8deff..0424065eb 100644 --- a/src/cyrsasl_plain.erl +++ b/src/cyrsasl_plain.erl @@ -5,7 +5,7 @@ %%% Created : 8 Mar 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/cyrsasl_scram.erl b/src/cyrsasl_scram.erl index 55e06fd25..2b32c322e 100644 --- a/src/cyrsasl_scram.erl +++ b/src/cyrsasl_scram.erl @@ -5,7 +5,7 @@ %%% Created : 7 Aug 2011 by Stephen Röttger <stephen.roettger@googlemail.com> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd.erl b/src/ejabberd.erl index 5a6fc64d7..4edab98f1 100644 --- a/src/ejabberd.erl +++ b/src/ejabberd.erl @@ -5,7 +5,7 @@ %%% Created : 16 Nov 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_access_permissions.erl b/src/ejabberd_access_permissions.erl index 60ad68a29..83defb13e 100644 --- a/src/ejabberd_access_permissions.erl +++ b/src/ejabberd_access_permissions.erl @@ -5,7 +5,7 @@ %%% Created : 7 Sep 2016 by Paweł Chmielowski <pawel@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -237,7 +237,8 @@ get_definitions(#state{definitions = Defs, fragments_generators = Gens} = State) {all, none}}}, {<<"admin access">>, {[], - [{acl, admin}], + [{acl,{acl,admin}}, + {oauth,[<<"ejabberd:admin">>],[{acl,{acl,admin}}]}], {all, [start, stop]}}}], NDefs = case Defs of none -> @@ -266,7 +267,7 @@ matches_definition({_Name, {From, Who, What}}, Cmd, Module, Host, CallerInfo) -> lists:any( fun({access, Access}) when Scope == none -> acl:access_matches(Access, CallerInfo, Host) == allow; - ({acl, _} = Acl) when Scope == none -> + ({acl, Acl}) when Scope == none -> acl:acl_rule_matches(Acl, CallerInfo, Host); ({oauth, Scopes, List}) when Scope /= none -> case ejabberd_oauth:scope_in_scope_list(Scope, Scopes) of @@ -274,7 +275,7 @@ matches_definition({_Name, {From, Who, What}}, Cmd, Module, Host, CallerInfo) -> lists:any( fun({access, Access}) -> acl:access_matches(Access, CallerInfo, Host) == allow; - ({acl, _} = Acl) -> + ({acl, Acl} = Acl) -> acl:acl_rule_matches(Acl, CallerInfo, Host) end, List); _ -> @@ -331,7 +332,8 @@ command_matches_patterns(C, [_ | Tail]) -> parse_api_permissions(Data) when is_list(Data) -> throw({replace_with, [parse_api_permission(Name, Args) || {Name, Args} <- Data]}). -parse_api_permission(Name, Args) -> +parse_api_permission(Name, Args0) -> + Args = lists:flatten(Args0), {From, Who, What} = case key_split(Args, [{from, []}, {who, none}, {what, []}]) of {error, Msg} -> report_error(<<"~s inside api_permission '~s' section">>, [Msg, Name]); @@ -406,7 +408,7 @@ parse_who(Name, Defs, ParseOauth) when is_list(Defs) -> {scope, ScopeList2} end; (Atom) when is_atom(Atom) -> - {acl, Atom}; + {acl, {acl, Atom}}; ([Other]) -> try acl:normalize_spec(Other) of Rule2 -> diff --git a/src/ejabberd_admin.erl b/src/ejabberd_admin.erl index cf89439b2..67778e71c 100644 --- a/src/ejabberd_admin.erl +++ b/src/ejabberd_admin.erl @@ -5,7 +5,7 @@ %%% Created : 7 May 2006 by Mickael Remond <mremond@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -76,6 +76,9 @@ get_commands_spec() -> #ejabberd_commands{name = status, tags = [server], desc = "Get status of the ejabberd server", module = ?MODULE, function = status, + result_desc = "Result tuple", + result_example = {ok, <<"The node ejabberd@localhost is started with status: started" + "ejabberd X.X is running in that node">>}, args = [], result = {res, restuple}}, #ejabberd_commands{name = stop, tags = [server], desc = "Stop ejabberd gracefully", @@ -101,11 +104,15 @@ get_commands_spec() -> "ejabberdctl stop_kindly 60 " "\\\"The server will stop in one minute.\\\"", module = ?MODULE, function = stop_kindly, + args_desc = ["Seconds to wait", "Announcement to send, with quotes"], + args_example = [60, <<"Server will stop now.">>], args = [{delay, integer}, {announcement, string}], result = {res, rescode}}, #ejabberd_commands{name = get_loglevel, tags = [logs, server], desc = "Get the current loglevel", module = ejabberd_logger, function = get, + result_desc = "Tuple with the log level number, its keyword and description", + result_example = {4, <<"info">>, <<"Info">>}, args = [], result = {leveltuple, {tuple, [{levelnumber, integer}, {levelatom, atom}, @@ -114,6 +121,10 @@ get_commands_spec() -> #ejabberd_commands{name = set_loglevel, tags = [logs, server], desc = "Set the loglevel (0 to 5)", module = ?MODULE, function = set_loglevel, + args_desc = ["Integer of the desired logging level, between 1 and 5"], + args_example = [5], + result_desc = "The type of logger module used", + result_example = lager, args = [{loglevel, integer}], result = {logger, atom}}, @@ -121,10 +132,12 @@ get_commands_spec() -> desc = "List modified modules that can be updated", module = ?MODULE, function = update_list, args = [], + result_example = ["mod_configure", "mod_vcard"], result = {modules, {list, {module, string}}}}, #ejabberd_commands{name = update, tags = [server], desc = "Update the given module, or use the keyword: all", module = ?MODULE, function = update, + args_example = ["mod_vcard"], args = [{module, string}], result = {res, restuple}}, @@ -132,22 +145,32 @@ get_commands_spec() -> desc = "Register a user", policy = admin, module = ?MODULE, function = register, + args_desc = ["Username", "Local vhost served by ejabberd", "Password"], + args_example = [<<"bob">>, <<"example.com">>, <<"SomEPass44">>], args = [{user, binary}, {host, binary}, {password, binary}], result = {res, restuple}}, #ejabberd_commands{name = unregister, tags = [accounts], desc = "Unregister a user", policy = admin, module = ?MODULE, function = unregister, + args_desc = ["Username", "Local vhost served by ejabberd"], + args_example = [<<"bob">>, <<"example.com">>], args = [{user, binary}, {host, binary}], result = {res, restuple}}, #ejabberd_commands{name = registered_users, tags = [accounts], desc = "List all registered users in HOST", module = ?MODULE, function = registered_users, + args_desc = ["Local vhost"], + args_example = [<<"example.com">>], + result_desc = "List of registered accounts usernames", + result_example = [<<"user1">>, <<"user2">>], args = [{host, binary}], result = {users, {list, {username, string}}}}, #ejabberd_commands{name = registered_vhosts, tags = [server], desc = "List all registered vhosts in SERVER", module = ?MODULE, function = registered_vhosts, + result_desc = "List of available vhosts", + result_example = [<<"example.com">>, <<"anon.example.com">>], args = [], result = {vhosts, {list, {vhost, string}}}}, #ejabberd_commands{name = reload_config, tags = [server], @@ -159,59 +182,85 @@ get_commands_spec() -> #ejabberd_commands{name = join_cluster, tags = [cluster], desc = "Join this node into the cluster handled by Node", module = ?MODULE, function = join_cluster, + args_desc = ["Nodename of the node to join"], + args_example = [<<"ejabberd1@machine7">>], args = [{node, binary}], result = {res, rescode}}, #ejabberd_commands{name = leave_cluster, tags = [cluster], - desc = "Remove node handled by Node from the cluster", + desc = "Remove and shutdown Node from the running cluster", + longdesc = "This command can be run from any running node of the cluster, " + "even the node to be removed.", module = ?MODULE, function = leave_cluster, + args_desc = ["Nodename of the node to kick from the cluster"], + args_example = [<<"ejabberd1@machine8">>], args = [{node, binary}], result = {res, rescode}}, + #ejabberd_commands{name = list_cluster, tags = [cluster], desc = "List nodes that are part of the cluster handled by Node", module = ?MODULE, function = list_cluster, + result_example = [ejabberd1@machine7, ejabberd1@machine8], args = [], result = {nodes, {list, {node, atom}}}}, #ejabberd_commands{name = import_file, tags = [mnesia], desc = "Import user data from jabberd14 spool file", module = ?MODULE, function = import_file, + args_desc = ["Full path to the jabberd14 spool file"], + args_example = ["/var/lib/ejabberd/jabberd14.spool"], args = [{file, string}], result = {res, restuple}}, #ejabberd_commands{name = import_dir, tags = [mnesia], desc = "Import users data from jabberd14 spool dir", module = ?MODULE, function = import_dir, + args_desc = ["Full path to the jabberd14 spool directory"], + args_example = ["/var/lib/ejabberd/jabberd14/"], args = [{file, string}], result = {res, restuple}}, #ejabberd_commands{name = import_piefxis, tags = [mnesia], desc = "Import users data from a PIEFXIS file (XEP-0227)", module = ejabberd_piefxis, function = import_file, + args_desc = ["Full path to the PIEFXIS file"], + args_example = ["/var/lib/ejabberd/example.com.xml"], args = [{file, string}], result = {res, rescode}}, #ejabberd_commands{name = export_piefxis, tags = [mnesia], desc = "Export data of all users in the server to PIEFXIS files (XEP-0227)", module = ejabberd_piefxis, function = export_server, + args_desc = ["Full path to a directory"], + args_example = ["/var/lib/ejabberd/"], args = [{dir, string}], result = {res, rescode}}, #ejabberd_commands{name = export_piefxis_host, tags = [mnesia], desc = "Export data of users in a host to PIEFXIS files (XEP-0227)", module = ejabberd_piefxis, function = export_host, + args_desc = ["Full path to a directory", "Vhost to export"], + args_example = ["/var/lib/ejabberd/", "example.com"], args = [{dir, string}, {host, string}], result = {res, rescode}}, #ejabberd_commands{name = delete_mnesia, tags = [mnesia, sql], - desc = "Export all tables as SQL queries to a file", + desc = "Delete elements in Mnesia database for a given vhost", module = ejd2sql, function = delete, + args_desc = ["Vhost which content will be deleted in Mnesia database"], + args_example = ["example.com"], args = [{host, string}], result = {res, rescode}}, #ejabberd_commands{name = convert_to_scram, tags = [sql], desc = "Convert the passwords in 'users' ODBC table to SCRAM", module = ejabberd_auth_sql, function = convert_to_scram, + args_desc = ["Vhost which users' passwords will be scrammed"], + args_example = ["example.com"], args = [{host, binary}], result = {res, rescode}}, #ejabberd_commands{name = import_prosody, tags = [mnesia, sql, riak], desc = "Import data from Prosody", module = prosody2ejabberd, function = from_dir, + args_desc = ["Full path to the Prosody data directory"], + args_example = ["/var/lib/prosody/datadump/"], args = [{dir, string}], result = {res, rescode}}, #ejabberd_commands{name = convert_to_yaml, tags = [config], desc = "Convert the input file from Erlang to YAML format", module = ejabberd_config, function = convert_to_yaml, + args_desc = ["Full path to the original configuration file", "And full path to final file"], + args_example = ["/etc/ejabberd/ejabberd.cfg", "/etc/ejabberd/ejabberd.yml"], args = [{in, string}, {out, string}], result = {res, rescode}}, @@ -222,11 +271,15 @@ get_commands_spec() -> #ejabberd_commands{name = delete_old_messages, tags = [purge], desc = "Delete offline messages older than DAYS", module = ?MODULE, function = delete_old_messages, + args_desc = ["Number of days"], + args_example = [31], args = [{days, integer}], result = {res, rescode}}, #ejabberd_commands{name = export2sql, tags = [mnesia], - desc = "Export virtual host information from Mnesia tables to SQL files", + desc = "Export virtual host information from Mnesia tables to SQL file", module = ejd2sql, function = export, + args_desc = ["Vhost", "Full path to the destination SQL file"], + args_example = ["example.com", "/var/lib/ejabberd/example.com.sql"], args = [{host, string}, {file, string}], result = {res, rescode}}, #ejabberd_commands{name = set_master, tags = [mnesia], @@ -234,36 +287,54 @@ get_commands_spec() -> longdesc = "If you provide as nodename \"self\", this " "node will be set as its own master.", module = ?MODULE, function = set_master, + args_desc = ["Name of the erlang node that will be considered master of this node"], + args_example = ["ejabberd@machine7"], args = [{nodename, string}], result = {res, restuple}}, #ejabberd_commands{name = mnesia_change_nodename, tags = [mnesia], desc = "Change the erlang node name in a backup file", module = ?MODULE, function = mnesia_change_nodename, + args_desc = ["Name of the old erlang node", "Name of the new node", + "Path to old backup file", "Path to the new backup file"], + args_example = ["ejabberd@machine1", "ejabberd@machine2", + "/var/lib/ejabberd/old.backup", "/var/lib/ejabberd/new.backup"], args = [{oldnodename, string}, {newnodename, string}, {oldbackup, string}, {newbackup, string}], result = {res, restuple}}, #ejabberd_commands{name = backup, tags = [mnesia], desc = "Store the database to backup file", module = ?MODULE, function = backup_mnesia, + args_desc = ["Full path for the destination backup file"], + args_example = ["/var/lib/ejabberd/database.backup"], args = [{file, string}], result = {res, restuple}}, #ejabberd_commands{name = restore, tags = [mnesia], desc = "Restore the database from backup file", module = ?MODULE, function = restore_mnesia, + args_desc = ["Full path to the backup file"], + args_example = ["/var/lib/ejabberd/database.backup"], args = [{file, string}], result = {res, restuple}}, #ejabberd_commands{name = dump, tags = [mnesia], - desc = "Dump the database to text file", + desc = "Dump the database to a text file", module = ?MODULE, function = dump_mnesia, + args_desc = ["Full path for the text file"], + args_example = ["/var/lib/ejabberd/database.txt"], args = [{file, string}], result = {res, restuple}}, #ejabberd_commands{name = dump_table, tags = [mnesia], - desc = "Dump a table to text file", + desc = "Dump a table to a text file", module = ?MODULE, function = dump_table, + args_desc = ["Full path for the text file", "Table name"], + args_example = ["/var/lib/ejabberd/table-muc-registered.txt", "muc_registered"], args = [{file, string}, {table, string}], result = {res, restuple}}, #ejabberd_commands{name = load, tags = [mnesia], - desc = "Restore the database from text file", + desc = "Restore the database from a text file", module = ?MODULE, function = load_mnesia, + args_desc = ["Full path to the text file"], + args_example = ["/var/lib/ejabberd/database.txt"], args = [{file, string}], result = {res, restuple}}, #ejabberd_commands{name = install_fallback, tags = [mnesia], desc = "Install the database from a fallback file", module = ?MODULE, function = install_fallback_mnesia, + args_desc = ["Full path to the fallback file"], + args_example = ["/var/lib/ejabberd/database.fallback"], args = [{file, string}], result = {res, restuple}} ]. diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index e866d1db4..493600afc 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -5,7 +5,7 @@ %%% Created : 31 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_auth.erl b/src/ejabberd_auth.erl index 17bc729cc..b77e574d7 100644 --- a/src/ejabberd_auth.erl +++ b/src/ejabberd_auth.erl @@ -5,7 +5,7 @@ %%% Created : 23 Nov 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_auth_anonymous.erl b/src/ejabberd_auth_anonymous.erl index d8947033a..59d4c99e7 100644 --- a/src/ejabberd_auth_anonymous.erl +++ b/src/ejabberd_auth_anonymous.erl @@ -5,7 +5,7 @@ %%% Created : 17 Feb 2006 by Mickael Remond <mremond@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_auth_external.erl b/src/ejabberd_auth_external.erl index bba65af1c..b1ec7a9bd 100644 --- a/src/ejabberd_auth_external.erl +++ b/src/ejabberd_auth_external.erl @@ -5,7 +5,7 @@ %%% Created : 12 Dec 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_auth_ldap.erl b/src/ejabberd_auth_ldap.erl index 3cb04b596..d88300423 100644 --- a/src/ejabberd_auth_ldap.erl +++ b/src/ejabberd_auth_ldap.erl @@ -5,7 +5,7 @@ %%% Created : 12 Dec 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_auth_mnesia.erl b/src/ejabberd_auth_mnesia.erl index eac19f024..1c565d485 100644 --- a/src/ejabberd_auth_mnesia.erl +++ b/src/ejabberd_auth_mnesia.erl @@ -5,7 +5,7 @@ %%% Created : 12 Dec 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_auth_pam.erl b/src/ejabberd_auth_pam.erl index fa4b9f078..603c8cd89 100644 --- a/src/ejabberd_auth_pam.erl +++ b/src/ejabberd_auth_pam.erl @@ -5,7 +5,7 @@ %%% Created : 5 Jul 2007 by Evgeniy Khramtsov <xram@jabber.ru> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_auth_riak.erl b/src/ejabberd_auth_riak.erl index 51571c4e2..16468dea1 100644 --- a/src/ejabberd_auth_riak.erl +++ b/src/ejabberd_auth_riak.erl @@ -5,7 +5,7 @@ %%% Created : 12 Nov 2012 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_auth_sql.erl b/src/ejabberd_auth_sql.erl index 93dac4f4f..313e9faea 100644 --- a/src/ejabberd_auth_sql.erl +++ b/src/ejabberd_auth_sql.erl @@ -5,7 +5,7 @@ %%% Created : 12 Dec 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_bosh.erl b/src/ejabberd_bosh.erl index e032f1bbe..b38de2515 100644 --- a/src/ejabberd_bosh.erl +++ b/src/ejabberd_bosh.erl @@ -5,7 +5,7 @@ %%% Created : 20 Jul 2011 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_c2s_config.erl b/src/ejabberd_c2s_config.erl index 3384e3387..5db740777 100644 --- a/src/ejabberd_c2s_config.erl +++ b/src/ejabberd_c2s_config.erl @@ -6,7 +6,7 @@ %%% Created : 2 Nov 2007 by Mickael Remond <mremond@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index 85d7595a2..5ab6cf980 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -5,7 +5,7 @@ %%% Created : 26 Apr 2008 by Evgeniy Khramtsov <xramtsov@gmail.com> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_cluster.erl b/src/ejabberd_cluster.erl index 5826d6d31..a331a0084 100644 --- a/src/ejabberd_cluster.erl +++ b/src/ejabberd_cluster.erl @@ -5,7 +5,7 @@ %%% Created : 7 Oct 2015 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -27,7 +27,7 @@ %% API -export([get_nodes/0, call/4, multicall/3, multicall/4]). --export([join/1, leave/1]). +-export([join/1, leave/1, get_known_nodes/0]). -export([node_id/0, get_node_by_id/1]). -include("ejabberd.hrl"). @@ -38,6 +38,12 @@ get_nodes() -> mnesia:system_info(running_db_nodes). +-spec get_known_nodes() -> [node()]. + +get_known_nodes() -> + lists:usort(mnesia:system_info(db_nodes) + ++ mnesia:system_info(extra_db_nodes)). + -spec call(node(), module(), atom(), [any()]) -> any(). call(Node, Module, Function, Args) -> diff --git a/src/ejabberd_commands.erl b/src/ejabberd_commands.erl index 223163a2b..4ba38a559 100644 --- a/src/ejabberd_commands.erl +++ b/src/ejabberd_commands.erl @@ -5,7 +5,7 @@ %%% Created : 20 May 2008 by Badlop <badlop@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_commands_doc.erl b/src/ejabberd_commands_doc.erl index bb519a600..f34449011 100644 --- a/src/ejabberd_commands_doc.erl +++ b/src/ejabberd_commands_doc.erl @@ -5,7 +5,7 @@ %%% Created : 20 May 2008 by Badlop <badlop@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index f9df31bf0..e15da3319 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -5,7 +5,7 @@ %%% Created : 14 Dec 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -858,8 +858,8 @@ get_option(Opt, F, Default) -> case Opt of {Key, Host} when Host /= global -> get_option({Key, global}, F, Default); - _ -> - Default + _ -> + Default end end. @@ -1056,8 +1056,10 @@ replace_module(mod_private_odbc) -> {mod_private, sql}; replace_module(mod_roster_odbc) -> {mod_roster, sql}; replace_module(mod_shared_roster_odbc) -> {mod_shared_roster, sql}; replace_module(mod_vcard_odbc) -> {mod_vcard, sql}; +replace_module(mod_vcard_ldap) -> {mod_vcard, ldap}; replace_module(mod_vcard_xupdate_odbc) -> {mod_vcard_xupdate, sql}; replace_module(mod_pubsub_odbc) -> {mod_pubsub, sql}; +replace_module(mod_http_bind) -> mod_bosh; replace_module(Module) -> case is_elixir_module(Module) of true -> expand_elixir_module(Module); diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index 63adcdf69..32789956c 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -5,7 +5,7 @@ %%% Created : 11 Jan 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_hooks.erl b/src/ejabberd_hooks.erl index f63d1d75c..9f782b235 100644 --- a/src/ejabberd_hooks.erl +++ b/src/ejabberd_hooks.erl @@ -5,7 +5,7 @@ %%% Created : 8 Aug 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -376,7 +376,7 @@ run_fold1([{_Seq, Module, Function} | Ls], Hook, Val, Args) -> safe_apply(Hook, Module, Function, Args) -> try if is_function(Function) -> apply(Function, Args); - true -> + true -> apply(Module, Function, Args) end catch E:R when E /= exit, R /= normal -> diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl index 1a33580ea..bd3291508 100644 --- a/src/ejabberd_http.erl +++ b/src/ejabberd_http.erl @@ -5,7 +5,7 @@ %%% Created : 27 Feb 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -135,7 +135,7 @@ init({SockMod, Socket}, Opts) -> false -> [] end, Bind = case proplists:get_bool(http_bind, Opts) of - true -> [{[<<"http-bind">>], mod_http_bind}]; + true -> [{[<<"http-bind">>], mod_bosh}]; false -> [] end, XMLRPC = case proplists:get_bool(xmlrpc, Opts) of @@ -150,9 +150,14 @@ init({SockMod, Socket}, Opts) -> ({Path, Mod}) -> {Path, Mod} end, Hs), - [{str:tokens( - iolist_to_binary(Path), <<"/">>), - Mod} || {Path, Mod} <- Hs1] + Hs2 = [{str:tokens( + iolist_to_binary(Path), <<"/">>), + Mod} || {Path, Mod} <- Hs1], + [{Path, + case Mod of + mod_http_bind -> mod_bosh; + _ -> Mod + end} || {Path, Mod} <- Hs2] end, []), RequestHandlers = DefinedHandlers ++ Captcha ++ Register ++ Admin ++ Bind ++ XMLRPC, diff --git a/src/ejabberd_http_bind.erl b/src/ejabberd_http_bind.erl deleted file mode 100644 index ea64b3cdf..000000000 --- a/src/ejabberd_http_bind.erl +++ /dev/null @@ -1,1211 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : ejabberd_http_bind.erl -%%% Author : Stefan Strigler <steve@zeank.in-berlin.de> -%%% Purpose : Implements XMPP over BOSH (XEP-0206) -%%% Created : 21 Sep 2005 by Stefan Strigler <steve@zeank.in-berlin.de> -%%% Modified: may 2009 by Mickael Remond, Alexey Schepin -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(ejabberd_http_bind). - --protocol({xep, 124, '1.11'}). --protocol({xep, 206, '1.4'}). - --behaviour(gen_fsm). - -%% External exports --export([start_link/4, - init/1, - handle_event/3, - handle_sync_event/4, - code_change/4, - handle_info/3, - terminate/3, - send/2, - send_xml/2, - sockname/1, - peername/1, - setopts/2, - controlling_process/2, - become_controller/2, - custom_receiver/1, - reset_stream/1, - change_shaper/2, - monitor/1, - close/1, - start/5, - handle_session_start/8, - handle_http_put/7, - http_put/7, - http_get/2, - prepare_response/4, - process_request/3]). - --include("ejabberd.hrl"). --include("logger.hrl"). - --include("xmpp.hrl"). - --include("ejabberd_http.hrl"). - --include("http_bind.hrl"). - --record(http_bind, - {id, pid, to, hold, wait, process_delay, version}). - --define(NULL_PEER, {{0, 0, 0, 0}, 0}). - -%% http binding request --record(hbr, {rid, - key, - out}). - --record(state, {id, - rid = none, - key, - socket, - output = "", - input = queue:new(), - waiting_input = false, - shaper_state, - shaper_timer, - last_receiver, - last_poll, - http_receiver, - out_of_order_receiver = false, - wait_timer, - ctime = 0, - timer, - pause = 0, - unprocessed_req_list = [], % list of request that have been delayed for proper reordering: {Request, PID} - req_list = [], % list of requests (cache) - max_inactivity, - max_pause, - ip = ?NULL_PEER - }). - -%% Internal request format: --record(http_put, {rid, - attrs, - payload, - payload_size, - hold, - stream, - ip}). - -%%-define(DBGFSM, true). --ifdef(DBGFSM). - --define(FSMOPTS, [{debug, [trace]}]). - --else. - --define(FSMOPTS, []). - --endif. - -%% Wait 100ms before continue processing, to allow the client provide more related stanzas. --define(BOSH_VERSION, <<"1.8">>). - --define(NS_BOSH, <<"urn:xmpp:xbosh">>). - --define(NS_HTTP_BIND, - <<"http://jabber.org/protocol/httpbind">>). - --define(MAX_REQUESTS, 2). - --define(MIN_POLLING, 2000000). - --define(MAX_WAIT, 3600). - --define(MAX_INACTIVITY, 30000). - --define(MAX_PAUSE, 120). - --define(PROCESS_DELAY_DEFAULT, 100). - --define(PROCESS_DELAY_MIN, 0). - --define(PROCESS_DELAY_MAX, 1000). - --define(PROCNAME_MHB, ejabberd_mod_http_bind). - -start(XMPPDomain, Sid, Key, IP, HOpts) -> - ?DEBUG("Starting session", []), - case catch gen_fsm:start(?MODULE, - [Sid, Key, IP, HOpts], - ?FSMOPTS) - of - {ok, Pid} -> {ok, Pid}; - _ -> check_bind_module(XMPPDomain), - {error, "Cannot start HTTP bind session"} - end. - -start_link(Sid, Key, IP, HOpts) -> - gen_fsm:start_link(?MODULE, [Sid, Key, IP, HOpts], ?FSMOPTS). - -send({http_bind, FsmRef, _IP}, Packet) -> - gen_fsm:sync_send_all_state_event(FsmRef, - {send, Packet}). - -send_xml({http_bind, FsmRef, _IP}, Packet) -> - gen_fsm:sync_send_all_state_event(FsmRef, - {send_xml, Packet}). - -setopts({http_bind, FsmRef, _IP}, Opts) -> - case lists:member({active, once}, Opts) of - true -> - gen_fsm:send_all_state_event(FsmRef, {activate, self()}); - _ -> - ok - end. - -controlling_process(_Socket, _Pid) -> ok. - -custom_receiver({http_bind, FsmRef, _IP}) -> - {receiver, ?MODULE, FsmRef}. - -become_controller(FsmRef, C2SPid) -> - gen_fsm:send_all_state_event(FsmRef, - {become_controller, C2SPid}). - -reset_stream({http_bind, _FsmRef, _IP}) -> - ok. - -change_shaper({http_bind, FsmRef, _IP}, Shaper) -> - gen_fsm:send_all_state_event(FsmRef, - {change_shaper, Shaper}). - -monitor({http_bind, FsmRef, _IP}) -> - erlang:monitor(process, FsmRef). - -close({http_bind, FsmRef, _IP}) -> - catch gen_fsm:sync_send_all_state_event(FsmRef, - {stop, close}). - -sockname(_Socket) -> {ok, ?NULL_PEER}. - -peername({http_bind, _FsmRef, IP}) -> {ok, IP}. - - -%% Entry point for data coming from client through ejabberd HTTP server: -process_request(Data, IP, HOpts) -> - Opts1 = ejabberd_c2s_config:get_c2s_limits(), - Opts = [{xml_socket, true} | Opts1], - MaxStanzaSize = case lists:keysearch(max_stanza_size, 1, - Opts) - of - {value, {_, Size}} -> Size; - _ -> infinity - end, - PayloadSize = iolist_size(Data), - case catch parse_request(Data, PayloadSize, - MaxStanzaSize) - of - %% No existing session: - {ok, {<<"">>, Rid, Attrs, Payload}} -> - case fxml:get_attr_s(<<"to">>, Attrs) of - <<"">> -> - ?DEBUG("Session not created (Improper addressing)", []), - {200, ?HEADER, - <<"<body type='terminate' condition='improper-ad" - "dressing' xmlns='", - (?NS_HTTP_BIND)/binary, "'/>">>}; - XmppDomain -> - NXmppDomain = jid:nameprep(XmppDomain), - Sid = p1_sha:sha(term_to_binary({p1_time_compat:monotonic_time(), make_ref()})), - case start(NXmppDomain, Sid, <<"">>, IP, HOpts) of - {error, _} -> - {500, ?HEADER, - <<"<body type='terminate' condition='internal-se" - "rver-error' xmlns='", - (?NS_HTTP_BIND)/binary, - "'>Internal Server Error</body>">>}; - {ok, Pid} -> - handle_session_start(Pid, NXmppDomain, Sid, Rid, Attrs, - Payload, PayloadSize, IP) - end - end; - %% Existing session - {ok, {Sid, Rid, Attrs, Payload1}} -> - StreamStart = case fxml:get_attr_s(<<"xmpp:restart">>, - Attrs) - of - <<"true">> -> true; - _ -> false - end, - Payload2 = case fxml:get_attr_s(<<"type">>, Attrs) of - <<"terminate">> -> - Payload1 ++ [{xmlstreamend, <<"stream:stream">>}]; - _ -> Payload1 - end, - handle_http_put(Sid, Rid, Attrs, Payload2, PayloadSize, - StreamStart, IP); - {size_limit, Sid} -> - case mnesia:dirty_read({http_bind, Sid}) of - {error, _} -> {404, ?HEADER, <<"">>}; - {ok, #http_bind{pid = FsmRef}} -> - gen_fsm:sync_send_all_state_event(FsmRef, - {stop, close}), - {200, ?HEADER, - <<"<body type='terminate' condition='undefined-c" - "ondition' xmlns='", - (?NS_HTTP_BIND)/binary, "'>Request Too Large</body>">>} - end; - _ -> - ?DEBUG("Received bad request: ~p", [Data]), - {400, ?HEADER, <<"">>} - end. - -handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs, - Payload, PayloadSize, IP) -> - ?DEBUG("got pid: ~p", [Pid]), - Wait = case str:to_integer(fxml:get_attr_s(<<"wait">>, - Attrs)) - of - {error, _} -> ?MAX_WAIT; - {CWait, _} -> - if CWait > (?MAX_WAIT) -> ?MAX_WAIT; - true -> CWait - end - end, - Hold = case str:to_integer(fxml:get_attr_s(<<"hold">>, - Attrs)) - of - {error, _} -> (?MAX_REQUESTS) - 1; - {CHold, _} -> - if CHold > (?MAX_REQUESTS) - 1 -> (?MAX_REQUESTS) - 1; - true -> CHold - end - end, - Pdelay = case - str:to_integer(fxml:get_attr_s(<<"process-delay">>, - Attrs)) - of - {error, _} -> ?PROCESS_DELAY_DEFAULT; - {CPdelay, _} - when ((?PROCESS_DELAY_MIN) =< CPdelay) and - (CPdelay =< (?PROCESS_DELAY_MAX)) -> - CPdelay; - {CPdelay, _} -> - lists:max([lists:min([CPdelay, ?PROCESS_DELAY_MAX]), - ?PROCESS_DELAY_MIN]) - end, - Version = case catch - list_to_float(binary_to_list(fxml:get_attr_s(<<"ver">>, Attrs))) - of - {'EXIT', _} -> 0.0; - V -> V - end, - XmppVersion = fxml:get_attr_s(<<"xmpp:version">>, Attrs), - ?DEBUG("Create session: ~p", [Sid]), - mnesia:dirty_write( - #http_bind{id = Sid, - pid = Pid, - to = {XmppDomain, - XmppVersion}, - hold = Hold, - wait = Wait, - process_delay = Pdelay, - version = Version - }), - handle_http_put(Sid, Rid, Attrs, Payload, PayloadSize, true, IP). - -%%%---------------------------------------------------------------------- -%%% Callback functions from gen_fsm -%%%---------------------------------------------------------------------- - -init([Sid, Key, IP, HOpts]) -> - ?DEBUG("started: ~p", [{Sid, Key, IP}]), - Opts1 = ejabberd_c2s_config:get_c2s_limits(), - SOpts = lists:filtermap(fun({stream_management, _}) -> true; - ({max_ack_queue, _}) -> true; - ({ack_timeout, _}) -> true; - ({resume_timeout, _}) -> true; - ({max_resume_timeout, _}) -> true; - ({resend_on_timeout, _}) -> true; - (_) -> false - end, HOpts), - - Opts = [{xml_socket, true} | SOpts ++ Opts1], - Shaper = none, - ShaperState = shaper:new(Shaper), - Socket = {http_bind, self(), IP}, - ejabberd_socket:start(ejabberd_c2s, ?MODULE, Socket, Opts), - Timer = erlang:start_timer(?MAX_INACTIVITY, self(), []), - {ok, loop, #state{id = Sid, - key = Key, - socket = Socket, - shaper_state = ShaperState, - max_inactivity = ?MAX_INACTIVITY, - max_pause = ?MAX_PAUSE, - timer = Timer}}. - -handle_event({become_controller, C2SPid}, StateName, StateData) -> - case StateData#state.input of - cancel -> - {next_state, StateName, - StateData#state{waiting_input = C2SPid}}; - Input -> - lists:foreach(fun (Event) -> C2SPid ! Event end, - queue:to_list(Input)), - {next_state, StateName, - StateData#state{input = queue:new(), - waiting_input = C2SPid}} - end; -handle_event({change_shaper, Shaper}, StateName, - StateData) -> - NewShaperState = shaper:new(Shaper), - {next_state, StateName, - StateData#state{shaper_state = NewShaperState}}; -handle_event(_Event, StateName, StateData) -> - {next_state, StateName, StateData}. - -handle_sync_event({send_xml, Packet}, _From, StateName, - #state{http_receiver = undefined} = StateData) -> - Output = [Packet | StateData#state.output], - Reply = ok, - {reply, Reply, StateName, - StateData#state{output = Output}}; -handle_sync_event({send_xml, Packet}, _From, StateName, - #state{out_of_order_receiver = true} = StateData) -> - Output = [Packet | StateData#state.output], - Reply = ok, - {reply, Reply, StateName, - StateData#state{output = Output}}; -handle_sync_event({send_xml, Packet}, _From, StateName, - StateData) -> - Output = [Packet | StateData#state.output], - cancel_timer(StateData#state.timer), - Timer = set_inactivity_timer(StateData#state.pause, - StateData#state.max_inactivity), - HTTPReply = {ok, Output}, - gen_fsm:reply(StateData#state.http_receiver, HTTPReply), - cancel_timer(StateData#state.wait_timer), - Rid = StateData#state.rid, - ReqList = [#hbr{rid = Rid, key = StateData#state.key, - out = Output} - | [El - || El <- StateData#state.req_list, El#hbr.rid /= Rid]], - Reply = ok, - {reply, Reply, StateName, - StateData#state{output = [], http_receiver = undefined, - req_list = ReqList, wait_timer = undefined, - timer = Timer}}; - -handle_sync_event({stop,close}, _From, _StateName, StateData) -> - Reply = ok, - {stop, normal, Reply, StateData}; -handle_sync_event({stop,stream_closed}, _From, _StateName, StateData) -> - Reply = ok, - {stop, normal, Reply, StateData}; -handle_sync_event({stop,Reason}, _From, _StateName, StateData) -> - ?DEBUG("Closing bind session ~p - Reason: ~p", [StateData#state.id, Reason]), - Reply = ok, - {stop, normal, Reply, StateData}; -%% HTTP PUT: Receive packets from the client -handle_sync_event(#http_put{rid = Rid}, _From, - StateName, StateData) - when StateData#state.shaper_timer /= undefined -> - Pause = case - erlang:read_timer(StateData#state.shaper_timer) - of - false -> 0; - P -> P - end, - Reply = {wait, Pause}, - ?DEBUG("Shaper timer for RID ~p: ~p", [Rid, Reply]), - {reply, Reply, StateName, StateData}; -handle_sync_event(#http_put{payload_size = - PayloadSize} = - Request, - _From, StateName, StateData) -> - ?DEBUG("New request: ~p", [Request]), - {NewShaperState, NewShaperTimer} = - update_shaper(StateData#state.shaper_state, - PayloadSize), - handle_http_put_event(Request, StateName, - StateData#state{shaper_state = NewShaperState, - shaper_timer = NewShaperTimer}); -%% HTTP GET: send packets to the client -handle_sync_event({http_get, Rid, Wait, Hold}, From, StateName, StateData) -> - TNow = p1_time_compat:system_time(micro_seconds), - if (Hold > 0) and - ((StateData#state.output == []) or (StateData#state.rid < Rid)) and - ((TNow - StateData#state.ctime) < (Wait*1000*1000)) and - (StateData#state.rid =< Rid) and - (StateData#state.pause == 0) -> - send_receiver_reply(StateData#state.http_receiver, {ok, empty}), - cancel_timer(StateData#state.wait_timer), - WaitTimer = erlang:start_timer(Wait * 1000, self(), []), - cancel_timer(StateData#state.timer), - {next_state, StateName, StateData#state{ - http_receiver = From, - out_of_order_receiver = StateData#state.rid < Rid, - wait_timer = WaitTimer, - timer = undefined}}; - true -> - cancel_timer(StateData#state.timer), - Reply = {ok, StateData#state.output}, - ReqList = [#hbr{rid = Rid, - key = StateData#state.key, - out = StateData#state.output} - | [El - || El <- StateData#state.req_list, - El#hbr.rid /= Rid]], - if (StateData#state.http_receiver /= undefined) and - StateData#state.out_of_order_receiver -> - {reply, Reply, StateName, - StateData#state{output = [], timer = undefined, - req_list = ReqList, - out_of_order_receiver = false}}; - true -> - send_receiver_reply(StateData#state.http_receiver, {ok, empty}), - cancel_timer(StateData#state.wait_timer), - Timer = set_inactivity_timer(StateData#state.pause, - StateData#state.max_inactivity), - {reply, Reply, StateName, - StateData#state{output = [], - http_receiver = undefined, - wait_timer = undefined, - timer = Timer, - req_list = ReqList}} - end - end; -handle_sync_event(peername, _From, StateName, - StateData) -> - Reply = {ok, StateData#state.ip}, - {reply, Reply, StateName, StateData}; -handle_sync_event(_Event, _From, StateName, - StateData) -> - Reply = ok, {reply, Reply, StateName, StateData}. - -code_change(_OldVsn, StateName, StateData, _Extra) -> - {ok, StateName, StateData}. - -handle_info({timeout, Timer, _}, _StateName, - #state{id = SID, timer = Timer} = StateData) -> - ?INFO_MSG("Session timeout. Closing the HTTP bind " - "session: ~p", - [SID]), - {stop, normal, StateData}; -handle_info({timeout, WaitTimer, _}, StateName, - #state{wait_timer = WaitTimer} = StateData) -> - if StateData#state.http_receiver /= undefined -> - cancel_timer(StateData#state.timer), - Timer = set_inactivity_timer(StateData#state.pause, - StateData#state.max_inactivity), - gen_fsm:reply(StateData#state.http_receiver, - {ok, empty}), - Rid = StateData#state.rid, - ReqList = [#hbr{rid = Rid, key = StateData#state.key, - out = []} - | [El - || El <- StateData#state.req_list, El#hbr.rid /= Rid]], - {next_state, StateName, - StateData#state{http_receiver = undefined, - req_list = ReqList, wait_timer = undefined, - timer = Timer}}; - true -> {next_state, StateName, StateData} - end; -handle_info({timeout, ShaperTimer, _}, StateName, - #state{shaper_timer = ShaperTimer} = StateData) -> - {next_state, StateName, StateData#state{shaper_timer = undefined}}; - -handle_info(_, StateName, StateData) -> - {next_state, StateName, StateData}. - -terminate(_Reason, _StateName, StateData) -> - ?DEBUG("terminate: Deleting session ~s", - [StateData#state.id]), - mnesia:dirty_delete({http_bind, StateData#state.id}), - send_receiver_reply(StateData#state.http_receiver, - {ok, terminate}), - case StateData#state.waiting_input of - false -> ok; - C2SPid -> gen_fsm:send_event(C2SPid, closed) - end, - ok. - -%%%---------------------------------------------------------------------- -%%% Internal functions -%%%---------------------------------------------------------------------- - -%% PUT / Get processing: -handle_http_put_event(#http_put{rid = Rid, - attrs = Attrs, hold = Hold} = - Request, - StateName, StateData) -> - ?DEBUG("New request: ~p", [Request]), - RidAllow = rid_allow(StateData#state.rid, Rid, Attrs, - Hold, StateData#state.max_pause), - case RidAllow of - buffer -> - ?DEBUG("Buffered request: ~p", [Request]), - PendingRequests = StateData#state.unprocessed_req_list, - Requests = lists:keydelete(Rid, 2, PendingRequests), - ReqList = [#hbr{rid = Rid, key = StateData#state.key, - out = []} - | [El - || El <- StateData#state.req_list, - El#hbr.rid > Rid - 1 - Hold]], - ?DEBUG("reqlist: ~p", [ReqList]), - UnprocessedReqList = [Request | Requests], - cancel_timer(StateData#state.timer), - Timer = set_inactivity_timer(0, - StateData#state.max_inactivity), - {reply, ok, StateName, - StateData#state{unprocessed_req_list = - UnprocessedReqList, - req_list = ReqList, timer = Timer}, - hibernate}; - _ -> - process_http_put(Request, StateName, StateData, - RidAllow) - end. - -process_http_put(#http_put{rid = Rid, attrs = Attrs, - payload = Payload, hold = Hold, stream = StreamTo, - ip = IP} = - Request, - StateName, StateData, RidAllow) -> - ?DEBUG("Actually processing request: ~p", [Request]), - Key = fxml:get_attr_s(<<"key">>, Attrs), - NewKey = fxml:get_attr_s(<<"newkey">>, Attrs), - KeyAllow = case RidAllow of - repeat -> true; - false -> false; - {true, _} -> - case StateData#state.key of - <<"">> -> true; - OldKey -> - NextKey = p1_sha:sha(Key), - ?DEBUG("Key/OldKey/NextKey: ~s/~s/~s", - [Key, OldKey, NextKey]), - if OldKey == NextKey -> true; - true -> ?DEBUG("wrong key: ~s", [Key]), false - end - end - end, - TNow = p1_time_compat:system_time(micro_seconds), - LastPoll = if Payload == [] -> TNow; - true -> 0 - end, - if (Payload == []) and (Hold == 0) and - (TNow - StateData#state.last_poll < (?MIN_POLLING)) -> - Reply = {error, polling_too_frequently}, - {reply, Reply, StateName, StateData}; - KeyAllow -> - case RidAllow of - false -> - Reply = {error, not_exists}, - {reply, Reply, StateName, StateData}; - repeat -> - ?DEBUG("REPEATING ~p", [Rid]), - case [El#hbr.out - || El <- StateData#state.req_list, El#hbr.rid == Rid] - of - [] -> {error, not_exists}; - [Out | _XS] -> - if (Rid == StateData#state.rid) and - (StateData#state.http_receiver /= undefined) -> - {reply, ok, StateName, StateData}; - true -> - Reply = {repeat, lists:reverse(Out)}, - {reply, Reply, StateName, - StateData#state{last_poll = LastPoll}} - end - end; - {true, Pause} -> - SaveKey = if NewKey == <<"">> -> Key; - true -> NewKey - end, - ?DEBUG(" -- SaveKey: ~s~n", [SaveKey]), - ReqList1 = [El - || El <- StateData#state.req_list, - El#hbr.rid > Rid - 1 - Hold], - ReqList = case lists:keymember(Rid, #hbr.rid, ReqList1) - of - true -> ReqList1; - false -> - [#hbr{rid = Rid, key = StateData#state.key, - out = []} - | ReqList1] - end, - ?DEBUG("reqlist: ~p", [ReqList]), - cancel_timer(StateData#state.timer), - Timer = set_inactivity_timer(Pause, - StateData#state.max_inactivity), - case StateData#state.waiting_input of - false -> - Input = lists:foldl(fun queue:in/2, - StateData#state.input, Payload), - Reply = ok, - process_buffered_request(Reply, StateName, - StateData#state{input = Input, - rid = Rid, - key = SaveKey, - ctime = TNow, - timer = Timer, - pause = Pause, - last_poll = - LastPoll, - req_list = - ReqList, - ip = IP}); - C2SPid -> - case StreamTo of - {To, <<"">>} -> - gen_fsm:send_event(C2SPid, - {xmlstreamstart, - <<"stream:stream">>, - [{<<"to">>, To}, - {<<"xmlns">>, ?NS_CLIENT}, - {<<"xmlns:stream">>, - ?NS_STREAM}]}); - {To, Version} -> - gen_fsm:send_event(C2SPid, - {xmlstreamstart, - <<"stream:stream">>, - [{<<"to">>, To}, - {<<"xmlns">>, ?NS_CLIENT}, - {<<"version">>, Version}, - {<<"xmlns:stream">>, - ?NS_STREAM}]}); - _ -> ok - end, - MaxInactivity = get_max_inactivity(StreamTo, - StateData#state.max_inactivity), - MaxPause = get_max_inactivity(StreamTo, - StateData#state.max_pause), - ?DEBUG("really sending now: ~p", [Payload]), - lists:foreach(fun ({xmlstreamend, End}) -> - gen_fsm:send_event(C2SPid, - {xmlstreamend, - End}); - (El) -> - gen_fsm:send_event(C2SPid, - {xmlstreamelement, - El}) - end, - Payload), - Reply = ok, - process_buffered_request(Reply, StateName, - StateData#state{input = - queue:new(), - rid = Rid, - key = SaveKey, - ctime = TNow, - timer = Timer, - pause = Pause, - last_poll = - LastPoll, - req_list = - ReqList, - max_inactivity = - MaxInactivity, - max_pause = - MaxPause, - ip = IP}) - end - end; - true -> - Reply = {error, bad_key}, - {reply, Reply, StateName, StateData} - end. - -process_buffered_request(Reply, StateName, StateData) -> - Rid = StateData#state.rid, - Requests = StateData#state.unprocessed_req_list, - case lists:keysearch(Rid + 1, 2, Requests) of - {value, Request} -> - ?DEBUG("Processing buffered request: ~p", [Request]), - NewRequests = lists:keydelete(Rid + 1, 2, Requests), - handle_http_put_event(Request, StateName, - StateData#state{unprocessed_req_list = - NewRequests}); - _ -> {reply, Reply, StateName, StateData, hibernate} - end. - -handle_http_put(Sid, Rid, Attrs, Payload, PayloadSize, - StreamStart, IP) -> - case http_put(Sid, Rid, Attrs, Payload, PayloadSize, - StreamStart, IP) - of - {error, not_exists} -> - ?DEBUG("no session associated with sid: ~p", [Sid]), - {404, ?HEADER, <<"">>}; - {{error, Reason}, Sess} -> - ?DEBUG("Error on HTTP put. Reason: ~p", [Reason]), - handle_http_put_error(Reason, Sess); - {{repeat, OutPacket}, Sess} -> - ?DEBUG("http_put said 'repeat!' ...~nOutPacket: ~p", - [OutPacket]), - send_outpacket(Sess, OutPacket); - {{wait, Pause}, _Sess} -> - ?DEBUG("Trafic Shaper: Delaying request ~p", [Rid]), - timer:sleep(Pause), - handle_http_put(Sid, Rid, Attrs, Payload, PayloadSize, - StreamStart, IP); - {ok, Sess} -> - prepare_response(Sess, Rid, [], StreamStart) - end. - -http_put(Sid, Rid, Attrs, Payload, PayloadSize, - StreamStart, IP) -> - ?DEBUG("Looking for session: ~p", [Sid]), - case mnesia:dirty_read({http_bind, Sid}) of - [] -> - {error, not_exists}; - [#http_bind{pid = FsmRef, hold=Hold, - to= {To, StreamVersion}} = Sess] -> - NewStream = case StreamStart of - true -> {To, StreamVersion}; - _ -> <<"">> - end, - {gen_fsm:sync_send_all_state_event( - FsmRef, #http_put{rid = Rid, - attrs = Attrs, - payload = Payload, - payload_size = PayloadSize, - hold = Hold, - stream = NewStream, - ip = IP}, - 30000), Sess} - end. - -handle_http_put_error(Reason, - #http_bind{pid = FsmRef, version = Version}) - when Version >= 0 -> - gen_fsm:sync_send_all_state_event(FsmRef, - {stop, {put_error, Reason}}), - case Reason of - not_exists -> - {200, ?HEADER, - fxml:element_to_binary(#xmlel{name = <<"body">>, - attrs = - [{<<"xmlns">>, ?NS_HTTP_BIND}, - {<<"type">>, <<"terminate">>}, - {<<"condition">>, - <<"item-not-found">>}], - children = []})}; - bad_key -> - {200, ?HEADER, - fxml:element_to_binary(#xmlel{name = <<"body">>, - attrs = - [{<<"xmlns">>, ?NS_HTTP_BIND}, - {<<"type">>, <<"terminate">>}, - {<<"condition">>, - <<"item-not-found">>}], - children = []})}; - polling_too_frequently -> - {200, ?HEADER, - fxml:element_to_binary(#xmlel{name = <<"body">>, - attrs = - [{<<"xmlns">>, ?NS_HTTP_BIND}, - {<<"type">>, <<"terminate">>}, - {<<"condition">>, - <<"policy-violation">>}], - children = []})} - end; -handle_http_put_error(Reason, - #http_bind{pid = FsmRef}) -> - gen_fsm:sync_send_all_state_event(FsmRef, - {stop, {put_error_no_version, Reason}}), - case Reason of - not_exists -> %% bad rid - ?DEBUG("Closing HTTP bind session (Bad rid).", []), - {404, ?HEADER, <<"">>}; - bad_key -> - ?DEBUG("Closing HTTP bind session (Bad key).", []), - {404, ?HEADER, <<"">>}; - polling_too_frequently -> - ?DEBUG("Closing HTTP bind session (User polling " - "too frequently).", - []), - {403, ?HEADER, <<"">>} - end. - -%% Control RID ordering -rid_allow(none, _NewRid, _Attrs, _Hold, _MaxPause) -> - {true, 0}; -rid_allow(OldRid, NewRid, Attrs, Hold, MaxPause) -> - ?DEBUG("Previous rid / New rid: ~p/~p", - [OldRid, NewRid]), - if - %% We did not miss any packet, we can process it immediately: - NewRid == OldRid + 1 -> - case catch - binary_to_integer(fxml:get_attr_s(<<"pause">>, - Attrs)) - of - {'EXIT', _} -> {true, 0}; - Pause1 when Pause1 =< MaxPause -> - ?DEBUG("got pause: ~p", [Pause1]), {true, Pause1}; - _ -> {true, 0} - end; - %% We have missed packets, we need to cached it to process it later on: - (OldRid < NewRid) and (NewRid =< OldRid + Hold + 1) -> - buffer; - (NewRid =< OldRid) and (NewRid > OldRid - Hold - 1) -> - repeat; - true -> false - end. - -update_shaper(ShaperState, PayloadSize) -> - {NewShaperState, Pause} = shaper:update(ShaperState, - PayloadSize), - if Pause > 0 -> - ShaperTimer = erlang:start_timer(Pause, self(), - activate), - {NewShaperState, ShaperTimer}; - true -> {NewShaperState, undefined} - end. - -prepare_response(Sess, Rid, OutputEls, StreamStart) -> - receive after Sess#http_bind.process_delay -> ok end, - case catch http_get(Sess, Rid) of - {ok, cancel} -> - {200, ?HEADER, - <<"<body type='error' xmlns='", (?NS_HTTP_BIND)/binary, - "'/>">>}; - {ok, empty} -> - {200, ?HEADER, - <<"<body xmlns='", (?NS_HTTP_BIND)/binary, "'/>">>}; - {ok, terminate} -> - {200, ?HEADER, - <<"<body type='terminate' xmlns='", - (?NS_HTTP_BIND)/binary, "'/>">>}; - {ok, ROutPacket} -> - OutPacket = lists:reverse(ROutPacket), - ?DEBUG("OutPacket: ~p", [OutputEls ++ OutPacket]), - prepare_outpacket_response(Sess, Rid, - OutputEls ++ OutPacket, StreamStart); - {'EXIT', {shutdown, _}} -> - {200, ?HEADER, - <<"<body type='terminate' condition='system-shut" - "down' xmlns='", - (?NS_HTTP_BIND)/binary, "'/>">>}; - {'EXIT', _Reason} -> - {200, ?HEADER, - <<"<body type='terminate' xmlns='", - (?NS_HTTP_BIND)/binary, "'/>">>} - end. - -%% Send output payloads on establised sessions -prepare_outpacket_response(Sess, _Rid, OutPacket, - false) -> - case catch send_outpacket(Sess, OutPacket) of - {'EXIT', _Reason} -> - ?DEBUG("Error in sending packet ~p ", [_Reason]), - {200, ?HEADER, - <<"<body type='terminate' xmlns='", - (?NS_HTTP_BIND)/binary, "'/>">>}; - SendRes -> SendRes - end; -%% Handle a new session along with its output payload -prepare_outpacket_response(#http_bind{id = Sid, - wait = Wait, hold = Hold, to = To} = - _Sess, - _Rid, OutPacket, true) -> - case OutPacket of - [{xmlstreamstart, _, OutAttrs} | Els] -> - AuthID = fxml:get_attr_s(<<"id">>, OutAttrs), - From = fxml:get_attr_s(<<"from">>, OutAttrs), - Version = fxml:get_attr_s(<<"version">>, OutAttrs), - OutEls = case Els of - [] -> []; - [{xmlstreamelement, - #xmlel{name = <<"stream:features">>, - attrs = StreamAttribs, children = StreamEls}} - | StreamTail] -> - TypedTail = [check_default_xmlns(OEl) - || {xmlstreamelement, OEl} <- StreamTail], - [#xmlel{name = <<"stream:features">>, - attrs = - [{<<"xmlns:stream">>, ?NS_STREAM}] ++ - StreamAttribs, - children = StreamEls}] - ++ TypedTail; - StreamTail -> - [check_default_xmlns(OEl) - || {xmlstreamelement, OEl} <- StreamTail] - end, - case OutEls of - [#xmlel{name = <<"stream:error">>}] -> - {200, ?HEADER, - <<"<body type='terminate' condition='host-unknow" - "n' xmlns='", - (?NS_HTTP_BIND)/binary, "'/>">>}; - _ -> - BOSH_attribs = [{<<"authid">>, AuthID}, - {<<"xmlns:xmpp">>, ?NS_BOSH}, - {<<"xmlns:stream">>, ?NS_STREAM}] - ++ - case OutEls of - [] -> []; - _ -> [{<<"xmpp:version">>, Version}] - end, - MaxInactivity = get_max_inactivity(To, ?MAX_INACTIVITY), - MaxPause = get_max_pause(To), - {200, ?HEADER, - fxml:element_to_binary(#xmlel{name = <<"body">>, - attrs = - [{<<"xmlns">>, ?NS_HTTP_BIND}, - {<<"sid">>, Sid}, - {<<"wait">>, - integer_to_binary(Wait)}, - {<<"requests">>, - integer_to_binary(Hold + 1)}, - {<<"inactivity">>, - integer_to_binary( - trunc(MaxInactivity / 1000))}, - {<<"maxpause">>, - integer_to_binary(MaxPause)}, - {<<"polling">>, - integer_to_binary( - trunc((?MIN_POLLING) / 1000000))}, - {<<"ver">>, ?BOSH_VERSION}, - {<<"from">>, From}, - {<<"secure">>, <<"true">>}] - ++ BOSH_attribs, - children = OutEls})} - end; - _ -> - {200, ?HEADER, - <<"<body type='terminate' condition='internal-se" - "rver-error' xmlns='", - (?NS_HTTP_BIND)/binary, "'/>">>} - end. - -http_get(#http_bind{pid = FsmRef, wait = Wait, - hold = Hold}, - Rid) -> - gen_fsm:sync_send_all_state_event(FsmRef, - {http_get, Rid, Wait, Hold}, - 2 * (?MAX_WAIT) * 1000). - -send_outpacket(#http_bind{pid = FsmRef}, OutPacket) -> - case OutPacket of - [] -> - {200, ?HEADER, - <<"<body xmlns='", (?NS_HTTP_BIND)/binary, "'/>">>}; - [{xmlstreamend, _}] -> - gen_fsm:sync_send_all_state_event(FsmRef, - {stop, stream_closed}), - {200, ?HEADER, - <<"<body xmlns='", (?NS_HTTP_BIND)/binary, "'/>">>}; - _ -> - AllElements = lists:all(fun ({xmlstreamelement, - #xmlel{name = <<"stream:error">>}}) -> - false; - ({xmlstreamelement, _}) -> true; - ({xmlstreamraw, _}) -> true; - (_) -> false - end, - OutPacket), - case AllElements of - true -> - TypedEls = lists:foldl(fun ({xmlstreamelement, El}, - Acc) -> - Acc ++ - [fxml:element_to_binary(check_default_xmlns(El))]; - ({xmlstreamraw, R}, Acc) -> - Acc ++ [R] - end, - [], OutPacket), - Body = <<"<body xmlns='", (?NS_HTTP_BIND)/binary, "'>", - (iolist_to_binary(TypedEls))/binary, "</body>">>, - ?DEBUG(" --- outgoing data --- ~n~s~n --- END " - "--- ~n", - [Body]), - {200, ?HEADER, Body}; - false -> - case OutPacket of - [{xmlstreamstart, _, _} | SEls] -> - OutEls = case SEls of - [{xmlstreamelement, - #xmlel{name = <<"stream:features">>, - attrs = StreamAttribs, - children = StreamEls}} - | StreamTail] -> - TypedTail = [check_default_xmlns(OEl) - || {xmlstreamelement, OEl} - <- StreamTail], - [#xmlel{name = <<"stream:features">>, - attrs = - [{<<"xmlns:stream">>, - ?NS_STREAM}] - ++ StreamAttribs, - children = StreamEls}] - ++ TypedTail; - StreamTail -> - [check_default_xmlns(OEl) - || {xmlstreamelement, OEl} <- StreamTail] - end, - {200, ?HEADER, - fxml:element_to_binary(#xmlel{name = <<"body">>, - attrs = - [{<<"xmlns">>, - ?NS_HTTP_BIND}], - children = OutEls})}; - _ -> - SErrCond = lists:filter(fun ({xmlstreamelement, - #xmlel{name = - <<"stream:error">>}}) -> - true; - (_) -> false - end, - OutPacket), - StreamErrCond = case SErrCond of - [] -> null; - [{xmlstreamelement, - #xmlel{} = StreamErrorTag} - | _] -> - [StreamErrorTag] - end, - gen_fsm:sync_send_all_state_event(FsmRef, - {stop, - {stream_error, - OutPacket}}), - case StreamErrCond of - null -> - {200, ?HEADER, - <<"<body type='terminate' condition='internal-se" - "rver-error' xmlns='", - (?NS_HTTP_BIND)/binary, "'/>">>}; - _ -> - {200, ?HEADER, - <<"<body type='terminate' condition='remote-stre" - "am-error' xmlns='", - (?NS_HTTP_BIND)/binary, "' ", "xmlns:stream='", - (?NS_STREAM)/binary, "'>", - (elements_to_string(StreamErrCond))/binary, - "</body>">>} - end - end - end - end. - -parse_request(Data, PayloadSize, MaxStanzaSize) -> - ?DEBUG("--- incoming data --- ~n~s~n --- END " - "--- ", - [Data]), - case fxml_stream:parse_element(Data) of - #xmlel{name = <<"body">>, attrs = Attrs, - children = Els} -> - Xmlns = fxml:get_attr_s(<<"xmlns">>, Attrs), - if Xmlns /= (?NS_HTTP_BIND) -> {error, bad_request}; - true -> - case catch - binary_to_integer(fxml:get_attr_s(<<"rid">>, - Attrs)) - of - {'EXIT', _} -> {error, bad_request}; - Rid -> - FixedEls = lists:filter(fun (I) -> - case I of - #xmlel{} -> true; - _ -> false - end - end, - Els), - Sid = fxml:get_attr_s(<<"sid">>, Attrs), - if PayloadSize =< MaxStanzaSize -> - {ok, {Sid, Rid, Attrs, FixedEls}}; - true -> {size_limit, Sid} - end - end - end; - #xmlel{} -> {error, bad_request}; - {error, _Reason} -> {error, bad_request} - end. - -send_receiver_reply(undefined, _Reply) -> ok; -send_receiver_reply(Receiver, Reply) -> - gen_fsm:reply(Receiver, Reply). - -%% Cancel timer and empty message queue. -cancel_timer(undefined) -> ok; -cancel_timer(Timer) -> - erlang:cancel_timer(Timer), - receive {timeout, Timer, _} -> ok after 0 -> ok end. - -%% If client asked for a pause (pause > 0), we apply the pause value -%% as inactivity timer: -set_inactivity_timer(Pause, _MaxInactivity) - when Pause > 0 -> - erlang:start_timer(Pause * 1000, self(), []); -%% Otherwise, we apply the max_inactivity value as inactivity timer: -set_inactivity_timer(_Pause, MaxInactivity) -> - erlang:start_timer(MaxInactivity, self(), []). - -elements_to_string([]) -> []; -elements_to_string([El | Els]) -> - [fxml:element_to_binary(El) | elements_to_string(Els)]. - -%% @spec (To, Default::integer()) -> integer() -%% where To = [] | {Host::string(), Version::string()} -get_max_inactivity({Host, _}, Default) -> - case gen_mod:get_module_opt(Host, mod_http_bind, max_inactivity, - fun(I) when is_integer(I), I>0 -> I end, - undefined) - of - Seconds when is_integer(Seconds) -> Seconds * 1000; - undefined -> Default - end; -get_max_inactivity(_, Default) -> Default. - -get_max_pause({Host, _}) -> - gen_mod:get_module_opt(Host, mod_http_bind, max_pause, - fun(I) when is_integer(I), I>0 -> I end, - ?MAX_PAUSE); -get_max_pause(_) -> ?MAX_PAUSE. - -check_default_xmlns(#xmlel{name = Name, attrs = Attrs, - children = Els} = - El) -> - case fxml:get_tag_attr_s(<<"xmlns">>, El) of - <<"">> -> - #xmlel{name = Name, - attrs = [{<<"xmlns">>, ?NS_CLIENT} | Attrs], - children = Els}; - _ -> El - end; -check_default_xmlns(El) -> El. - -%% Check that mod_http_bind has been defined in config file. -%% Print a warning in log file if this is not the case. -check_bind_module(XmppDomain) -> - case gen_mod:is_loaded(XmppDomain, mod_http_bind) of - true -> true; - false -> - ?ERROR_MSG("You are trying to use BOSH (HTTP Bind) " - "in host ~p, but the module mod_http_bind " - "is not started in that host. Configure " - "your BOSH client to connect to the correct " - "host, or add your desired host to the " - "configuration, or check your 'modules' " - "section in your ejabberd configuration " - "file.", - [XmppDomain]), - false - end. diff --git a/src/ejabberd_http_ws.erl b/src/ejabberd_http_ws.erl index 6d90dba4b..6ac257c91 100644 --- a/src/ejabberd_http_ws.erl +++ b/src/ejabberd_http_ws.erl @@ -5,7 +5,7 @@ %%% Created : 09-10-2010 by Eric Cestari <ecestari@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_idna.erl b/src/ejabberd_idna.erl index f889b411a..8ef34879c 100644 --- a/src/ejabberd_idna.erl +++ b/src/ejabberd_idna.erl @@ -5,7 +5,7 @@ %%% Created : 10 Apr 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_listener.erl b/src/ejabberd_listener.erl index 35dbdedef..bad1da134 100644 --- a/src/ejabberd_listener.erl +++ b/src/ejabberd_listener.erl @@ -5,7 +5,7 @@ %%% Created : 16 Nov 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_local.erl b/src/ejabberd_local.erl index 60a628db7..b5e1d8abc 100644 --- a/src/ejabberd_local.erl +++ b/src/ejabberd_local.erl @@ -5,7 +5,7 @@ %%% Created : 30 Nov 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_logger.erl b/src/ejabberd_logger.erl index 795d4f390..f57ac977d 100644 --- a/src/ejabberd_logger.erl +++ b/src/ejabberd_logger.erl @@ -1,11 +1,11 @@ %%%------------------------------------------------------------------- -%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%% @doc -%%% -%%% @end +%%% File : ejabberd_logger.erl +%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net> +%%% Purpose : ejabberd logger wrapper %%% Created : 12 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% -%%% ejabberd, Copyright (C) 2013-2016 ProcessOne +%%% +%%% ejabberd, Copyright (C) 2013-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_mnesia.erl b/src/ejabberd_mnesia.erl index 0e067ad65..db31e277a 100644 --- a/src/ejabberd_mnesia.erl +++ b/src/ejabberd_mnesia.erl @@ -5,7 +5,7 @@ %%% Created : 17 Nov 2016 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -35,31 +35,43 @@ -define(STORAGE_TYPES, [disc_copies, disc_only_copies, ram_copies]). -define(NEED_RESET, [local_content, type]). -create(Module, Name, TabDef) -> - Schema = schema(Module, Name, TabDef), +-include("logger.hrl"). + +create(Module, Name, TabDef) + when is_atom(Module), is_atom(Name), is_list(TabDef) -> + Path = os:getenv("EJABBERD_SCHEMA_PATH"), + Schema = schema(Path, Module, Name, TabDef), {attributes, Attrs} = lists:keyfind(attributes, 1, Schema), case catch mnesia:table_info(Name, attributes) of {'EXIT', _} -> - mnesia:create_table(Name, Schema); + mnesia_op(create_table, [Name, TabDef]); Attrs -> - case need_reset(TabDef, Schema) of + case need_reset(Name, Schema) of true -> reset(Name, Schema); - false -> update(Name, Schema) + false -> update(Name, Attrs, Schema) end; OldAttrs -> Fun = case lists:member({transform,1}, Module:module_info(exports)) of true -> fun(Old) -> Module:transform(Old) end; false -> fun(Old) -> transform(OldAttrs, Attrs, Old) end end, - mnesia:transform_table(Name, Fun, Attrs) + mnesia_op(transform_table, [Name, Fun, Attrs]) end. -reset(Name, TabDef) -> - mnesia:delete_table(Name), - ejabberd_mnesia:create(?MODULE, Name, TabDef). +reset(Name, TabDef) + when is_atom(Name), is_list(TabDef) -> + mnesia_op(delete_table, [Name]), + mnesia_op(create_table, [Name, TabDef]). -update(Name, TabDef) -> - Storage = mnesia:table_info(Name, storage_type), +update(Name, TabDef) + when is_atom(Name), is_list(TabDef) -> + {attributes, Attrs} = lists:keyfind(attributes, 1, TabDef), + update(Name, Attrs, TabDef). +update(Name, Attrs, TabDef) -> + Storage = case catch mnesia:table_info(Name, storage_type) of + {'EXIT', _} -> unknown; + Type -> Type + end, NewStorage = lists:foldl( fun({Key, _}, Acc) -> case lists:member(Key, ?STORAGE_TYPES) of @@ -67,34 +79,41 @@ update(Name, TabDef) -> false -> Acc end end, Storage, TabDef), - R1 = if Storage=/=NewStorage -> - mnesia:change_table_copy_type(Name, node(), NewStorage); - true -> - {atomic, ok} - end, - Indexes = mnesia:table_info(Name, index), + R1 = [mnesia_op(change_table_copy_type, [Name, node(), NewStorage]) + || Storage=/=NewStorage], + CurIndexes = [lists:nth(N-1, Attrs) || N<-mnesia:table_info(Name, index)], NewIndexes = proplists:get_value(index, TabDef, []), - [mnesia:del_table_index(Name, Attr) - || Attr <- Indexes--NewIndexes], - R2 = [mnesia:add_table_index(Name, Attr) - || Attr <- NewIndexes--Indexes], + R2 = [mnesia_op(del_table_index, [Name, Attr]) + || Attr <- CurIndexes--NewIndexes], + R3 = [mnesia_op(add_table_index, [Name, Attr]) + || Attr <- NewIndexes--CurIndexes], lists:foldl( fun({atomic, ok}, Acc) -> Acc; (Error, _Acc) -> Error - end, {atomic, ok}, [R1|R2]). + end, {atomic, ok}, R1++R2++R3). % % utilities % -schema(Module, Name, TabDef) -> - case parse(Module) of +schema(false, Module, _Name, TabDef) -> + ?DEBUG("No custom ~s schema path", [Module]), + TabDef; +schema(Path, Module, Name, TabDef) -> + File = filename:join(Path, atom_to_list(Module)++".mnesia"), + case parse(File) of {ok, CustomDefs} -> case lists:keyfind(Name, 1, CustomDefs) of - {Name, CustomDef} -> merge(TabDef, CustomDef); - _ -> TabDef + {Name, CustomDef} -> + ?INFO_MSG("Using custom ~s schema for table ~s", + [Module, Name]), + merge(TabDef, CustomDef); + _ -> + TabDef end; - _ -> + {error, Error} -> + ?ERROR_MSG("Can not use custom ~s schema for table ~s: ~p", + [Module, Name, Error]), TabDef end. @@ -116,28 +135,15 @@ merge(TabDef, CustomDef) -> lists:ukeysort(1, CustomDef), lists:ukeysort(1, CleanDef)). -parse(Module) -> - Path = case os:getenv("EJABBERD_SCHEMA_PATH") of - false -> - case code:priv_dir(ejabberd) of - {error, _} -> "schema"; % $SPOOL_DIR/schema - Priv -> filename:join(Priv, "schema") - end; - CustomDir -> - CustomDir - end, - File = filename:join(Path, atom_to_list(Module)++".mnesia"), +parse(File) -> case file:consult(File) of {ok, Terms} -> parse(Terms, []); Error -> Error end. - parse([], Acc) -> {ok, lists:reverse(Acc)}; parse([{Name, Storage, TabDef}|Tail], Acc) - when is_atom(Name), - is_atom(Storage), - is_list(TabDef) -> + when is_atom(Name), is_atom(Storage), is_list(TabDef) -> NewDef = case lists:member(Storage, ?STORAGE_TYPES) of true -> [{Storage, [node()]} | TabDef]; false -> TabDef @@ -146,12 +152,12 @@ parse([{Name, Storage, TabDef}|Tail], Acc) parse([Other|_], _) -> {error, {invalid, Other}}. -need_reset(FromDef, ToDef) -> - ValuesF = [lists:keyfind(Key, 1, FromDef) || Key <- ?NEED_RESET], - ValuesT = [lists:keyfind(Key, 1, ToDef) || Key <- ?NEED_RESET], +need_reset(Table, TabDef) -> + ValuesF = [mnesia:table_info(Table, Key) || Key <- ?NEED_RESET], + ValuesT = [proplists:get_value(Key, TabDef) || Key <- ?NEED_RESET], lists:foldl( fun({Val, Val}, Acc) -> Acc; - ({_, false}, Acc) -> Acc; + ({_, undefined}, Acc) -> Acc; ({_, _}, _) -> true end, false, lists:zip(ValuesF, ValuesT)). @@ -167,3 +173,13 @@ transform(OldAttrs, Attrs, Old) -> end, [], lists:reverse(Attrs)), {Attrs, NewRecord} = lists:unzip(After), list_to_tuple([Name|NewRecord]). + +mnesia_op(Fun, Args) -> + case apply(mnesia, Fun, Args) of + {atomic, ok} -> + {atomic, ok}; + Other -> + ?ERROR_MSG("failure on mnesia ~s ~p: ~p", + [Fun, Args, Other]), + Other + end. diff --git a/src/ejabberd_oauth.erl b/src/ejabberd_oauth.erl index 74e26e8da..61944a79d 100644 --- a/src/ejabberd_oauth.erl +++ b/src/ejabberd_oauth.erl @@ -5,7 +5,7 @@ %%% Created : 20 Mar 2015 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_oauth_mnesia.erl b/src/ejabberd_oauth_mnesia.erl index bdd2d0edd..c9ef6dcac 100644 --- a/src/ejabberd_oauth_mnesia.erl +++ b/src/ejabberd_oauth_mnesia.erl @@ -5,7 +5,7 @@ %%% Created : 20 Jul 2016 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_oauth_rest.erl b/src/ejabberd_oauth_rest.erl index c932d16f5..ec9ef0d88 100644 --- a/src/ejabberd_oauth_rest.erl +++ b/src/ejabberd_oauth_rest.erl @@ -5,7 +5,7 @@ %%% Created : 26 Jul 2016 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_oauth_sql.erl b/src/ejabberd_oauth_sql.erl index 3c09362c2..4906600f4 100644 --- a/src/ejabberd_oauth_sql.erl +++ b/src/ejabberd_oauth_sql.erl @@ -5,7 +5,7 @@ %%% Created : 27 Jul 2016 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_piefxis.erl b/src/ejabberd_piefxis.erl index 9e6cbd715..1115f16cb 100644 --- a/src/ejabberd_piefxis.erl +++ b/src/ejabberd_piefxis.erl @@ -1,14 +1,11 @@ %%%---------------------------------------------------------------------- %%% File : ejabberd_piefxis.erl -%%% Author : Pablo Polvorin, Vidal Santiago Martinez +%%% Author : Pablo Polvorin, Vidal Santiago Martinez, Evgeniy Khramtsov %%% Purpose : XEP-0227: Portable Import/Export Format for XMPP-IM Servers %%% Created : 17 Jul 2008 by Pablo Polvorin <pablo.polvorin@process-one.net> -%%%------------------------------------------------------------------- -%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%% @doc %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -494,7 +491,7 @@ process_privacy(#privacy_query{lists = Lists, {ok, State}; true -> stop("Failed to write privacy: ~p", [Reason]) - end; + end; _ -> {ok, State} end. diff --git a/src/ejabberd_rdbms.erl b/src/ejabberd_rdbms.erl index 5224b035b..e3a211f8e 100644 --- a/src/ejabberd_rdbms.erl +++ b/src/ejabberd_rdbms.erl @@ -5,7 +5,7 @@ %%% Created : 31 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_receiver.erl b/src/ejabberd_receiver.erl index ffa55806f..355fcbbd2 100644 --- a/src/ejabberd_receiver.erl +++ b/src/ejabberd_receiver.erl @@ -5,7 +5,7 @@ %%% Created : 10 Nov 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_redis.erl b/src/ejabberd_redis.erl index c6e3b4dd0..9d4264df3 100644 --- a/src/ejabberd_redis.erl +++ b/src/ejabberd_redis.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : ejabberd_redis.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 8 May 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(ejabberd_redis). -behaviour(gen_server). diff --git a/src/ejabberd_regexp.erl b/src/ejabberd_regexp.erl index b79774e31..b4ef7ac16 100644 --- a/src/ejabberd_regexp.erl +++ b/src/ejabberd_regexp.erl @@ -5,7 +5,7 @@ %%% Created : 8 Dec 2011 by Badlop %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_riak.erl b/src/ejabberd_riak.erl index 44628d1c2..a6ea55e98 100644 --- a/src/ejabberd_riak.erl +++ b/src/ejabberd_riak.erl @@ -1,12 +1,11 @@ %%%------------------------------------------------------------------- -%%% @author Alexey Shchepin <alexey@process-one.net> -%%% @doc -%%% Interface for Riak database -%%% @end +%%% File : ejabberd_riak.erl +%%% Author : Alexey Shchepin <alexey@process-one.net> +%%% Purpose : Interface for Riak database %%% Created : 29 Dec 2011 by Alexey Shchepin <alexey@process-one.net> -%%% @copyright (C) 2002-2016 ProcessOne %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_riak_sup.erl b/src/ejabberd_riak_sup.erl index ad65ecf80..840de29b5 100644 --- a/src/ejabberd_riak_sup.erl +++ b/src/ejabberd_riak_sup.erl @@ -5,7 +5,7 @@ %%% Created : 29 Dec 2011 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_router_multicast.erl b/src/ejabberd_router_multicast.erl index 4383e1672..19c6da144 100644 --- a/src/ejabberd_router_multicast.erl +++ b/src/ejabberd_router_multicast.erl @@ -5,7 +5,7 @@ %%% Created : 11 Aug 2007 by Badlop <badlop@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_s2s.erl b/src/ejabberd_s2s.erl index bf3c5c06f..86cf1a1f5 100644 --- a/src/ejabberd_s2s.erl +++ b/src/ejabberd_s2s.erl @@ -5,7 +5,7 @@ %%% Created : 7 Dec 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -355,12 +355,12 @@ do_route(From, To, Packet) -> [From, To, Packet, 8]), case start_connection(From, To) of {ok, Pid} when is_pid(Pid) -> - ?DEBUG("sending to process ~p~n", [Pid]), - #jid{lserver = MyServer} = From, + ?DEBUG("sending to process ~p~n", [Pid]), + #jid{lserver = MyServer} = From, ejabberd_hooks:run(s2s_send_packet, MyServer, [From, To, Packet]), ejabberd_s2s_out:route(Pid, xmpp:set_from_to(Packet, From, To)); {error, Reason} -> - Lang = xmpp:get_lang(Packet), + Lang = xmpp:get_lang(Packet), Err = case Reason of policy_violation -> xmpp:err_policy_violation( @@ -397,18 +397,18 @@ start_connection(From, To, Opts) -> %% is in whitelist: LServer = ejabberd_router:host_of_route(MyServer), case is_service(From, To) of - true -> + true -> {error, policy_violation}; false -> case allow_host(LServer, Server) of true -> NeededConnections = needed_connections_number( [], - MaxS2SConnectionsNumber, - MaxS2SConnectionsNumberPerNode), - open_several_connections(NeededConnections, MyServer, - Server, From, FromTo, - MaxS2SConnectionsNumber, + MaxS2SConnectionsNumber, + MaxS2SConnectionsNumberPerNode), + open_several_connections(NeededConnections, MyServer, + Server, From, FromTo, + MaxS2SConnectionsNumber, MaxS2SConnectionsNumberPerNode, Opts); false -> {error, forbidden} @@ -453,7 +453,7 @@ open_several_connections(N, MyServer, Server, From, case lists:flatmap( fun(_) -> new_connection(MyServer, Server, - From, FromTo, MaxS2SConnectionsNumber, + From, FromTo, MaxS2SConnectionsNumber, MaxS2SConnectionsNumberPerNode, Opts) end, lists:seq(1, N)) of [] -> diff --git a/src/ejabberd_s2s_in.erl b/src/ejabberd_s2s_in.erl index f447cf9dd..3b4b6a989 100644 --- a/src/ejabberd_s2s_in.erl +++ b/src/ejabberd_s2s_in.erl @@ -2,7 +2,7 @@ %%% Created : 12 Dec 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -153,7 +153,7 @@ handle_stream_start(_StreamStart, #{lserver := LServer} = State) -> case check_to(jid:make(LServer), State) of false -> send(State, xmpp:serr_host_unknown()); - true -> + true -> ServerHost = ejabberd_router:host_of_route(LServer), State#{server_host => ServerHost} end. @@ -174,13 +174,13 @@ handle_auth_success(RServer, Mech, _AuthModule, [SockMod:pp(Socket), Mech, RServer, LServer, ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]), State1 = case ejabberd_s2s:allow_host(ServerHost, RServer) of - true -> + true -> AuthDomains1 = sets:add_element(RServer, AuthDomains), change_shaper(State, RServer), State#{auth_domains => AuthDomains1}; false -> State - end, + end, ejabberd_hooks:run_fold(s2s_in_auth_result, ServerHost, State1, [true, RServer]). handle_auth_failure(RServer, Mech, Reason, @@ -213,7 +213,7 @@ handle_authenticated_packet(Pkt, State) -> case Pkt1 of drop -> ok; _ -> ejabberd_router:route(From, To, Pkt1) - end, + end, State2; {error, Err} -> send(State, Err) @@ -244,11 +244,11 @@ init([State, Opts]) -> {_, OptString} -> ProtoOpts = str:join(OptString, <<$|>>), [{protocol_options, ProtoOpts}|TLSOpts1] - end, + end, TLSOpts3 = case proplists:get_bool(tls_compression, Opts) of false -> [compression_none | TLSOpts2]; true -> TLSOpts2 - end, + end, State1 = State#{tls_options => TLSOpts3, auth_domains => sets:new(), xmlns => ?NS_SERVER, @@ -276,7 +276,7 @@ handle_info(Info, #{server_host := LServer} = State) -> terminate(Reason, #{auth_domains := AuthDomains}) -> case Reason of - {process_limit, _} -> + {process_limit, _} -> sets:fold( fun(Host, _) -> ejabberd_s2s:external_host_overloaded(Host) @@ -294,13 +294,13 @@ code_change(_OldVsn, State, _Extra) -> -spec check_from_to(jid(), jid(), state()) -> ok | {error, stream_error()}. check_from_to(From, To, State) -> case check_from(From, State) of - true -> + true -> case check_to(To, State) of - true -> + true -> ok; - false -> + false -> {error, xmpp:serr_host_unknown()} - end; + end; false -> {error, xmpp:serr_invalid_from()} end. diff --git a/src/ejabberd_s2s_out.erl b/src/ejabberd_s2s_out.erl index 70ab0cfe4..a923860f3 100644 --- a/src/ejabberd_s2s_out.erl +++ b/src/ejabberd_s2s_out.erl @@ -2,7 +2,7 @@ %%% Created : 16 Dec 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -54,10 +54,10 @@ %%%=================================================================== start(From, To, Opts) -> case proplists:get_value(supervisor, Opts, true) of - true -> + true -> supervisor:start_child(ejabberd_s2s_out_sup, [From, To, Opts]); - _ -> + _ -> xmpp_stream_out:start(?MODULE, [ejabberd_socket, From, To, Opts], ejabberd_config:fsm_limit_opts([])) end. @@ -274,7 +274,7 @@ handle_cast({update_state, Fun}, State) -> case Fun of {M, F, A} -> erlang:apply(M, F, [State|A]); _ when is_function(Fun) -> Fun(State) - end; + end; handle_cast(Msg, #{server := LServer} = State) -> ejabberd_hooks:run_fold(s2s_out_handle_cast, LServer, State, [Msg]). @@ -293,7 +293,7 @@ terminate(Reason, #{server := LServer, State1 = case Reason of normal -> State; _ -> State#{stop_reason => internal_failure} - end, + end, bounce_queue(State1), bounce_message_queue(State1). @@ -347,9 +347,9 @@ mk_bounce_error(Lang, #{stop_reason := Why}) -> xmpp:err_internal_server_error(); {dns, _} -> xmpp:err_remote_server_not_found(Reason, Lang); - _ -> + _ -> xmpp:err_remote_server_timeout(Reason, Lang) - end; + end; mk_bounce_error(_Lang, _State) -> %% We should not be here. Probably :) xmpp:err_remote_server_not_found(). diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index d84de3db4..dd949f2f9 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -2,7 +2,7 @@ %%% Created : 11 Dec 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -101,21 +101,21 @@ handle_stream_start(_StreamStart, lang := Lang, host_opts := HostOpts} = State) -> case ejabberd_router:is_my_host(RemoteServer) of - true -> + true -> Txt = <<"Unable to register route on existing local domain">>, xmpp_stream_in:send(State, xmpp:serr_conflict(Txt, Lang)); - false -> + false -> NewHostOpts = case dict:is_key(RemoteServer, HostOpts) of true -> HostOpts; false -> case dict:find(global, HostOpts) of - {ok, GlobalPass} -> + {ok, GlobalPass} -> dict:from_list([{RemoteServer, GlobalPass}]); - error -> + error -> HostOpts - end - end, + end + end, State#{host_opts => NewHostOpts} end. @@ -125,7 +125,7 @@ get_password_fun(#{remote_server := RemoteServer, host_opts := HostOpts}) -> fun(_) -> case dict:find(RemoteServer, HostOpts) of - {ok, Password} -> + {ok, Password} -> {Password, undefined}; error -> ?ERROR_MSG("(~s) Domain ~s is unconfigured for " @@ -144,10 +144,10 @@ handle_auth_success(_, Mech, _, "for ~s from ~s", [SockMod:pp(Socket), Mech, RemoteServer, ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]), - lists:foreach( - fun (H) -> - ejabberd_router:register_route(H, ?MYNAME), - ejabberd_hooks:run(component_connected, [H]) + lists:foreach( + fun (H) -> + ejabberd_router:register_route(H, ?MYNAME), + ejabberd_hooks:run(component_connected, [H]) end, dict:fetch_keys(HostOpts)), State. @@ -165,19 +165,19 @@ handle_auth_failure(_, Mech, Reason, handle_authenticated_packet(Pkt, #{lang := Lang} = State) -> From = xmpp:get_from(Pkt), case check_from(From, State) of - true -> + true -> To = xmpp:get_to(Pkt), ejabberd_router:route(From, To, Pkt), State; - false -> - Txt = <<"Improper domain part of 'from' attribute">>, + false -> + Txt = <<"Improper domain part of 'from' attribute">>, Err = xmpp:serr_invalid_from(Txt, Lang), xmpp_stream_in:send(State, Err) end. handle_info({route, From, To, Packet}, #{access := Access} = State) -> case acl:match_rule(global, Access, From) of - allow -> + allow -> Pkt = xmpp:set_from_to(Packet, From, To), xmpp_stream_in:send(State, Pkt); deny -> @@ -195,11 +195,11 @@ terminate(Reason, #{stream_state := StreamState, host_opts := HostOpts}) -> established -> lists:foreach( fun(H) -> - ejabberd_router:unregister_route(H), + ejabberd_router:unregister_route(H), ejabberd_hooks:run(component_disconnected, [H, Reason]) end, dict:fetch_keys(HostOpts)); _ -> - ok + ok end. code_change(_OldVsn, State, _Extra) -> diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 5eb671149..98aaed573 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -5,7 +5,7 @@ %%% Created : 24 Nov 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -777,7 +777,7 @@ force_update_presence({LUser, LServer}) -> get_sm_backend(Host) -> DBType = case ejabberd_config:get_option( - {sm_db_type, Host}, + {sm_db_type, Host}, fun(T) -> ejabberd_config:v_db(?MODULE, T) end) of undefined -> ejabberd_config:default_ram_db(Host, ?MODULE); diff --git a/src/ejabberd_sm_mnesia.erl b/src/ejabberd_sm_mnesia.erl index ed38ceee9..028f301ed 100644 --- a/src/ejabberd_sm_mnesia.erl +++ b/src/ejabberd_sm_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2015-2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : ejabberd_sm_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 9 Mar 2015 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(ejabberd_sm_mnesia). -behaviour(gen_server). @@ -82,14 +98,11 @@ init([]) -> update_tables(), ejabberd_mnesia:create(?MODULE, session, [{ram_copies, [node()]}, - {attributes, record_info(fields, session)}]), + {attributes, record_info(fields, session)}, + {index, [usr,us]}]), ejabberd_mnesia:create(?MODULE, session_counter, [{ram_copies, [node()]}, {attributes, record_info(fields, session_counter)}]), - mnesia:add_table_index(session, usr), - mnesia:add_table_index(session, us), - mnesia:add_table_copy(session, node(), ram_copies), - mnesia:add_table_copy(session_counter, node(), ram_copies), mnesia:subscribe(system), {ok, #state{}}. diff --git a/src/ejabberd_sm_redis.erl b/src/ejabberd_sm_redis.erl index 049f1de58..689e0ccdb 100644 --- a/src/ejabberd_sm_redis.erl +++ b/src/ejabberd_sm_redis.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2015-2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : ejabberd_sm_redis.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 11 Mar 2015 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(ejabberd_sm_redis). -behaviour(ejabberd_config). diff --git a/src/ejabberd_sm_sql.erl b/src/ejabberd_sm_sql.erl index 2a7b80c19..d59c3670a 100644 --- a/src/ejabberd_sm_sql.erl +++ b/src/ejabberd_sm_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2015-2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : ejabberd_sm_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 9 Mar 2015 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(ejabberd_sm_sql). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/ejabberd_socket.erl b/src/ejabberd_socket.erl index 83b7ae9b9..c7b57a6a1 100644 --- a/src/ejabberd_socket.erl +++ b/src/ejabberd_socket.erl @@ -5,7 +5,7 @@ %%% Created : 23 Aug 2006 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -55,16 +55,14 @@ -include("xmpp.hrl"). -include("logger.hrl"). --type sockmod() :: ejabberd_http_bind | - ejabberd_bosh | +-type sockmod() :: ejabberd_bosh | ejabberd_http_ws | gen_tcp | fast_tls | ezlib. -type receiver() :: pid () | atom(). -type socket() :: pid() | inet:socket() | fast_tls:tls_socket() | ezlib:zlib_socket() | - ejabberd_bosh:bind_socket() | - ejabberd_http_bind:bind_socket(). + ejabberd_bosh:bind_socket(). -record(socket_state, {sockmod = gen_tcp :: sockmod(), socket = self() :: socket(), @@ -92,22 +90,22 @@ start(Module, SockMod, Socket, Opts) -> case Module:socket_type() of independent -> {ok, independent}; - xml_stream -> + xml_stream -> MaxStanzaSize = proplists:get_value(max_stanza_size, Opts, infinity), {ReceiverMod, Receiver, RecRef} = try SockMod:custom_receiver(Socket) of - {receiver, RecMod, RecPid} -> + {receiver, RecMod, RecPid} -> {RecMod, RecPid, RecMod} catch _:_ -> RecPid = ejabberd_receiver:start( Socket, SockMod, none, MaxStanzaSize), {ejabberd_receiver, RecPid, RecPid} - end, - SocketData = #socket_state{sockmod = SockMod, - socket = Socket, receiver = RecRef}, - case Module:start({?MODULE, SocketData}, Opts) of - {ok, Pid} -> - case SockMod:controlling_process(Socket, Receiver) of + end, + SocketData = #socket_state{sockmod = SockMod, + socket = Socket, receiver = RecRef}, + case Module:start({?MODULE, SocketData}, Opts) of + {ok, Pid} -> + case SockMod:controlling_process(Socket, Receiver) of ok -> ReceiverMod:become_controller(Receiver, Pid), {ok, Receiver}; @@ -116,27 +114,27 @@ start(Module, SockMod, Socket, Opts) -> Err end; Err -> - SockMod:close(Socket), - case ReceiverMod of - ejabberd_receiver -> ReceiverMod:close(Receiver); - _ -> ok + SockMod:close(Socket), + case ReceiverMod of + ejabberd_receiver -> ReceiverMod:close(Receiver); + _ -> ok end, Err - end; - raw -> - case Module:start({SockMod, Socket}, Opts) of - {ok, Pid} -> - case SockMod:controlling_process(Socket, Pid) of + end; + raw -> + case Module:start({SockMod, Socket}, Opts) of + {ok, Pid} -> + case SockMod:controlling_process(Socket, Pid) of ok -> {ok, Pid}; {error, _} = Err -> SockMod:close(Socket), Err - end; + end; Err -> SockMod:close(Socket), Err - end + end end. connect(Addr, Port, Opts) -> @@ -261,7 +259,6 @@ get_transport(#socket_state{sockmod = SockMod, fast_tls -> tls_zlib end; ejabberd_bosh -> http_bind; - ejabberd_http_bind -> http_bind; ejabberd_http_ws -> websocket end. diff --git a/src/ejabberd_sql.erl b/src/ejabberd_sql.erl index 8db8b6c5f..46dd68297 100644 --- a/src/ejabberd_sql.erl +++ b/src/ejabberd_sql.erl @@ -5,7 +5,7 @@ %%% Created : 8 Dec 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -279,8 +279,8 @@ init([Host, StartInterval]) -> connecting(connect, #state{host = Host} = State) -> ConnectRes = case db_opts(Host) of - [mysql | Args] -> apply(fun mysql_connect/5, Args); - [pgsql | Args] -> apply(fun pgsql_connect/5, Args); + [mysql | Args] -> apply(fun mysql_connect/7, Args); + [pgsql | Args] -> apply(fun pgsql_connect/7, Args); [sqlite | Args] -> apply(fun sqlite_connect/1, Args); [mssql | Args] -> apply(fun odbc_connect/1, Args); [odbc | Args] -> apply(fun odbc_connect/1, Args) @@ -782,13 +782,14 @@ sqlite_to_odbc(_Host, _) -> %% part of init/1 %% Open a database connection to PostgreSQL -pgsql_connect(Server, Port, DB, Username, Password) -> +pgsql_connect(Server, Port, DB, Username, Password, Transport, SSLOpts) -> case pgsql:connect([{host, Server}, {database, DB}, {user, Username}, {password, Password}, {port, Port}, - {as_binary, true}]) of + {transport, Transport}, + {as_binary, true}|SSLOpts]) of {ok, Ref} -> pgsql:squery(Ref, [<<"alter database \"">>, DB, <<"\" set ">>, <<"standard_conforming_strings='off';">>]), @@ -837,7 +838,7 @@ pgsql_execute_to_odbc(_) -> {updated, undefined}. %% part of init/1 %% Open a database connection to MySQL -mysql_connect(Server, Port, DB, Username, Password) -> +mysql_connect(Server, Port, DB, Username, Password, _, _) -> case p1_mysql_conn:start(binary_to_list(Server), Port, binary_to_list(Username), binary_to_list(Password), @@ -921,6 +922,14 @@ db_opts(Host) -> Server = ejabberd_config:get_option({sql_server, Host}, fun iolist_to_binary/1, <<"localhost">>), + Transport = case ejabberd_config:get_option( + {sql_ssl, Host}, + fun(B) when is_boolean(B) -> B end, + false) of + false -> tcp; + true -> ssl + end, + warn_if_ssl_unsupported(Transport, Type), case Type of odbc -> [odbc, Server]; @@ -944,15 +953,54 @@ db_opts(Host) -> Pass = ejabberd_config:get_option({sql_password, Host}, fun iolist_to_binary/1, <<"">>), + SSLOpts = get_ssl_opts(Transport, Host), case Type of mssql -> [mssql, <<"DSN=", Host/binary, ";UID=", User/binary, ";PWD=", Pass/binary>>]; _ -> - [Type, Server, Port, DB, User, Pass] + [Type, Server, Port, DB, User, Pass, Transport, SSLOpts] end end. +warn_if_ssl_unsupported(tcp, _) -> + ok; +warn_if_ssl_unsupported(ssl, pgsql) -> + ok; +warn_if_ssl_unsupported(ssl, Type) -> + ?WARNING_MSG("SSL connection is not supported for ~s", [Type]). + +get_ssl_opts(ssl, Host) -> + Opts1 = case ejabberd_config:get_option({sql_ssl_certfile, Host}, + fun iolist_to_binary/1) of + undefined -> []; + CertFile -> [{certfile, CertFile}] + end, + Opts2 = case ejabberd_config:get_option({sql_ssl_cafile, Host}, + fun iolist_to_binary/1) of + undefined -> Opts1; + CAFile -> [{cacertfile, CAFile}|Opts1] + end, + case ejabberd_config:get_option({sql_ssl_verify, Host}, + fun(B) when is_boolean(B) -> B end, + false) of + true -> + case lists:keymember(cacertfile, 1, Opts2) of + true -> + [{verify, verify_peer}|Opts2]; + false -> + ?WARNING_MSG("SSL verification is enabled for " + "SQL connection, but option " + "'sql_ssl_cafile' is not set; " + "verification will be disabled", []), + Opts2 + end; + false -> + Opts2 + end; +get_ssl_opts(tcp, _) -> + []. + init_mssql(Host) -> Server = ejabberd_config:get_option({sql_server, Host}, fun iolist_to_binary/1, @@ -1061,7 +1109,12 @@ opt_type(sql_type) -> (odbc) -> odbc end; opt_type(sql_username) -> fun iolist_to_binary/1; +opt_type(sql_ssl) -> fun(B) when is_boolean(B) -> B end; +opt_type(sql_ssl_verify) -> fun(B) when is_boolean(B) -> B end; +opt_type(sql_ssl_certfile) -> fun iolist_to_binary/1; +opt_type(sql_ssl_cafile) -> fun iolist_to_binary/1; opt_type(_) -> [max_fsm_queue, sql_database, sql_keepalive_interval, sql_password, sql_port, sql_server, sql_type, - sql_username]. + sql_username, sql_ssl, sql_ssl_verify, sql_ssl_cerfile, + sql_ssl_cafile]. diff --git a/src/ejabberd_sql_pt.erl b/src/ejabberd_sql_pt.erl index e51b7f928..e90947a5f 100644 --- a/src/ejabberd_sql_pt.erl +++ b/src/ejabberd_sql_pt.erl @@ -2,9 +2,27 @@ %%% File : ejabberd_sql_pt.erl %%% Author : Alexey Shchepin <alexey@process-one.net> %%% Description : Parse transform for SQL queries -%%% %%% Created : 20 Jan 2016 by Alexey Shchepin <alexey@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(ejabberd_sql_pt). %% API diff --git a/src/ejabberd_sql_sup.erl b/src/ejabberd_sql_sup.erl index 93bc10ac5..995f90317 100644 --- a/src/ejabberd_sql_sup.erl +++ b/src/ejabberd_sql_sup.erl @@ -5,7 +5,7 @@ %%% Created : 22 Dec 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_stun.erl b/src/ejabberd_stun.erl index 3c91117d1..ebe98f476 100644 --- a/src/ejabberd_stun.erl +++ b/src/ejabberd_stun.erl @@ -1,12 +1,11 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2014, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : ejabberd_stun.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> +%%% Purpose : STUN RFC-5766 %%% Created : 8 May 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net> %%% -%%% ejabberd, Copyright (C) 2013-2016 ProcessOne +%%% +%%% ejabberd, Copyright (C) 2013-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_sup.erl b/src/ejabberd_sup.erl index 27ed70137..f9a48be4d 100644 --- a/src/ejabberd_sup.erl +++ b/src/ejabberd_sup.erl @@ -5,7 +5,7 @@ %%% Created : 31 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_system_monitor.erl b/src/ejabberd_system_monitor.erl index 5d52a041d..324362b88 100644 --- a/src/ejabberd_system_monitor.erl +++ b/src/ejabberd_system_monitor.erl @@ -5,7 +5,7 @@ %%% Created : 21 Mar 2007 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_tmp_sup.erl b/src/ejabberd_tmp_sup.erl index 8b9f4fc12..64fb69211 100644 --- a/src/ejabberd_tmp_sup.erl +++ b/src/ejabberd_tmp_sup.erl @@ -5,7 +5,7 @@ %%% Created : 18 Jul 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_update.erl b/src/ejabberd_update.erl index 75ccc3dea..96244448a 100644 --- a/src/ejabberd_update.erl +++ b/src/ejabberd_update.erl @@ -5,7 +5,7 @@ %%% Created : 27 Jan 2006 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_web.erl b/src/ejabberd_web.erl index 523feb9c7..7a40d2c70 100644 --- a/src/ejabberd_web.erl +++ b/src/ejabberd_web.erl @@ -6,7 +6,7 @@ %%% Created : 28 Feb 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejabberd_web_admin.erl b/src/ejabberd_web_admin.erl index e1c0760e9..7ab5451c7 100644 --- a/src/ejabberd_web_admin.erl +++ b/src/ejabberd_web_admin.erl @@ -5,7 +5,7 @@ %%% Created : 9 Apr 2004 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -349,7 +349,7 @@ make_xhtml(Els, Host, Node, Lang, JID) -> [?XAE(<<"div">>, [{<<"id">>, <<"copyright">>}], [?XE(<<"p">>, [?AC(<<"https://www.ejabberd.im/">>, <<"ejabberd">>), - ?C(<<" (c) 2002-2016 ">>), + ?C(<<" (c) 2002-2017 ">>), ?AC(<<"https://www.process-one.net/">>, <<"ProcessOne, leader in messaging and push solutions">>)] )])])])]}}. @@ -1805,9 +1805,8 @@ histogram([], _Integral, _Current, Count, Hist) -> %%%% get_nodes get_nodes(Lang) -> - RunningNodes = mnesia:system_info(running_db_nodes), - StoppedNodes = lists:usort(mnesia:system_info(db_nodes) - ++ mnesia:system_info(extra_db_nodes)) + RunningNodes = ejabberd_cluster:get_nodes(), + StoppedNodes = ejabberd_cluster:get_known_nodes() -- RunningNodes, FRN = if RunningNodes == [] -> ?CT(<<"None">>); true -> @@ -1833,8 +1832,8 @@ get_nodes(Lang) -> ?XCT(<<"h3">>, <<"Stopped Nodes">>), FSN]. search_running_node(SNode) -> - search_running_node(SNode, - mnesia:system_info(running_db_nodes)). + RunningNodes = ejabberd_cluster:get_nodes(), + search_running_node(SNode, RunningNodes). search_running_node(_, []) -> false; search_running_node(SNode, [Node | Nodes]) -> diff --git a/src/ejabberd_websocket.erl b/src/ejabberd_websocket.erl index 76568aa2d..d87bf9bb1 100644 --- a/src/ejabberd_websocket.erl +++ b/src/ejabberd_websocket.erl @@ -33,7 +33,7 @@ %%% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE %%% POSSIBILITY OF SUCH DAMAGE. %%% ========================================================================================================== -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%%---------------------------------------------------------------------- -module(ejabberd_websocket). diff --git a/src/ejabberd_xmlrpc.erl b/src/ejabberd_xmlrpc.erl index 2792d08c1..fec6fb96a 100644 --- a/src/ejabberd_xmlrpc.erl +++ b/src/ejabberd_xmlrpc.erl @@ -5,7 +5,7 @@ %%% Created : 21 Aug 2007 by Badlop <badlop@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ejd2sql.erl b/src/ejd2sql.erl index 9b7fdbbef..ae37a9b55 100644 --- a/src/ejd2sql.erl +++ b/src/ejd2sql.erl @@ -5,7 +5,7 @@ %%% Created : 22 Aug 2005 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/eldap_filter.erl b/src/eldap_filter.erl index d46e410a4..ac33f985a 100644 --- a/src/eldap_filter.erl +++ b/src/eldap_filter.erl @@ -6,7 +6,7 @@ %%% Author: Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/eldap_pool.erl b/src/eldap_pool.erl index 8e0096f86..3927e4436 100644 --- a/src/eldap_pool.erl +++ b/src/eldap_pool.erl @@ -5,7 +5,7 @@ %%% Created : 12 Nov 2006 by Evgeniy Khramtsov <xram@jabber.ru> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/eldap_utils.erl b/src/eldap_utils.erl index 9b9e5fbce..8c071c6dd 100644 --- a/src/eldap_utils.erl +++ b/src/eldap_utils.erl @@ -5,7 +5,7 @@ %%% Created : 12 Oct 2006 by Mickael Remond <mremond@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/elixir_logger_backend.erl b/src/elixir_logger_backend.erl index c055853f7..4a928b43f 100644 --- a/src/elixir_logger_backend.erl +++ b/src/elixir_logger_backend.erl @@ -1,11 +1,11 @@ %%%------------------------------------------------------------------- -%%% @author Mickael Remond <mremond@process-one.net> -%%% @doc -%%% This module bridges lager logs to Elixir Logger. -%%% @end +%%% File : elixir_logger_backend.erl +%%% Author : Mickael Remond <mremond@process-one.net> +%%% Purpose : This module bridges lager logs to Elixir Logger. %%% Created : 9 March 2016 by Mickael Remond <mremond@process-one.net> %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/ext_mod.erl b/src/ext_mod.erl index 5b970623b..7090c25a5 100644 --- a/src/ext_mod.erl +++ b/src/ext_mod.erl @@ -5,7 +5,7 @@ %%% Created : 19 Feb 2015 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2006-2016 ProcessOne +%%% ejabberd, Copyright (C) 2006-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -29,11 +29,13 @@ -author("Christophe Romain <christophe.romain@process-one.net>"). -export([start/0, stop/0, update/0, check/1, - available_command/0, available/0, available/1, - installed_command/0, installed/0, installed/1, - install/1, uninstall/1, upgrade/0, upgrade/1, - add_sources/2, del_sources/1, modules_dir/0, - config_dir/0, opt_type/1, get_commands_spec/0]). + available_command/0, available/0, available/1, + installed_command/0, installed/0, installed/1, + install/1, uninstall/1, upgrade/0, upgrade/1, + add_sources/2, del_sources/1, modules_dir/0, + config_dir/0, opt_type/1, get_commands_spec/0]). + +-export([compile_erlang_file/2, compile_elixir_file/2]). -include("ejabberd_commands.hrl"). -include("logger.hrl"). @@ -341,14 +343,17 @@ copy(From, To) -> SubTo = filename:join(To, F), copy(SubFrom, SubTo) end, - lists:foldl(fun({ok, C2}, {ok, C1}) -> {ok, C1+C2}; - ({ok, _}, Error) -> Error; + lists:foldl(fun(ok, ok) -> ok; + (ok, Error) -> Error; (Error, _) -> Error - end, {ok, 0}, + end, ok, [Copy(filename:basename(X)) || X<-filelib:wildcard(From++"/*")]); false -> filelib:ensure_dir(To), - file:copy(From, To) + case file:copy(From, To) of + {ok, _} -> ok; + Error -> Error + end end. delete_path(Path) -> @@ -461,19 +466,15 @@ compile_and_install(Module, Spec) -> LibDir = module_lib_dir(Module), case filelib:is_dir(SrcDir) of true -> - {ok, Dir} = file:get_cwd(), - file:set_cwd(SrcDir), - Result = case compile_deps(Module, Spec, LibDir) of + case compile_deps(SrcDir) of ok -> - case compile(Module, Spec, LibDir) of - ok -> install(Module, Spec, LibDir); + case compile(SrcDir) of + ok -> install(Module, Spec, SrcDir, LibDir); Error -> Error end; Error -> Error - end, - file:set_cwd(Dir), - Result; + end; false -> Path = proplists:get_value(url, Spec, ""), case add_sources(Module, Path) of @@ -482,78 +483,54 @@ compile_and_install(Module, Spec) -> end end. -compile_deps(_Module, _Spec, DestDir) -> - case filelib:is_dir("deps") of - true -> ok; - false -> fetch_rebar_deps() +compile_deps(LibDir) -> + Deps = filename:join(LibDir, "deps"), + case filelib:is_dir(Deps) of + true -> ok; % assume deps are included + false -> fetch_rebar_deps(LibDir) end, - Ebin = filename:join(DestDir, "ebin"), - filelib:ensure_dir(filename:join(Ebin, ".")), - Result = lists:foldl(fun(Dep, Acc) -> - Inc = filename:join(Dep, "include"), - Lib = filename:join(Dep, "lib"), - Src = filename:join(Dep, "src"), - Options = [{outdir, Ebin}, {i, Inc}], - [file:copy(App, Ebin) || App <- filelib:wildcard(Src++"/*.app")], - - %% Compile erlang files - Acc1 = Acc ++ [case compile:file(File, Options) of - {ok, _} -> ok; - {ok, _, _} -> ok; - {ok, _, _, _} -> ok; - error -> {error, {compilation_failed, File}}; - Error -> Error - end - || File <- filelib:wildcard(Src++"/*.erl")], - - %% Compile elixir files - Acc1 ++ [case compile_elixir_file(Ebin, File) of - {ok, _} -> ok; - {error, File} -> {error, {compilation_failed, File}} - end - || File <- filelib:wildcard(Lib ++ "/*.ex")] - - end, [], filelib:wildcard("deps/*")), + Rs = [compile(Dep) || Dep <- filelib:wildcard(filename:join(Deps, "*"))], + compile_result(Rs). + +compile(LibDir) -> + Bin = filename:join(LibDir, "ebin"), + Inc = filename:join(LibDir, "include"), + Lib = filename:join(LibDir, "lib"), + Src = filename:join(LibDir, "src"), + Options = [{outdir, Bin}, {i, Inc} | compile_options()], + filelib:ensure_dir(filename:join(Bin, ".")), + [copy(App, Bin) || App <- filelib:wildcard(Src++"/*.app")], + Er = [compile_erlang_file(Bin, File, Options) + || File <- filelib:wildcard(Src++"/*.erl")], + Ex = [compile_elixir_file(Bin, File) + || File <- filelib:wildcard(Lib ++ "/*.ex")], + compile_result(Er++Ex). + +compile_result(Results) -> case lists:dropwhile( - fun(ok) -> true; - (_) -> false - end, Result) of + fun({ok, _}) -> true; + (_) -> false + end, Results) of [] -> ok; [Error|_] -> Error end. -compile(_Module, _Spec, DestDir) -> - Ebin = filename:join(DestDir, "ebin"), - filelib:ensure_dir(filename:join(Ebin, ".")), - EjabBin = filename:dirname(code:which(ejabberd)), - EjabInc = filename:join(filename:dirname(EjabBin), "include"), - Options = [{outdir, Ebin}, {i, "include"}, {i, EjabInc}, - verbose, report_errors, report_warnings], - [file:copy(App, Ebin) || App <- filelib:wildcard("src/*.app")], - - %% Compile erlang files - Result = [case compile:file(File, Options) of - {ok, _} -> ok; - {ok, _, _} -> ok; - {ok, _, _, _} -> ok; - error -> {error, {compilation_failed, File}}; - Error -> Error - end - || File <- filelib:wildcard("src/*.erl")], - - %% Compile elixir files - Result1 = Result ++ [case compile_elixir_file(Ebin, File) of - {ok, _} -> ok; - {error, File} -> {error, {compilation_failed, File}} - end - || File <- filelib:wildcard("lib/*.ex")], - - case lists:dropwhile( - fun(ok) -> true; - (_) -> false - end, Result1) of - [] -> ok; - [Error|_] -> Error +compile_options() -> + [verbose, report_errors, report_warnings] + ++ [{i, filename:join(code:lib_dir(App), "include")} + || App <- [fast_xml, xmpp, ejabberd]]. + +compile_erlang_file(Dest, File) -> + compile_erlang_file(Dest, File, compile_options()). + +compile_erlang_file(Dest, File, ErlOptions) -> + Options = [{outdir, Dest} | ErlOptions], + case compile:file(File, Options) of + {ok, Module} -> {ok, Module}; + {ok, Module, _} -> {ok, Module}; + {ok, Module, _, _} -> {ok, Module}; + error -> {error, {compilation_failed, File}}; + {error, E, W} -> {error, {compilation_failed, File, E, W}} end. compile_elixir_file(Dest, File) when is_list(Dest) and is_list(File) -> @@ -563,13 +540,15 @@ compile_elixir_file(Dest, File) -> try 'Elixir.Kernel.ParallelCompiler':files_to_path([File], Dest, []) of [Module] -> {ok, Module} catch - _ -> {error, File} + _ -> {error, {compilation_failed, File}} end. -install(Module, Spec, DestDir) -> - Errors = lists:dropwhile(fun({_, {ok, _}}) -> true; +install(Module, Spec, SrcDir, LibDir) -> + {ok, CurDir} = file:get_cwd(), + file:set_cwd(SrcDir), + Errors = lists:dropwhile(fun({_, ok}) -> true; (_) -> false - end, [{File, copy(File, filename:join(DestDir, File))} + end, [{File, copy(File, filename:join(LibDir, File))} || File <- filelib:wildcard("{ebin,priv,conf,include}/**")]), Result = case Errors of [{F, {error, E}}|_] -> @@ -577,25 +556,28 @@ install(Module, Spec, DestDir) -> [] -> SpecPath = proplists:get_value(path, Spec), SpecFile = filename:flatten([Module, ".spec"]), - copy(filename:join(SpecPath, SpecFile), filename:join(DestDir, SpecFile)) + copy(filename:join(SpecPath, SpecFile), filename:join(LibDir, SpecFile)) end, - case Result of - {ok, _} -> ok; - Error -> Error - end. + file:set_cwd(CurDir), + Result. %% -- minimalist rebar spec parser, only support git -fetch_rebar_deps() -> - case rebar_deps("rebar.config")++rebar_deps("rebar.config.script") of +fetch_rebar_deps(SrcDir) -> + case rebar_deps(filename:join(SrcDir, "rebar.config")) + ++ rebar_deps(filename:join(SrcDir, "rebar.config.script")) of [] -> ok; Deps -> + {ok, CurDir} = file:get_cwd(), + file:set_cwd(SrcDir), filelib:ensure_dir(filename:join("deps", ".")), lists:foreach(fun({_App, Cmd}) -> os:cmd("cd deps; "++Cmd++"; cd ..") - end, Deps) + end, Deps), + file:set_cwd(CurDir) end. + rebar_deps(Script) -> case file:script(Script) of {ok, Config} when is_list(Config) -> @@ -636,7 +618,7 @@ format({Key, Val}) -> % TODO: improve Yaml parsing opt_type(allow_contrib_modules) -> fun (false) -> false; - (no) -> false; - (_) -> true + (no) -> false; + (_) -> true end; opt_type(_) -> [allow_contrib_modules]. diff --git a/src/extauth.erl b/src/extauth.erl index 6063d3670..6ec7e7760 100644 --- a/src/extauth.erl +++ b/src/extauth.erl @@ -5,7 +5,7 @@ %%% Created : 30 Jul 2004 by Leif Johansson <leifj@it.su.se> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/gen_iq_handler.erl b/src/gen_iq_handler.erl index 4a7a03c27..74c6f4da0 100644 --- a/src/gen_iq_handler.erl +++ b/src/gen_iq_handler.erl @@ -5,7 +5,7 @@ %%% Created : 22 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 1ee949912..c77726ef1 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -5,7 +5,7 @@ %%% Created : 24 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/gen_pubsub_node.erl b/src/gen_pubsub_node.erl index 5690c8a1d..8fd8ed59e 100644 --- a/src/gen_pubsub_node.erl +++ b/src/gen_pubsub_node.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/gen_pubsub_nodetree.erl b/src/gen_pubsub_nodetree.erl index a18bc8d39..f8fdc43a2 100644 --- a/src/gen_pubsub_nodetree.erl +++ b/src/gen_pubsub_nodetree.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/jd2ejd.erl b/src/jd2ejd.erl index fd70f8b1e..c344b15a0 100644 --- a/src/jd2ejd.erl +++ b/src/jd2ejd.erl @@ -5,7 +5,7 @@ %%% Created : 2 Feb 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/jlib.erl b/src/jlib.erl index 939baae84..33fc7d6bb 100644 --- a/src/jlib.erl +++ b/src/jlib.erl @@ -5,7 +5,7 @@ %%% Created : 23 Nov 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_adhoc.erl b/src/mod_adhoc.erl index 5b582d82b..fc0c62831 100644 --- a/src/mod_adhoc.erl +++ b/src/mod_adhoc.erl @@ -5,7 +5,7 @@ %%% Created : 15 Nov 2005 by Magnus Henoch <henoch@dtek.chalmers.se> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index 39feb9e26..472e9fbe3 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -5,7 +5,7 @@ %%% Created : 10 Aug 2008 by Badlop <badlop@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -36,7 +36,7 @@ % Commands API -export([ % Adminsys - compile/1, get_cookie/0, remove_node/1, export2sql/2, + compile/1, get_cookie/0, export2sql/2, restart_module/2, % Sessions @@ -145,15 +145,6 @@ get_commands_spec() -> result = {cookie, string}, result_example = "MWTAVMODFELNLSMYXPPD", result_desc = "Erlang cookie used for authentication by ejabberd"}, - #ejabberd_commands{name = remove_node, tags = [erlang], - desc = "Remove an ejabberd node from Mnesia clustering config", - module = ?MODULE, function = remove_node, - args = [{node, string}], - args_example = ["ejabberd@server2"], - args_desc = ["Name of erlang node to remove"], - result = {res, rescode}, - result_example = ok, - result_desc = "Status code: 0 on success, 1 otherwise"}, #ejabberd_commands{name = export2sql, tags = [mnesia], desc = "Export Mnesia tables to files in directory", module = ?MODULE, function = export2sql, @@ -467,7 +458,7 @@ get_commands_spec() -> {user, binary}, {server, binary}], result = {res, rescode}}, #ejabberd_commands{name = process_rosteritems, tags = [roster], - desc = "List or delete rosteritems that match filtering options", + desc = "List/delete rosteritems that match filter (only Mnesia)", longdesc = "Explanation of each argument:\n" " - action: what to do with each rosteritem that " "matches all the filtering options\n" @@ -648,19 +639,23 @@ get_commands_spec() -> %%% -%%% Node +%%% Adminsys %%% compile(File) -> - compile:file(File). + Ebin = filename:join(code:lib_dir(ejabberd), "ebin"), + case ext_mod:compile_erlang_file(Ebin, File) of + {ok, Module} -> + code:purge(Module), + code:load_file(Module), + ok; + _ -> + error + end. get_cookie() -> atom_to_list(erlang:get_cookie()). -remove_node(Node) -> - mnesia:del_table_copy(schema, list_to_atom(Node)), - ok. - restart_module(Host, Module) when is_binary(Module) -> restart_module(Host, jlib:binary_to_atom(Module)); restart_module(Host, Module) when is_atom(Module) -> @@ -1111,8 +1106,8 @@ set_vcard(User, Host, Name, Subname, SomeContent) -> get_vcard_content(User, Server, Data) -> case mod_vcard:get_vcard(jid:nodeprep(User), jid:nameprep(Server)) of - [_|_] = Els -> - case get_vcard(Data, Els) of + [El|_] -> + case get_vcard(Data, El) of [false] -> throw(error_no_value_found_in_vcard); ElemList -> ?DEBUG("ELS ~p", [ElemList]), [fxml:get_tag_cdata(Elem) || Elem <- ElemList] end; diff --git a/src/mod_announce.erl b/src/mod_announce.erl index 15524ce1e..d4740fa5f 100644 --- a/src/mod_announce.erl +++ b/src/mod_announce.erl @@ -5,7 +5,7 @@ %%% Created : 11 Aug 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_announce_mnesia.erl b/src/mod_announce_mnesia.erl index 47753965d..09316189a 100644 --- a/src/mod_announce_mnesia.erl +++ b/src/mod_announce_mnesia.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_announce_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_announce_mnesia). + -behaviour(mod_announce). %% API diff --git a/src/mod_announce_riak.erl b/src/mod_announce_riak.erl index 242adee0c..b231dec9c 100644 --- a/src/mod_announce_riak.erl +++ b/src/mod_announce_riak.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_announce_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_announce_riak). + -behaviour(mod_announce). %% API diff --git a/src/mod_announce_sql.erl b/src/mod_announce_sql.erl index 90e3f9d75..42d990efc 100644 --- a/src/mod_announce_sql.erl +++ b/src/mod_announce_sql.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_announce_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_announce_sql). + -behaviour(mod_announce). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_blocking.erl b/src/mod_blocking.erl index 5195bfb73..3f9e90256 100644 --- a/src/mod_blocking.erl +++ b/src/mod_blocking.erl @@ -5,7 +5,7 @@ %%% Created : 24 Aug 2008 by Stephan Maka <stephan@spaceboyz.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -114,7 +114,7 @@ listitems_to_jids([], JIDs) -> JIDs; listitems_to_jids([#listitem{type = jid, action = deny, value = JID} = Item | Items], - JIDs) -> + JIDs) -> Match = case Item of #listitem{match_all = true} -> true; @@ -155,13 +155,13 @@ process_block(#iq{from = #jid{luser = LUser, lserver = LServer}, end, Mod = db_mod(LServer), case Mod:process_blocklist_block(LUser, LServer, Filter) of - {atomic, {ok, Default, List}} -> - UserList = make_userlist(Default, List), + {atomic, {ok, Default, List}} -> + UserList = make_userlist(Default, List), broadcast_list_update(LUser, LServer, UserList, Default), broadcast_event(LUser, LServer, #block{items = [jid:make(J) || J <- JIDs]}), xmpp:make_iq_result(IQ); - _Err -> + _Err -> ?ERROR_MSG("Error processing ~p: ~p", [{LUser, LServer, JIDs}, _Err]), Err = xmpp:err_internal_server_error(<<"Database failure">>, Lang), xmpp:make_error(IQ, Err) @@ -179,12 +179,12 @@ process_unblock_all(#iq{from = #jid{luser = LUser, lserver = LServer}, case Mod:unblock_by_filter(LUser, LServer, Filter) of {atomic, ok} -> xmpp:make_iq_result(IQ); - {atomic, {ok, Default, List}} -> - UserList = make_userlist(Default, List), + {atomic, {ok, Default, List}} -> + UserList = make_userlist(Default, List), broadcast_list_update(LUser, LServer, UserList, Default), broadcast_event(LUser, LServer, #unblock{}), xmpp:make_iq_result(IQ); - _Err -> + _Err -> ?ERROR_MSG("Error processing ~p: ~p", [{LUser, LServer}, _Err]), Err = xmpp:err_internal_server_error(<<"Database failure">>, Lang), xmpp:make_error(IQ, Err) @@ -205,13 +205,13 @@ process_unblock(#iq{from = #jid{luser = LUser, lserver = LServer}, case Mod:unblock_by_filter(LUser, LServer, Filter) of {atomic, ok} -> xmpp:make_iq_result(IQ); - {atomic, {ok, Default, List}} -> - UserList = make_userlist(Default, List), + {atomic, {ok, Default, List}} -> + UserList = make_userlist(Default, List), broadcast_list_update(LUser, LServer, UserList, Default), broadcast_event(LUser, LServer, #unblock{items = [jid:make(J) || J <- JIDs]}), xmpp:make_iq_result(IQ); - _Err -> + _Err -> ?ERROR_MSG("Error processing ~p: ~p", [{LUser, LServer, JIDs}, _Err]), Err = xmpp:err_internal_server_error(<<"Database failure">>, Lang), xmpp:make_error(IQ, Err) @@ -243,12 +243,12 @@ process_get(#iq{from = #jid{luser = LUser, lserver = LServer}, lang = Lang} = IQ) -> Mod = db_mod(LServer), case Mod:process_blocklist_get(LUser, LServer) of - error -> + error -> Err = xmpp:err_internal_server_error(<<"Database failure">>, Lang), xmpp:make_error(IQ, Err); - List -> + List -> LJIDs = listitems_to_jids(List, []), - Items = [jid:make(J) || J <- LJIDs], + Items = [jid:make(J) || J <- LJIDs], xmpp:make_iq_result(IQ, #block_list{items = Items}) end. diff --git a/src/mod_blocking_mnesia.erl b/src/mod_blocking_mnesia.erl index b64202717..f22e8171d 100644 --- a/src/mod_blocking_mnesia.erl +++ b/src/mod_blocking_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_blocking_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_blocking_mnesia). -behaviour(mod_blocking). diff --git a/src/mod_blocking_riak.erl b/src/mod_blocking_riak.erl index 1f15591ef..307cd8744 100644 --- a/src/mod_blocking_riak.erl +++ b/src/mod_blocking_riak.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_blocking_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_blocking_riak). -behaviour(mod_blocking). diff --git a/src/mod_blocking_sql.erl b/src/mod_blocking_sql.erl index 402d6de19..191c389d9 100644 --- a/src/mod_blocking_sql.erl +++ b/src/mod_blocking_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_blocking_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_blocking_sql). -behaviour(mod_blocking). diff --git a/src/mod_bosh.erl b/src/mod_bosh.erl index 43a00edce..62dc31ac8 100644 --- a/src/mod_bosh.erl +++ b/src/mod_bosh.erl @@ -7,7 +7,7 @@ %%% Created : 20 Jul 2011 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -76,37 +76,6 @@ process(_Path, _Request) -> #xmlel{name = <<"h1">>, attrs = [], children = [{xmlcdata, <<"400 Bad Request">>}]}}. -get_human_html_xmlel() -> - Heading = <<"ejabberd ", (jlib:atom_to_binary(?MODULE))/binary>>, - #xmlel{name = <<"html">>, - attrs = - [{<<"xmlns">>, <<"http://www.w3.org/1999/xhtml">>}], - children = - [#xmlel{name = <<"head">>, attrs = [], - children = - [#xmlel{name = <<"title">>, attrs = [], - children = [{xmlcdata, Heading}]}]}, - #xmlel{name = <<"body">>, attrs = [], - children = - [#xmlel{name = <<"h1">>, attrs = [], - children = [{xmlcdata, Heading}]}, - #xmlel{name = <<"p">>, attrs = [], - children = - [{xmlcdata, <<"An implementation of ">>}, - #xmlel{name = <<"a">>, - attrs = - [{<<"href">>, - <<"http://xmpp.org/extensions/xep-0206.html">>}], - children = - [{xmlcdata, - <<"XMPP over BOSH (XEP-0206)">>}]}]}, - #xmlel{name = <<"p">>, attrs = [], - children = - [{xmlcdata, - <<"This web page is only informative. To " - "use HTTP-Bind you need a Jabber/XMPP " - "client that supports it.">>}]}]}]}. - open_session(SID, Pid) -> Mod = gen_mod:ram_db_mod(global, ?MODULE), Mod:open_session(SID, Pid). @@ -185,3 +154,130 @@ mod_opt_type(ram_db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end; mod_opt_type(_) -> [json, max_concat, max_inactivity, max_pause, prebind, ram_db_type]. + + +%%%---------------------------------------------------------------------- +%%% Help Web Page +%%%---------------------------------------------------------------------- + +get_human_html_xmlel() -> + Heading = <<"ejabberd ", + (iolist_to_binary(atom_to_list(?MODULE)))/binary>>, + #xmlel{name = <<"html">>, + attrs = + [{<<"xmlns">>, <<"http://www.w3.org/1999/xhtml">>}], + children = + [#xmlel{name = <<"head">>, + children = + [#xmlel{name = <<"title">>, + children = [{xmlcdata, Heading}]}, + #xmlel{name = <<"style">>, + children = [{xmlcdata, get_style_cdata()}]}]}, + #xmlel{name = <<"body">>, + children = + [#xmlel{name = <<"div">>, + attrs = [{<<"class">>, <<"container">>}], + children = get_container_children(Heading)}]}]}. + +get_container_children(Heading) -> + [#xmlel{name = <<"div">>, + attrs = [{<<"class">>, <<"section">>}], + children = + [#xmlel{name = <<"div">>, + attrs = [{<<"class">>, <<"block">>}], + children = + [#xmlel{name = <<"a">>, + attrs = [{<<"href">>, <<"https://www.ejabberd.im">>}], + children = + [#xmlel{name = <<"img">>, + attrs = [{<<"height">>, <<"32">>}, + {<<"src">>, get_image_src()}]}]}]}]}, + #xmlel{name = <<"div">>, + attrs = [{<<"class">>, <<"white section">>}], + children = + [#xmlel{name = <<"div">>, + attrs = [{<<"class">>, <<"block">>}], + children = + [#xmlel{name = <<"h1">>, children = [{xmlcdata, Heading}]}, + #xmlel{name = <<"p">>, children = + [{xmlcdata, <<"An implementation of ">>}, + #xmlel{name = <<"a">>, + attrs = [{<<"href">>, <<"http://xmpp.org/extensions/xep-0206.html">>}], + children = [{xmlcdata, <<"XMPP over BOSH (XEP-0206)">>}]}]}, + #xmlel{name = <<"p">>, children = + [{xmlcdata, <<"This web page is only informative. To " + "use HTTP-Bind you need a Jabber/XMPP " + "client that supports it.">>}]}]}]}, + #xmlel{name = <<"div">>, + attrs = [{<<"class">>, <<"section">>}], + children = + [#xmlel{name = <<"div">>, + attrs = [{<<"class">>, <<"block">>}], + children = + [#xmlel{name = <<"a">>, + attrs = [{<<"href">>, <<"https://www.ejabberd.im">>}, + {<<"title">>, <<"ejabberd XMPP server">>}], + children = [{xmlcdata, <<"ejabberd">>}]}, + {xmlcdata, <<" is maintained by ">>}, + #xmlel{name = <<"a">>, + attrs = [{<<"href">>, <<"https://www.process-one.net">>}, + {<<"title">>, <<"ProcessOne - Leader in Instant Messaging and Push Solutions">>}], + children = [{xmlcdata, <<"ProcessOne">>}]} ]}]} + ]. + +get_style_cdata() -> + <<" + body { + margin: 0; + padding: 0; + font-family: sans-serif; + color: #fff; + } + h1 { + font-size: 3em; + color: #444; + } + p { + line-height: 1.5em; + color: #888; + } + a { + color: #fff; + } + a:hover, + a:active { + text-decoration: underline; + } + .container { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: #424A55; + background-image: -webkit-linear-gradient(270deg, rgba(48,52,62,0) 24%, #30353e 100%); + background-image: linear-gradient(-180deg, rgba(48,52,62,0) 24%, #30353e 100%); + } + .section { + padding: 3em; + } + .white.section { + background: #fff; + border-bottom: 4px solid #41AFCA; + } + .white.section a { + text-decoration: none; + color: #41AFCA; + } + .white.section a:hover, + .white.section a:active { + text-decoration: underline; + } + .block { + margin: 0 auto; + max-width: 900px; + width: 100%; + }">>. + +get_image_src() -> + <<"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAABACAYAAACgPErgAAAVtklEQVR42uydeXhU1d2ADzuyCcii4FZBZdEqVYtaUGqlikVwaRWsrWBRKIh8KgXcEAX9VECtoljcURAJICJWQLaKLAEjIHtBSNhC9oQkk2SW+36/52P+iIE5d5kzk4Fn3ud5H/7gIbnD3PPOveeeuVedygD9xLlQMh9yJ0D+GeokJAg1xcEWzOWYj0DBaQm0fXdaMCu8bROgpJVKksQj0+F84OXw/jRd7KVOdbbCFI6jdDNktlAnESVQNwSzOI6yhZBaV1UzAXiB4wj8CBtbqiRJXDIILtgL+zmOb8aoU5Xh0MMiEr5x6iSiAIZYROLo/aoayYMeocjbNlklSeKC9VAjBDM5IcEQfNZFnYq8AM8SkcJV6iSiCGYRkT1LVDWSA08Tkfy9MLaeOsUA2ot9xJHiW2KK+LW4Mvxnijg1/Pd9xQvFGiqJLUOhcT5kE5Etg0/VYI3TBOvbkyxYKURk2dpqDZb2gyEjC1SjUyBQdcQe4mtimujDHWXiD+Lr4g1iXZXkhISgBZBLZIaoU5GR0I2IVDxxkgVrNhH5z+pqDZb2g+FAJjQ4aYMFtBAfEzdils3iP8TkhYkqlMEZFuQQmcHqVGUBTOI40lLhz02TwUoGKxJAI/FxMYPYckB8Smyikvw/vlM/WHqAP4ifiHPF0fBsYyUkg5UM1okAbhV/JL5sE29TSZLBOhHJYCWDVRXgNPFVqpfXxQbJYCWDlQxWMlgRAc4VV5EYrBZ/kQxWMljJYFVLsBomdLCAS8RdJBZ7xMuSwTIcLKCO2EG8VrxdvEfsLV4F1vkJstq9BlidwN8hVleSLLgUuFzsEv6zs9g4EYIFNBAvFi87tm3WZWI7oHZ8glWnkWbb6ortCG/bsT+tDsBpcYrVpeIhzBHAHJni5XGOd5PwvnKJif0DaCh2/Pn7y/linbgFKx/qrjkWpffEHZo3qVhMBWuC2EVVA4ehay6sAYJgBeDocuh9iYqCL+F04DbxLTFNPMzxWGI6WCuBJ8Rfxi5YK34WLKC5BX3FVzj22n8S/fwcX/i9+1wcLraLVbAqr8OqgNOA31nwPLBc3HWCNU1+cbe4WBwjXhbD08A9eOcn8SNxmHij+EuxQ3iwdxP/Jr4pbsU7+2J5ehiCNuI9FkwN78sZol+0xDSYd6OH75R2BcZasALYKwZO0IWd4fd3LIS6g1XHeLBWQV1gsLgJ9wTBWgSBm1ScuBYuAvI4jrx9cOEZyiXzoUUIxhbDPm+fvFlL4PPe5oO14FslvAjnrYeXgYO4p0T8UrzJbLB2HlbCZMqbfwOjgrDD41HLCrE/LK1pKFYNxFS8sVDsK1Y5ctQeRf42HLcy3JMmNjIc6+ss+ETMRUuRH9Zd7SBS9QMwCFiDNzZBYAT4G5dTUcuC7KiClQ3dj8B6osYSAzOgoq2KMatgChF5e5RyQQXcVwL7MMNXsKOTuWAd2FBG9uhyyMMI6XPBd7GZYOUd8pP+UCn8hBEOr4KCbgYG7Ju4Z43YU0VB+LRoLu6ZpgyQAhflw2e4Y7lYS0XADzdZ8ANGsLaX88PgACHvwfLBY4Afo4T2Q9lNMZ68W0lE/J8oB5RDkxDMwDhF+XC4v6tgxZdcKLov+mBhYR4/FD8VRTRu93CE97RYTxkCuFfMxR13qSjIhoE+Tx9qPh9Mb6WqcBRqBuBli5hguQ4WUGsPvGsRKyw/hAaoGJEPy4lI4Uxlw3XHzu/XEVNKHk3QYAmWWDEecmraBqtaCE6HrCYeJpX34Jwc8eYYXp3cjHPSxWbKA9/Da3im+CeY1kBV4gNoUQILiB/6YD0JNYFP4jMoGFINwZqhNHwKLbfB5ji9/kdMBss8vk9MBcs8pasht7GLSIzHOQfFX6kYApyFuw/FFz38jveJitxBqhI3QMsS2IiQMMFaDFOJHyF45fZECdYOqA0sIX5YMPkOk8Eyz96xpoJlnvIZDgduazEfZ+SJVyoNhqO1DWcUim1dfJf2DTxTVgxFY1Ql+kOtivDYSJhgTYX7cIx1EJgmDhSvEbuK12XAiHyYCxThCKsQHmiXCMHa5+5T+BBY74qVX39vcUIhbLBwSkUO7DonBsEqBCtFfBjoHt6+34mjLfg34HO4feL8mw0HqwKsr8XRwA2E9x3xYY693jzHvWfZCAdheAZnWG6+1wecKd4oDhFHicPFvm6WI4SXRBTijOcdzi3+BefkifPAehLoI14Pqcdt/1x3YyNb/BisYUC38PvbU3wivOQhGHWw+sK5ASjAltBB8D8MQe05NXCBBZOBCmxJXwbTa1RnsDbCL4Pgx5ajeeJjYDVXEZgDNSugVwhW44j1sw0GKwjrX4El2kGzHDqVwzvO1x3d2dhMsPbMgjnaRZGroW0OjHcY1VIYeZHNMoZ0nPFP5YDwIJwp5miWinwt3u7w5z3g4lS1sc2c1Tl+Z0eTRXBkLKy1PWp7Ga4EAthSXAhHn4BQa5vX2zUIX1rRBKvU0fluYDaUt3F5xa5rNmzFlsfurs5grYP52JK7AVZcpBxSCrU3wvPOPtgzuxsI1gG3l9/90Cfg6Ihm/ONRBssn3udyceNVftiBLXNnaAZHbxcLNZs6uPXMFJdHCF84OeICluIIfQTzHI3jrI0Q7Kwc4myaxEqDtR2VC9bCCMDvOliZ0NGCCv1pwb7XlEdmQCtgOVp2bYU69aojWB/AVUEIoWcpfNlMeQD4q/0bs/GL6IK1JR3Wd/T4/lxZDJloKTgMrzXzFqyDJfBNT+WB2dD2kO1Eb9AP/zrhAAQ+xhl/d7A6fm0U977qbvPzr3YYwlkqArnQ2f4swb8SZjZXDtkG3SxsWSZ6HRt9RJ+rYP0H/omWdVNUlGyDxpm2b/i4P1VHsPbYnhrl7IQ/NlNRAPzDfqnH0o4eg1UEEy+N8mkl3e1P378e4CFYFnzRR0VBVzgP26BumqyqANQX92JPhm5FOXC2uJXoKBR7KA3AQuzZLzaMcJbwqv2pfXFL5YKV8BFaCvfCH1uqKDgKA0NOgzUAGuRp7664eaUyxD3Qpkz7u0oWxDtY/aBhFhzUD7hBN6goeRVq7IRVNkEY4y1YRx5VBiiHV9ByaK77YOW+pwxQCn9DS/4W2Fy7SgCuEEPYM1ETkXriSsxwRLxQe7RhjyV2VVW4E+ofhj1oSe2rXDAaGhTBAbQM72vo6VDzHQXrX9r7nxeXwqrLYWcNoFa0hj8F7rQiTuAV5cHIFvEM1jvQ3UJH+QJliN9Dj5B2APkWuw/Wrm3QrJ6hZyC20q/C9qfDsgbOg1WYDxe2NbRtdfTfZbXKIbW9x8ns30QISA1xEmbZLDbRzJEdwp6hqgqvwVWWdt9avVy5ZDL8Wj9VstbYwUwpdALKbIP1HxhJRAJlwPfhHWWzATeJafpz9bd/H89grYBRaHn+RmWQn2CdZtsyYWhjd8HaPVQZZKl2HV7AgvEXOw9W1pvKIDNhGFrevbVKACY6vPLWSHN0NUp8ThxnyJfECzRHWSlermaugfvRcuQu5ZLv4F60pN+lDLIZUmyDtRRmklAUPBzPYK2GT3Vf4IX+jZRBPoYniUioHA62dx6sQAVkt1MGSYXeFjoC3ZwFKyRm/14Z5Bu4OKidZwsOqjL4P8eeZSqBAMZgz0JVhQ3wOhEpLoLxZyqXHIAJRKS0CF48UxnkWehnG6wj8BUJxfK3VZQUuAiW/ntRwa+UYR6BP+gH+f6eLoK1CQprKoMchIv82itNGfc5DFY+FLUyvG0NS2E/Ecl8qcrg/w573kuwYP0Re1JVFd7RfvAWbYIU1/vJ2/AhETm6HlJqKIOshA4hKNMGK5RwwZrygYFHqC9zGqygNlgrP4vBjQW7hcCKHKy9tzh/kGrqd8ow+6CVX3tPovShKkw2PKuJx2G4tKEyyF6o4YPvicjhN1UlHD5TcGKCBetG7Nkq/ixA+doPNv9i5YFp2iuE1mJlmBxoEbR7kKqVcMGaOU1FyTpYq7tbg/NgbZ+tDLMLrrcJVi9ViTLtKfsq48E6CK392p0m/e8qTDE8RUQOHobmRoN1AGqWQZomWFMq33FE/C/2vJBgwboee/aKdVzMfXk6U3hLGyyMBysXWga1i5jTBqmchAvWY31VlGRqbyrmn64qka8NVsj4/MZg6IPgNFj7tV9iLfsRVtdSBsmATgEIaoJ/mwqzEwYTkWABbDhLGSQdGpdp12OVPF7lmQO7HU1gJxDAI9izs+oRVlAfrH8rDyzQXoAp3gxv1zJ8UaVTSDtHec9f1bqEmXQPiuUfwjdR/Se8AG0sOEpEUidVmax8n4iU58OKFoaPsJ5xE6x/wwT9pPuTRifdv4K79Nv3QZdK8yb90PLazcogH8HlIQgQkfl3ewjWpwn2yLH92JOmhFgHqwSGE5EyH7x/vjJICtyjX362s6f6Cf6hX9tSOB8Q+SJGfimmQPogZYCXoD9avh1WZYAORcvwfsogpbDeTbBmwW1oKR6mDJIGs4iIvxAeOLPSpGxn/dGYb6rhJRdPod2jn7nGQ7DWaQJSQzxLbC22iqFtxDvE7ThjRTyCNQ1uRkvqYGWQQzBH/yV3+R7zFOhhab8u8smt6iThN1AjB1brd+rnuqhKvAFX6hdz/rgBLqqpDJAHPS2w3ARrIpzth2IiEtgBM+spA2RBB/33unZ9qyrxDNTLg52a11MAS842dDrYRH/XhfxDMLyhh2AViK0jBKum+K5YKObE0CLc8WE8gvUStC7XbtuWrXBeHWWA7tDJp933dq+F8TXVHmgS1M4LFByE/q3VScB826OrwG7IqqsqcQvU3Q+70OJ7SEVJO6iVARsQHAcrTBosR8vrI5UBNsBctBQ+raowD6ag5ev3lQFmw3i0FM9SgiZYOiJ+KHMs4iUkFk+aC5aeLbAULYERygBB+BIt+8ZV3lHfQ8uRRaDqqASmF7Sxf8xV6SR1AjbBi+gphPIuUcb0aQQvwfoWBqDFKoEXuqooWAID0RLyw56OJ7j319WAhZZp/aOMVTegDC0ZfaII1sdKA9CPxOLWeAVrMgy0Hxu9ukS5NvEh+33v6Q6VT4uusCCElpnz4Ie6KgFZAWctgTS0lPjg2osiLDRtFwAfWoKHIfRrj/NCI0oAr8EqgAZ+2IOew7DkWuWBAPQvBT9ayuZo5uUWo8cH6z1FKwTXFkEOWio2Q1ndKIJVILa1XYGeGBSJbeIVrObQKBPS0VJ6ABZ7itY2eLAIO1JmqKqUwzzsWQyB9soFwGliQxUj/HCNs/tiH5hqM2hfxxarCPwPughBI80dEBwHK3wUOMDCjtKjbp5GlAn1vodxgIWeoO6hDGvhmqDtzygXA0/BN3VcPF/yAYfzO3crQRcsE+uxgIfEUqqXVUowGyw9I2EY9uRCxV0uls803AwTsacC3uisqjIEOgMV2GLlAeMgdK7NbW47Aq+Ke8UD4jsw4yyDj9ruIE6yoAxbyo/AjjOVhnehVQFk4ojQIgjeDNSNsGO3FP9mwVYEE8FqAbUOwwoccWAh+HuCVS/C9jUNwZ+BNByx9A0Hd4+ciiOOpELx3WBFumNB/RD0smARjti5FPrVNBCsQvECB9G6SvwaZ/xX/F/xf8S5YojoGRXvYM2C+j7nT8uZC9ZvI42NhdA8AAOALTgi5TkVic/gSRxjFQDzxKFiH7G7eJv4WAhWBqCc49i/Gya2US7hWPzuFf8iTrBgGVCOY4r/5HCupF8AV2wDazrwiDhEfEFcKGYRxkiwwlRAeyAb5+wQPxFHioPEseLn4gEcU7gdLm3q4PubTVw+ay9DTBGfCm/bKPFTcSfOyYe+FyrBQLAQPnfzyHdxSvg1F4hlYrGYHn5d94hNTnC/qxK8Uya2Mx8se0rhCsCHc7aCVXnfG2fB/Ao4hGPSV8O59VQkfgs1N8IiYkrBK8oFW+E5wIdndkx2eVXkeYxgPljh7bs1CCHigr8Ull7u4r26pBgKiBtb7lCCqWCFeVi5AKgtthE7iL8QGykNwGi8s0AJcQ9WmOnwIHEjlAFp5yg7noNmQCoxo2yNizmWoUG8Yon73oOzayiXAG8mZLDC/BkGlIBFTMkvg1v6eFhPc31mzKNVIf59hBJiECy/2FvFCOCcKObBesQjWNV/8aFiPxR0cbNRrcVVxITgauWAR6H+IdiNZxZPinJdyKSEDFaY5dAXyCY2HIJPeyqPvAlXANuJDT74/n4leA6WPUfFXjEKVjMxD/css/m5c7TBMsgmGBGI2VG+9T0UtvdyI7cme+EzjPPhROWACmiJp0/q8lzY/RdlgFUwDCjGGFZYXbDSb3Fx4aGzH77DKBmrIPdCFSUcWyU9B6Pk7ICMbkowFiz9fNFAZRjgGjGIOwLi1UrDBv0R1hJlmCLoFYIMs2Mj8D74m6poAIZbkGtmg/gIbmumHLID5uOK0GzIb294B7skCAssoiYLsh6FdWIk/D7Ycp7LZ7vV2Qejifo9CmYBo+Hb2oY/jQcC+4iKUAnwCmxvrgTjwdLzttjS0L7U3uOjwqYoG3ZqF19WvKVigA/aBGEaUEFUWFsh+CeTa50uCMAUC3LwRioEb1MueRw62a/DsXLE9yH4GxVD/HCjBfPEYlxxdDsUjgPrbCXMprTF/oiPnip9QnnEgnND8KwFu3DHdigfC4vaqhgBNA3CwxZsxB37xFdhUSelQRssM+wVh4iNPb7+RhwLyhHcs8PJM/+OHLv1ziaOw5cNmReoGAL8KgRvBWC/5e4IZh2EBomnqVgQgrYWDBUXApkRlhaUillgLRVfFm8AaiqPAN3ENWJ+2ExxJVjTIHQXBM9UcSQI51twLzBNXMSxQOSIeeEdchNYC469dq6HH+qd4DYpvwA+FPeIeeF/86Ch9+g0C34HTBC/FLeK2eHfkyWmiZ+LT4rXhddqxYUQ1LLgGmCMOF/8QcwKb1tOeFsXhNcu3QyWLhDmg2XPLvFZ8UpRO8iAVuL14nPiTrxRLnZVDjkC54TveJAfdjEcuUzFia/h9FLoDbwifhV+3XmVxsZ6cQ5Yj0LoChVPkI0TO4q9wLoDuFW8TrxAbGr4d9WwoAVwhni6SiCA+mIzsXn4/6S2i3/bIPzvasdw++pW2r6mYi2VIAC1wtvUPLyNdZUGz8EyTyj8s78KnzK+LL4kviPOE9eJeUTP/R5f+xlgnZEIY8OC5pXGRg2VJEkSTbBOXsaoJEmSJIN1EvC0SvJ/7dSxigEAHIDxf5FisAilbNbbWGSi5OZ7BgZPcS/hAZTNwFtYSVltit2iU/c9gxv8u75ffa/wSQ4ruR+ahySHldyZJiHJYSW3pnZIcliJHekrJDmsxMM60JQqIUkJh3WhJX1SKSTpzcN60J1udKQNfdOIaiFJLwxrTwua0Zj61PtjXfqgDtWpEJL04rCetKKBM5GUeVgnGoYkJR1Wka60o0ZIUuJhVWlLzZCk5MMqUyv0r/wCSDD/4sxS1q8AAAAASUVORK5CYII=">>. diff --git a/src/mod_caps.erl b/src/mod_caps.erl index d5a623669..391a3ba74 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -5,7 +5,7 @@ %%% Created : 7 Oct 2006 by Magnus Henoch <henoch@dtek.chalmers.se> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -146,11 +146,11 @@ user_receive_packet({#presence{from = From, type = available} = Pkt, #{lserver := LServer} = State}) -> IsRemote = not ejabberd_router:is_my_host(From#jid.lserver), if IsRemote -> - case read_caps(Pkt) of - nothing -> ok; - #caps{version = Version, exts = Exts} = Caps -> + case read_caps(Pkt) of + nothing -> ok; + #caps{version = Version, exts = Exts} = Caps -> feature_request(LServer, From, Caps, [Version | Exts]) - end; + end; true -> ok end, {Pkt, State}; @@ -162,10 +162,10 @@ user_receive_packet(Acc) -> caps_stream_features(Acc, MyHost) -> case gen_mod:is_loaded(MyHost, ?MODULE) of true -> - case make_my_disco_hash(MyHost) of + case make_my_disco_hash(MyHost) of <<"">> -> Acc; - Hash -> + Hash -> [#caps{hash = <<"sha-1">>, node = ?EJABBERD_URI, version = Hash}|Acc] end; @@ -221,27 +221,27 @@ c2s_presence_in(C2SState, and ((Subscription == both) or (Subscription == to)), Delete = (Type == unavailable) or (Type == error), if Insert or Delete -> - LFrom = jid:tolower(From), + LFrom = jid:tolower(From), Rs = maps:get(caps_resources, C2SState, gb_trees:empty()), - Caps = read_caps(Presence), - NewRs = case Caps of - nothing when Insert == true -> Rs; - _ when Insert == true -> - case gb_trees:lookup(LFrom, Rs) of - {value, Caps} -> Rs; - none -> - ejabberd_hooks:run(caps_add, To#jid.lserver, - [From, To, - get_features(To#jid.lserver, Caps)]), - gb_trees:insert(LFrom, Caps, Rs); - _ -> - ejabberd_hooks:run(caps_update, To#jid.lserver, - [From, To, - get_features(To#jid.lserver, Caps)]), - gb_trees:update(LFrom, Caps, Rs) - end; - _ -> gb_trees:delete_any(LFrom, Rs) - end, + Caps = read_caps(Presence), + NewRs = case Caps of + nothing when Insert == true -> Rs; + _ when Insert == true -> + case gb_trees:lookup(LFrom, Rs) of + {value, Caps} -> Rs; + none -> + ejabberd_hooks:run(caps_add, To#jid.lserver, + [From, To, + get_features(To#jid.lserver, Caps)]), + gb_trees:insert(LFrom, Caps, Rs); + _ -> + ejabberd_hooks:run(caps_update, To#jid.lserver, + [From, To, + get_features(To#jid.lserver, Caps)]), + gb_trees:update(LFrom, Caps, Rs) + end; + _ -> gb_trees:delete_any(LFrom, Rs) + end, C2SState#{caps_resources => NewRs}; true -> C2SState diff --git a/src/mod_caps_mnesia.erl b/src/mod_caps_mnesia.erl index ed22841e8..02ea9aaf0 100644 --- a/src/mod_caps_mnesia.erl +++ b/src/mod_caps_mnesia.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_caps_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_caps_mnesia). + -behaviour(mod_caps). %% API diff --git a/src/mod_caps_riak.erl b/src/mod_caps_riak.erl index a504bb6ce..301fdd1db 100644 --- a/src/mod_caps_riak.erl +++ b/src/mod_caps_riak.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_caps_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_caps_riak). + -behaviour(mod_caps). %% API diff --git a/src/mod_caps_sql.erl b/src/mod_caps_sql.erl index fee0f0960..9bacecb9c 100644 --- a/src/mod_caps_sql.erl +++ b/src/mod_caps_sql.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_caps_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_caps_sql). + -behaviour(mod_caps). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_carboncopy.erl b/src/mod_carboncopy.erl index ea44aed95..202c7005a 100644 --- a/src/mod_carboncopy.erl +++ b/src/mod_carboncopy.erl @@ -7,7 +7,7 @@ %%% {mod_carboncopy, []} %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_carboncopy_mnesia.erl b/src/mod_carboncopy_mnesia.erl index 4cc7e6049..9c6a2ffaf 100644 --- a/src/mod_carboncopy_mnesia.erl +++ b/src/mod_carboncopy_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_carboncopy_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 15 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_carboncopy_mnesia). -behaviour(mod_carboncopy). diff --git a/src/mod_client_state.erl b/src/mod_client_state.erl index 175929a57..d38de6832 100644 --- a/src/mod_client_state.erl +++ b/src/mod_client_state.erl @@ -5,7 +5,7 @@ %%% Created : 11 Sep 2014 by Holger Weiss <holger@zedat.fu-berlin.de> %%% %%% -%%% ejabberd, Copyright (C) 2014-2016 ProcessOne +%%% ejabberd, Copyright (C) 2014-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -214,8 +214,8 @@ filter_chat_states({#message{from = From, to = To} = Msg, %% conversations across clients. Acc; _ -> - ?DEBUG("Got standalone chat state notification for ~s", - [jid:to_string(To)]), + ?DEBUG("Got standalone chat state notification for ~s", + [jid:to_string(To)]), enqueue_stanza(chatstate, Msg, C2SState) end; false -> @@ -270,7 +270,7 @@ enqueue_stanza(Type, Stanza, #{csi_state := inactive, csi_queue := Q} = C2SState) -> case queue_len(Q) >= ?CSI_QUEUE_MAX of true -> - ?DEBUG("CSI queue too large, going to flush it", []), + ?DEBUG("CSI queue too large, going to flush it", []), C2SState1 = flush_queue(C2SState), enqueue_stanza(Type, Stanza, C2SState1); false -> @@ -290,7 +290,7 @@ dequeue_sender(#jid{luser = U, lserver = S}, {Stanzas, Q1} -> C2SState1 = flush_stanzas(C2SState, Stanzas), C2SState1#{csi_queue => Q1}; - error -> + error -> C2SState end. diff --git a/src/mod_configure.erl b/src/mod_configure.erl index 436d736e6..b1827be05 100644 --- a/src/mod_configure.erl +++ b/src/mod_configure.erl @@ -5,7 +5,7 @@ %%% Created : 19 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -42,6 +42,7 @@ -include("logger.hrl"). -include("xmpp.hrl"). -include("ejabberd_sm.hrl"). +-include_lib("stdlib/include/ms_transform.hrl"). -define(T(Lang, Text), translate:translate(Lang, Text)). @@ -340,16 +341,15 @@ adhoc_local_items(Acc, From, PermLev = get_permission_level(From), Nodes = recursively_get_local_items(PermLev, LServer, <<"">>, Server, Lang), - Nodes1 = lists:filter(fun (N) -> - Nd = fxml:get_tag_attr_s(<<"node">>, N), - F = get_local_features([], From, To, Nd, - Lang), - case F of - {result, [?NS_COMMANDS]} -> true; - _ -> false - end - end, - Nodes), + Nodes1 = lists:filter( + fun (#disco_item{node = Nd}) -> + F = get_local_features([], From, To, Nd, Lang), + case F of + {result, [?NS_COMMANDS]} -> true; + _ -> false + end + end, + Nodes), {result, Items ++ Nodes1}; _ -> Acc end. diff --git a/src/mod_delegation.erl b/src/mod_delegation.erl index 2cf9525fc..fcc857c29 100644 --- a/src/mod_delegation.erl +++ b/src/mod_delegation.erl @@ -4,7 +4,7 @@ %%% Purpose : XEP-0355: Namespace Delegation %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_disco.erl b/src/mod_disco.erl index 6f6d26651..73f691dc6 100644 --- a/src/mod_disco.erl +++ b/src/mod_disco.erl @@ -5,7 +5,7 @@ %%% Created : 1 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_echo.erl b/src/mod_echo.erl index e7d64dd67..796c8cb1c 100644 --- a/src/mod_echo.erl +++ b/src/mod_echo.erl @@ -5,7 +5,7 @@ %%% Created : 15 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_fail2ban.erl b/src/mod_fail2ban.erl index e8cc29816..2c6ff618c 100644 --- a/src/mod_fail2ban.erl +++ b/src/mod_fail2ban.erl @@ -1,12 +1,11 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @doc -%%% -%%% @end +%%% File : mod_fail2ban.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> +%%% Purpose : %%% Created : 15 Aug 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2014-2016 ProcessOne +%%% ejabberd, Copyright (C) 2014-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -71,15 +70,15 @@ c2s_auth_result(#{ip := {Addr, _}, lserver := LServer} = State, false, _User) -> ?C2S_MAX_AUTH_FAILURES), UnbanTS = p1_time_compat:system_time(seconds) + BanLifetime, Attempts = case ets:lookup(failed_auth, Addr) of - [{Addr, N, _, _}] -> + [{Addr, N, _, _}] -> ets:insert(failed_auth, {Addr, N+1, UnbanTS, MaxFailures}), N+1; - [] -> + [] -> ets:insert(failed_auth, {Addr, 1, UnbanTS, MaxFailures}), 1 - end, + end, if Attempts >= MaxFailures -> log_and_disconnect(State, Attempts, UnbanTS); true -> diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl index 3700060cb..d962aaefe 100644 --- a/src/mod_http_api.erl +++ b/src/mod_http_api.erl @@ -5,7 +5,7 @@ %%% Created : 15 Sep 2014 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -298,7 +298,7 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) -> throw:{error, account_unprivileged} -> {403, 31, <<"Command need to be run with admin priviledge.">>}; throw:{error, access_rules_unauthorized} -> - {403, 32, <<"AccessRules: Account associated to token does not have the right to perform the operation.">>}; + {403, 32, <<"AccessRules: Account does not have the right to perform the operation.">>}; throw:{invalid_parameter, Msg} -> {400, iolist_to_binary(Msg)}; throw:{error, Why} when is_atom(Why) -> @@ -539,26 +539,28 @@ permission_addon() -> fun(V) -> V end, none), Rules = acl:resolve_access(Access, global), - R = lists:filtermap( - fun({V, AclRules}) when V == all; V == [all]; V == [allow]; V == allow -> - {true, {[{allow, AclRules}], {[<<"*">>], []}}}; - ({List, AclRules}) when is_list(List) -> - {true, {[{allow, AclRules}], {List, []}}}; - (_) -> - false - end, Rules), - case R of - [] -> - none; - _ -> - {_, Res} = lists:foldl( - fun({R2, L2}, {Idx, Acc}) -> - {Idx+1, [{<<"'mod_http_api admin_ip_access' option compatibility shim ", - (integer_to_binary(Idx))/binary>>, - {[?MODULE], [{access, R2}], L2}} | Acc]} - end, {1, []}, R), - Res - end. + R = case Rules of + all -> + [{[{allow, all}], {all, []}}]; + none -> + []; + _ -> + lists:filtermap( + fun({V, AclRules}) when V == all; V == [all]; V == [allow]; V == allow -> + {true, {[{allow, AclRules}], {all, []}}}; + ({List, AclRules}) when is_list(List) -> + {true, {[{allow, AclRules}], {List, []}}}; + (_) -> + false + end, Rules) + end, + {_, Res} = lists:foldl( + fun({R2, L2}, {Idx, Acc}) -> + {Idx+1, [{<<"'mod_http_api admin_ip_access' option compatibility shim ", + (integer_to_binary(Idx))/binary>>, + {[?MODULE], [{access, R2}], L2}} | Acc]} + end, {1, []}, R), + Res. mod_opt_type(admin_ip_access) -> fun acl:access_rules_validator/1; mod_opt_type(_) -> [admin_ip_access]. diff --git a/src/mod_http_bind.erl b/src/mod_http_bind.erl deleted file mode 100644 index 68500f2c4..000000000 --- a/src/mod_http_bind.erl +++ /dev/null @@ -1,239 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : mod_http_bind.erl -%%% Author : Stefan Strigler <steve@zeank.in-berlin.de> -%%% Purpose : Implementation of XMPP over BOSH (XEP-0206) -%%% Created : Tue Feb 20 13:15:52 CET 2007 -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - -%%%---------------------------------------------------------------------- -%%% This module acts as a bridge to ejabberd_http_bind which implements -%%% the real stuff, this is to handle the new pluggable architecture for -%%% extending ejabberd's http service. -%%%---------------------------------------------------------------------- - --module(mod_http_bind). - --author('steve@zeank.in-berlin.de'). - -%%-define(ejabberd_debug, true). - --behaviour(gen_mod). - --export([start/2, stop/1, process/2, mod_opt_type/1, depends/2]). - --include("ejabberd.hrl"). --include("logger.hrl"). - --include("xmpp.hrl"). - --include("ejabberd_http.hrl"). - --include("http_bind.hrl"). - --define(PROCNAME_MHB, ejabberd_mod_http_bind). - -%% Duplicated from ejabberd_http_bind. -%% TODO: move to hrl file. --record(http_bind, - {id, pid, to, hold, wait, process_delay, version}). - -%%%---------------------------------------------------------------------- -%%% API -%%%---------------------------------------------------------------------- - -process([], #request{method = 'POST', data = <<>>}) -> - ?DEBUG("Bad Request: no data", []), - {400, ?HEADER, - #xmlel{name = <<"h1">>, children = [{xmlcdata, <<"400 Bad Request">>}]}}; -process([], - #request{method = 'POST', data = Data, ip = IP, opts = Opts}) -> - ?DEBUG("Incoming data: ~s", [Data]), - ejabberd_http_bind:process_request(Data, IP, Opts); -process([], #request{method = 'GET', data = <<>>}) -> - {200, ?HEADER, get_human_html_xmlel()}; -process([], #request{method = 'OPTIONS', data = <<>>}) -> - {200, ?OPTIONS_HEADER, <<>>}; -process([], #request{method = 'HEAD'}) -> - {200, ?HEADER, <<>>}; -process(_Path, _Request) -> - ?DEBUG("Bad Request: ~p", [_Request]), - {400, ?HEADER, - #xmlel{name = <<"h1">>, children = [{xmlcdata, <<"400 Bad Request">>}]}}. - -%%%---------------------------------------------------------------------- -%%% BEHAVIOUR CALLBACKS -%%%---------------------------------------------------------------------- -start(_Host, _Opts) -> - setup_database(). - -stop(_Host) -> - ok. - -setup_database() -> - migrate_database(), - ejabberd_mnesia:create(?MODULE, http_bind, - [{ram_copies, [node()]}, - {attributes, record_info(fields, http_bind)}]). - -migrate_database() -> - case catch mnesia:table_info(http_bind, attributes) of - [id, pid, to, hold, wait, process_delay, version] -> - ok; - _ -> - %% Since the stored information is not important, instead - %% of actually migrating data, let's just destroy the table - mnesia:delete_table(http_bind) - end. - -mod_opt_type(max_inactivity) -> - fun (I) when is_integer(I), I > 0 -> I end; -mod_opt_type(max_pause) -> - fun (I) when is_integer(I), I > 0 -> I end; -mod_opt_type(_) -> [max_inactivity, max_pause]. - -depends(_Host, _Opts) -> - []. - -%%%---------------------------------------------------------------------- -%%% Help Web Page -%%%---------------------------------------------------------------------- - -get_human_html_xmlel() -> - Heading = <<"ejabberd ", - (iolist_to_binary(atom_to_list(?MODULE)))/binary>>, - #xmlel{name = <<"html">>, - attrs = - [{<<"xmlns">>, <<"http://www.w3.org/1999/xhtml">>}], - children = - [#xmlel{name = <<"head">>, - children = - [#xmlel{name = <<"title">>, - children = [{xmlcdata, Heading}]}, - #xmlel{name = <<"style">>, - children = [{xmlcdata, get_style_cdata()}]}]}, - #xmlel{name = <<"body">>, - children = - [#xmlel{name = <<"div">>, - attrs = [{<<"class">>, <<"container">>}], - children = get_container_children(Heading)}]}]}. - -get_container_children(Heading) -> - [#xmlel{name = <<"div">>, - attrs = [{<<"class">>, <<"section">>}], - children = - [#xmlel{name = <<"div">>, - attrs = [{<<"class">>, <<"block">>}], - children = - [#xmlel{name = <<"a">>, - attrs = [{<<"href">>, <<"https://www.ejabberd.im">>}], - children = - [#xmlel{name = <<"img">>, - attrs = [{<<"height">>, <<"32">>}, - {<<"src">>, get_image_src()}]}]}]}]}, - #xmlel{name = <<"div">>, - attrs = [{<<"class">>, <<"white section">>}], - children = - [#xmlel{name = <<"div">>, - attrs = [{<<"class">>, <<"block">>}], - children = - [#xmlel{name = <<"h1">>, children = [{xmlcdata, Heading}]}, - #xmlel{name = <<"p">>, children = - [{xmlcdata, <<"An implementation of ">>}, - #xmlel{name = <<"a">>, - attrs = [{<<"href">>, <<"http://xmpp.org/extensions/xep-0206.html">>}], - children = [{xmlcdata, <<"XMPP over BOSH (XEP-0206)">>}]}]}, - #xmlel{name = <<"p">>, children = - [{xmlcdata, <<"This web page is only informative. To " - "use HTTP-Bind you need a Jabber/XMPP " - "client that supports it.">>}]}]}]}, - #xmlel{name = <<"div">>, - attrs = [{<<"class">>, <<"section">>}], - children = - [#xmlel{name = <<"div">>, - attrs = [{<<"class">>, <<"block">>}], - children = - [#xmlel{name = <<"a">>, - attrs = [{<<"href">>, <<"https://www.ejabberd.im">>}, - {<<"title">>, <<"ejabberd XMPP server">>}], - children = [{xmlcdata, <<"ejabberd">>}]}, - {xmlcdata, <<" is maintained by ">>}, - #xmlel{name = <<"a">>, - attrs = [{<<"href">>, <<"https://www.process-one.net">>}, - {<<"title">>, <<"ProcessOne - Leader in Instant Messaging and Push Solutions">>}], - children = [{xmlcdata, <<"ProcessOne">>}]} ]}]} - ]. - -get_style_cdata() -> - <<" - body { - margin: 0; - padding: 0; - font-family: sans-serif; - color: #fff; - } - h1 { - font-size: 3em; - color: #444; - } - p { - line-height: 1.5em; - color: #888; - } - a { - color: #fff; - } - a:hover, - a:active { - text-decoration: underline; - } - .container { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: #424A55; - background-image: -webkit-linear-gradient(270deg, rgba(48,52,62,0) 24%, #30353e 100%); - background-image: linear-gradient(-180deg, rgba(48,52,62,0) 24%, #30353e 100%); - } - .section { - padding: 3em; - } - .white.section { - background: #fff; - border-bottom: 4px solid #41AFCA; - } - .white.section a { - text-decoration: none; - color: #41AFCA; - } - .white.section a:hover, - .white.section a:active { - text-decoration: underline; - } - .block { - margin: 0 auto; - max-width: 900px; - width: 100%; - }">>. - -get_image_src() -> - <<"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAABACAYAAACgPErgAAAVtklEQVR42uydeXhU1d2ADzuyCcii4FZBZdEqVYtaUGqlikVwaRWsrWBRKIh8KgXcEAX9VECtoljcURAJICJWQLaKLAEjIHtBSNhC9oQkk2SW+36/52P+iIE5d5kzk4Fn3ud5H/7gIbnD3PPOveeeuVedygD9xLlQMh9yJ0D+GeokJAg1xcEWzOWYj0DBaQm0fXdaMCu8bROgpJVKksQj0+F84OXw/jRd7KVOdbbCFI6jdDNktlAnESVQNwSzOI6yhZBaV1UzAXiB4wj8CBtbqiRJXDIILtgL+zmOb8aoU5Xh0MMiEr5x6iSiAIZYROLo/aoayYMeocjbNlklSeKC9VAjBDM5IcEQfNZFnYq8AM8SkcJV6iSiCGYRkT1LVDWSA08Tkfy9MLaeOsUA2ot9xJHiW2KK+LW4Mvxnijg1/Pd9xQvFGiqJLUOhcT5kE5Etg0/VYI3TBOvbkyxYKURk2dpqDZb2gyEjC1SjUyBQdcQe4mtimujDHWXiD+Lr4g1iXZXkhISgBZBLZIaoU5GR0I2IVDxxkgVrNhH5z+pqDZb2g+FAJjQ4aYMFtBAfEzdils3iP8TkhYkqlMEZFuQQmcHqVGUBTOI40lLhz02TwUoGKxJAI/FxMYPYckB8Smyikvw/vlM/WHqAP4ifiHPF0fBsYyUkg5UM1okAbhV/JL5sE29TSZLBOhHJYCWDVRXgNPFVqpfXxQbJYCWDlQxWMlgRAc4VV5EYrBZ/kQxWMljJYFVLsBomdLCAS8RdJBZ7xMuSwTIcLKCO2EG8VrxdvEfsLV4F1vkJstq9BlidwN8hVleSLLgUuFzsEv6zs9g4EYIFNBAvFi87tm3WZWI7oHZ8glWnkWbb6ortCG/bsT+tDsBpcYrVpeIhzBHAHJni5XGOd5PwvnKJif0DaCh2/Pn7y/linbgFKx/qrjkWpffEHZo3qVhMBWuC2EVVA4ehay6sAYJgBeDocuh9iYqCL+F04DbxLTFNPMzxWGI6WCuBJ8Rfxi5YK34WLKC5BX3FVzj22n8S/fwcX/i9+1wcLraLVbAqr8OqgNOA31nwPLBc3HWCNU1+cbe4WBwjXhbD08A9eOcn8SNxmHij+EuxQ3iwdxP/Jr4pbsU7+2J5ehiCNuI9FkwN78sZol+0xDSYd6OH75R2BcZasALYKwZO0IWd4fd3LIS6g1XHeLBWQV1gsLgJ9wTBWgSBm1ScuBYuAvI4jrx9cOEZyiXzoUUIxhbDPm+fvFlL4PPe5oO14FslvAjnrYeXgYO4p0T8UrzJbLB2HlbCZMqbfwOjgrDD41HLCrE/LK1pKFYNxFS8sVDsK1Y5ctQeRf42HLcy3JMmNjIc6+ss+ETMRUuRH9Zd7SBS9QMwCFiDNzZBYAT4G5dTUcuC7KiClQ3dj8B6osYSAzOgoq2KMatgChF5e5RyQQXcVwL7MMNXsKOTuWAd2FBG9uhyyMMI6XPBd7GZYOUd8pP+UCn8hBEOr4KCbgYG7Ju4Z43YU0VB+LRoLu6ZpgyQAhflw2e4Y7lYS0XADzdZ8ANGsLaX88PgACHvwfLBY4Afo4T2Q9lNMZ68W0lE/J8oB5RDkxDMwDhF+XC4v6tgxZdcKLov+mBhYR4/FD8VRTRu93CE97RYTxkCuFfMxR13qSjIhoE+Tx9qPh9Mb6WqcBRqBuBli5hguQ4WUGsPvGsRKyw/hAaoGJEPy4lI4Uxlw3XHzu/XEVNKHk3QYAmWWDEecmraBqtaCE6HrCYeJpX34Jwc8eYYXp3cjHPSxWbKA9/Da3im+CeY1kBV4gNoUQILiB/6YD0JNYFP4jMoGFINwZqhNHwKLbfB5ji9/kdMBss8vk9MBcs8pasht7GLSIzHOQfFX6kYApyFuw/FFz38jveJitxBqhI3QMsS2IiQMMFaDFOJHyF45fZECdYOqA0sIX5YMPkOk8Eyz96xpoJlnvIZDgduazEfZ+SJVyoNhqO1DWcUim1dfJf2DTxTVgxFY1Ql+kOtivDYSJhgTYX7cIx1EJgmDhSvEbuK12XAiHyYCxThCKsQHmiXCMHa5+5T+BBY74qVX39vcUIhbLBwSkUO7DonBsEqBCtFfBjoHt6+34mjLfg34HO4feL8mw0HqwKsr8XRwA2E9x3xYY693jzHvWfZCAdheAZnWG6+1wecKd4oDhFHicPFvm6WI4SXRBTijOcdzi3+BefkifPAehLoI14Pqcdt/1x3YyNb/BisYUC38PvbU3wivOQhGHWw+sK5ASjAltBB8D8MQe05NXCBBZOBCmxJXwbTa1RnsDbCL4Pgx5ajeeJjYDVXEZgDNSugVwhW44j1sw0GKwjrX4El2kGzHDqVwzvO1x3d2dhMsPbMgjnaRZGroW0OjHcY1VIYeZHNMoZ0nPFP5YDwIJwp5miWinwt3u7w5z3g4lS1sc2c1Tl+Z0eTRXBkLKy1PWp7Ga4EAthSXAhHn4BQa5vX2zUIX1rRBKvU0fluYDaUt3F5xa5rNmzFlsfurs5grYP52JK7AVZcpBxSCrU3wvPOPtgzuxsI1gG3l9/90Cfg6Ihm/ONRBssn3udyceNVftiBLXNnaAZHbxcLNZs6uPXMFJdHCF84OeICluIIfQTzHI3jrI0Q7Kwc4myaxEqDtR2VC9bCCMDvOliZ0NGCCv1pwb7XlEdmQCtgOVp2bYU69aojWB/AVUEIoWcpfNlMeQD4q/0bs/GL6IK1JR3Wd/T4/lxZDJloKTgMrzXzFqyDJfBNT+WB2dD2kO1Eb9AP/zrhAAQ+xhl/d7A6fm0U977qbvPzr3YYwlkqArnQ2f4swb8SZjZXDtkG3SxsWSZ6HRt9RJ+rYP0H/omWdVNUlGyDxpm2b/i4P1VHsPbYnhrl7IQ/NlNRAPzDfqnH0o4eg1UEEy+N8mkl3e1P378e4CFYFnzRR0VBVzgP26BumqyqANQX92JPhm5FOXC2uJXoKBR7KA3AQuzZLzaMcJbwqv2pfXFL5YKV8BFaCvfCH1uqKDgKA0NOgzUAGuRp7664eaUyxD3Qpkz7u0oWxDtY/aBhFhzUD7hBN6goeRVq7IRVNkEY4y1YRx5VBiiHV9ByaK77YOW+pwxQCn9DS/4W2Fy7SgCuEEPYM1ETkXriSsxwRLxQe7RhjyV2VVW4E+ofhj1oSe2rXDAaGhTBAbQM72vo6VDzHQXrX9r7nxeXwqrLYWcNoFa0hj8F7rQiTuAV5cHIFvEM1jvQ3UJH+QJliN9Dj5B2APkWuw/Wrm3QrJ6hZyC20q/C9qfDsgbOg1WYDxe2NbRtdfTfZbXKIbW9x8ns30QISA1xEmbZLDbRzJEdwp6hqgqvwVWWdt9avVy5ZDL8Wj9VstbYwUwpdALKbIP1HxhJRAJlwPfhHWWzATeJafpz9bd/H89grYBRaHn+RmWQn2CdZtsyYWhjd8HaPVQZZKl2HV7AgvEXOw9W1pvKIDNhGFrevbVKACY6vPLWSHN0NUp8ThxnyJfECzRHWSlermaugfvRcuQu5ZLv4F60pN+lDLIZUmyDtRRmklAUPBzPYK2GT3Vf4IX+jZRBPoYniUioHA62dx6sQAVkt1MGSYXeFjoC3ZwFKyRm/14Z5Bu4OKidZwsOqjL4P8eeZSqBAMZgz0JVhQ3wOhEpLoLxZyqXHIAJRKS0CF48UxnkWehnG6wj8BUJxfK3VZQUuAiW/ntRwa+UYR6BP+gH+f6eLoK1CQprKoMchIv82itNGfc5DFY+FLUyvG0NS2E/Ecl8qcrg/w573kuwYP0Re1JVFd7RfvAWbYIU1/vJ2/AhETm6HlJqKIOshA4hKNMGK5RwwZrygYFHqC9zGqygNlgrP4vBjQW7hcCKHKy9tzh/kGrqd8ow+6CVX3tPovShKkw2PKuJx2G4tKEyyF6o4YPvicjhN1UlHD5TcGKCBetG7Nkq/ixA+doPNv9i5YFp2iuE1mJlmBxoEbR7kKqVcMGaOU1FyTpYq7tbg/NgbZ+tDLMLrrcJVi9ViTLtKfsq48E6CK392p0m/e8qTDE8RUQOHobmRoN1AGqWQZomWFMq33FE/C/2vJBgwboee/aKdVzMfXk6U3hLGyyMBysXWga1i5jTBqmchAvWY31VlGRqbyrmn64qka8NVsj4/MZg6IPgNFj7tV9iLfsRVtdSBsmATgEIaoJ/mwqzEwYTkWABbDhLGSQdGpdp12OVPF7lmQO7HU1gJxDAI9izs+oRVlAfrH8rDyzQXoAp3gxv1zJ8UaVTSDtHec9f1bqEmXQPiuUfwjdR/Se8AG0sOEpEUidVmax8n4iU58OKFoaPsJ5xE6x/wwT9pPuTRifdv4K79Nv3QZdK8yb90PLazcogH8HlIQgQkfl3ewjWpwn2yLH92JOmhFgHqwSGE5EyH7x/vjJICtyjX362s6f6Cf6hX9tSOB8Q+SJGfimmQPogZYCXoD9avh1WZYAORcvwfsogpbDeTbBmwW1oKR6mDJIGs4iIvxAeOLPSpGxn/dGYb6rhJRdPod2jn7nGQ7DWaQJSQzxLbC22iqFtxDvE7ThjRTyCNQ1uRkvqYGWQQzBH/yV3+R7zFOhhab8u8smt6iThN1AjB1brd+rnuqhKvAFX6hdz/rgBLqqpDJAHPS2w3ARrIpzth2IiEtgBM+spA2RBB/33unZ9qyrxDNTLg52a11MAS842dDrYRH/XhfxDMLyhh2AViK0jBKum+K5YKObE0CLc8WE8gvUStC7XbtuWrXBeHWWA7tDJp933dq+F8TXVHmgS1M4LFByE/q3VScB826OrwG7IqqsqcQvU3Q+70OJ7SEVJO6iVARsQHAcrTBosR8vrI5UBNsBctBQ+raowD6ag5ev3lQFmw3i0FM9SgiZYOiJ+KHMs4iUkFk+aC5aeLbAULYERygBB+BIt+8ZV3lHfQ8uRRaDqqASmF7Sxf8xV6SR1AjbBi+gphPIuUcb0aQQvwfoWBqDFKoEXuqooWAID0RLyw56OJ7j319WAhZZp/aOMVTegDC0ZfaII1sdKA9CPxOLWeAVrMgy0Hxu9ukS5NvEh+33v6Q6VT4uusCCElpnz4Ie6KgFZAWctgTS0lPjg2osiLDRtFwAfWoKHIfRrj/NCI0oAr8EqgAZ+2IOew7DkWuWBAPQvBT9ayuZo5uUWo8cH6z1FKwTXFkEOWio2Q1ndKIJVILa1XYGeGBSJbeIVrObQKBPS0VJ6ABZ7itY2eLAIO1JmqKqUwzzsWQyB9soFwGliQxUj/HCNs/tiH5hqM2hfxxarCPwPughBI80dEBwHK3wUOMDCjtKjbp5GlAn1vodxgIWeoO6hDGvhmqDtzygXA0/BN3VcPF/yAYfzO3crQRcsE+uxgIfEUqqXVUowGyw9I2EY9uRCxV0uls803AwTsacC3uisqjIEOgMV2GLlAeMgdK7NbW47Aq+Ke8UD4jsw4yyDj9ruIE6yoAxbyo/AjjOVhnehVQFk4ojQIgjeDNSNsGO3FP9mwVYEE8FqAbUOwwoccWAh+HuCVS/C9jUNwZ+BNByx9A0Hd4+ciiOOpELx3WBFumNB/RD0smARjti5FPrVNBCsQvECB9G6SvwaZ/xX/F/xf8S5YojoGRXvYM2C+j7nT8uZC9ZvI42NhdA8AAOALTgi5TkVic/gSRxjFQDzxKFiH7G7eJv4WAhWBqCc49i/Gya2US7hWPzuFf8iTrBgGVCOY4r/5HCupF8AV2wDazrwiDhEfEFcKGYRxkiwwlRAeyAb5+wQPxFHioPEseLn4gEcU7gdLm3q4PubTVw+ay9DTBGfCm/bKPFTcSfOyYe+FyrBQLAQPnfzyHdxSvg1F4hlYrGYHn5d94hNTnC/qxK8Uya2Mx8se0rhCsCHc7aCVXnfG2fB/Ao4hGPSV8O59VQkfgs1N8IiYkrBK8oFW+E5wIdndkx2eVXkeYxgPljh7bs1CCHigr8Ull7u4r26pBgKiBtb7lCCqWCFeVi5AKgtthE7iL8QGykNwGi8s0AJcQ9WmOnwIHEjlAFp5yg7noNmQCoxo2yNizmWoUG8Yon73oOzayiXAG8mZLDC/BkGlIBFTMkvg1v6eFhPc31mzKNVIf59hBJiECy/2FvFCOCcKObBesQjWNV/8aFiPxR0cbNRrcVVxITgauWAR6H+IdiNZxZPinJdyKSEDFaY5dAXyCY2HIJPeyqPvAlXANuJDT74/n4leA6WPUfFXjEKVjMxD/css/m5c7TBMsgmGBGI2VG+9T0UtvdyI7cme+EzjPPhROWACmiJp0/q8lzY/RdlgFUwDCjGGFZYXbDSb3Fx4aGzH77DKBmrIPdCFSUcWyU9B6Pk7ICMbkowFiz9fNFAZRjgGjGIOwLi1UrDBv0R1hJlmCLoFYIMs2Mj8D74m6poAIZbkGtmg/gIbmumHLID5uOK0GzIb294B7skCAssoiYLsh6FdWIk/D7Ycp7LZ7vV2Qejifo9CmYBo+Hb2oY/jQcC+4iKUAnwCmxvrgTjwdLzttjS0L7U3uOjwqYoG3ZqF19WvKVigA/aBGEaUEFUWFsh+CeTa50uCMAUC3LwRioEb1MueRw62a/DsXLE9yH4GxVD/HCjBfPEYlxxdDsUjgPrbCXMprTF/oiPnip9QnnEgnND8KwFu3DHdigfC4vaqhgBNA3CwxZsxB37xFdhUSelQRssM+wVh4iNPb7+RhwLyhHcs8PJM/+OHLv1ziaOw5cNmReoGAL8KgRvBWC/5e4IZh2EBomnqVgQgrYWDBUXApkRlhaUillgLRVfFm8AaiqPAN3ENWJ+2ExxJVjTIHQXBM9UcSQI51twLzBNXMSxQOSIeeEdchNYC469dq6HH+qd4DYpvwA+FPeIeeF/86Ch9+g0C34HTBC/FLeK2eHfkyWmiZ+LT4rXhddqxYUQ1LLgGmCMOF/8QcwKb1tOeFsXhNcu3QyWLhDmg2XPLvFZ8UpRO8iAVuL14nPiTrxRLnZVDjkC54TveJAfdjEcuUzFia/h9FLoDbwifhV+3XmVxsZ6cQ5Yj0LoChVPkI0TO4q9wLoDuFW8TrxAbGr4d9WwoAVwhni6SiCA+mIzsXn4/6S2i3/bIPzvasdw++pW2r6mYi2VIAC1wtvUPLyNdZUGz8EyTyj8s78KnzK+LL4kviPOE9eJeUTP/R5f+xlgnZEIY8OC5pXGRg2VJEkSTbBOXsaoJEmSJIN1EvC0SvJ/7dSxigEAHIDxf5FisAilbNbbWGSi5OZ7BgZPcS/hAZTNwFtYSVltit2iU/c9gxv8u75ffa/wSQ4ruR+ahySHldyZJiHJYSW3pnZIcliJHekrJDmsxMM60JQqIUkJh3WhJX1SKSTpzcN60J1udKQNfdOIaiFJLwxrTwua0Zj61PtjXfqgDtWpEJL04rCetKKBM5GUeVgnGoYkJR1Wka60o0ZIUuJhVWlLzZCk5MMqUyv0r/wCSDD/4sxS1q8AAAAASUVORK5CYII=">>. diff --git a/src/mod_http_fileserver.erl b/src/mod_http_fileserver.erl index 734dbb126..f837e8689 100644 --- a/src/mod_http_fileserver.erl +++ b/src/mod_http_fileserver.erl @@ -5,7 +5,7 @@ %%% Created : %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_http_upload.erl b/src/mod_http_upload.erl index 5b1d279a3..55efc1ab0 100644 --- a/src/mod_http_upload.erl +++ b/src/mod_http_upload.erl @@ -5,7 +5,7 @@ %%% Created : 20 Aug 2015 by Holger Weiss <holger@zedat.fu-berlin.de> %%% %%% -%%% ejabberd, Copyright (C) 2015-2016 ProcessOne +%%% ejabberd, Copyright (C) 2015-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_http_upload_quota.erl b/src/mod_http_upload_quota.erl index 9522cd3d4..c7a697743 100644 --- a/src/mod_http_upload_quota.erl +++ b/src/mod_http_upload_quota.erl @@ -5,7 +5,7 @@ %%% Created : 15 Oct 2015 by Holger Weiss <holger@zedat.fu-berlin.de> %%% %%% -%%% ejabberd, Copyright (C) 2015-2016 ProcessOne +%%% ejabberd, Copyright (C) 2015-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_irc.erl b/src/mod_irc.erl index f43a6653d..5df7588f4 100644 --- a/src/mod_irc.erl +++ b/src/mod_irc.erl @@ -5,7 +5,7 @@ %%% Created : 15 Feb 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_irc_connection.erl b/src/mod_irc_connection.erl index 2e604203c..27e227952 100644 --- a/src/mod_irc_connection.erl +++ b/src/mod_irc_connection.erl @@ -5,7 +5,7 @@ %%% Created : 15 Feb 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_irc_mnesia.erl b/src/mod_irc_mnesia.erl index e23f5a268..ecbe41bb3 100644 --- a/src/mod_irc_mnesia.erl +++ b/src/mod_irc_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_irc_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_irc_mnesia). -behaviour(mod_irc). diff --git a/src/mod_irc_riak.erl b/src/mod_irc_riak.erl index a71859c5c..23f2a2c3c 100644 --- a/src/mod_irc_riak.erl +++ b/src/mod_irc_riak.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_irc_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_irc_riak). -behaviour(mod_irc). diff --git a/src/mod_irc_sql.erl b/src/mod_irc_sql.erl index 7905db91f..f27b05f6c 100644 --- a/src/mod_irc_sql.erl +++ b/src/mod_irc_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_irc_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_irc_sql). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_last.erl b/src/mod_last.erl index 7a08d362b..b5d17311e 100644 --- a/src/mod_last.erl +++ b/src/mod_last.erl @@ -5,7 +5,7 @@ %%% Created : 24 Oct 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_last_mnesia.erl b/src/mod_last_mnesia.erl index 269ed4ba0..1ca9fb112 100644 --- a/src/mod_last_mnesia.erl +++ b/src/mod_last_mnesia.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_last_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_last_mnesia). + -behaviour(mod_last). %% API diff --git a/src/mod_last_riak.erl b/src/mod_last_riak.erl index d25a3a156..9b71f9946 100644 --- a/src/mod_last_riak.erl +++ b/src/mod_last_riak.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_last_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_last_riak). + -behaviour(mod_last). %% API diff --git a/src/mod_last_sql.erl b/src/mod_last_sql.erl index 0351e668c..8dee68b3f 100644 --- a/src/mod_last_sql.erl +++ b/src/mod_last_sql.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_last_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_last_sql). + -behaviour(mod_last). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_mam.erl b/src/mod_mam.erl index ca5930218..f55c1ccf2 100644 --- a/src/mod_mam.erl +++ b/src/mod_mam.erl @@ -1,12 +1,11 @@ %%%------------------------------------------------------------------- -%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%% @doc -%%% Message Archive Management (XEP-0313) -%%% @end +%%% File : mod_mam.erl +%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net> +%%% Purpose : Message Archive Management (XEP-0313) %%% Created : 4 Jul 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2013-2016 ProcessOne +%%% ejabberd, Copyright (C) 2013-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -202,16 +201,16 @@ user_receive_packet({Pkt, #{jid := JID} = C2SState}) -> LUser = JID#jid.luser, LServer = JID#jid.lserver, Pkt2 = case should_archive(Pkt, LServer) of - true -> + true -> Pkt1 = strip_my_archived_tag(Pkt, LServer), case store_msg(C2SState, Pkt1, LUser, LServer, Peer, recv) of - {ok, ID} -> + {ok, ID} -> set_stanza_id(Pkt1, JID, ID); - _ -> + _ -> Pkt1 - end; - _ -> - Pkt + end; + _ -> + Pkt end, {Pkt2, C2SState}. @@ -221,17 +220,17 @@ user_send_packet({Pkt, #{jid := JID} = C2SState}) -> LUser = JID#jid.luser, LServer = JID#jid.lserver, Pkt2 = case should_archive(Pkt, LServer) of - true -> + true -> Pkt1 = strip_my_archived_tag(Pkt, LServer), case store_msg(C2SState, xmpp:set_from_to(Pkt1, JID, Peer), - LUser, LServer, Peer, send) of - {ok, ID} -> + LUser, LServer, Peer, send) of + {ok, ID} -> set_stanza_id(Pkt1, JID, ID); - _ -> + _ -> Pkt1 - end; - false -> - Pkt + end; + false -> + Pkt end, {Pkt2, C2SState}. @@ -781,7 +780,15 @@ msg_to_el(#archive_msg{timestamp = TS, packet = Pkt1, nick = Nick, peer = Peer}, MsgType, JidRequestor, #jid{lserver = LServer} = JidArchive) -> Pkt2 = maybe_update_from_to(Pkt1, JidRequestor, JidArchive, Peer, MsgType, Nick), - #forwarded{xml_els = [xmpp:encode(Pkt2)], + El = case Pkt2 of + #xmlel{attrs = Attrs} -> + Attrs1 = lists:keystore(<<"xmlns">>, 1, Attrs, + {<<"xmlns">>, ?NS_CLIENT}), + Pkt2#xmlel{attrs = Attrs1}; + _ -> + xmpp:encode(Pkt2) + end, + #forwarded{xml_els = [El], delay = #delay{stamp = TS, from = jid:make(LServer)}}. maybe_update_from_to(#xmlel{} = El, JidRequestor, JidArchive, Peer, diff --git a/src/mod_mam_mnesia.erl b/src/mod_mam_mnesia.erl index 89ab92ff1..6b296f772 100644 --- a/src/mod_mam_mnesia.erl +++ b/src/mod_mam_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_mam_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 15 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_mam_mnesia). -behaviour(mod_mam). diff --git a/src/mod_mam_sql.erl b/src/mod_mam_sql.erl index c500745a3..a99c359c6 100644 --- a/src/mod_mam_sql.erl +++ b/src/mod_mam_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_mam_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 15 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_mam_sql). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_metrics.erl b/src/mod_metrics.erl index 1698690d4..7f35a6a50 100644 --- a/src/mod_metrics.erl +++ b/src/mod_metrics.erl @@ -5,7 +5,7 @@ %%% Created : 22 Oct 2015 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_mix.erl b/src/mod_mix.erl index f7bd0ec9a..99d18e774 100644 --- a/src/mod_mix.erl +++ b/src/mod_mix.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_mix.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 2 Mar 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_mix). -behaviour(gen_server). diff --git a/src/mod_muc.erl b/src/mod_muc.erl index e75fb3893..a91fcc810 100644 --- a/src/mod_muc.erl +++ b/src/mod_muc.erl @@ -5,7 +5,7 @@ %%% Created : 19 Mar 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -623,19 +623,19 @@ load_permanent_rooms(Host, ServerHost, Access, RMod = gen_mod:ram_db_mod(ServerHost, ?MODULE), lists:foreach( fun(R) -> - {Room, Host} = R#muc_room.name_host, + {Room, Host} = R#muc_room.name_host, case RMod:find_online_room(Room, Host) of error -> - {ok, Pid} = mod_muc_room:start(Host, - ServerHost, Access, Room, - HistorySize, RoomShaper, - R#muc_room.opts), + {ok, Pid} = mod_muc_room:start(Host, + ServerHost, Access, Room, + HistorySize, RoomShaper, + R#muc_room.opts), RMod:register_online_room(Room, Host, Pid); {ok, _} -> ok - end - end, - get_rooms(ServerHost, Host)). + end + end, + get_rooms(ServerHost, Host)). start_new_room(Host, ServerHost, Access, Room, HistorySize, RoomShaper, From, @@ -692,18 +692,18 @@ iq_disco_items(_ServerHost, _Host, _From, Lang, _MaxRoomsDiscoItems, _Node, _RSM -spec get_room_disco_item({binary(), binary(), pid()}, term()) -> {ok, disco_item()} | - {error, timeout | notfound}. + {error, timeout | notfound}. get_room_disco_item({Name, Host, Pid}, Query) -> - RoomJID = jid:make(Name, Host), - try gen_fsm:sync_send_all_state_event(Pid, Query, 100) of - {item, Desc} -> - {ok, #disco_item{jid = RoomJID, name = Desc}}; - false -> - {error, notfound} - catch _:{timeout, _} -> - {error, timeout}; - _:{noproc, _} -> - {error, notfound} + RoomJID = jid:make(Name, Host), + try gen_fsm:sync_send_all_state_event(Pid, Query, 100) of + {item, Desc} -> + {ok, #disco_item{jid = RoomJID, name = Desc}}; + false -> + {error, notfound} + catch _:{timeout, _} -> + {error, timeout}; + _:{noproc, _} -> + {error, notfound} end. get_subscribed_rooms(ServerHost, Host, From) -> @@ -795,8 +795,8 @@ process_iq_register_set(ServerHost, Host, From, broadcast_service_message(ServerHost, Host, Msg) -> lists:foreach( fun({_, _, Pid}) -> - gen_fsm:send_all_state_event( - Pid, {service_message, Msg}) + gen_fsm:send_all_state_event( + Pid, {service_message, Msg}) end, get_online_rooms(ServerHost, Host)). -spec get_online_rooms(binary(), binary()) -> [{binary(), binary(), pid()}]. diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index 48835c016..55f182ba3 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -3,7 +3,24 @@ %%% Author : Badlop <badlop@ono.com> %%% Purpose : Tools for additional MUC administration %%% Created : 8 Sep 2007 by Badlop <badlop@ono.com> -%%% Id : $Id: mod_muc_admin.erl 1133 2012-10-17 22:13:06Z badlop $ +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% %%%---------------------------------------------------------------------- -module(mod_muc_admin). @@ -973,38 +990,50 @@ get_subscribers(Name, Host) -> throw({error, "The room does not exist"}) end. +%% Copied from mod_muc_room.erl +get_config_opt_name(Pos) -> + Fs = [config|record_info(fields, config)], + lists:nth(Pos, Fs). +-define(MAKE_CONFIG_OPT(Opt), + {get_config_opt_name(Opt), element(Opt, Config)}). make_opts(StateData) -> Config = StateData#state.config, - [ - {title, Config#config.title}, - {vcard, Config#config.vcard}, - {voice_request_min_interval, Config#config.voice_request_min_interval}, - {allow_change_subj, Config#config.allow_change_subj}, - {allow_query_users, Config#config.allow_query_users}, - {allow_private_messages, Config#config.allow_private_messages}, - {allow_private_messages_from_visitors, Config#config.allow_private_messages_from_visitors}, - {allow_visitor_status, Config#config.allow_visitor_status}, - {allow_visitor_nickchange, Config#config.allow_visitor_nickchange}, - {allow_voice_requests, Config#config.allow_voice_requests}, - {public, Config#config.public}, - {public_list, Config#config.public_list}, - {persistent, Config#config.persistent}, - {mam, Config#config.mam}, - {moderated, Config#config.moderated}, - {members_by_default, Config#config.members_by_default}, - {members_only, Config#config.members_only}, - {allow_user_invites, Config#config.allow_user_invites}, - {password_protected, Config#config.password_protected}, - {password, Config#config.password}, - {anonymous, Config#config.anonymous}, - {captcha_protected, Config#config.captcha_protected}, - {description, Config#config.description}, - {logging, Config#config.logging}, - {max_users, Config#config.max_users}, - {affiliations, ?DICT:to_list(StateData#state.affiliations)}, + Subscribers = (?DICT):fold( + fun(_LJID, Sub, Acc) -> + [{Sub#subscriber.jid, + Sub#subscriber.nick, + Sub#subscriber.nodes}|Acc] + end, [], StateData#state.subscribers), + [?MAKE_CONFIG_OPT(#config.title), ?MAKE_CONFIG_OPT(#config.description), + ?MAKE_CONFIG_OPT(#config.allow_change_subj), + ?MAKE_CONFIG_OPT(#config.allow_query_users), + ?MAKE_CONFIG_OPT(#config.allow_private_messages), + ?MAKE_CONFIG_OPT(#config.allow_private_messages_from_visitors), + ?MAKE_CONFIG_OPT(#config.allow_visitor_status), + ?MAKE_CONFIG_OPT(#config.allow_visitor_nickchange), + ?MAKE_CONFIG_OPT(#config.public), ?MAKE_CONFIG_OPT(#config.public_list), + ?MAKE_CONFIG_OPT(#config.persistent), + ?MAKE_CONFIG_OPT(#config.moderated), + ?MAKE_CONFIG_OPT(#config.members_by_default), + ?MAKE_CONFIG_OPT(#config.members_only), + ?MAKE_CONFIG_OPT(#config.allow_user_invites), + ?MAKE_CONFIG_OPT(#config.password_protected), + ?MAKE_CONFIG_OPT(#config.captcha_protected), + ?MAKE_CONFIG_OPT(#config.password), ?MAKE_CONFIG_OPT(#config.anonymous), + ?MAKE_CONFIG_OPT(#config.logging), ?MAKE_CONFIG_OPT(#config.max_users), + ?MAKE_CONFIG_OPT(#config.allow_voice_requests), + ?MAKE_CONFIG_OPT(#config.allow_subscription), + ?MAKE_CONFIG_OPT(#config.mam), + ?MAKE_CONFIG_OPT(#config.presence_broadcast), + ?MAKE_CONFIG_OPT(#config.voice_request_min_interval), + ?MAKE_CONFIG_OPT(#config.vcard), + {captcha_whitelist, + (?SETS):to_list((StateData#state.config)#config.captcha_whitelist)}, + {affiliations, + (?DICT):to_list(StateData#state.affiliations)}, {subject, StateData#state.subject}, - {subject_author, StateData#state.subject_author} - ]. + {subject_author, StateData#state.subject_author}, + {subscribers, Subscribers}]. %%---------------------------- diff --git a/src/mod_muc_log.erl b/src/mod_muc_log.erl index 2f5b31992..700f7284e 100644 --- a/src/mod_muc_log.erl +++ b/src/mod_muc_log.erl @@ -5,7 +5,7 @@ %%% Created : 12 Mar 2006 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -1170,7 +1170,7 @@ get_room_occupants(RoomJIDString) -> get_room_state(RoomName, MucService) -> case mod_muc:find_online_room(RoomName, MucService) of {ok, RoomPid} -> - get_room_state(RoomPid); + get_room_state(RoomPid); error -> #state{} end. diff --git a/src/mod_muc_mnesia.erl b/src/mod_muc_mnesia.erl index e73c31bcd..9fdd1dce2 100644 --- a/src/mod_muc_mnesia.erl +++ b/src/mod_muc_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_muc_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_muc_mnesia). -behaviour(mod_muc). @@ -282,9 +298,9 @@ init([Host, Opts]) -> ejabberd_mnesia:create(?MODULE, muc_registered, [{disc_copies, [node()]}, {attributes, - record_info(fields, muc_registered)}]), - update_tables(MyHost), - mnesia:add_table_index(muc_registered, nick); + record_info(fields, muc_registered)}, + {index, [nick]}]), + update_tables(MyHost); _ -> ok end, @@ -294,11 +310,9 @@ init([Host, Opts]) -> ejabberd_mnesia:create(?MODULE, muc_online_room, [{ram_copies, [node()]}, {type, ordered_set}, - {attributes, - record_info(fields, muc_online_room)}]), + {attributes, record_info(fields, muc_online_room)}]), mnesia:add_table_copy(muc_online_room, node(), ram_copies), - catch ets:new(muc_online_users, - [bag, named_table, public, {keypos, 2}]), + catch ets:new(muc_online_users, [bag, named_table, public, {keypos, 2}]), clean_table_from_bad_node(node(), MyHost), mnesia:subscribe(system); _ -> diff --git a/src/mod_muc_riak.erl b/src/mod_muc_riak.erl index 47e50f86c..23681e883 100644 --- a/src/mod_muc_riak.erl +++ b/src/mod_muc_riak.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_muc_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_muc_riak). -behaviour(mod_muc). diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 73bcdd166..40e9633b1 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -5,7 +5,7 @@ %%% Created : 19 Mar 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -825,14 +825,15 @@ process_normal_message(From, #message{lang = Lang} = Pkt, StateData) -> Action = lists:foldl( fun(_, {error, _} = Err) -> Err; - (#muc_user{invites = [#muc_invite{to = undefined}]}, _) -> - Txt = <<"No 'to' attribute found">>, - {error, xmpp:err_bad_request(Txt, Lang)}; - (#muc_user{invites = [I]}, _) -> - {ok, I}; - (#muc_user{invites = [_|_]}, _) -> - Txt = <<"Multiple invitations are not allowed">>, - {error, xmpp:err_resource_constraint(Txt, Lang)}; + (_, {ok, _} = Result) -> + Result; + (#muc_user{invites = [_|_] = Invites}, _) -> + case check_invitation(From, Invites, Lang, StateData) of + ok -> + {ok, Invites}; + {error, _} = Err -> + Err + end; (#xdata{type = submit, fields = Fs}, _) -> try {ok, muc_request:decode(Fs)} catch _:{muc_request, Why} -> @@ -843,8 +844,11 @@ process_normal_message(From, #message{lang = Lang} = Pkt, StateData) -> Acc end, ok, xmpp:get_els(Pkt)), case Action of - {ok, #muc_invite{} = Invitation} -> - process_invitation(From, Pkt, Invitation, StateData); + {ok, [#muc_invite{}|_] = Invitations} -> + lists:foldl( + fun(Invitation, AccState) -> + process_invitation(From, Invitation, Lang, AccState) + end, StateData, Invitations); {ok, [{role, participant}]} -> process_voice_request(From, Pkt, StateData); {ok, VoiceApproval} -> @@ -856,29 +860,23 @@ process_normal_message(From, #message{lang = Lang} = Pkt, StateData) -> StateData end. --spec process_invitation(jid(), message(), muc_invite(), state()) -> state(). -process_invitation(From, Pkt, Invitation, StateData) -> - Lang = xmpp:get_lang(Pkt), - case check_invitation(From, Invitation, Lang, StateData) of - {error, Error} -> - ejabberd_router:route_error(StateData#state.jid, From, Pkt, Error), - StateData; - IJID -> - Config = StateData#state.config, - case Config#config.members_only of - true -> - case get_affiliation(IJID, StateData) of - none -> - NSD = set_affiliation(IJID, member, StateData), - send_affiliation(IJID, member, StateData), - store_room(NSD), - NSD; - _ -> - StateData - end; - false -> +-spec process_invitation(jid(), muc_invite(), binary(), state()) -> state(). +process_invitation(From, Invitation, Lang, StateData) -> + IJID = route_invitation(From, Invitation, Lang, StateData), + Config = StateData#state.config, + case Config#config.members_only of + true -> + case get_affiliation(IJID, StateData) of + none -> + NSD = set_affiliation(IJID, member, StateData), + send_affiliation(IJID, member, StateData), + store_room(NSD), + NSD; + _ -> StateData - end + end; + false -> + StateData end. -spec process_voice_request(jid(), message(), state()) -> state(). @@ -1264,12 +1262,7 @@ get_error_condition(undefined) -> "undefined". get_error_text(Error) -> - case fxml:get_subtag_with_xmlns(Error, <<"text">>, ?NS_STANZAS) of - #xmlel{} = Tag -> - fxml:get_tag_cdata(Tag); - false -> - <<"">> - end. + (Error#stanza_error.text)#text.data. -spec make_reason(stanza(), jid(), state(), binary()) -> binary(). make_reason(Packet, From, StateData, Reason1) -> @@ -2999,6 +2992,30 @@ get_actor_nick(MJID, StateData) -> _ -> <<"">> end. +convert_legacy_fields(Fs) -> + lists:map( + fun(#xdata_field{var = Var} = F) -> + NewVar = case Var of + <<"muc#roomconfig_allowvisitorstatus">> -> + <<"allow_visitor_status">>; + <<"muc#roomconfig_allowvisitornickchange">> -> + <<"allow_visitor_nickchange">>; + <<"muc#roomconfig_allowvoicerequests">> -> + <<"allow_voice_requests">>; + <<"muc#roomconfig_allow_subscription">> -> + <<"allow_subscription">>; + <<"muc#roomconfig_voicerequestmininterval">> -> + <<"voice_request_min_interval">>; + <<"muc#roomconfig_captcha_whitelist">> -> + <<"captcha_whitelist">>; + <<"muc#roomconfig_mam">> -> + <<"mam">>; + _ -> + Var + end, + F#xdata_field{var = NewVar} + end, Fs). + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Owner stuff -spec process_iq_owner(jid(), iq(), state()) -> @@ -3024,7 +3041,8 @@ process_iq_owner(From, #iq{type = set, lang = Lang, #xdata{type = cancel} -> {result, undefined}; #xdata{type = submit, fields = Fs} -> - try muc_roomconfig:decode(Fs) of + Fs1 = convert_legacy_fields(Fs), + try muc_roomconfig:decode(Fs1) of Options -> case is_allowed_log_change(Options, StateData, From) andalso is_allowed_persistent_change(Options, StateData, From) andalso @@ -3707,7 +3725,7 @@ process_iq_vcard(From, #iq{type = set, lang = Lang, sub_els = [SubEl]}, {ignore, state()}. process_iq_mucsub(_From, #iq{type = set, lang = Lang, sub_els = [#muc_subscribe{}]}, - #state{config = #config{allow_subscription = false}}) -> + #state{just_created = false, config = #config{allow_subscription = false}}) -> {error, xmpp:err_not_allowed(<<"Subscriptions are not allowed">>, Lang)}; process_iq_mucsub(From, #iq{type = set, lang = Lang, @@ -3736,7 +3754,8 @@ process_iq_mucsub(From, NewStateData = set_subscriber(From, Nick, Nodes, StateData), {result, subscribe_result(Packet), NewStateData}; error -> - add_new_user(From, Nick, Packet, StateData) + SD2 = StateData#state{config = (StateData#state.config)#config{allow_subscription = true}}, + add_new_user(From, Nick, Packet, SD2) end; process_iq_mucsub(From, #iq{type = set, sub_els = [#muc_unsubscribe{}]}, StateData) -> @@ -3876,60 +3895,73 @@ send_voice_request(From, Lang, StateData) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Invitation support - --spec check_invitation(jid(), muc_invite(), binary(), state()) -> {error, stanza_error()} | jid(). -check_invitation(From, Invitation, Lang, StateData) -> +-spec check_invitation(jid(), [muc_invite()], binary(), state()) -> + ok | {error, stanza_error()}. +check_invitation(From, Invitations, Lang, StateData) -> FAffiliation = get_affiliation(From, StateData), - CanInvite = (StateData#state.config)#config.allow_user_invites - orelse - FAffiliation == admin orelse FAffiliation == owner, + CanInvite = (StateData#state.config)#config.allow_user_invites orelse + FAffiliation == admin orelse FAffiliation == owner, case CanInvite of + true -> + case lists:all( + fun(#muc_invite{to = #jid{}}) -> true; + (_) -> false + end, Invitations) of + true -> + ok; + false -> + Txt = <<"No 'to' attribute found in the invitation">>, + {error, xmpp:err_bad_request(Txt, Lang)} + end; false -> Txt = <<"Invitations are not allowed in this conference">>, - {error, xmpp:err_not_allowed(Txt, Lang)}; - true -> - #muc_invite{to = JID, reason = Reason} = Invitation, - Invite = Invitation#muc_invite{to = undefined, from = From}, - Password = case (StateData#state.config)#config.password_protected of - true -> - (StateData#state.config)#config.password; - false -> - undefined - end, - XUser = #muc_user{password = Password, invites = [Invite]}, - XConference = #x_conference{jid = jid:make(StateData#state.room, - StateData#state.host), - reason = Reason}, - Body = iolist_to_binary( - [io_lib:format( - translate:translate( - Lang, - <<"~s invites you to the room ~s">>), - [jid:to_string(From), - jid:to_string({StateData#state.room, - StateData#state.host, - <<"">>})]), - case (StateData#state.config)#config.password_protected of - true -> - <<", ", - (translate:translate( - Lang, <<"the password is">>))/binary, - " '", - ((StateData#state.config)#config.password)/binary, - "'">>; - _ -> <<"">> - end, - case Reason of - <<"">> -> <<"">>; - _ -> <<" (", Reason/binary, ") ">> - end]), - Msg = #message{type = normal, - body = xmpp:mk_text(Body), - sub_els = [XUser, XConference]}, - ejabberd_router:route(StateData#state.jid, JID, Msg), - JID + {error, xmpp:err_not_allowed(Txt, Lang)} end. +-spec route_invitation(jid(), muc_invite(), binary(), state()) -> jid(). +route_invitation(From, Invitation, Lang, StateData) -> + #muc_invite{to = JID, reason = Reason} = Invitation, + Invite = Invitation#muc_invite{to = undefined, from = From}, + Password = case (StateData#state.config)#config.password_protected of + true -> + (StateData#state.config)#config.password; + false -> + undefined + end, + XUser = #muc_user{password = Password, invites = [Invite]}, + XConference = #x_conference{jid = jid:make(StateData#state.room, + StateData#state.host), + reason = Reason}, + Body = iolist_to_binary( + [io_lib:format( + translate:translate( + Lang, + <<"~s invites you to the room ~s">>), + [jid:to_string(From), + jid:to_string({StateData#state.room, StateData#state.host, <<"">>})]), + case (StateData#state.config)#config.password_protected of + true -> + <<", ", + (translate:translate( + Lang, <<"the password is">>))/binary, + " '", + ((StateData#state.config)#config.password)/binary, + "'">>; + _ -> <<"">> + end, + case Reason of + <<"">> -> <<"">>; + _ -> <<" (", Reason/binary, ") ">> + end]), + Msg = #message{type = normal, + body = xmpp:mk_text(Body), + sub_els = [XUser, XConference]}, + ejabberd_hooks:run(muc_invite, StateData#state.server_host, + [StateData#state.jid, StateData#state.config, + From, JID, Reason]), + ejabberd_router:route(StateData#state.jid, JID, Msg), + JID. + %% Handle a message sent to the room by a non-participant. %% If it is a decline, send to the inviter. %% Otherwise, an error message is sent to the sender. diff --git a/src/mod_muc_sql.erl b/src/mod_muc_sql.erl index 6a37451c0..f02cc77a8 100644 --- a/src/mod_muc_sql.erl +++ b/src/mod_muc_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_muc_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_muc_sql). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_multicast.erl b/src/mod_multicast.erl index fbd2402ee..08d993106 100644 --- a/src/mod_multicast.erl +++ b/src/mod_multicast.erl @@ -5,7 +5,7 @@ %%% Created : 29 May 2007 by Badlop <badlop@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_offline.erl b/src/mod_offline.erl index 8443fde0c..b34572ba8 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -5,7 +5,7 @@ %%% Created : 5 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -126,7 +126,6 @@ start(Host, Opts) -> stop(Host) -> Proc = gen_mod:get_module_proc(Host, ?PROCNAME), - catch ?GEN_SERVER:call(Proc, stop), supervisor:terminate_child(ejabberd_sup, Proc), supervisor:delete_child(ejabberd_sup, Proc), ok. @@ -283,16 +282,16 @@ get_sm_items(_Acc, #jid{luser = U, lserver = S} = JID, #jid{luser = U, lserver = S}, ?NS_FLEX_OFFLINE, _Lang) -> ejabberd_sm:route(JID, {resend_offline, false}), - Mod = gen_mod:db_mod(S, ?MODULE), - Hdrs = Mod:read_message_headers(U, S), - BareJID = jid:remove_resource(JID), - {result, lists:map( - fun({Seq, From, _To, _TS, _El}) -> - Node = integer_to_binary(Seq), - #disco_item{jid = BareJID, - node = Node, - name = jid:to_string(From)} - end, Hdrs)}; + Mod = gen_mod:db_mod(S, ?MODULE), + Hdrs = Mod:read_message_headers(U, S), + BareJID = jid:remove_resource(JID), + {result, lists:map( + fun({Seq, From, _To, _TS, _El}) -> + Node = integer_to_binary(Seq), + #disco_item{jid = BareJID, + node = Node, + name = jid:to_string(From)} + end, Hdrs)}; get_sm_items(Acc, _From, _To, _Node, _Lang) -> Acc. @@ -401,8 +400,8 @@ set_offline_tag(Msg, Node) -> -spec handle_offline_fetch(jid()) -> ok. handle_offline_fetch(#jid{luser = U, lserver = S} = JID) -> ejabberd_sm:route(JID, {resend_offline, false}), - lists:foreach( - fun({Node, El}) -> + lists:foreach( + fun({Node, El}) -> El1 = set_offline_tag(El, Node), From = xmpp:get_from(El1), To = xmpp:get_to(El1), @@ -869,11 +868,13 @@ count_offline_messages(User, Server) -> -spec add_delay_info(message(), binary(), undefined | erlang:timestamp()) -> message(). -add_delay_info(Packet, _LServer, undefined) -> - Packet; -add_delay_info(Packet, LServer, {_, _, _} = TS) -> +add_delay_info(Packet, LServer, TS) -> + NewTS = case TS of + undefined -> p1_time_compat:timestamp(); + _ -> TS + end, Packet1 = xmpp:put_meta(Packet, from_offline, true), - xmpp_util:add_delay_info(Packet1, jid:make(LServer), TS, + xmpp_util:add_delay_info(Packet1, jid:make(LServer), NewTS, <<"Offline storage">>). -spec get_priority_from_presence(presence()) -> integer(). diff --git a/src/mod_offline_mnesia.erl b/src/mod_offline_mnesia.erl index fb75f618e..f04321237 100644 --- a/src/mod_offline_mnesia.erl +++ b/src/mod_offline_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_offline_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 15 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_offline_mnesia). -behaviour(mod_offline). diff --git a/src/mod_offline_riak.erl b/src/mod_offline_riak.erl index 824abc89c..ffc1450aa 100644 --- a/src/mod_offline_riak.erl +++ b/src/mod_offline_riak.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_offline_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 15 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_offline_riak). -behaviour(mod_offline). diff --git a/src/mod_offline_sql.erl b/src/mod_offline_sql.erl index e626df425..5a9631c92 100644 --- a/src/mod_offline_sql.erl +++ b/src/mod_offline_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_offline_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 15 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_offline_sql). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_ping.erl b/src/mod_ping.erl index 09550ee9a..49664f338 100644 --- a/src/mod_ping.erl +++ b/src/mod_ping.erl @@ -5,7 +5,7 @@ %%% Created : 11 Jul 2009 by Brian Cully <bjc@kublai.com> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_pres_counter.erl b/src/mod_pres_counter.erl index 8da4f7b29..c22562a11 100644 --- a/src/mod_pres_counter.erl +++ b/src/mod_pres_counter.erl @@ -5,7 +5,7 @@ %%% Created : 23 Sep 2010 by Ahmed Omar %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_privacy.erl b/src/mod_privacy.erl index 6eb939c3c..cfced6d06 100644 --- a/src/mod_privacy.erl +++ b/src/mod_privacy.erl @@ -5,7 +5,7 @@ %%% Created : 21 Jul 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -125,7 +125,7 @@ process_iq(#iq{lang = Lang} = IQ) -> -spec process_iq_get(iq()) -> iq(). process_iq_get(#iq{lang = Lang, - sub_els = [#privacy_query{default = Default, + sub_els = [#privacy_query{default = Default, active = Active}]} = IQ) when Default /= undefined; Active /= undefined -> Txt = <<"Only <list/> element is allowed in this query">>, @@ -159,9 +159,9 @@ process_lists_get(#iq{from = #jid{luser = LUser, lserver = LServer}, {Default, ListNames} -> xmpp:make_iq_result( IQ, - #privacy_query{active = Active, - default = Default, - lists = [#privacy_list{name = ListName} + #privacy_query{active = Active, + default = Default, + lists = [#privacy_list{name = ListName} || ListName <- ListNames]}) end. @@ -180,7 +180,7 @@ process_list_get(#iq{from = #jid{luser = LUser, lserver = LServer}, LItems = lists:map(fun encode_list_item/1, Items), xmpp:make_iq_result( IQ, - #privacy_query{ + #privacy_query{ lists = [#privacy_list{name = Name, items = LItems}]}) end. @@ -248,8 +248,8 @@ decode_value(Type, Value) -> -spec process_iq_set(iq()) -> iq(). process_iq_set(#iq{lang = Lang, - sub_els = [#privacy_query{default = Default, - active = Active, + sub_els = [#privacy_query{default = Default, + active = Active, lists = Lists}]} = IQ) -> case Lists of [#privacy_list{items = Items, name = ListName}] @@ -484,46 +484,46 @@ check_packet(_, #{jid := #jid{luser = LUser, lserver = LServer}, {#jid{lserver = LServer}, #jid{luser = <<"">>, lserver = LServer}} when Dir == out -> %% Allow any packets to local server - allow; + allow; {#jid{luser = LUser, lserver = LServer, lresource = <<"">>}, #jid{luser = LUser, lserver = LServer}} when Dir == in -> %% Allow incoming packets from user's bare jid to his full jid - allow; + allow; {#jid{luser = LUser, lserver = LServer}, #jid{luser = LUser, lserver = LServer, lresource = <<"">>}} when Dir == out -> %% Allow outgoing packets from user's full jid to his bare JID allow; _ when List == [] -> - allow; - _ -> - PType = case Packet of - #message{} -> message; - #iq{} -> iq; - #presence{type = available} -> presence; - #presence{type = unavailable} -> presence; - _ -> other - end, - PType2 = case {PType, Dir} of - {message, in} -> message; - {iq, in} -> iq; - {presence, in} -> presence_in; - {presence, out} -> presence_out; - {_, _} -> other - end, - LJID = case Dir of - in -> jid:tolower(From); - out -> jid:tolower(To) + allow; + _ -> + PType = case Packet of + #message{} -> message; + #iq{} -> iq; + #presence{type = available} -> presence; + #presence{type = unavailable} -> presence; + _ -> other + end, + PType2 = case {PType, Dir} of + {message, in} -> message; + {iq, in} -> iq; + {presence, in} -> presence_in; + {presence, out} -> presence_out; + {_, _} -> other end, + LJID = case Dir of + in -> jid:tolower(From); + out -> jid:tolower(To) + end, {Subscription, Groups} = case NeedDb of - true -> - ejabberd_hooks:run_fold(roster_get_jid_info, + true -> + ejabberd_hooks:run_fold(roster_get_jid_info, LServer, - {none, []}, + {none, []}, [LUser, LServer, LJID]); false -> {[], []} - end, + end, check_packet_aux(List, PType2, LJID, Subscription, Groups) end; check_packet(Acc, #jid{luser = LUser, lserver = LServer} = JID, Packet, Dir) -> diff --git a/src/mod_privacy_mnesia.erl b/src/mod_privacy_mnesia.erl index eca6f8ecd..e3adc7948 100644 --- a/src/mod_privacy_mnesia.erl +++ b/src/mod_privacy_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_privacy_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_privacy_mnesia). -behaviour(mod_privacy). diff --git a/src/mod_privacy_riak.erl b/src/mod_privacy_riak.erl index b96a08cbc..28851d042 100644 --- a/src/mod_privacy_riak.erl +++ b/src/mod_privacy_riak.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_privacy_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_privacy_riak). -behaviour(mod_privacy). diff --git a/src/mod_privacy_sql.erl b/src/mod_privacy_sql.erl index 1984237c6..4260fcb5d 100644 --- a/src/mod_privacy_sql.erl +++ b/src/mod_privacy_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_privacy_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_privacy_sql). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_private.erl b/src/mod_private.erl index d11cad36f..b5ec72907 100644 --- a/src/mod_private.erl +++ b/src/mod_private.erl @@ -5,7 +5,7 @@ %%% Created : 16 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_private_mnesia.erl b/src/mod_private_mnesia.erl index 42e5ddfd8..fd588aac2 100644 --- a/src/mod_private_mnesia.erl +++ b/src/mod_private_mnesia.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_private_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_private_mnesia). + -behaviour(mod_private). %% API diff --git a/src/mod_private_riak.erl b/src/mod_private_riak.erl index 7b091c4a6..5c5185573 100644 --- a/src/mod_private_riak.erl +++ b/src/mod_private_riak.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_private_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_private_riak). -behaviour(mod_private). diff --git a/src/mod_private_sql.erl b/src/mod_private_sql.erl index b459916e4..800b31a21 100644 --- a/src/mod_private_sql.erl +++ b/src/mod_private_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_private_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_private_sql). -behaviour(mod_private). diff --git a/src/mod_privilege.erl b/src/mod_privilege.erl index ae0a67e72..b860d9a39 100644 --- a/src/mod_privilege.erl +++ b/src/mod_privilege.erl @@ -4,7 +4,7 @@ %%% Purpose : XEP-0356: Privileged Entity %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_proxy65.erl b/src/mod_proxy65.erl index 0c403e23b..8486802d0 100644 --- a/src/mod_proxy65.erl +++ b/src/mod_proxy65.erl @@ -5,7 +5,7 @@ %%% Created : 12 Oct 2006 by Evgeniy Khramtsov <xram@jabber.ru> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_proxy65_lib.erl b/src/mod_proxy65_lib.erl index 3cacbf98b..6b0d420e3 100644 --- a/src/mod_proxy65_lib.erl +++ b/src/mod_proxy65_lib.erl @@ -5,7 +5,7 @@ %%% Created : 12 Oct 2006 by Evgeniy Khramtsov <xram@jabber.ru> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_proxy65_service.erl b/src/mod_proxy65_service.erl index db844cb81..f51b33db2 100644 --- a/src/mod_proxy65_service.erl +++ b/src/mod_proxy65_service.erl @@ -5,7 +5,7 @@ %%% Created : 12 Oct 2006 by Evgeniy Khramtsov <xram@jabber.ru> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_proxy65_stream.erl b/src/mod_proxy65_stream.erl index a363577d3..a04e9e94b 100644 --- a/src/mod_proxy65_stream.erl +++ b/src/mod_proxy65_stream.erl @@ -4,7 +4,7 @@ %%% Purpose : Bytestream process. %%% Created : 12 Oct 2006 by Evgeniy Khramtsov <xram@jabber.ru> %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index 527c010a0..eba2cab29 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -263,7 +263,10 @@ init([ServerHost, Opts]) -> fun(A) when is_integer(A) andalso A >= 0 -> A end, ?MAXITEMS), MaxSubsNode = gen_mod:get_opt(max_subscriptions_node, Opts, fun(A) when is_integer(A) andalso A >= 0 -> A end, undefined), - [pubsub_index:init(Host, ServerHost, Opts) || gen_mod:db_type(ServerHost, ?MODULE)==mnesia], + case gen_mod:db_type(ServerHost, ?MODULE) of + mnesia -> init_mnesia(Host, ServerHost, Opts); + _ -> ok + end, {Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts), DefaultModule = plugin(Host, hd(Plugins)), BaseOptions = DefaultModule:options(), @@ -336,9 +339,6 @@ init([ServerHost, Opts]) -> false -> ok end, - pubsub_migrate:update_node_database(Host, ServerHost), - pubsub_migrate:update_state_database(Host, ServerHost), - pubsub_migrate:update_lastitem_database(Host, ServerHost), {_, State} = init_send_loop(ServerHost), {ok, State}. @@ -381,6 +381,18 @@ depends(ServerHost, Opts) -> end end, Plugins). +init_mnesia(Host, ServerHost, Opts) -> + pubsub_index:init(Host, ServerHost, Opts), + spawn(fun() -> + %% maybe upgrade db. this can take time when upgrading existing + %% data from ejabberd 2.1.x, so we don't want this to block + %% calling gen_server:start + pubsub_migrate:update_node_database(Host, ServerHost), + pubsub_migrate:update_state_database(Host, ServerHost), + pubsub_migrate:update_item_database(Host, ServerHost), + pubsub_migrate:update_lastitem_database(Host, ServerHost) + end). + %% @doc Call the init/1 function for each plugin declared in the config file. %% The default plugin module is implicit. %% <p>The Erlang code for the plugin is located in a module called @@ -2211,20 +2223,20 @@ send_items(Host, Node, _Nidx, _Type, Options, LJID, _) -> dispatch_items(Host, LJID, Node, Stanza). dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, - Node, Stanza) -> + Node, Stanza) -> C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of - ToPid when is_pid(ToPid) -> ToPid; - _ -> - R = user_resource(FromU, FromS, FromR), - case ejabberd_sm:get_session_pid(FromU, FromS, R) of - FromPid when is_pid(FromPid) -> FromPid; - _ -> undefined - end - end, + ToPid when is_pid(ToPid) -> ToPid; + _ -> + R = user_resource(FromU, FromS, FromR), + case ejabberd_sm:get_session_pid(FromU, FromS, R) of + FromPid when is_pid(FromPid) -> FromPid; + _ -> undefined + end + end, if C2SPid == undefined -> ok; - true -> + true -> C2SPid ! {send_filtered, {pep_message, <<Node/binary, "+notify">>}, - service_jid(From), jid:make(To), + service_jid(From), jid:make(To), Stanza} end; dispatch_items(From, To, _Node, Stanza) -> @@ -2762,7 +2774,7 @@ get_resource_state({U, S, R}, ShowValues, JIDs) -> #presence{type = unavailable} -> <<"unavailable">>; #presence{show = undefined} -> <<"online">>; #presence{show = S} -> atom_to_binary(S, latin1) - end, + end, case lists:member(Show, ShowValues) of %% If yes, item can be delivered true -> lists:append([{U, S, R}], JIDs); @@ -3007,11 +3019,11 @@ broadcast_stanza({LUser, LServer, LResource}, Publisher, Node, Nidx, Type, NodeO broadcast_stanza({LUser, LServer, <<>>}, Node, Nidx, Type, NodeOptions, SubsByDepth, NotifyType, BaseStanza, SHIM), %% Handles implicit presence subscriptions SenderResource = user_resource(LUser, LServer, LResource), - NotificationType = get_option(NodeOptions, notification_type, headline), - Stanza = add_message_type(BaseStanza, NotificationType), - %% set the from address on the notification to the bare JID of the account owner - %% Also, add "replyto" if entity has presence subscription to the account owner - %% See XEP-0163 1.1 section 4.3.1 + NotificationType = get_option(NodeOptions, notification_type, headline), + Stanza = add_message_type(BaseStanza, NotificationType), + %% set the from address on the notification to the bare JID of the account owner + %% Also, add "replyto" if entity has presence subscription to the account owner + %% See XEP-0163 1.1 section 4.3.1 ejabberd_sm:route(jid:make(LUser, LServer, SenderResource), {pep_message, <<((Node))/binary, "+notify">>, jid:make(LUser, LServer, <<"">>), diff --git a/src/mod_register.erl b/src/mod_register.erl index 8917d4c5c..7bb60753b 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -5,7 +5,7 @@ %%% Created : 8 Dec 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_register_web.erl b/src/mod_register_web.erl index 20b370fb9..21db76b46 100644 --- a/src/mod_register_web.erl +++ b/src/mod_register_web.erl @@ -5,7 +5,7 @@ %%% Created : 4 May 2008 by Badlop <badlop@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_roster.erl b/src/mod_roster.erl index c22d02bb6..44649631a 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -5,7 +5,7 @@ %%% Created : 11 Dec 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -218,9 +218,9 @@ roster_version_on_db(Host) -> get_versioning_feature(Acc, Host) -> case gen_mod:is_loaded(Host, ?MODULE) of true -> - case roster_versioning_enabled(Host) of - true -> - [#rosterver_feature{}|Acc]; + case roster_versioning_enabled(Host) of + true -> + [#rosterver_feature{}|Acc]; false -> Acc end; @@ -532,9 +532,9 @@ c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer} = JID, fill_subscription_lists([I | Is], F, T) -> J = element(3, I#roster.usj), {F1, T1} = case I#roster.subscription of - both -> + both -> {?SETS:add_element(J, F), ?SETS:add_element(J, T)}; - from -> + from -> {?SETS:add_element(J, F), T}; to -> {F, ?SETS:add_element(J, T)}; @@ -843,7 +843,7 @@ c2s_self_presence({#presence{type = available} = Pkt, #{lserver := LServer} = State}) -> Prio = get_priority_from_presence(Pkt), if Prio >= 0 -> - Mod = gen_mod:db_mod(LServer, ?MODULE), + Mod = gen_mod:db_mod(LServer, ?MODULE), State1 = resend_pending_subscriptions(State, Mod), {Pkt, State1}; true -> @@ -858,12 +858,12 @@ resend_pending_subscriptions(#{jid := JID} = State, Mod) -> Result = Mod:get_only_items(JID#jid.luser, JID#jid.lserver), lists:foldl( fun(#roster{ask = Ask} = R, AccState) when Ask == in; Ask == both -> - Message = R#roster.askmessage, - Status = if is_binary(Message) -> (Message); - true -> <<"">> - end, + Message = R#roster.askmessage, + Status = if is_binary(Message) -> (Message); + true -> <<"">> + end, Sub = #presence{from = R#roster.jid, to = BareJID, - type = subscribe, + type = subscribe, status = xmpp:mk_text(Status)}, ejabberd_c2s:send(AccState, Sub); (_, AccState) -> diff --git a/src/mod_roster_mnesia.erl b/src/mod_roster_mnesia.erl index 04bdf72e7..e1a1fa1b5 100644 --- a/src/mod_roster_mnesia.erl +++ b/src/mod_roster_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_roster_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_roster_mnesia). -behaviour(mod_roster). @@ -26,14 +42,13 @@ init(_Host, _Opts) -> ejabberd_mnesia:create(?MODULE, roster, [{disc_copies, [node()]}, - {attributes, record_info(fields, roster)}]), + {attributes, record_info(fields, roster)}, + {index, [us]}]), ejabberd_mnesia:create(?MODULE, roster_version, [{disc_copies, [node()]}, {attributes, record_info(fields, roster_version)}]), - update_tables(), - mnesia:add_table_index(roster, us), - mnesia:add_table_index(roster_version, us). + update_tables(). read_roster_version(LUser, LServer) -> US = {LUser, LServer}, diff --git a/src/mod_roster_riak.erl b/src/mod_roster_riak.erl index 40992d77d..25788cddf 100644 --- a/src/mod_roster_riak.erl +++ b/src/mod_roster_riak.erl @@ -1,13 +1,28 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_roster_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- --module(mod_roster_riak). +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- +-module(mod_roster_riak). -behaviour(mod_roster). diff --git a/src/mod_roster_sql.erl b/src/mod_roster_sql.erl index 2fc6b112e..ba0fd529e 100644 --- a/src/mod_roster_sql.erl +++ b/src/mod_roster_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_roster_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_roster_sql). -compile([{parse_transform, ejabberd_sql_pt}]). @@ -22,6 +38,7 @@ -include("mod_roster.hrl"). -include("ejabberd_sql_pt.hrl"). +-include("logger.hrl"). %%%=================================================================== %%% API @@ -101,7 +118,13 @@ get_roster_by_jid(LUser, LServer, LJID) -> get_only_items(LUser, LServer) -> case catch sql_queries:get_roster(LServer, LUser) of {selected, Is} when is_list(Is) -> - lists:map(fun(I) -> raw_to_record(LServer, I) end, Is); + lists:flatmap( + fun(I) -> + case raw_to_record(LServer, I) of + error -> []; + R -> [R] + end + end, Is); _ -> [] end. @@ -116,14 +139,19 @@ get_roster_by_jid_with_groups(LUser, LServer, LJID) -> SJID = jid:to_string(LJID), case sql_queries:get_roster_by_jid(LServer, LUser, SJID) of {selected, [I]} -> - R = raw_to_record(LServer, I), - Groups = - case sql_queries:get_roster_groups(LServer, LUser, SJID) of - {selected, JGrps} when is_list(JGrps) -> - [JGrp || {JGrp} <- JGrps]; - _ -> [] - end, - R#roster{groups = Groups}; + case raw_to_record(LServer, I) of + error -> + #roster{usj = {LUser, LServer, LJID}, + us = {LUser, LServer}, jid = LJID}; + R -> + Groups = + case sql_queries:get_roster_groups(LServer, LUser, SJID) of + {selected, JGrps} when is_list(JGrps) -> + [JGrp || {JGrp} <- JGrps]; + _ -> [] + end, + R#roster{groups = Groups} + end; {selected, []} -> #roster{usj = {LUser, LServer, LJID}, us = {LUser, LServer}, jid = LJID} @@ -152,7 +180,13 @@ read_subscription_and_groups(LUser, LServer, LJID) -> <<"B">> -> both; <<"T">> -> to; <<"F">> -> from; - _ -> none + <<"N">> -> none; + <<"">> -> none; + _ -> + ?ERROR_MSG("~s", [format_row_error( + LUser, LServer, + {subscription, SSubscription})]), + none end, Groups = case catch sql_queries:get_rostergroup_by_jid( LServer, LUser, SJID) of @@ -201,22 +235,34 @@ raw_to_record(LServer, {User, SJID, Nick, SSubscription, SAsk, SAskMessage, _SServer, _SSubscribe, _SType}) -> case jid:from_string(SJID) of - error -> error; + error -> + ?ERROR_MSG("~s", [format_row_error(User, LServer, {jid, SJID})]), + error; JID -> LJID = jid:tolower(JID), Subscription = case SSubscription of - <<"B">> -> both; - <<"T">> -> to; - <<"F">> -> from; - _ -> none + <<"B">> -> both; + <<"T">> -> to; + <<"F">> -> from; + <<"N">> -> none; + <<"">> -> none; + _ -> + ?ERROR_MSG("~s", [format_row_error( + User, LServer, + {subscription, SSubscription})]), + none end, Ask = case SAsk of - <<"S">> -> subscribe; - <<"U">> -> unsubscribe; - <<"B">> -> both; - <<"O">> -> out; - <<"I">> -> in; - _ -> none + <<"S">> -> subscribe; + <<"U">> -> unsubscribe; + <<"B">> -> both; + <<"O">> -> out; + <<"I">> -> in; + <<"N">> -> none; + <<"">> -> none; + _ -> + ?ERROR_MSG("~s", [format_row_error(User, LServer, {ask, SAsk})]), + none end, #roster{usj = {User, LServer, LJID}, us = {User, LServer}, jid = LJID, name = Nick, @@ -244,3 +290,11 @@ record_to_row( none -> <<"N">> end, {LUser, SJID, Name, SSubscription, SAsk, AskMessage}. + +format_row_error(User, Server, Why) -> + [case Why of + {jid, JID} -> ["Malformed 'jid' field with value '", JID, "'"]; + {subscription, Sub} -> ["Malformed 'subscription' field with value '", Sub, "'"]; + {ask, Ask} -> ["Malformed 'ask' field with value '", Ask, "'"] + end, + " detected for ", User, "@", Server, " in table 'rosterusers'"]. diff --git a/src/mod_service_log.erl b/src/mod_service_log.erl index f27c4d0d8..d29cd1329 100644 --- a/src/mod_service_log.erl +++ b/src/mod_service_log.erl @@ -5,7 +5,7 @@ %%% Created : 24 Aug 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl index 783954317..077f9bfab 100644 --- a/src/mod_shared_roster.erl +++ b/src/mod_shared_roster.erl @@ -5,7 +5,7 @@ %%% Created : 5 Mar 2005 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -297,8 +297,8 @@ c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer} = JID, US = {LUser, LServer}, DisplayedGroups = get_user_displayed_groups(US), SRUsers = lists:flatmap(fun(Group) -> - get_group_users(LServer, Group) - end, + get_group_users(LServer, Group) + end, DisplayedGroups), BareLJID = jid:tolower(jid:remove_resource(JID)), PresBoth = lists:foldl( @@ -921,7 +921,7 @@ shared_roster_group(Host, Group, Query, Lang) -> ?XE(<<"td">>, [?TEXTAREA(<<"members">>, integer_to_binary(lists:max([3, - byte_size(FMembers)])), + length(Members)+3])), <<"20">>, FMembers)])]), ?XE(<<"tr">>, [?XCT(<<"td">>, <<"Displayed Groups:">>), diff --git a/src/mod_shared_roster_ldap.erl b/src/mod_shared_roster_ldap.erl index 777854b8e..e79bcc5c0 100644 --- a/src/mod_shared_roster_ldap.erl +++ b/src/mod_shared_roster_ldap.erl @@ -7,7 +7,7 @@ %%% Created : 5 Mar 2005 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -166,8 +166,8 @@ c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer} = JID, US = {LUser, LServer}, DisplayedGroups = get_user_displayed_groups(US), SRUsers = lists:flatmap(fun(Group) -> - get_group_users(LServer, Group) - end, + get_group_users(LServer, Group) + end, DisplayedGroups), BareLJID = jid:tolower(jid:remove_resource(JID)), PresBoth = lists:foldl( diff --git a/src/mod_shared_roster_mnesia.erl b/src/mod_shared_roster_mnesia.erl index ed4525041..702e27a09 100644 --- a/src/mod_shared_roster_mnesia.erl +++ b/src/mod_shared_roster_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_shared_roster_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_shared_roster_mnesia). -behaviour(mod_shared_roster). @@ -31,9 +47,9 @@ init(_Host, _Opts) -> {attributes, record_info(fields, sr_group)}]), ejabberd_mnesia:create(?MODULE, sr_user, [{disc_copies, [node()]}, {type, bag}, - {attributes, record_info(fields, sr_user)}]), - update_tables(), - mnesia:add_table_index(sr_user, group_host). + {attributes, record_info(fields, sr_user)}, + {index, [group_host]}]), + update_tables(). list_groups(Host) -> mnesia:dirty_select(sr_group, diff --git a/src/mod_shared_roster_riak.erl b/src/mod_shared_roster_riak.erl index bdb750981..1bf7a1429 100644 --- a/src/mod_shared_roster_riak.erl +++ b/src/mod_shared_roster_riak.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_shared_roster_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_shared_roster_riak). -behaviour(mod_shared_roster). diff --git a/src/mod_shared_roster_sql.erl b/src/mod_shared_roster_sql.erl index 9f723f839..fd815f629 100644 --- a/src/mod_shared_roster_sql.erl +++ b/src/mod_shared_roster_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_shared_roster_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_shared_roster_sql). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_sic.erl b/src/mod_sic.erl index 4bb4eb9eb..fe8d8aa0f 100644 --- a/src/mod_sic.erl +++ b/src/mod_sic.erl @@ -5,7 +5,7 @@ %%% Created : 6 Mar 2010 by Karim Gemayel <karim.gemayel@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_sip.erl b/src/mod_sip.erl index 816100f47..7d62bdfc3 100644 --- a/src/mod_sip.erl +++ b/src/mod_sip.erl @@ -1,12 +1,11 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @doc -%%% -%%% @end +%%% File : mod_sip.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> +%%% Purpose : SIP RFC-3261 %%% Created : 21 Apr 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2014-2016 ProcessOne +%%% ejabberd, Copyright (C) 2014-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_sip_proxy.erl b/src/mod_sip_proxy.erl index 06daf0810..bff6f18a2 100644 --- a/src/mod_sip_proxy.erl +++ b/src/mod_sip_proxy.erl @@ -1,12 +1,11 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @doc -%%% -%%% @end +%%% File : mod_sip_proxy.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> +%%% Purpose : %%% Created : 21 Apr 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2014-2016 ProcessOne +%%% ejabberd, Copyright (C) 2014-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_sip_registrar.erl b/src/mod_sip_registrar.erl index 4ae8e077b..83cf77a0d 100644 --- a/src/mod_sip_registrar.erl +++ b/src/mod_sip_registrar.erl @@ -1,12 +1,11 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @doc -%%% -%%% @end +%%% File : mod_sip_registrar.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> +%%% Purpose : %%% Created : 23 Apr 2014 by Evgeny Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2014-2016 ProcessOne +%%% ejabberd, Copyright (C) 2014-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -182,10 +181,8 @@ init([]) -> ejabberd_mnesia:create(?MODULE, sip_session, [{ram_copies, [node()]}, {type, bag}, - {attributes, record_info(fields, sip_session)}]), - mnesia:add_table_index(sip_session, conn_mref), - mnesia:add_table_index(sip_session, socket), - mnesia:add_table_copy(sip_session, node(), ram_copies), + {attributes, record_info(fields, sip_session)}, + {index, [conn_mref,socket]}]), {ok, #state{}}. handle_call({write, Sessions, Supported}, _From, State) -> diff --git a/src/mod_stats.erl b/src/mod_stats.erl index e43409e06..6cafdf732 100644 --- a/src/mod_stats.erl +++ b/src/mod_stats.erl @@ -5,7 +5,7 @@ %%% Created : 11 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_time.erl b/src/mod_time.erl index 0aeb6831c..883fd4b1a 100644 --- a/src/mod_time.erl +++ b/src/mod_time.erl @@ -6,7 +6,7 @@ %%% Created : 18 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_vcard.erl b/src/mod_vcard.erl index 843281ef8..7dd6d251d 100644 --- a/src/mod_vcard.erl +++ b/src/mod_vcard.erl @@ -5,7 +5,7 @@ %%% Created : 2 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/mod_vcard_ldap.erl b/src/mod_vcard_ldap.erl index 47504c39d..3678ebbcd 100644 --- a/src/mod_vcard_ldap.erl +++ b/src/mod_vcard_ldap.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_vcard_ldap.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 29 Jul 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_vcard_ldap). -behaviour(ejabberd_config). diff --git a/src/mod_vcard_mnesia.erl b/src/mod_vcard_mnesia.erl index 40ea36381..5faff5261 100644 --- a/src/mod_vcard_mnesia.erl +++ b/src/mod_vcard_mnesia.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_vcard_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_vcard_mnesia). -behaviour(mod_vcard). @@ -30,20 +46,13 @@ init(_Host, _Opts) -> ejabberd_mnesia:create(?MODULE, vcard_search, [{disc_copies, [node()]}, {attributes, - record_info(fields, vcard_search)}]), - update_tables(), - mnesia:add_table_index(vcard_search, luser), - mnesia:add_table_index(vcard_search, lfn), - mnesia:add_table_index(vcard_search, lfamily), - mnesia:add_table_index(vcard_search, lgiven), - mnesia:add_table_index(vcard_search, lmiddle), - mnesia:add_table_index(vcard_search, lnickname), - mnesia:add_table_index(vcard_search, lbday), - mnesia:add_table_index(vcard_search, lctry), - mnesia:add_table_index(vcard_search, llocality), - mnesia:add_table_index(vcard_search, lemail), - mnesia:add_table_index(vcard_search, lorgname), - mnesia:add_table_index(vcard_search, lorgunit). + record_info(fields, vcard_search)}, + {index, [ luser, lfn, lfamily, + lgiven, lmiddle, lnickname, + lbday, lctry, llocality, + lemail, lorgname, lorgunit + ]}]), + update_tables(). stop(_Host) -> ok. diff --git a/src/mod_vcard_riak.erl b/src/mod_vcard_riak.erl index 411ec45fa..31148ccb1 100644 --- a/src/mod_vcard_riak.erl +++ b/src/mod_vcard_riak.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_vcard_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_vcard_riak). -behaviour(mod_vcard). diff --git a/src/mod_vcard_sql.erl b/src/mod_vcard_sql.erl index 7fd64c44e..c2bc11dfb 100644 --- a/src/mod_vcard_sql.erl +++ b/src/mod_vcard_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_vcard_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_vcard_sql). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_vcard_xupdate.erl b/src/mod_vcard_xupdate.erl index 900758e39..12e31b8dc 100644 --- a/src/mod_vcard_xupdate.erl +++ b/src/mod_vcard_xupdate.erl @@ -3,6 +3,24 @@ %%% Author : Igor Goryachev <igor@goryachev.org> %%% Purpose : Add avatar hash in presence on behalf of client (XEP-0153) %%% Created : 9 Mar 2007 by Igor Goryachev <igor@goryachev.org> +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% %%%---------------------------------------------------------------------- -module(mod_vcard_xupdate). diff --git a/src/mod_vcard_xupdate_mnesia.erl b/src/mod_vcard_xupdate_mnesia.erl index 454d97e25..879f5b115 100644 --- a/src/mod_vcard_xupdate_mnesia.erl +++ b/src/mod_vcard_xupdate_mnesia.erl @@ -1,12 +1,29 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_vcard_xupdate_mnesia.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_vcard_xupdate_mnesia). + -behaviour(mod_vcard_xupdate). %% API diff --git a/src/mod_vcard_xupdate_riak.erl b/src/mod_vcard_xupdate_riak.erl index cff77f887..8e20bba4b 100644 --- a/src/mod_vcard_xupdate_riak.erl +++ b/src/mod_vcard_xupdate_riak.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_vcard_xupdate_riak.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_vcard_xupdate_riak). -behaviour(mod_vcard_xupdate). diff --git a/src/mod_vcard_xupdate_sql.erl b/src/mod_vcard_xupdate_sql.erl index fd2716c33..e2e3d1a78 100644 --- a/src/mod_vcard_xupdate_sql.erl +++ b/src/mod_vcard_xupdate_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : mod_vcard_xupdate_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 13 Apr 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_vcard_xupdate_sql). -compile([{parse_transform, ejabberd_sql_pt}]). diff --git a/src/mod_version.erl b/src/mod_version.erl index 36bf796ee..ee35a3c41 100644 --- a/src/mod_version.erl +++ b/src/mod_version.erl @@ -5,7 +5,7 @@ %%% Created : 18 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_buddy.erl b/src/node_buddy.erl index fb2fd1f2e..a01332b67 100644 --- a/src/node_buddy.erl +++ b/src/node_buddy.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_club.erl b/src/node_club.erl index 837fa6fbb..54ee5d763 100644 --- a/src/node_club.erl +++ b/src/node_club.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_dag.erl b/src/node_dag.erl index 45f8ade63..c81b2bc80 100644 --- a/src/node_dag.erl +++ b/src/node_dag.erl @@ -5,7 +5,7 @@ %%% Created : 15 Jun 2009 by Brian Cully <bjc@kublai.com> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_dispatch.erl b/src/node_dispatch.erl index 0a72b18d5..bde20e772 100644 --- a/src/node_dispatch.erl +++ b/src/node_dispatch.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_flat.erl b/src/node_flat.erl index 55093b0e7..1809915ff 100644 --- a/src/node_flat.erl +++ b/src/node_flat.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -58,6 +58,9 @@ init(_Host, _ServerHost, _Opts) -> ejabberd_mnesia:create(?MODULE, pubsub_item, [{disc_only_copies, [node()]}, {attributes, record_info(fields, pubsub_item)}]), + ejabberd_mnesia:create(?MODULE, pubsub_orphan, + [{disc_copies, [node()]}, + {attributes, record_info(fields, pubsub_orphan)}]), ItemsFields = record_info(fields, pubsub_item), case mnesia:table_info(pubsub_item, attributes) of ItemsFields -> ok; @@ -137,10 +140,11 @@ delete_node(Nodes) -> end, Reply = lists:map(fun (#pubsub_node{id = Nidx} = PubsubNode) -> {result, States} = get_states(Nidx), - lists:foreach(fun (#pubsub_state{stateid = {LJID, _}, items = Items}) -> - del_items(Nidx, Items), - del_state(Nidx, LJID) + lists:foreach(fun (State) -> + del_items(Nidx, State#pubsub_state.items), + del_state(State#pubsub_state{items = []}) end, States), + del_orphan_items(Nidx), {PubsubNode, lists:flatmap(Tr, States)} end, Nodes), {result, {default, broadcast, Reply}}. @@ -286,7 +290,7 @@ unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> SubState#pubsub_state.subscriptions), case Sub of {value, S} -> - delete_subscriptions(SubKey, Nidx, [S], SubState), + delete_subscriptions(SubState, [S]), {result, default}; false -> {error, @@ -294,11 +298,11 @@ unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> end; %% Asking to remove all subscriptions to the given node SubId == all -> - delete_subscriptions(SubKey, Nidx, Subscriptions, SubState), + delete_subscriptions(SubState, Subscriptions), {result, default}; %% No subid supplied, but there's only one matching subscription length(Subscriptions) == 1 -> - delete_subscriptions(SubKey, Nidx, Subscriptions, SubState), + delete_subscriptions(SubState, Subscriptions), {result, default}; %% No subid and more than one possible subscription match. true -> @@ -306,13 +310,13 @@ unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> mod_pubsub:extended_error((xmpp:err_bad_request()), mod_pubsub:err_subid_required())} end. -delete_subscriptions(SubKey, Nidx, Subscriptions, SubState) -> +delete_subscriptions(SubState, Subscriptions) -> NewSubs = lists:foldl(fun ({Subscription, SubId}, Acc) -> %%pubsub_subscription:delete_subscription(SubKey, Nidx, SubId), Acc -- [{Subscription, SubId}] end, SubState#pubsub_state.subscriptions, Subscriptions), case {SubState#pubsub_state.affiliation, NewSubs} of - {none, []} -> del_state(Nidx, SubKey); + {none, []} -> del_state(SubState); _ -> set_state(SubState#pubsub_state{subscriptions = NewSubs}) end. @@ -473,6 +477,7 @@ purge_node(Nidx, Owner) -> set_state(S#pubsub_state{items = []}) end, States), + del_orphan_items(Nidx), {result, {default, broadcast}}; _ -> {error, xmpp:err_forbidden()} @@ -515,7 +520,7 @@ set_affiliation(Nidx, Owner, Affiliation) -> GenKey = jid:remove_resource(SubKey), GenState = get_state(Nidx, GenKey), case {Affiliation, GenState#pubsub_state.subscriptions} of - {none, []} -> del_state(Nidx, GenKey); + {none, []} -> del_state(GenState); _ -> set_state(GenState#pubsub_state{affiliation = Affiliation}) end. @@ -588,7 +593,7 @@ set_subscriptions(Nidx, Owner, Subscription, SubId) -> end; {<<>>, [{_, SID}]} -> case Subscription of - none -> unsub_with_subid(Nidx, SID, SubState); + none -> unsub_with_subid(SubState, SID); _ -> replace_subscription({Subscription, SID}, SubState) end; {<<>>, [_ | _]} -> @@ -596,7 +601,7 @@ set_subscriptions(Nidx, Owner, Subscription, SubId) -> mod_pubsub:extended_error((xmpp:err_bad_request()), mod_pubsub:err_subid_required())}; _ -> case Subscription of - none -> unsub_with_subid(Nidx, SubId, SubState); + none -> unsub_with_subid(SubState, SubId); _ -> replace_subscription({Subscription, SubId}, SubState) end end. @@ -616,13 +621,13 @@ new_subscription(_Nidx, _Owner, Sub, SubState) -> set_state(SubState#pubsub_state{subscriptions = [{Sub, SubId} | Subs]}), {Sub, SubId}. -unsub_with_subid(Nidx, SubId, #pubsub_state{stateid = {Entity, _}} = SubState) -> +unsub_with_subid(SubState, SubId) -> %%pubsub_subscription:delete_subscription(SubState#pubsub_state.stateid, Nidx, SubId), NewSubs = [{S, Sid} || {S, Sid} <- SubState#pubsub_state.subscriptions, SubId =/= Sid], case {NewSubs, SubState#pubsub_state.affiliation} of - {[], none} -> del_state(Nidx, Entity); + {[], none} -> del_state(SubState); _ -> set_state(SubState#pubsub_state{subscriptions = NewSubs}) end. @@ -697,7 +702,14 @@ set_state(State) when is_record(State, pubsub_state) -> %set_state(_) -> {error, ?ERR_INTERNAL_SERVER_ERROR}. %% @doc <p>Delete a state from database.</p> -del_state(Nidx, Key) -> +del_state(#pubsub_state{stateid = {Key, Nidx}, items = Items}) -> + case Items of + [] -> + ok; + _ -> + Orphan = #pubsub_orphan{nodeid = Nidx, items = Items}, + mnesia:write(Orphan) + end, mnesia:delete({pubsub_state, {Key, Nidx}}). %% @doc Returns the list of stored items for a given node. @@ -801,6 +813,15 @@ del_items(Nidx, ItemIds) -> end, ItemIds). +del_orphan_items(Nidx) -> + case mnesia:read({pubsub_orphan, Nidx}) of + [#pubsub_orphan{items = ItemIds}] -> + del_items(Nidx, ItemIds), + mnesia:delete({pubsub_orphan, Nidx}); + _ -> + ok + end. + get_item_name(_Host, _Node, Id) -> Id. diff --git a/src/node_flat_sql.erl b/src/node_flat_sql.erl index 7e5ce788f..2df1ffb26 100644 --- a/src/node_flat_sql.erl +++ b/src/node_flat_sql.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_hometree.erl b/src/node_hometree.erl index 67c5e9332..1255c3d5f 100644 --- a/src/node_hometree.erl +++ b/src/node_hometree.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_hometree_sql.erl b/src/node_hometree_sql.erl index 661a2aab4..00d712d0b 100644 --- a/src/node_hometree_sql.erl +++ b/src/node_hometree_sql.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_mb.erl b/src/node_mb.erl index c06c08d67..04370f61f 100644 --- a/src/node_mb.erl +++ b/src/node_mb.erl @@ -5,7 +5,7 @@ %%% Created : 25 Sep 2008 by Eric Cestari <ecestari@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_mb_sql.erl b/src/node_mb_sql.erl index 0f5c409ff..5a04e27c8 100644 --- a/src/node_mb_sql.erl +++ b/src/node_mb_sql.erl @@ -5,7 +5,7 @@ %%% Created : 6 Sep 2016 by Holger Weiss <holger@zedat.fu-berlin.de> %%% %%% -%%% ejabberd, Copyright (C) 2016 ProcessOne +%%% ejabberd, Copyright (C) 2016-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_mix.erl b/src/node_mix.erl index 71a8d3180..485782a9c 100644 --- a/src/node_mix.erl +++ b/src/node_mix.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : node_mix.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 8 Mar 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(node_mix). -behaviour(gen_pubsub_node). diff --git a/src/node_mix_sql.erl b/src/node_mix_sql.erl index cbe0b3d02..de7319fa7 100644 --- a/src/node_mix_sql.erl +++ b/src/node_mix_sql.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : node_mix_sql.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 8 Mar 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(node_mix_sql). -behaviour(gen_pubsub_node). diff --git a/src/node_online.erl b/src/node_online.erl index 2620e6a49..56357a652 100644 --- a/src/node_online.erl +++ b/src/node_online.erl @@ -5,7 +5,7 @@ %%% Created : 15 Dec 2015 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_pep.erl b/src/node_pep.erl index f3b5836cf..c79df4e15 100644 --- a/src/node_pep.erl +++ b/src/node_pep.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_pep_sql.erl b/src/node_pep_sql.erl index ac42cb94f..68a2ce946 100644 --- a/src/node_pep_sql.erl +++ b/src/node_pep_sql.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_private.erl b/src/node_private.erl index 1888ce33d..6cf50bfc2 100644 --- a/src/node_private.erl +++ b/src/node_private.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/node_public.erl b/src/node_public.erl index ca200e002..84e71590e 100644 --- a/src/node_public.erl +++ b/src/node_public.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/nodetree_dag.erl b/src/nodetree_dag.erl index f17f2846d..a44e71553 100644 --- a/src/nodetree_dag.erl +++ b/src/nodetree_dag.erl @@ -5,7 +5,7 @@ %%% Created : 15 Jun 2009 by Brian Cully <bjc@kublai.com> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/nodetree_tree.erl b/src/nodetree_tree.erl index eb28e3408..4d9b727b7 100644 --- a/src/nodetree_tree.erl +++ b/src/nodetree_tree.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -51,13 +51,8 @@ init(_Host, _ServerHost, _Options) -> ejabberd_mnesia:create(?MODULE, pubsub_node, [{disc_copies, [node()]}, - {attributes, record_info(fields, pubsub_node)}]), - mnesia:add_table_index(pubsub_node, id), - NodesFields = record_info(fields, pubsub_node), - case mnesia:table_info(pubsub_node, attributes) of - NodesFields -> ok; - _ -> ok - end, + {attributes, record_info(fields, pubsub_node)}, + {index, [id]}]), %% mnesia:transform_table(pubsub_state, ignore, StatesFields) ok. diff --git a/src/nodetree_tree_sql.erl b/src/nodetree_tree_sql.erl index 5e4462160..02119720b 100644 --- a/src/nodetree_tree_sql.erl +++ b/src/nodetree_tree_sql.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/nodetree_virtual.erl b/src/nodetree_virtual.erl index 31802db2b..d29d9224f 100644 --- a/src/nodetree_virtual.erl +++ b/src/nodetree_virtual.erl @@ -5,7 +5,7 @@ %%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/prosody2ejabberd.erl b/src/prosody2ejabberd.erl index fcc472dce..afb714d9b 100644 --- a/src/prosody2ejabberd.erl +++ b/src/prosody2ejabberd.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% File : prosody2ejabberd.erl +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 20 Jan 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(prosody2ejabberd). %% API diff --git a/src/pubsub_db_sql.erl b/src/pubsub_db_sql.erl index 986a0b9b2..ae7a9fde6 100644 --- a/src/pubsub_db_sql.erl +++ b/src/pubsub_db_sql.erl @@ -5,7 +5,7 @@ %%% Created : 7 Aug 2009 by Pablo Polvorin <pablo.polvorin@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/pubsub_index.erl b/src/pubsub_index.erl index 45361e141..2e17bb2a6 100644 --- a/src/pubsub_index.erl +++ b/src/pubsub_index.erl @@ -5,7 +5,7 @@ %%% Created : 30 Apr 2009 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/pubsub_migrate.erl b/src/pubsub_migrate.erl index a329f3c39..ba5735a30 100644 --- a/src/pubsub_migrate.erl +++ b/src/pubsub_migrate.erl @@ -5,7 +5,7 @@ %%% Created : 26 Jul 2014 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -31,106 +31,8 @@ -export([update_node_database/2, update_state_database/2]). -export([update_item_database/2, update_lastitem_database/2]). -update_item_database_binary() -> - F = fun () -> - case catch mnesia:read({pubsub_last_item, mnesia:first(pubsub_last_item)}) of - [First] when is_list(First#pubsub_last_item.itemid) -> - ?INFO_MSG("Binarization of pubsub items table...", []), - lists:foreach(fun (Id) -> - [Node] = mnesia:read({pubsub_last_item, Id}), - - ItemId = iolist_to_binary(Node#pubsub_last_item.itemid), - - ok = mnesia:delete({pubsub_last_item, Id}), - ok = mnesia:write(Node#pubsub_last_item{itemid=ItemId}) - end, - mnesia:all_keys(pubsub_last_item)); - _-> no_need - end - end, - case mnesia:transaction(F) of - {aborted, Reason} -> - ?ERROR_MSG("Failed to binarize pubsub items table: ~p", [Reason]); - {atomic, no_need} -> - ok; - {atomic, Result} -> - ?INFO_MSG("Pubsub items table has been binarized: ~p", [Result]) - end. - update_item_database(_Host, _ServerHost) -> - F = fun() -> - ?INFO_MSG("Migration of old pubsub items...", []), - lists:foreach(fun (Key) -> - [Item] = mnesia:read({pubsub_item, Key}), - Payload = [xmlelement_to_xmlel(El) || El <- Item#pubsub_item.payload], - mnesia:write(Item#pubsub_item{payload=Payload}) - end, - mnesia:all_keys(pubsub_item)) - end, - case mnesia:transaction(F) of - {aborted, Reason} -> - ?ERROR_MSG("Failed to migrate old pubsub items to xmlel: ~p", [Reason]); - {atomic, Result} -> - ?INFO_MSG("Pubsub items has been migrated: ~p", [Result]) - end. - -xmlelement_to_xmlel({xmlelement, A, B, C}) when is_list(C) -> - {xmlel, A, B, [xmlelement_to_xmlel(El) || El <- C]}; -xmlelement_to_xmlel(El) -> - El. - -update_node_database_binary() -> - F = fun () -> - case catch mnesia:read({pubsub_node, mnesia:first(pubsub_node)}) of - [First] when is_list(First#pubsub_node.type) -> - ?INFO_MSG("Binarization of pubsub nodes table...", []), - lists:foreach(fun ({H, N}) -> - [Node] = mnesia:read({pubsub_node, {H, N}}), - - Type = iolist_to_binary(Node#pubsub_node.type), - BN = case N of - Binary when is_binary(Binary) -> - N; - _ -> - {result, BN1} = mod_pubsub:node_call(H, Type, path_to_node, [N]), - BN1 - end, - BP = case [case P of - Binary2 when is_binary(Binary2) -> P; - _ -> element(2, mod_pubsub:node_call(H, Type, path_to_node, [P])) - end - || P <- Node#pubsub_node.parents] of - [<<>>] -> []; - Parents -> Parents - end, - - BH = case H of - {U, S, R} -> {iolist_to_binary(U), iolist_to_binary(S), iolist_to_binary(R)}; - String -> iolist_to_binary(String) - end, - - Owners = [{iolist_to_binary(U), iolist_to_binary(S), iolist_to_binary(R)} || - {U, S, R} <- Node#pubsub_node.owners], - - ok = mnesia:delete({pubsub_node, {H, N}}), - ok = mnesia:write(Node#pubsub_node{nodeid = {BH, BN}, - parents = BP, - type = Type, - owners = Owners}); - (_) -> ok - end, - mnesia:all_keys(pubsub_node)); - _-> no_need - end - end, - case mnesia:transaction(F) of - {aborted, Reason} -> - ?ERROR_MSG("Failed to binarize pubsub node table: ~p", [Reason]); - {atomic, no_need} -> - ok; - {atomic, Result} -> - ?INFO_MSG("Pubsub nodes table has been binarized: ~p", [Result]) - end. + convert_list_items(). update_node_database(Host, ServerHost) -> mnesia:del_table_index(pubsub_node, type), @@ -386,7 +288,7 @@ update_node_database(Host, ServerHost) -> rename_default_nodeplugin(); _ -> ok end, - update_node_database_binary(). + convert_list_nodes(). rename_default_nodeplugin() -> lists:foreach(fun (Node) -> @@ -402,14 +304,14 @@ update_state_database(_Host, _ServerHost) -> [stateid, nodeidx, items, affiliation, subscriptions] -> ?INFO_MSG("Upgrading pubsub states table...", []), F = fun ({pubsub_state, {{U,S,R}, NodeID}, _NodeIdx, Items, Aff, Sub}, Acc) -> - JID = {iolist_to_binary(U), iolist_to_binary(S), iolist_to_binary(R)}, + JID = {U,S,R}, Subs = case Sub of none -> []; [] -> []; _ -> - {result, SubID} = pubsub_subscription:subscribe_node(JID, NodeID, []), + SubID = pubsub_subscription:make_subid(), [{Sub, SubID}] end, NewState = #pubsub_state{stateid = {JID, NodeID}, @@ -437,7 +339,108 @@ update_state_database(_Host, _ServerHost) -> end; _ -> ok - end. + end, + convert_list_subscriptions(), + convert_list_states(). update_lastitem_database(_Host, _ServerHost) -> - update_item_database_binary(). + convert_list_lasts(). + +%% binarization from old 2.1.x + +convert_list_items() -> + convert_list_records( + pubsub_item, + record_info(fields, pubsub_item), + fun(#pubsub_item{itemid = {I, _}}) -> I end, + fun(#pubsub_item{itemid = {I, Nidx}, + creation = {C, CKey}, + modification = {M, MKey}, + payload = Els} = R) -> + R#pubsub_item{itemid = {bin(I), Nidx}, + creation = {C, binusr(CKey)}, + modification = {M, binusr(MKey)}, + payload = [fxml:to_xmlel(El) || El<-Els]} + end). + +convert_list_states() -> + convert_list_records( + pubsub_state, + record_info(fields, pubsub_state), + fun(#pubsub_state{stateid = {{U,_,_}, _}}) -> U end, + fun(#pubsub_state{stateid = {U, Nidx}, + items = Is, + affiliation = A, + subscriptions = Ss} = R) -> + R#pubsub_state{stateid = {binusr(U), Nidx}, + items = [bin(I) || I<-Is], + affiliation = A, + subscriptions = [{S,bin(Sid)} || {S,Sid}<-Ss]} + end). + +convert_list_nodes() -> + convert_list_records( + pubsub_node, + record_info(fields, pubsub_node), + fun(#pubsub_node{nodeid = {{U,_,_}, _}}) -> U; + (#pubsub_node{nodeid = {H, _}}) -> H end, + fun(#pubsub_node{nodeid = {H, N}, + id = I, + parents = Ps, + type = T, + owners = Os, + options = Opts} = R) -> + R#pubsub_node{nodeid = {binhost(H), bin(N)}, + id = I, + parents = [bin(P) || P<-Ps], + type = bin(T), + owners = [binusr(O) || O<-Os], + options = Opts} + end). + +convert_list_subscriptions() -> + [convert_list_records( + pubsub_subscription, + record_info(fields, pubsub_subscription), + fun(#pubsub_subscription{subid = I}) -> I end, + fun(#pubsub_subscription{subid = I, + options = Opts} = R) -> + R#pubsub_subscription{subid = bin(I), + options = Opts} + end) || lists:member(pubsub_subscription, mnesia:system_info(tables))]. + +convert_list_lasts() -> + convert_list_records( + pubsub_last_item, + record_info(fields, pubsub_last_item), + fun(#pubsub_last_item{itemid = I}) -> I end, + fun(#pubsub_last_item{itemid = I, + nodeid = Nidx, + creation = {C, CKey}, + payload = Payload} = R) -> + R#pubsub_last_item{itemid = bin(I), + nodeid = Nidx, + creation = {C, binusr(CKey)}, + payload = fxml:to_xmlel(Payload)} + end). + +%% internal tools + +convert_list_records(Tab, Fields, DetectFun, ConvertFun) -> + case mnesia:table_info(Tab, attributes) of + Fields -> + ejabberd_config:convert_table_to_binary( + Tab, Fields, set, DetectFun, ConvertFun); + _ -> + ?INFO_MSG("Recreating ~p table", [Tab]), + mnesia:transform_table(Tab, ignore, Fields), + convert_list_records(Tab, Fields, DetectFun, ConvertFun) + end. + +binhost({U,S,R}) -> binusr({U,S,R}); +binhost(L) -> bin(L). + +binusr({U,S,R}) -> {bin(U), bin(S), bin(R)}. + +bin(L) -> iolist_to_binary(L). + diff --git a/src/pubsub_subscription.erl b/src/pubsub_subscription.erl index 0ca066dae..746e39e36 100644 --- a/src/pubsub_subscription.erl +++ b/src/pubsub_subscription.erl @@ -5,7 +5,7 @@ %%% Created : 29 May 2009 by Brian Cully <bjc@kublai.com> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/pubsub_subscription_sql.erl b/src/pubsub_subscription_sql.erl index fddfe881e..3315748c9 100644 --- a/src/pubsub_subscription_sql.erl +++ b/src/pubsub_subscription_sql.erl @@ -6,7 +6,7 @@ %%% Created : 7 Aug 2009 by Pablo Polvorin <pablo.polvorin@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/randoms.erl b/src/randoms.erl index ae477d27d..90cc34f10 100644 --- a/src/randoms.erl +++ b/src/randoms.erl @@ -5,7 +5,7 @@ %%% Created : 13 Dec 2002 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/rest.erl b/src/rest.erl index 091002fa5..34e72a674 100644 --- a/src/rest.erl +++ b/src/rest.erl @@ -5,7 +5,7 @@ %%% Created : 16 Oct 2014 by Christophe Romain <christophe.romain@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/scram.erl b/src/scram.erl index 1c1c28ec9..ee7960475 100644 --- a/src/scram.erl +++ b/src/scram.erl @@ -5,7 +5,7 @@ %%% Created : 7 Aug 2011 by Stephen Röttger <stephen.roettger@googlemail.com> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/shaper.erl b/src/shaper.erl index 19c9a049d..9ce3f5b6f 100644 --- a/src/shaper.erl +++ b/src/shaper.erl @@ -5,7 +5,7 @@ %%% Created : 9 Feb 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/sql_queries.erl b/src/sql_queries.erl index 2afa32ac8..da18c56f4 100644 --- a/src/sql_queries.erl +++ b/src/sql_queries.erl @@ -5,7 +5,7 @@ %%% Created : by Mickael Remond <mremond@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/str.erl b/src/str.erl index 43fd51878..28537da0f 100644 --- a/src/str.erl +++ b/src/str.erl @@ -5,7 +5,7 @@ %%% Created : 23 Feb 2012 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/translate.erl b/src/translate.erl index e9f61ab8c..43f980ebf 100644 --- a/src/translate.erl +++ b/src/translate.erl @@ -5,7 +5,7 @@ %%% Created : 6 Jan 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/src/win32_dns.erl b/src/win32_dns.erl index 5dda22b98..df8471cd2 100644 --- a/src/win32_dns.erl +++ b/src/win32_dns.erl @@ -5,7 +5,7 @@ %%% Created : 5 Mar 2009 by Geoff Cant %%% %%% -%%% ejabberd, Copyright (C) 2002-2016 ProcessOne +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/test/acl_test.exs b/test/acl_test.exs index 0ab92ade8..cdfc4f328 100644 --- a/test/acl_test.exs +++ b/test/acl_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/announce_tests.erl b/test/announce_tests.erl index 3eea5298c..7b621a3d1 100644 --- a/test/announce_tests.erl +++ b/test/announce_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(announce_tests). %% API diff --git a/test/carbons_tests.erl b/test/carbons_tests.erl index 00dd57e3c..a85cece8c 100644 --- a/test/carbons_tests.erl +++ b/test/carbons_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(carbons_tests). %% API diff --git a/test/csi_tests.erl b/test/csi_tests.erl index 9a96b8a59..a539c9c24 100644 --- a/test/csi_tests.erl +++ b/test/csi_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(csi_tests). %% API diff --git a/test/ejabberd_SUITE.erl b/test/ejabberd_SUITE.erl index 46711ad49..76ffa8f2b 100644 --- a/test/ejabberd_SUITE.erl +++ b/test/ejabberd_SUITE.erl @@ -1,11 +1,27 @@ %%%------------------------------------------------------------------- -%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2002-2016, ProcessOne -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 2 Jun 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + + -module(ejabberd_SUITE). -compile(export_all). diff --git a/test/ejabberd_admin_test.exs b/test/ejabberd_admin_test.exs index 31b8ab2e2..effcbc579 100644 --- a/test/ejabberd_admin_test.exs +++ b/test/ejabberd_admin_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2015 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/ejabberd_auth_mock.exs b/test/ejabberd_auth_mock.exs index 83019c8ee..08d1d7366 100644 --- a/test/ejabberd_auth_mock.exs +++ b/test/ejabberd_auth_mock.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/ejabberd_commands_mock_test.exs b/test/ejabberd_commands_mock_test.exs index 12444f79a..83d1f4923 100644 --- a/test/ejabberd_commands_mock_test.exs +++ b/test/ejabberd_commands_mock_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/ejabberd_commands_test.exs b/test/ejabberd_commands_test.exs index c8219d0cf..9c3066d31 100644 --- a/test/ejabberd_commands_test.exs +++ b/test/ejabberd_commands_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/ejabberd_cyrsasl_test.exs b/test/ejabberd_cyrsasl_test.exs index 6b0127015..a4367ff8d 100644 --- a/test/ejabberd_cyrsasl_test.exs +++ b/test/ejabberd_cyrsasl_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -32,6 +32,7 @@ defmodule EjabberdCyrsaslTest do :ok = :cyrsasl.start cyrstate = :cyrsasl.server_new("domain1", "domain1", "domain1", :ok, &get_password/1, &check_password/3, &check_password_digest/5) + setup_anonymous_mocks() {:ok, cyrstate: cyrstate} end @@ -44,16 +45,15 @@ defmodule EjabberdCyrsaslTest do test "Plain text (correct user wrong pass)", context do step1 = :cyrsasl.server_start(context[:cyrstate], "PLAIN", <<0,"user1",0,"badpass">>) - assert step1 == {:error, :"not-authorized", "user1"} + assert step1 == {:error, :not_authorized, "user1"} end test "Plain text (wrong user wrong pass)", context do step1 = :cyrsasl.server_start(context[:cyrstate], "PLAIN", <<0,"nouser1",0,"badpass">>) - assert step1 == {:error, :"not-authorized", "nouser1"} + assert step1 == {:error, :not_authorized, "nouser1"} end test "Anonymous", context do - setup_anonymous_mocks() step1 = :cyrsasl.server_start(context[:cyrstate], "ANONYMOUS", "domain1") assert {:ok, _} = step1 end @@ -63,15 +63,15 @@ defmodule EjabberdCyrsaslTest do end test "Digest-MD5 (correct user wrong pass)", context do - assert {:error, :"not-authorized", "user1"} = process_digest_md5(context[:cyrstate], "user1", "domain1", "badpass") + assert {:error, :not_authorized, "user1"} = process_digest_md5(context[:cyrstate], "user1", "domain1", "badpass") end test "Digest-MD5 (wrong user correct pass)", context do - assert {:error, :"not-authorized", "baduser"} = process_digest_md5(context[:cyrstate], "baduser", "domain1", "pass") + assert {:error, :not_authorized, "baduser"} = process_digest_md5(context[:cyrstate], "baduser", "domain1", "pass") end test "Digest-MD5 (wrong user and pass)", context do - assert {:error, :"not-authorized", "baduser"} = process_digest_md5(context[:cyrstate], "baduser", "domain1", "badpass") + assert {:error, :not_authorized, "baduser"} = process_digest_md5(context[:cyrstate], "baduser", "domain1", "badpass") end defp process_digest_md5(cyrstate, user, domain, pass) do diff --git a/test/ejabberd_hooks_test.exs b/test/ejabberd_hooks_test.exs index a69fbbd61..90624147c 100644 --- a/test/ejabberd_hooks_test.exs +++ b/test/ejabberd_hooks_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/ejabberd_oauth_mock.exs b/test/ejabberd_oauth_mock.exs index 965bff1e6..8f1f11843 100644 --- a/test/ejabberd_oauth_mock.exs +++ b/test/ejabberd_oauth_mock.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/ejabberd_sm_mock.exs b/test/ejabberd_sm_mock.exs index 53c2c750f..87c5bb83d 100644 --- a/test/ejabberd_sm_mock.exs +++ b/test/ejabberd_sm_mock.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/elixir_SUITE.erl b/test/elixir_SUITE.erl index aaef9151d..7ef4f2cdb 100644 --- a/test/elixir_SUITE.erl +++ b/test/elixir_SUITE.erl @@ -1,7 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Mickael Remond <mremond@process-one.net> -%%% @copyright (C) 2002-2016, ProcessOne -%%% @doc +%%% Author : Mickael Remond <mremond@process-one.net> +%%% Created : 19 Feb 2015 by Mickael Remond <mremond@process-one.net> +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + %%% This is a common test wrapper to run our ejabberd tests written in %%% Elixir from standard common test code. %%% @@ -9,9 +28,6 @@ %%% ./rebar skip_deps=true ct suites=elixir %%% or from ejabber overall test suite: %%% make quicktest -%%% @end -%%% Created : 19 Feb 2015 by Mickael Remond <mremond@process-one.net> -%%%------------------------------------------------------------------- -module(elixir_SUITE). diff --git a/test/example_tests.erl b/test/example_tests.erl index d7965376e..61b84cc2d 100644 --- a/test/example_tests.erl +++ b/test/example_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(example_tests). %% API diff --git a/test/jid_test.exs b/test/jid_test.exs index 7d063b707..0701d699f 100644 --- a/test/jid_test.exs +++ b/test/jid_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/ldap_srv.erl b/test/ldap_srv.erl index 69b8a27e7..d5dc8dbe2 100644 --- a/test/ldap_srv.erl +++ b/test/ldap_srv.erl @@ -1,11 +1,28 @@ %%%------------------------------------------------------------------- -%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2013-2016, Evgeniy Khramtsov -%%% @doc -%%% Simple LDAP server intended for LDAP modules testing -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 21 Jun 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + +%%% Simple LDAP server intended for LDAP modules testing + -module(ldap_srv). -behaviour(gen_server). diff --git a/test/mam_tests.erl b/test/mam_tests.erl index d628ddd2a..c961ed929 100644 --- a/test/mam_tests.erl +++ b/test/mam_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 14 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mam_tests). %% API diff --git a/test/mix_tests.erl b/test/mix_tests.erl index 56b1b35d7..74e83d2b2 100644 --- a/test/mix_tests.erl +++ b/test/mix_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mix_tests). %% API diff --git a/test/mod_admin_extra_test.exs b/test/mod_admin_extra_test.exs index 3baf4922f..23d708498 100644 --- a/test/mod_admin_extra_test.exs +++ b/test/mod_admin_extra_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2015 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/mod_http_api_mock_test.exs b/test/mod_http_api_mock_test.exs index 9ab53bee2..d7661ce4f 100644 --- a/test/mod_http_api_mock_test.exs +++ b/test/mod_http_api_mock_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2015 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/mod_http_api_test.exs b/test/mod_http_api_test.exs index c68270f1f..a9d05eafb 100644 --- a/test/mod_http_api_test.exs +++ b/test/mod_http_api_test.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/mod_last_mock.exs b/test/mod_last_mock.exs index 4f8da3666..2a22f6ca1 100644 --- a/test/mod_last_mock.exs +++ b/test/mod_last_mock.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/mod_legacy.erl b/test/mod_legacy.erl index dba977554..eedfbd3b5 100644 --- a/test/mod_legacy.erl +++ b/test/mod_legacy.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 25 Sep 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(mod_legacy). -behaviour(gen_mod). diff --git a/test/mod_roster_mock.exs b/test/mod_roster_mock.exs index ae990a6b1..58e759729 100644 --- a/test/mod_roster_mock.exs +++ b/test/mod_roster_mock.exs @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------- # -# ejabberd, Copyright (C) 2002-2016 ProcessOne +# ejabberd, Copyright (C) 2002-2017 ProcessOne # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/test/muc_tests.erl b/test/muc_tests.erl index d8e6dd8fb..c1c3b7b86 100644 --- a/test/muc_tests.erl +++ b/test/muc_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 15 Oct 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(muc_tests). %% API diff --git a/test/offline_tests.erl b/test/offline_tests.erl index ea34544e3..4964b8fee 100644 --- a/test/offline_tests.erl +++ b/test/offline_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 7 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(offline_tests). %% API diff --git a/test/privacy_tests.erl b/test/privacy_tests.erl index 640f53d48..fdde64958 100644 --- a/test/privacy_tests.erl +++ b/test/privacy_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 18 Oct 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(privacy_tests). %% API diff --git a/test/proxy65_tests.erl b/test/proxy65_tests.erl index 49e195d38..7934191f5 100644 --- a/test/proxy65_tests.erl +++ b/test/proxy65_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(proxy65_tests). %% API diff --git a/test/pubsub_tests.erl b/test/pubsub_tests.erl index daffc29ec..987754fc8 100644 --- a/test/pubsub_tests.erl +++ b/test/pubsub_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(pubsub_tests). %% API diff --git a/test/replaced_tests.erl b/test/replaced_tests.erl index e50c27f05..35df5e10b 100644 --- a/test/replaced_tests.erl +++ b/test/replaced_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(replaced_tests). %% API diff --git a/test/roster_tests.erl b/test/roster_tests.erl index 4aa06b953..879d13e74 100644 --- a/test/roster_tests.erl +++ b/test/roster_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 22 Oct 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(roster_tests). %% API diff --git a/test/sm_tests.erl b/test/sm_tests.erl index 0a74d392a..d2ec3bd56 100644 --- a/test/sm_tests.erl +++ b/test/sm_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(sm_tests). %% API diff --git a/test/suite.erl b/test/suite.erl index 3d832dd59..554b9b553 100644 --- a/test/suite.erl +++ b/test/suite.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeniy Khramtsov <> -%%% @copyright (C) 2013-2016, Evgeniy Khramtsov -%%% @doc +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> +%%% Created : 27 Jun 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% -%%% @end -%%% Created : 27 Jun 2013 by Evgeniy Khramtsov <> -%%%------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(suite). %% API diff --git a/test/vcard_tests.erl b/test/vcard_tests.erl index 26cfdc92b..27d619608 100644 --- a/test/vcard_tests.erl +++ b/test/vcard_tests.erl @@ -1,11 +1,26 @@ %%%------------------------------------------------------------------- -%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2016, Evgeny Khramtsov -%%% @doc -%%% -%%% @end +%%% Author : Evgeny Khramtsov <ekhramtsov@process-one.net> %%% Created : 16 Nov 2016 by Evgeny Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + -module(vcard_tests). %% API diff --git a/vars.config.in b/vars.config.in index 57fade8d7..5eca4889a 100644 --- a/vars.config.in +++ b/vars.config.in @@ -1,11 +1,23 @@ -%%%------------------------------------------------------------------- -%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%% @copyright (C) 2013-2016, Evgeniy Khramtsov -%%% @doc +%%%---------------------------------------------------------------------- %%% -%%% @end -%%% Created : 8 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> -%%%------------------------------------------------------------------- +%%% ejabberd, Copyright (C) 2002-2017 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + %% Macros {roster_gateway_workaround, @roster_gateway_workaround@}. {full_xml, @full_xml@}. |