From 49a3424a2680a28435c4bccaca00b4672b8451bc Mon Sep 17 00:00:00 2001 From: Eric Cestari Date: Wed, 8 Sep 2010 17:21:49 +0200 Subject: [PATCH 1/3] add *.so to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5b89fb9d5..d68bd6fe6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ Makefile archives .gitignore +*.so contrib/extract_translations/extract_translations.beam doc/contributed_modules.tex doc/features.aux From a77d53d738c411a856a5917fb686789a6831f8ae Mon Sep 17 00:00:00 2001 From: Eric Cestari Date: Wed, 8 Sep 2010 17:25:37 +0200 Subject: [PATCH 2/3] [TECH-1068] Added missing catch in process function --- src/web/pshb_http.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/pshb_http.erl b/src/web/pshb_http.erl index 20f472812..47efa0fc6 100644 --- a/src/web/pshb_http.erl +++ b/src/web/pshb_http.erl @@ -49,7 +49,7 @@ process([Domain | _Rest] = LocalPath, #request{auth = Auth} = Request)-> UD = get_auth(Auth), Module = backend(Domain), - case out(Module, Request, Request#request.method, LocalPath,UD) of + case catch out(Module, Request, Request#request.method, LocalPath,UD) of {'EXIT', Error} -> ?ERROR_MSG("Error while processing ~p : ~n~p", [LocalPath, Error]), error(500); From 660a2735f04308a5cf58aac7df51f18d2ff18931 Mon Sep 17 00:00:00 2001 From: Eric Cestari Date: Fri, 10 Sep 2010 14:11:56 +0200 Subject: [PATCH 3/3] mod_keepalive added to repos --- src/keepalive.hrl | 1 + src/mod_keepalive.erl | 71 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/keepalive.hrl create mode 100644 src/mod_keepalive.erl diff --git a/src/keepalive.hrl b/src/keepalive.hrl new file mode 100644 index 000000000..aad8aeca6 --- /dev/null +++ b/src/keepalive.hrl @@ -0,0 +1 @@ +-define(MODS, []). \ No newline at end of file diff --git a/src/mod_keepalive.erl b/src/mod_keepalive.erl new file mode 100644 index 000000000..1b468d94a --- /dev/null +++ b/src/mod_keepalive.erl @@ -0,0 +1,71 @@ +%%%---------------------------------------------------------------------- +%%% File : mod_keepalive.erl +%%% Author : Christophe romain +%%% Purpose : Hidden code autoload +%%% +%%% ejabberd, Copyright (C) 2002-2009 ProcessOne +%%%---------------------------------------------------------------------- + +-module(mod_keepalive). +-author('cromain@process-one.net'). + +-behaviour(gen_mod). + +-export([start/2, stop/1, init/1]). + +-include("keepalive.hrl"). + +start(Host, _Opts) -> + case init_host(Host) of + true -> + lists:foreach(fun({Mod, Beam}) -> + code:purge(Mod), + load_module(Mod, Beam) + end, ?MODS); + false -> + ok + end. + +stop(_Host) -> + ok. + +init(["pack"|Mods]) -> + Code = lists:foldl(fun(Mod, Acc) -> + case file:read_file(Mod++".beam") of + {error, _} -> Acc; + {ok, Bin} -> [{list_to_atom(Mod), Bin}|Acc] + end + end, [], Mods), + io:format("-define(MODS, ~p).", [Code]); +init(_) -> + error. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Internal module protection + +-define(VALID_HOSTS, []). % default is unlimited use +-define(MAX_USERS, 0). % default is unlimited use + +init_host(VHost) -> + case ?VALID_HOSTS of + [] -> % unlimited use + true; + ValidList -> % limited use + init_host(VHost, ValidList) + end. +init_host([], _) -> + false; +init_host(VHost, ValidEncryptedList) -> + EncryptedHost = erlang:md5(lists:reverse(VHost)), + case lists:member(EncryptedHost, ValidEncryptedList) of + true -> + case ?MAX_USERS of + 0 -> true; + N -> ejabberd_auth:get_vh_registered_users_number(VHost) =< N + end; + false -> + case string:chr(VHost, $.) of + 0 -> false; + Pos -> init_host(string:substr(VHost, Pos+1), ValidEncryptedList) + end + end. \ No newline at end of file