24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-14 22:00:16 +02:00

Merge revisions from 1444 to revision 1457 from trunk.

SVN Revision: 1458
This commit is contained in:
Jean-Sébastien Pédron 2008-07-17 15:33:50 +00:00
parent 532e8ee228
commit 07b1210b50
39 changed files with 166 additions and 132 deletions

View File

@ -1,9 +1,48 @@
2008-07-17 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
Merge revisions from 1444 to revision 1457 from trunk.
2008-07-17 Jean-Sébastien Pédron <js.pedron@meetic-corp.com> 2008-07-17 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/mod_caps.erl, src/ejabberd_c2s.erl: Start conversion to exmpp. * src/mod_caps.erl, src/ejabberd_c2s.erl: Start conversion to exmpp.
For now, only direct calls from ejabberd_c2s are done. Calls through For now, only direct calls from ejabberd_c2s are done. Calls through
gen_iq_handler aren't. gen_iq_handler aren't.
2008-07-17 Christophe Romain <christophe.romain@process-one.net>
* src/web/Makefile.in: use -DSSL39 if compiling with R12
2008-07-16 Badlop <badlop@process-one.net>
* src/ejabberd_c2s.erl: Put auth_module in Info always (EJAB-549)
* src/*.hrl: Get back all ejabberd header files to their original
placement in src/ subdirectories (EJAB-696)
* src/*/*.erl: Likewise
* src/*/Makefile.in: Likewise
* src/Makefile.in: Install header files in system include/ dir,
reproducing the subdirectory structure of src/
* src/ejabberdctl.template: Update environment variable names
2008-07-15 Badlop <badlop@process-one.net>
* src/ejabberdctl.template: Small fix so arguments of the command
are also passed to erl
* doc/guide.tex: Improve explanation of option 'hosts' in
ejabberd_service
* doc/guide.html: Likewise
2008-07-15 Alexey Shchepin <alexey@process-one.net>
* src/web/ejabberd_http_poll.erl: Report connection's IP address
* src/ejabberd_c2s.erl: Rolled back the previous IP getting patch
* src/ejabberd_sm.erl: Likewise
* src/ejabberd_receiver.erl: Likewise
* src/web/ejabberd_http_poll.erl: Likewise
2008-07-15 Jean-Sébastien Pédron <js.pedron@meetic-corp.com> 2008-07-15 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
Merge revisions from 1434 to revision 1444 from trunk. Merge revisions from 1434 to revision 1444 from trunk.

View File

@ -637,9 +637,14 @@ This option can be used with <TT>ejabberd_service</TT> only. It is
used to disable control on the from field on packets send by an used to disable control on the from field on packets send by an
external components. The option can be either <TT>true</TT> or external components. The option can be either <TT>true</TT> or
<TT>false</TT>. The default value is <TT>true</TT> which conforms to <A HREF="http://www.xmpp.org/extensions/xep-0114.html">XEP-0114</A>. <TT>false</TT>. The default value is <TT>true</TT> which conforms to <A HREF="http://www.xmpp.org/extensions/xep-0114.html">XEP-0114</A>.
</DD><DT CLASS="dt-description"><B><TT>{hosts, [Hostnames], [HostOptions]}</TT></B></DT><DD CLASS="dd-description"> This option </DD><DT CLASS="dt-description"><B><TT>{hosts, [Hostnames], [HostOptions]}</TT></B></DT><DD CLASS="dd-description">
defines one or more hostnames of connected services and enables you to This option of <TT>ejabberd_service</TT> allows to define one or more hostnames
specify additional options including <TT>{password, Secret}</TT>. of external Jabber components that provide a service.
In <TT>HostOptions</TT> it is possible to define the password required to those components
when attempt to connect to ejabberd: <TT>{password, Secret}</TT>.
Note that you cannot define in a single <TT>ejabberd_service</TT> components of
different services: add an <TT>ejabberd_service</TT> for each service,
as seen in an example below.
</DD><DT CLASS="dt-description"><B><TT>http_bind</TT></B></DT><DD CLASS="dd-description"> </DD><DT CLASS="dt-description"><B><TT>http_bind</TT></B></DT><DD CLASS="dd-description">
This option enables HTTP Binding (<A HREF="http://www.xmpp.org/extensions/xep-0124.html">XEP-0124</A> and <A HREF="http://www.xmpp.org/extensions/xep-0206.html">XEP-0206</A>) support. HTTP Bind This option enables HTTP Binding (<A HREF="http://www.xmpp.org/extensions/xep-0124.html">XEP-0124</A> and <A HREF="http://www.xmpp.org/extensions/xep-0206.html">XEP-0206</A>) support. HTTP Bind
enables access via HTTP requests to <TT>ejabberd</TT> from behind firewalls which enables access via HTTP requests to <TT>ejabberd</TT> from behind firewalls which
@ -818,19 +823,19 @@ connected to port 5237 with password &#X2018;<TT>ggsecret</TT>&#X2019;.
ssl, {certfile, "/path/to/ssl.pem"}]}, ssl, {certfile, "/path/to/ssl.pem"}]},
{5269, ejabberd_s2s_in, []}, {5269, ejabberd_s2s_in, []},
{5280, ejabberd_http, [http_poll, web_admin]}, {5280, ejabberd_http, [http_poll, web_admin]},
{5233, ejabberd_service, [{host, "aim.example.org", {5233, ejabberd_service, [{hosts, ["aim.example.org"],
[{password, "aimsecret"}]}]}, [{password, "aimsecret"}]}]},
{5234, ejabberd_service, [{hosts, ["icq.example.org", "sms.example.org"], {5234, ejabberd_service, [{hosts, ["icq.example.org", "sms.example.org"],
[{password, "jitsecret"}]}]}, [{password, "jitsecret"}]}]},
{5235, ejabberd_service, [{host, "msn.example.org", {5235, ejabberd_service, [{hosts, ["msn.example.org"],
[{password, "msnsecret"}]}]}, [{password, "msnsecret"}]}]},
{5236, ejabberd_service, [{host, "yahoo.example.org", {5236, ejabberd_service, [{hosts, ["yahoo.example.org"],
[{password, "yahoosecret"}]}]}, [{password, "yahoosecret"}]}]},
{5237, ejabberd_service, [{host, "gg.example.org", {5237, ejabberd_service, [{hosts, ["gg.example.org"],
[{password, "ggsecret"}]}]}, [{password, "ggsecret"}]}]},
{5238, ejabberd_service, [{host, "jmc.example.org", {5238, ejabberd_service, [{hosts, ["jmc.example.org"],
[{password, "jmcsecret"}]}]}, [{password, "jmcsecret"}]}]},
{5239, ejabberd_service, [{host, "custom.example.org", {5239, ejabberd_service, [{hosts, ["custom.example.org"],
[{password, "customsecret"}]}, [{password, "customsecret"}]},
{service_check_from, false}]} {service_check_from, false}]}
] ]

View File

@ -748,9 +748,14 @@ This is a detailed description of each option allowed by the listening modules:
used to disable control on the from field on packets send by an used to disable control on the from field on packets send by an
external components. The option can be either \term{true} or external components. The option can be either \term{true} or
\term{false}. The default value is \term{true} which conforms to \xepref{0114}. \term{false}. The default value is \term{true} which conforms to \xepref{0114}.
\titem{\{hosts, [Hostnames], [HostOptions]\}} \ind{options!hosts}This option \titem{\{hosts, [Hostnames], [HostOptions]\}} \ind{options!hosts}
defines one or more hostnames of connected services and enables you to This option of \term{ejabberd\_service} allows to define one or more hostnames
specify additional options including \poption{\{password, Secret\}}. of external Jabber components that provide a service.
In \term{HostOptions} it is possible to define the password required to those components
when attempt to connect to ejabberd: \poption{\{password, Secret\}}.
Note that you cannot define in a single \term{ejabberd\_service} components of
different services: add an \term{ejabberd\_service} for each service,
as seen in an example below.
\titem{http\_bind} \ind{options!http\_bind}\ind{protocols!XEP-0206: HTTP Binding}\ind{JWChat}\ind{web-based Jabber client} \titem{http\_bind} \ind{options!http\_bind}\ind{protocols!XEP-0206: HTTP Binding}\ind{JWChat}\ind{web-based Jabber client}
This option enables HTTP Binding (\xepref{0124} and \xepref{0206}) support. HTTP Bind This option enables HTTP Binding (\xepref{0124} and \xepref{0206}) support. HTTP Bind
enables access via HTTP requests to \ejabberd{} from behind firewalls which enables access via HTTP requests to \ejabberd{} from behind firewalls which
@ -945,19 +950,19 @@ In this example, the following configuration defines that:
ssl, {certfile, "/path/to/ssl.pem"}]}, ssl, {certfile, "/path/to/ssl.pem"}]},
{5269, ejabberd_s2s_in, []}, {5269, ejabberd_s2s_in, []},
{5280, ejabberd_http, [http_poll, web_admin]}, {5280, ejabberd_http, [http_poll, web_admin]},
{5233, ejabberd_service, [{host, "aim.example.org", {5233, ejabberd_service, [{hosts, ["aim.example.org"],
[{password, "aimsecret"}]}]}, [{password, "aimsecret"}]}]},
{5234, ejabberd_service, [{hosts, ["icq.example.org", "sms.example.org"], {5234, ejabberd_service, [{hosts, ["icq.example.org", "sms.example.org"],
[{password, "jitsecret"}]}]}, [{password, "jitsecret"}]}]},
{5235, ejabberd_service, [{host, "msn.example.org", {5235, ejabberd_service, [{hosts, ["msn.example.org"],
[{password, "msnsecret"}]}]}, [{password, "msnsecret"}]}]},
{5236, ejabberd_service, [{host, "yahoo.example.org", {5236, ejabberd_service, [{hosts, ["yahoo.example.org"],
[{password, "yahoosecret"}]}]}, [{password, "yahoosecret"}]}]},
{5237, ejabberd_service, [{host, "gg.example.org", {5237, ejabberd_service, [{hosts, ["gg.example.org"],
[{password, "ggsecret"}]}]}, [{password, "ggsecret"}]}]},
{5238, ejabberd_service, [{host, "jmc.example.org", {5238, ejabberd_service, [{hosts, ["jmc.example.org"],
[{password, "jmcsecret"}]}]}, [{password, "jmcsecret"}]}]},
{5239, ejabberd_service, [{host, "custom.example.org", {5239, ejabberd_service, [{hosts, ["custom.example.org"],
[{password, "customsecret"}]}, [{password, "customsecret"}]},
{service_check_from, false}]} {service_check_from, false}]}
] ]

View File

@ -29,7 +29,6 @@ else
endif endif
EFLAGS += @ERLANG_SSL39@ EFLAGS += @ERLANG_SSL39@
EFLAGS += -I ../include
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.
ifdef debug ifdef debug
@ -189,7 +188,15 @@ install: all
# #
# ejabberd header files # ejabberd header files
install -d $(INCLUDEDIR) install -d $(INCLUDEDIR)
install -m 644 ../include/*.hrl $(INCLUDEDIR) install -m 644 *.hrl $(INCLUDEDIR)
install -d $(INCLUDEDIR)/eldap/
install -m 644 eldap/*.hrl $(INCLUDEDIR)/eldap/
install -d $(INCLUDEDIR)/mod_proxy65/
install -m 644 mod_proxy65/*.hrl $(INCLUDEDIR)/mod_proxy65/
install -d $(INCLUDEDIR)/mod_pubsub/
install -m 644 mod_pubsub/*.hrl $(INCLUDEDIR)/mod_pubsub/
install -d $(INCLUDEDIR)/web/
install -m 644 web/*.hrl $(INCLUDEDIR)/web/
# #
# Binary C programs # Binary C programs
install -d $(PBINDIR) install -d $(PBINDIR)

View File

@ -58,7 +58,7 @@
]). ]).
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("eldap.hrl"). -include("eldap/eldap.hrl").
-record(state, {host, -record(state, {host,
eldap_id, eldap_id,

View File

@ -1221,9 +1221,6 @@ handle_info({route, FromOld, ToOld, PacketOld}, StateName, StateData) ->
handle_info({'DOWN', Monitor, _Type, _Object, _Info}, _StateName, StateData) handle_info({'DOWN', Monitor, _Type, _Object, _Info}, _StateName, StateData)
when Monitor == StateData#state.socket_monitor -> when Monitor == StateData#state.socket_monitor ->
{stop, normal, StateData}; {stop, normal, StateData};
handle_info({peername, IP}, StateName, StateData) ->
ejabberd_sm:set_session_ip(StateData#state.sid, IP),
fsm_next_state(StateName, StateData#state{ip = IP});
handle_info(Info, StateName, StateData) -> handle_info(Info, StateName, StateData) ->
?ERROR_MSG("Unexpected info: ~p", [Info]), ?ERROR_MSG("Unexpected info: ~p", [Info]),
fsm_next_state(StateName, StateData). fsm_next_state(StateName, StateData).
@ -1420,7 +1417,8 @@ presence_update(From, Packet, StateData) ->
undefined -> ""; undefined -> "";
S -> S S -> S
end, end,
Info = [{ip, StateData#state.ip},{conn, StateData#state.conn}], Info = [{ip, StateData#state.ip}, {conn, StateData#state.conn},
{auth_module, StateData#state.auth_module}],
ejabberd_sm:unset_presence(StateData#state.sid, ejabberd_sm:unset_presence(StateData#state.sid,
StateData#state.user, StateData#state.user,
StateData#state.server, StateData#state.server,
@ -1804,7 +1802,8 @@ roster_change(IJID, ISubscription, StateData) ->
update_priority(Priority, Packet, StateData) -> update_priority(Priority, Packet, StateData) ->
Info = [{ip, StateData#state.ip},{conn, StateData#state.conn}], Info = [{ip, StateData#state.ip}, {conn, StateData#state.conn},
{auth_module, StateData#state.auth_module}],
ejabberd_sm:set_presence(StateData#state.sid, ejabberd_sm:set_presence(StateData#state.sid,
StateData#state.user, StateData#state.user,
StateData#state.server, StateData#state.server,

View File

@ -268,8 +268,7 @@ code_change(_OldVsn, State, _Extra) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
activate_socket(#state{socket = Socket, activate_socket(#state{socket = Socket,
sock_mod = SockMod, sock_mod = SockMod}) ->
c2s_pid = C2SPid}) ->
PeerName = PeerName =
case SockMod of case SockMod of
gen_tcp -> gen_tcp ->
@ -282,8 +281,7 @@ activate_socket(#state{socket = Socket,
case PeerName of case PeerName of
{error, _Reason} -> {error, _Reason} ->
self() ! {tcp_closed, Socket}; self() ! {tcp_closed, Socket};
{ok, IP} -> {ok, _} ->
C2SPid ! {peername, IP},
ok ok
end. end.

View File

@ -49,8 +49,7 @@
ctl_process/2, ctl_process/2,
get_session_pid/3, get_session_pid/3,
get_user_info/3, get_user_info/3,
get_user_ip/3, get_user_ip/3
set_session_ip/2
]). ]).
%% gen_server callbacks %% gen_server callbacks
@ -187,18 +186,6 @@ get_user_info(User, Server, Resource) ->
[{node, Node}, {conn, Conn}, {ip, IP}] [{node, Node}, {conn, Conn}, {ip, IP}]
end. end.
set_session_ip(SID, IP) ->
case mnesia:dirty_read(session, SID) of
[#session{info = Info} = Session] ->
NewInfo = case lists:keymember(ip, 1, Info) of
true -> lists:keyreplace(ip, 1, Info, {ip, IP});
false -> [{ip, IP}|Info]
end,
mnesia:dirty_write(Session#session{info = NewInfo});
_ ->
ok
end.
set_presence(SID, User, Server, Resource, Priority, Presence, Info) -> set_presence(SID, User, Server, Resource, Priority, Presence, Info) ->
set_session(SID, User, Server, Resource, Priority, Info), set_session(SID, User, Server, Resource, Priority, Info),
% XXX OLD FORMAT: Presence. % XXX OLD FORMAT: Presence.

View File

@ -19,8 +19,9 @@ else
DYNAMIC_LIB_CFLAGS = -fpic -shared DYNAMIC_LIB_CFLAGS = -fpic -shared
endif endif
EFLAGS += -I ../../include EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.
ifdef debug ifdef debug
EFLAGS+=+debug_info EFLAGS+=+debug_info

View File

@ -15,12 +15,12 @@ ERL=@erl@
INSTALLUSER=@installuser@ INSTALLUSER=@installuser@
ETCDIR=@SYSCONFDIR@/ejabberd ETCDIR=@SYSCONFDIR@/ejabberd
EJABBERD_CONFIG_PATH=$ETCDIR/ejabberd.cfg EJABBERD_CONFIG_PATH=$ETCDIR/ejabberd.cfg
LOGDIR=@LOCALSTATEDIR@/log/ejabberd LOGS_DIR=@LOCALSTATEDIR@/log/ejabberd
SPOOLDIR=@LOCALSTATEDIR@/lib/ejabberd SPOOLDIR=@LOCALSTATEDIR@/lib/ejabberd
# read custom configuration # read custom configuration
CONFIG=$ETCDIR/ejabberdctl.cfg EJABBERDCTL_CONFIG_PATH=$ETCDIR/ejabberdctl.cfg
[ -f "$CONFIG" ] && . "$CONFIG" [ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH"
# parse command line parameters # parse command line parameters
ARGS= ARGS=
@ -31,8 +31,8 @@ while [ $# -ne 0 ] ; do
--) break ;; --) break ;;
--node) ERLANG_NODE=$1; shift ;; --node) ERLANG_NODE=$1; shift ;;
--config) EJABBERD_CONFIG_PATH=$1 ; shift ;; --config) EJABBERD_CONFIG_PATH=$1 ; shift ;;
--ctl-config) CONFIG=$1 ; shift ;; --ctl-config) EJABBERDCTL_CONFIG_PATH=$1 ; shift ;;
--logs) LOGDIR=$1 ; shift ;; --logs) LOGS_DIR=$1 ; shift ;;
--spool) SPOOLDIR=$1 ; shift ;; --spool) SPOOLDIR=$1 ; shift ;;
*) ARGS="$ARGS $PARAM" ;; *) ARGS="$ARGS $PARAM" ;;
esac esac
@ -66,16 +66,16 @@ ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES $KERNEL_OPTS"
# define additional environment variables # define additional environment variables
EJABBERDDIR=@LIBDIR@/ejabberd EJABBERDDIR=@LIBDIR@/ejabberd
BEAMDIR=$EJABBERDDIR/ebin EJABBERD_EBIN_PATH=$EJABBERDDIR/ebin
PRIVDIR=$EJABBERDDIR/priv EJABBERD_PRIV_PATH=$EJABBERDDIR/priv
PBINDIR=$PRIVDIR/bin EJABBERD_BIN_PATH=$EJABBERD_PRIV_PATH/bin
SODIR=$PRIVDIR/lib EJABBERD_SO_PATH=$EJABBERD_PRIV_PATH/lib
MSGSDIR=$PRIVDIR/msgs EJABBERD_MSGS_PATH=$EJABBERD_PRIV_PATH/msgs
EJABBERD_LOG_PATH=$LOGDIR/ejabberd.log EJABBERD_LOG_PATH=$LOGS_DIR/ejabberd.log
SASL_LOG_PATH=$LOGDIR/sasl.log SASL_LOG_PATH=$LOGS_DIR/sasl.log
DATETIME=`date "+%Y%m%d-%H%M%S"` DATETIME=`date "+%Y%m%d-%H%M%S"`
ERL_CRASH_DUMP=$LOGDIR/erl_crash_$DATETIME.dump ERL_CRASH_DUMP=$LOGS_DIR/erl_crash_$DATETIME.dump
ERL_INETRC=$ETCDIR/inetrc ERL_INETRC=$ETCDIR/inetrc
HOME=$SPOOLDIR HOME=$SPOOLDIR
@ -84,10 +84,10 @@ HOME=$SPOOLDIR
# export global variables # export global variables
export EJABBERD_CONFIG_PATH export EJABBERD_CONFIG_PATH
export MSGSDIR export EJABBERD_MSGS_PATH
export EJABBERD_LOG_PATH export EJABBERD_LOG_PATH
export SODIR export EJABBERD_SO_PATH
export PBINDIR export EJABBERD_BIN_PATH
export ERL_CRASH_DUMP export ERL_CRASH_DUMP
export ERL_INETRC export ERL_INETRC
export ERL_MAX_PORTS export ERL_MAX_PORTS
@ -105,7 +105,7 @@ start ()
$EXEC_CMD "$ERL \ $EXEC_CMD "$ERL \
$NAME $ERLANG_NODE \ $NAME $ERLANG_NODE \
-noinput -detached \ -noinput -detached \
-pa $BEAMDIR \ -pa $EJABBERD_EBIN_PATH \
-mnesia dir \"\\\"$SPOOLDIR\\\"\" \ -mnesia dir \"\\\"$SPOOLDIR\\\"\" \
-s ejabberd \ -s ejabberd \
-sasl sasl_error_logger \\{file,\\\"$SASL_LOG_PATH\\\"\\} \ -sasl sasl_error_logger \\{file,\\\"$SASL_LOG_PATH\\\"\\} \
@ -157,7 +157,7 @@ live ()
echo "" echo ""
$EXEC_CMD "$ERL \ $EXEC_CMD "$ERL \
$NAME $ERLANG_NODE \ $NAME $ERLANG_NODE \
-pa $BEAMDIR \ -pa $EJABBERD_EBIN_PATH \
-mnesia dir \"\\\"$SPOOLDIR\\\"\" \ -mnesia dir \"\\\"$SPOOLDIR\\\"\" \
-s ejabberd \ -s ejabberd \
$ERLANG_OPTS $ARGS \"$@\"" $ERLANG_OPTS $ARGS \"$@\""
@ -166,11 +166,12 @@ live ()
# common control function # common control function
ctl () ctl ()
{ {
COMMAND=$@
$EXEC_CMD "$ERL \ $EXEC_CMD "$ERL \
$NAME ejabberdctl \ $NAME ejabberdctl \
-noinput \ -noinput \
-pa $BEAMDIR \ -pa $EJABBERD_EBIN_PATH \
-s ejabberd_ctl -extra $ERLANG_NODE $@" -s ejabberd_ctl -extra $ERLANG_NODE $COMMAND"
result=$? result=$?
case $result in case $result in
0) :;; 0) :;;
@ -183,8 +184,8 @@ ctl ()
echo "" echo ""
echo "Optional parameters when starting an ejabberd node:" echo "Optional parameters when starting an ejabberd node:"
echo " --config file Config file of ejabberd: $EJABBERD_CONFIG_PATH" echo " --config file Config file of ejabberd: $EJABBERD_CONFIG_PATH"
echo " --ctl-config file Config file of ejabberdctl: $CONFIG" echo " --ctl-config file Config file of ejabberdctl: $EJABBERDCTL_CONFIG_PATH"
echo " --logs dir Directory for logs: $LOGDIR" echo " --logs dir Directory for logs: $LOGS_DIR"
echo " --spool dir Database spool dir: $SPOOLDIR" echo " --spool dir Database spool dir: $SPOOLDIR"
echo " --node nodename ejabberd node name: $ERLANG_NODE" echo " --node nodename ejabberd node name: $ERLANG_NODE"
echo "";; echo "";;

View File

@ -9,8 +9,9 @@ LIBS = @LIBS@
ERLANG_CFLAGS = @ERLANG_CFLAGS@ ERLANG_CFLAGS = @ERLANG_CFLAGS@
ERLANG_LIBS = @ERLANG_LIBS@ ERLANG_LIBS = @ERLANG_LIBS@
EFLAGS += -I ../../include EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.
ifdef debug ifdef debug
EFLAGS+=+debug_info EFLAGS+=+debug_info

View File

@ -16,7 +16,7 @@ else
DYNAMIC_LIB_CFLAGS = -fpic -shared DYNAMIC_LIB_CFLAGS = -fpic -shared
endif endif
EFLAGS += -I ../../include EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.

View File

@ -9,7 +9,7 @@ LIBS = @LIBS@
ERLANG_CFLAGS = @ERLANG_CFLAGS@ ERLANG_CFLAGS = @ERLANG_CFLAGS@
ERLANG_LIBS = @ERLANG_LIBS@ ERLANG_LIBS = @ERLANG_LIBS@
EFLAGS += -I ../../include EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.

View File

@ -43,8 +43,8 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("jlib.hrl"). -include("jlib.hrl").
-include("ejabberd_http.hrl"). -include("web/ejabberd_http.hrl").
-include("ejabberd_web_admin.hrl"). -include("web/ejabberd_web_admin.hrl").
-record(offline_msg, {us, timestamp, expire, from, to, packet}). -record(offline_msg, {us, timestamp, expire, from, to, packet}).

View File

@ -42,8 +42,8 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("jlib.hrl"). -include("jlib.hrl").
-include("ejabberd_http.hrl"). -include("web/ejabberd_http.hrl").
-include("ejabberd_web_admin.hrl"). -include("web/ejabberd_web_admin.hrl").
-record(offline_msg, {user, timestamp, expire, from, to, packet}). -record(offline_msg, {user, timestamp, expire, from, to, packet}).

View File

@ -9,7 +9,7 @@ LIBS = @LIBS@
ERLANG_CFLAGS = @ERLANG_CFLAGS@ ERLANG_CFLAGS = @ERLANG_CFLAGS@
ERLANG_LIBS = @ERLANG_LIBS@ ERLANG_LIBS = @ERLANG_LIBS@
EFLAGS += -I ../../include EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.

View File

@ -9,7 +9,7 @@ LIBS = @LIBS@
ERLANG_CFLAGS = @ERLANG_CFLAGS@ ERLANG_CFLAGS = @ERLANG_CFLAGS@
ERLANG_LIBS = @ERLANG_LIBS@ ERLANG_LIBS = @ERLANG_LIBS@
EFLAGS += -I ../../include EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.

View File

@ -47,8 +47,8 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("jlib.hrl"). -include("jlib.hrl").
-include("mod_roster.hrl"). -include("mod_roster.hrl").
-include("ejabberd_http.hrl"). -include("web/ejabberd_http.hrl").
-include("ejabberd_web_admin.hrl"). -include("web/ejabberd_web_admin.hrl").
start(Host, Opts) -> start(Host, Opts) ->

View File

@ -46,8 +46,8 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("jlib.hrl"). -include("jlib.hrl").
-include("mod_roster.hrl"). -include("mod_roster.hrl").
-include("ejabberd_http.hrl"). -include("web/ejabberd_http.hrl").
-include("ejabberd_web_admin.hrl"). -include("web/ejabberd_web_admin.hrl").
start(Host, Opts) -> start(Host, Opts) ->

View File

@ -52,8 +52,8 @@
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("jlib.hrl"). -include("jlib.hrl").
-include("mod_roster.hrl"). -include("mod_roster.hrl").
-include("ejabberd_http.hrl"). -include("web/ejabberd_http.hrl").
-include("ejabberd_web_admin.hrl"). -include("web/ejabberd_web_admin.hrl").
-record(sr_group, {group_host, opts}). -record(sr_group, {group_host, opts}).
-record(sr_user, {us, group_host}). -record(sr_user, {us, group_host}).

View File

@ -50,7 +50,7 @@
]). ]).
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("eldap.hrl"). -include("eldap/eldap.hrl").
-include("jlib.hrl"). -include("jlib.hrl").
-define(PROCNAME, ejabberd_mod_vcard_ldap). -define(PROCNAME, ejabberd_mod_vcard_ldap).

View File

@ -9,7 +9,7 @@ LIBS = @LIBS@
ERLANG_CFLAGS = @ERLANG_CFLAGS@ ERLANG_CFLAGS = @ERLANG_CFLAGS@
ERLANG_LIBS = @ERLANG_LIBS@ ERLANG_LIBS = @ERLANG_LIBS@
EFLAGS += -I ../../include EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.

View File

@ -9,7 +9,7 @@ LIBS = @LIBS@ @PAM_LIBS@
ERLANG_CFLAGS = @ERLANG_CFLAGS@ ERLANG_CFLAGS = @ERLANG_CFLAGS@
ERLANG_LIBS = @ERLANG_LIBS@ ERLANG_LIBS = @ERLANG_LIBS@
EFLAGS += -I ../../include EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.

View File

@ -16,7 +16,9 @@ else
DYNAMIC_LIB_CFLAGS = -fpic -shared DYNAMIC_LIB_CFLAGS = -fpic -shared
endif endif
EFLAGS = -I .. -pz .. EFLAGS += -I ..
EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.
ifdef debug ifdef debug
EFLAGS+=+debug_info EFLAGS+=+debug_info

View File

@ -19,7 +19,7 @@ else
DYNAMIC_LIB_CFLAGS = -fpic -shared DYNAMIC_LIB_CFLAGS = -fpic -shared
endif endif
EFLAGS += -I ../../include EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.

View File

@ -9,7 +9,8 @@ LIBS = @LIBS@
ERLANG_CFLAGS = @ERLANG_CFLAGS@ ERLANG_CFLAGS = @ERLANG_CFLAGS@
ERLANG_LIBS = @ERLANG_LIBS@ ERLANG_LIBS = @ERLANG_LIBS@
EFLAGS += -I ../../include EFLAGS += @ERLANG_SSL39@
EFLAGS += -I ..
EFLAGS += -pz .. EFLAGS += -pz ..
# make debug=true to compile Erlang module with debug informations. # make debug=true to compile Erlang module with debug informations.

View File

@ -30,7 +30,7 @@
-behaviour(gen_fsm). -behaviour(gen_fsm).
%% External exports %% External exports
-export([start_link/2, -export([start_link/3,
init/1, init/1,
handle_event/3, handle_event/3,
handle_sync_event/4, handle_sync_event/4,
@ -50,16 +50,14 @@
-record(http_poll, {id, pid}). -record(http_poll, {id, pid}).
-define(NULL_PEER, {{0, 0, 0, 0}, 0}).
-record(state, {id, -record(state, {id,
key, key,
socket,
output = "", output = "",
input = "", input = "",
waiting_input = false, %% {ReceiverPid, Tag} waiting_input = false, %% {ReceiverPid, Tag}
last_receiver, last_receiver,
timer, timer}).
ip = ?NULL_PEER }).
%-define(DBGFSM, true). %-define(DBGFSM, true).
@ -77,19 +75,19 @@
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% API %%% API
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
start(ID, Key) -> start(ID, Key, IP) ->
mnesia:create_table(http_poll, mnesia:create_table(http_poll,
[{ram_copies, [node()]}, [{ram_copies, [node()]},
{attributes, record_info(fields, http_poll)}]), {attributes, record_info(fields, http_poll)}]),
supervisor:start_child(ejabberd_http_poll_sup, [ID, Key]). supervisor:start_child(ejabberd_http_poll_sup, [ID, Key, IP]).
start_link(ID, Key) -> start_link(ID, Key, IP) ->
gen_fsm:start_link(?MODULE, [ID, Key], ?FSMOPTS). gen_fsm:start_link(?MODULE, [ID, Key, IP], ?FSMOPTS).
send({http_poll, FsmRef}, Packet) -> send({http_poll, FsmRef, _IP}, Packet) ->
gen_fsm:sync_send_all_state_event(FsmRef, {send, Packet}). gen_fsm:sync_send_all_state_event(FsmRef, {send, Packet}).
setopts({http_poll, FsmRef}, Opts) -> setopts({http_poll, FsmRef, _IP}, Opts) ->
case lists:member({active, once}, Opts) of case lists:member({active, once}, Opts) of
true -> true ->
gen_fsm:send_all_state_event(FsmRef, {activate, self()}); gen_fsm:send_all_state_event(FsmRef, {activate, self()});
@ -97,31 +95,27 @@ setopts({http_poll, FsmRef}, Opts) ->
ok ok
end. end.
sockname(_) -> sockname(_Socket) ->
{ok, ?NULL_PEER}. {ok, {{0, 0, 0, 0}, 0}}.
peername({http_poll, FsmRef}) -> peername({http_poll, _FsmRef, IP}) ->
case catch gen_fsm:sync_send_all_state_event(FsmRef, peername, 1000) of {ok, IP}.
{ok, IP} -> {ok, IP};
_ -> {ok, ?NULL_PEER}
end;
peername(_) ->
{ok, ?NULL_PEER}.
controlling_process(_Socket, _Pid) -> controlling_process(_Socket, _Pid) ->
ok. ok.
close({http_poll, FsmRef}) -> close({http_poll, FsmRef, _IP}) ->
catch gen_fsm:sync_send_all_state_event(FsmRef, close). catch gen_fsm:sync_send_all_state_event(FsmRef, close).
process([], #request{data = Data, ip = IP} = _Request) -> process([], #request{data = Data,
ip = IP} = _Request) ->
case catch parse_request(Data) of case catch parse_request(Data) of
{ok, ID1, Key, NewKey, Packet} -> {ok, ID1, Key, NewKey, Packet} ->
ID = if ID = if
(ID1 == "0") or (ID1 == "mobile") -> (ID1 == "0") or (ID1 == "mobile") ->
NewID = sha:sha(term_to_binary({now(), make_ref()})), NewID = sha:sha(term_to_binary({now(), make_ref()})),
{ok, Pid} = start(NewID, ""), {ok, Pid} = start(NewID, "", IP),
mnesia:transaction( mnesia:transaction(
fun() -> fun() ->
mnesia:write(#http_poll{id = NewID, mnesia:write(#http_poll{id = NewID,
@ -131,7 +125,7 @@ process([], #request{data = Data, ip = IP} = _Request) ->
true -> true ->
ID1 ID1
end, end,
case http_put(ID, Key, NewKey, Packet, IP) of case http_put(ID, Key, NewKey, Packet) of
{error, not_exists} -> {error, not_exists} ->
{200, ?BAD_REQUEST, ""}; {200, ?BAD_REQUEST, ""};
{error, bad_key} -> {error, bad_key} ->
@ -176,8 +170,8 @@ process(_, _Request) ->
%% ignore | %% ignore |
%% {stop, StopReason} %% {stop, StopReason}
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
init([ID, Key]) -> init([ID, Key, IP]) ->
?INFO_MSG("started: ~p", [{ID, Key}]), ?INFO_MSG("started: ~p", [{ID, Key, IP}]),
%% Read c2s options from the first ejabberd_c2s configuration in %% Read c2s options from the first ejabberd_c2s configuration in
%% the config file listen section %% the config file listen section
@ -187,12 +181,12 @@ init([ID, Key]) ->
%% connector. %% connector.
Opts = ejabberd_c2s_config:get_c2s_limits(), Opts = ejabberd_c2s_config:get_c2s_limits(),
ejabberd_socket:start(ejabberd_c2s, ?MODULE, {http_poll, self()}, Opts), Socket = {http_poll, self(), IP},
%{ok, C2SPid} = ejabberd_c2s:start({?MODULE, {http_poll, self()}}, Opts), ejabberd_socket:start(ejabberd_c2s, ?MODULE, Socket, Opts),
%ejabberd_c2s:become_controller(C2SPid),
Timer = erlang:start_timer(?HTTP_POLL_TIMEOUT, self(), []), Timer = erlang:start_timer(?HTTP_POLL_TIMEOUT, self(), []),
{ok, loop, #state{id = ID, {ok, loop, #state{id = ID,
key = Key, key = Key,
socket = Socket,
timer = Timer}}. timer = Timer}}.
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
@ -229,7 +223,7 @@ handle_event({activate, From}, StateName, StateData) ->
StateData#state{waiting_input = {From, ok}}}; StateData#state{waiting_input = {From, ok}}};
Input -> Input ->
Receiver = From, Receiver = From,
Receiver ! {tcp, {http_poll, self()}, list_to_binary(Input)}, Receiver ! {tcp, StateData#state.socket, list_to_binary(Input)},
{next_state, StateName, StateData#state{input = "", {next_state, StateName, StateData#state{input = "",
waiting_input = false, waiting_input = false,
last_receiver = Receiver last_receiver = Receiver
@ -257,7 +251,7 @@ handle_sync_event(stop, _From, _StateName, StateData) ->
Reply = ok, Reply = ok,
{stop, normal, Reply, StateData}; {stop, normal, Reply, StateData};
handle_sync_event({http_put, Key, NewKey, Packet, IP}, handle_sync_event({http_put, Key, NewKey, Packet},
_From, StateName, StateData) -> _From, StateName, StateData) ->
Allow = case StateData#state.key of Allow = case StateData#state.key of
"" -> "" ->
@ -279,10 +273,9 @@ handle_sync_event({http_put, Key, NewKey, Packet, IP},
Input = [StateData#state.input|Packet], Input = [StateData#state.input|Packet],
Reply = ok, Reply = ok,
{reply, Reply, StateName, StateData#state{input = Input, {reply, Reply, StateName, StateData#state{input = Input,
key = NewKey, key = NewKey}};
ip = IP}};
{Receiver, _Tag} -> {Receiver, _Tag} ->
Receiver ! {tcp, {http_poll, self()}, Receiver ! {tcp, StateData#state.socket,
list_to_binary(Packet)}, list_to_binary(Packet)},
cancel_timer(StateData#state.timer), cancel_timer(StateData#state.timer),
Timer = erlang:start_timer(?HTTP_POLL_TIMEOUT, self(), []), Timer = erlang:start_timer(?HTTP_POLL_TIMEOUT, self(), []),
@ -291,8 +284,7 @@ handle_sync_event({http_put, Key, NewKey, Packet, IP},
StateData#state{waiting_input = false, StateData#state{waiting_input = false,
last_receiver = Receiver, last_receiver = Receiver,
key = NewKey, key = NewKey,
timer = Timer, timer = Timer}}
ip = IP}}
end; end;
true -> true ->
Reply = {error, bad_key}, Reply = {error, bad_key},
@ -303,10 +295,6 @@ handle_sync_event(http_get, _From, StateName, StateData) ->
Reply = {ok, StateData#state.output}, Reply = {ok, StateData#state.output},
{reply, Reply, StateName, StateData#state{output = ""}}; {reply, Reply, StateName, StateData#state{output = ""}};
handle_sync_event(peername, _From, StateName, StateData) ->
Reply = {ok, StateData#state.ip},
{reply, Reply, StateName, StateData};
handle_sync_event(_Event, _From, StateName, StateData) -> handle_sync_event(_Event, _From, StateName, StateData) ->
Reply = ok, Reply = ok,
{reply, Reply, StateName, StateData}. {reply, Reply, StateName, StateData}.
@ -345,10 +333,10 @@ terminate(_Reason, _StateName, StateData) ->
case StateData#state.last_receiver of case StateData#state.last_receiver of
undefined -> ok; undefined -> ok;
Receiver -> Receiver ->
Receiver ! {tcp_closed, {http_poll, self()}} Receiver ! {tcp_closed, StateData#state.socket}
end; end;
{Receiver, _Tag} -> {Receiver, _Tag} ->
Receiver ! {tcp_closed, {http_poll, self()}} Receiver ! {tcp_closed, StateData#state.socket}
end, end,
catch resend_messages(StateData#state.output), catch resend_messages(StateData#state.output),
ok. ok.
@ -357,13 +345,13 @@ terminate(_Reason, _StateName, StateData) ->
%%% Internal functions %%% Internal functions
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
http_put(ID, Key, NewKey, Packet, IP) -> http_put(ID, Key, NewKey, Packet) ->
case mnesia:dirty_read({http_poll, ID}) of case mnesia:dirty_read({http_poll, ID}) of
[] -> [] ->
{error, not_exists}; {error, not_exists};
[#http_poll{pid = FsmRef}] -> [#http_poll{pid = FsmRef}] ->
gen_fsm:sync_send_all_state_event( gen_fsm:sync_send_all_state_event(
FsmRef, {http_put, Key, NewKey, Packet, IP}) FsmRef, {http_put, Key, NewKey, Packet})
end. end.
http_get(ID) -> http_get(ID) ->