aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMickaël Rémond <mickael.remond@process-one.net>2007-11-01 13:59:29 +0000
committerMickaël Rémond <mickael.remond@process-one.net>2007-11-01 13:59:29 +0000
commit426f6072dc8e87da76cc12de11a88235f2e25416 (patch)
tree9c8ef311044c680d6fa8a92b52d5ca385e6e6da3
parent* ChangeLog: Added missing info about last commits in ChangeLog. (diff)
* src/web/ejabberd_http_poll.erl: Support for c2s ACL access,
max_stanza and shaper on http_bind connections (EJAB-243, EJAB-415, EJAB-416) SVN Revision: 965
-rw-r--r--ChangeLog6
-rw-r--r--src/web/ejabberd_http_poll.erl44
2 files changed, 46 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 97a8bf7ae..f117e4252 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-01 Mickael Remond <mremond@process-one.net>
+
+ * src/web/ejabberd_http_poll.erl: Support for c2s ACL access,
+ max_stanza and shaper on http_bind connections (EJAB-243,
+ EJAB-415, EJAB-416)
+
2007-10-30 Jerome Sautret <jerome.sautret@process-one.net>
* src/ejabberd_s2s.erl: don't use the resource of the sender to choose
diff --git a/src/web/ejabberd_http_poll.erl b/src/web/ejabberd_http_poll.erl
index 912865116..ba85c940a 100644
--- a/src/web/ejabberd_http_poll.erl
+++ b/src/web/ejabberd_http_poll.erl
@@ -1,13 +1,13 @@
%%%----------------------------------------------------------------------
%%% File : ejabberd_http_poll.erl
-%%% Author : Alexey Shchepin <alexey@sevcom.net>
+%%% Author : Alexey Shchepin <alexey@process-one.net>
%%% Purpose : HTTP Polling support (JEP-0025)
-%%% Created : 4 Mar 2004 by Alexey Shchepin <alexey@sevcom.net>
+%%% Created : 4 Mar 2004 by Alexey Shchepin <alexey@process-one.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(ejabberd_http_poll).
--author('alexey@sevcom.net').
+-author('alexey@process-one.net').
-vsn('$Revision$ ').
-behaviour(gen_fsm).
@@ -153,7 +153,15 @@ process(_, _Request) ->
%%----------------------------------------------------------------------
init([ID, Key]) ->
?INFO_MSG("started: ~p", [{ID, Key}]),
- Opts = [], % TODO
+
+ %% Read c2s options from the first ejabberd_c2s configuration in
+ %% the config file listen section
+ %% TODO: We should have different access and shaper values for
+ %% each connector. The default behaviour should be however to use
+ %% the default c2s restrictions if not defined for the current
+ %% connector.
+ Opts = get_c2s_opts(),
+
ejabberd_socket:start(ejabberd_c2s, ?MODULE, {http_poll, self()}, Opts),
%{ok, C2SPid} = ejabberd_c2s:start({?MODULE, {http_poll, self()}}, Opts),
%ejabberd_c2s:become_controller(C2SPid),
@@ -318,6 +326,34 @@ terminate(Reason, StateName, StateData) ->
%%% Internal functions
%%%----------------------------------------------------------------------
+%% Get first c2s configuration limitations to apply it to other c2s
+%% connectors.
+get_c2s_opts() ->
+ case ejabberd_config:get_local_option(listen) of
+ undefined ->
+ [];
+ C2SFirstListen ->
+ case lists:keysearch(ejabberd_c2s, 2, C2SFirstListen) of
+ false ->
+ [];
+ {value, {_Port, ejabberd_c2s, Opts}} ->
+ select_opts_values(Opts)
+ end
+ end.
+%% Only get access, shaper and max_stanza_size values
+select_opts_values(Opts) ->
+ select_opts_values(Opts, []).
+select_opts_values([], SelectedValues) ->
+ SelectedValues;
+select_opts_values([{access,Value}|Opts], SelectedValues) ->
+ select_opts_values(Opts, [{access, Value}|SelectedValues]);
+select_opts_values([{shaper,Value}|Opts], SelectedValues) ->
+ select_opts_values(Opts, [{shaper, Value}|SelectedValues]);
+select_opts_values([{max_stanza_size,Value}|Opts], SelectedValues) ->
+ select_opts_values(Opts, [{max_stanza_size, Value}|SelectedValues]);
+select_opts_values([_Opt|Opts], SelectedValues) ->
+ select_opts_values(Opts, SelectedValues).
+
http_put(ID, Key, NewKey, Packet) ->
case mnesia:dirty_read({http_poll, ID}) of