Merge revisions from 1444 to revision 1457 from trunk.
SVN Revision: 1458
This commit is contained in:
parent
532e8ee228
commit
07b1210b50
39
ChangeLog
39
ChangeLog
|
@ -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>
|
||||
|
||||
* src/mod_caps.erl, src/ejabberd_c2s.erl: Start conversion to exmpp.
|
||||
For now, only direct calls from ejabberd_c2s are done. Calls through
|
||||
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>
|
||||
|
||||
Merge revisions from 1434 to revision 1444 from trunk.
|
||||
|
|
|
@ -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
|
||||
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>.
|
||||
</DD><DT CLASS="dt-description"><B><TT>{hosts, [Hostnames], [HostOptions]}</TT></B></DT><DD CLASS="dd-description"> This option
|
||||
defines one or more hostnames of connected services and enables you to
|
||||
specify additional options including <TT>{password, Secret}</TT>.
|
||||
</DD><DT CLASS="dt-description"><B><TT>{hosts, [Hostnames], [HostOptions]}</TT></B></DT><DD CLASS="dd-description">
|
||||
This option of <TT>ejabberd_service</TT> allows to define one or more hostnames
|
||||
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">
|
||||
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
|
||||
|
@ -818,19 +823,19 @@ connected to port 5237 with password ‘<TT>ggsecret</TT>’.
|
|||
ssl, {certfile, "/path/to/ssl.pem"}]},
|
||||
{5269, ejabberd_s2s_in, []},
|
||||
{5280, ejabberd_http, [http_poll, web_admin]},
|
||||
{5233, ejabberd_service, [{host, "aim.example.org",
|
||||
{5233, ejabberd_service, [{hosts, ["aim.example.org"],
|
||||
[{password, "aimsecret"}]}]},
|
||||
{5234, ejabberd_service, [{hosts, ["icq.example.org", "sms.example.org"],
|
||||
[{password, "jitsecret"}]}]},
|
||||
{5235, ejabberd_service, [{host, "msn.example.org",
|
||||
{5235, ejabberd_service, [{hosts, ["msn.example.org"],
|
||||
[{password, "msnsecret"}]}]},
|
||||
{5236, ejabberd_service, [{host, "yahoo.example.org",
|
||||
{5236, ejabberd_service, [{hosts, ["yahoo.example.org"],
|
||||
[{password, "yahoosecret"}]}]},
|
||||
{5237, ejabberd_service, [{host, "gg.example.org",
|
||||
{5237, ejabberd_service, [{hosts, ["gg.example.org"],
|
||||
[{password, "ggsecret"}]}]},
|
||||
{5238, ejabberd_service, [{host, "jmc.example.org",
|
||||
{5238, ejabberd_service, [{hosts, ["jmc.example.org"],
|
||||
[{password, "jmcsecret"}]}]},
|
||||
{5239, ejabberd_service, [{host, "custom.example.org",
|
||||
{5239, ejabberd_service, [{hosts, ["custom.example.org"],
|
||||
[{password, "customsecret"}]},
|
||||
{service_check_from, false}]}
|
||||
]
|
||||
|
|
|
@ -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
|
||||
external components. The option can be either \term{true} or
|
||||
\term{false}. The default value is \term{true} which conforms to \xepref{0114}.
|
||||
\titem{\{hosts, [Hostnames], [HostOptions]\}} \ind{options!hosts}This option
|
||||
defines one or more hostnames of connected services and enables you to
|
||||
specify additional options including \poption{\{password, Secret\}}.
|
||||
\titem{\{hosts, [Hostnames], [HostOptions]\}} \ind{options!hosts}
|
||||
This option of \term{ejabberd\_service} allows to define one or more hostnames
|
||||
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}
|
||||
This option enables HTTP Binding (\xepref{0124} and \xepref{0206}) support. HTTP Bind
|
||||
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"}]},
|
||||
{5269, ejabberd_s2s_in, []},
|
||||
{5280, ejabberd_http, [http_poll, web_admin]},
|
||||
{5233, ejabberd_service, [{host, "aim.example.org",
|
||||
{5233, ejabberd_service, [{hosts, ["aim.example.org"],
|
||||
[{password, "aimsecret"}]}]},
|
||||
{5234, ejabberd_service, [{hosts, ["icq.example.org", "sms.example.org"],
|
||||
[{password, "jitsecret"}]}]},
|
||||
{5235, ejabberd_service, [{host, "msn.example.org",
|
||||
{5235, ejabberd_service, [{hosts, ["msn.example.org"],
|
||||
[{password, "msnsecret"}]}]},
|
||||
{5236, ejabberd_service, [{host, "yahoo.example.org",
|
||||
{5236, ejabberd_service, [{hosts, ["yahoo.example.org"],
|
||||
[{password, "yahoosecret"}]}]},
|
||||
{5237, ejabberd_service, [{host, "gg.example.org",
|
||||
{5237, ejabberd_service, [{hosts, ["gg.example.org"],
|
||||
[{password, "ggsecret"}]}]},
|
||||
{5238, ejabberd_service, [{host, "jmc.example.org",
|
||||
{5238, ejabberd_service, [{hosts, ["jmc.example.org"],
|
||||
[{password, "jmcsecret"}]}]},
|
||||
{5239, ejabberd_service, [{host, "custom.example.org",
|
||||
{5239, ejabberd_service, [{hosts, ["custom.example.org"],
|
||||
[{password, "customsecret"}]},
|
||||
{service_check_from, false}]}
|
||||
]
|
||||
|
|
|
@ -29,7 +29,6 @@ else
|
|||
endif
|
||||
|
||||
EFLAGS += @ERLANG_SSL39@
|
||||
EFLAGS += -I ../include
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
ifdef debug
|
||||
|
@ -189,7 +188,15 @@ install: all
|
|||
#
|
||||
# ejabberd header files
|
||||
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
|
||||
install -d $(PBINDIR)
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("eldap.hrl").
|
||||
-include("eldap/eldap.hrl").
|
||||
|
||||
-record(state, {host,
|
||||
eldap_id,
|
||||
|
|
|
@ -1221,9 +1221,6 @@ handle_info({route, FromOld, ToOld, PacketOld}, StateName, StateData) ->
|
|||
handle_info({'DOWN', Monitor, _Type, _Object, _Info}, _StateName, StateData)
|
||||
when Monitor == StateData#state.socket_monitor ->
|
||||
{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) ->
|
||||
?ERROR_MSG("Unexpected info: ~p", [Info]),
|
||||
fsm_next_state(StateName, StateData).
|
||||
|
@ -1420,7 +1417,8 @@ presence_update(From, Packet, StateData) ->
|
|||
undefined -> "";
|
||||
S -> S
|
||||
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,
|
||||
StateData#state.user,
|
||||
StateData#state.server,
|
||||
|
@ -1804,7 +1802,8 @@ roster_change(IJID, ISubscription, 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,
|
||||
StateData#state.user,
|
||||
StateData#state.server,
|
||||
|
|
|
@ -268,8 +268,7 @@ code_change(_OldVsn, State, _Extra) ->
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
activate_socket(#state{socket = Socket,
|
||||
sock_mod = SockMod,
|
||||
c2s_pid = C2SPid}) ->
|
||||
sock_mod = SockMod}) ->
|
||||
PeerName =
|
||||
case SockMod of
|
||||
gen_tcp ->
|
||||
|
@ -282,8 +281,7 @@ activate_socket(#state{socket = Socket,
|
|||
case PeerName of
|
||||
{error, _Reason} ->
|
||||
self() ! {tcp_closed, Socket};
|
||||
{ok, IP} ->
|
||||
C2SPid ! {peername, IP},
|
||||
{ok, _} ->
|
||||
ok
|
||||
end.
|
||||
|
||||
|
|
|
@ -49,8 +49,7 @@
|
|||
ctl_process/2,
|
||||
get_session_pid/3,
|
||||
get_user_info/3,
|
||||
get_user_ip/3,
|
||||
set_session_ip/2
|
||||
get_user_ip/3
|
||||
]).
|
||||
|
||||
%% gen_server callbacks
|
||||
|
@ -187,18 +186,6 @@ get_user_info(User, Server, Resource) ->
|
|||
[{node, Node}, {conn, Conn}, {ip, IP}]
|
||||
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_session(SID, User, Server, Resource, Priority, Info),
|
||||
% XXX OLD FORMAT: Presence.
|
||||
|
|
|
@ -19,8 +19,9 @@ else
|
|||
DYNAMIC_LIB_CFLAGS = -fpic -shared
|
||||
endif
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
ifdef debug
|
||||
EFLAGS+=+debug_info
|
||||
|
|
|
@ -15,12 +15,12 @@ ERL=@erl@
|
|||
INSTALLUSER=@installuser@
|
||||
ETCDIR=@SYSCONFDIR@/ejabberd
|
||||
EJABBERD_CONFIG_PATH=$ETCDIR/ejabberd.cfg
|
||||
LOGDIR=@LOCALSTATEDIR@/log/ejabberd
|
||||
LOGS_DIR=@LOCALSTATEDIR@/log/ejabberd
|
||||
SPOOLDIR=@LOCALSTATEDIR@/lib/ejabberd
|
||||
|
||||
# read custom configuration
|
||||
CONFIG=$ETCDIR/ejabberdctl.cfg
|
||||
[ -f "$CONFIG" ] && . "$CONFIG"
|
||||
EJABBERDCTL_CONFIG_PATH=$ETCDIR/ejabberdctl.cfg
|
||||
[ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH"
|
||||
|
||||
# parse command line parameters
|
||||
ARGS=
|
||||
|
@ -31,8 +31,8 @@ while [ $# -ne 0 ] ; do
|
|||
--) break ;;
|
||||
--node) ERLANG_NODE=$1; shift ;;
|
||||
--config) EJABBERD_CONFIG_PATH=$1 ; shift ;;
|
||||
--ctl-config) CONFIG=$1 ; shift ;;
|
||||
--logs) LOGDIR=$1 ; shift ;;
|
||||
--ctl-config) EJABBERDCTL_CONFIG_PATH=$1 ; shift ;;
|
||||
--logs) LOGS_DIR=$1 ; shift ;;
|
||||
--spool) SPOOLDIR=$1 ; shift ;;
|
||||
*) ARGS="$ARGS $PARAM" ;;
|
||||
esac
|
||||
|
@ -66,16 +66,16 @@ ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES $KERNEL_OPTS"
|
|||
|
||||
# define additional environment variables
|
||||
EJABBERDDIR=@LIBDIR@/ejabberd
|
||||
BEAMDIR=$EJABBERDDIR/ebin
|
||||
PRIVDIR=$EJABBERDDIR/priv
|
||||
PBINDIR=$PRIVDIR/bin
|
||||
SODIR=$PRIVDIR/lib
|
||||
MSGSDIR=$PRIVDIR/msgs
|
||||
EJABBERD_EBIN_PATH=$EJABBERDDIR/ebin
|
||||
EJABBERD_PRIV_PATH=$EJABBERDDIR/priv
|
||||
EJABBERD_BIN_PATH=$EJABBERD_PRIV_PATH/bin
|
||||
EJABBERD_SO_PATH=$EJABBERD_PRIV_PATH/lib
|
||||
EJABBERD_MSGS_PATH=$EJABBERD_PRIV_PATH/msgs
|
||||
|
||||
EJABBERD_LOG_PATH=$LOGDIR/ejabberd.log
|
||||
SASL_LOG_PATH=$LOGDIR/sasl.log
|
||||
EJABBERD_LOG_PATH=$LOGS_DIR/ejabberd.log
|
||||
SASL_LOG_PATH=$LOGS_DIR/sasl.log
|
||||
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
|
||||
HOME=$SPOOLDIR
|
||||
|
||||
|
@ -84,10 +84,10 @@ HOME=$SPOOLDIR
|
|||
|
||||
# export global variables
|
||||
export EJABBERD_CONFIG_PATH
|
||||
export MSGSDIR
|
||||
export EJABBERD_MSGS_PATH
|
||||
export EJABBERD_LOG_PATH
|
||||
export SODIR
|
||||
export PBINDIR
|
||||
export EJABBERD_SO_PATH
|
||||
export EJABBERD_BIN_PATH
|
||||
export ERL_CRASH_DUMP
|
||||
export ERL_INETRC
|
||||
export ERL_MAX_PORTS
|
||||
|
@ -105,7 +105,7 @@ start ()
|
|||
$EXEC_CMD "$ERL \
|
||||
$NAME $ERLANG_NODE \
|
||||
-noinput -detached \
|
||||
-pa $BEAMDIR \
|
||||
-pa $EJABBERD_EBIN_PATH \
|
||||
-mnesia dir \"\\\"$SPOOLDIR\\\"\" \
|
||||
-s ejabberd \
|
||||
-sasl sasl_error_logger \\{file,\\\"$SASL_LOG_PATH\\\"\\} \
|
||||
|
@ -157,7 +157,7 @@ live ()
|
|||
echo ""
|
||||
$EXEC_CMD "$ERL \
|
||||
$NAME $ERLANG_NODE \
|
||||
-pa $BEAMDIR \
|
||||
-pa $EJABBERD_EBIN_PATH \
|
||||
-mnesia dir \"\\\"$SPOOLDIR\\\"\" \
|
||||
-s ejabberd \
|
||||
$ERLANG_OPTS $ARGS \"$@\""
|
||||
|
@ -166,11 +166,12 @@ live ()
|
|||
# common control function
|
||||
ctl ()
|
||||
{
|
||||
COMMAND=$@
|
||||
$EXEC_CMD "$ERL \
|
||||
$NAME ejabberdctl \
|
||||
-noinput \
|
||||
-pa $BEAMDIR \
|
||||
-s ejabberd_ctl -extra $ERLANG_NODE $@"
|
||||
-pa $EJABBERD_EBIN_PATH \
|
||||
-s ejabberd_ctl -extra $ERLANG_NODE $COMMAND"
|
||||
result=$?
|
||||
case $result in
|
||||
0) :;;
|
||||
|
@ -183,8 +184,8 @@ ctl ()
|
|||
echo ""
|
||||
echo "Optional parameters when starting an ejabberd node:"
|
||||
echo " --config file Config file of ejabberd: $EJABBERD_CONFIG_PATH"
|
||||
echo " --ctl-config file Config file of ejabberdctl: $CONFIG"
|
||||
echo " --logs dir Directory for logs: $LOGDIR"
|
||||
echo " --ctl-config file Config file of ejabberdctl: $EJABBERDCTL_CONFIG_PATH"
|
||||
echo " --logs dir Directory for logs: $LOGS_DIR"
|
||||
echo " --spool dir Database spool dir: $SPOOLDIR"
|
||||
echo " --node nodename ejabberd node name: $ERLANG_NODE"
|
||||
echo "";;
|
||||
|
|
|
@ -9,8 +9,9 @@ LIBS = @LIBS@
|
|||
ERLANG_CFLAGS = @ERLANG_CFLAGS@
|
||||
ERLANG_LIBS = @ERLANG_LIBS@
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
ifdef debug
|
||||
EFLAGS+=+debug_info
|
||||
|
|
|
@ -16,7 +16,7 @@ else
|
|||
DYNAMIC_LIB_CFLAGS = -fpic -shared
|
||||
endif
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
|
|
|
@ -9,7 +9,7 @@ LIBS = @LIBS@
|
|||
ERLANG_CFLAGS = @ERLANG_CFLAGS@
|
||||
ERLANG_LIBS = @ERLANG_LIBS@
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
|
||||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
-include("ejabberd_http.hrl").
|
||||
-include("ejabberd_web_admin.hrl").
|
||||
-include("web/ejabberd_http.hrl").
|
||||
-include("web/ejabberd_web_admin.hrl").
|
||||
|
||||
-record(offline_msg, {us, timestamp, expire, from, to, packet}).
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
|
||||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
-include("ejabberd_http.hrl").
|
||||
-include("ejabberd_web_admin.hrl").
|
||||
-include("web/ejabberd_http.hrl").
|
||||
-include("web/ejabberd_web_admin.hrl").
|
||||
|
||||
-record(offline_msg, {user, timestamp, expire, from, to, packet}).
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ LIBS = @LIBS@
|
|||
ERLANG_CFLAGS = @ERLANG_CFLAGS@
|
||||
ERLANG_LIBS = @ERLANG_LIBS@
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
|
|
|
@ -9,7 +9,7 @@ LIBS = @LIBS@
|
|||
ERLANG_CFLAGS = @ERLANG_CFLAGS@
|
||||
ERLANG_LIBS = @ERLANG_LIBS@
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
-include("mod_roster.hrl").
|
||||
-include("ejabberd_http.hrl").
|
||||
-include("ejabberd_web_admin.hrl").
|
||||
-include("web/ejabberd_http.hrl").
|
||||
-include("web/ejabberd_web_admin.hrl").
|
||||
|
||||
|
||||
start(Host, Opts) ->
|
||||
|
|
|
@ -46,8 +46,8 @@
|
|||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
-include("mod_roster.hrl").
|
||||
-include("ejabberd_http.hrl").
|
||||
-include("ejabberd_web_admin.hrl").
|
||||
-include("web/ejabberd_http.hrl").
|
||||
-include("web/ejabberd_web_admin.hrl").
|
||||
|
||||
|
||||
start(Host, Opts) ->
|
||||
|
|
|
@ -52,8 +52,8 @@
|
|||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
-include("mod_roster.hrl").
|
||||
-include("ejabberd_http.hrl").
|
||||
-include("ejabberd_web_admin.hrl").
|
||||
-include("web/ejabberd_http.hrl").
|
||||
-include("web/ejabberd_web_admin.hrl").
|
||||
|
||||
-record(sr_group, {group_host, opts}).
|
||||
-record(sr_user, {us, group_host}).
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("eldap.hrl").
|
||||
-include("eldap/eldap.hrl").
|
||||
-include("jlib.hrl").
|
||||
|
||||
-define(PROCNAME, ejabberd_mod_vcard_ldap).
|
||||
|
|
|
@ -9,7 +9,7 @@ LIBS = @LIBS@
|
|||
ERLANG_CFLAGS = @ERLANG_CFLAGS@
|
||||
ERLANG_LIBS = @ERLANG_LIBS@
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
|
|
|
@ -9,7 +9,7 @@ LIBS = @LIBS@ @PAM_LIBS@
|
|||
ERLANG_CFLAGS = @ERLANG_CFLAGS@
|
||||
ERLANG_LIBS = @ERLANG_LIBS@
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
|
|
|
@ -16,7 +16,9 @@ else
|
|||
DYNAMIC_LIB_CFLAGS = -fpic -shared
|
||||
endif
|
||||
|
||||
EFLAGS = -I .. -pz ..
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
ifdef debug
|
||||
EFLAGS+=+debug_info
|
||||
|
|
|
@ -19,7 +19,7 @@ else
|
|||
DYNAMIC_LIB_CFLAGS = -fpic -shared
|
||||
endif
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
|
|
|
@ -9,7 +9,8 @@ LIBS = @LIBS@
|
|||
ERLANG_CFLAGS = @ERLANG_CFLAGS@
|
||||
ERLANG_LIBS = @ERLANG_LIBS@
|
||||
|
||||
EFLAGS += -I ../../include
|
||||
EFLAGS += @ERLANG_SSL39@
|
||||
EFLAGS += -I ..
|
||||
EFLAGS += -pz ..
|
||||
|
||||
# make debug=true to compile Erlang module with debug informations.
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
-behaviour(gen_fsm).
|
||||
|
||||
%% External exports
|
||||
-export([start_link/2,
|
||||
-export([start_link/3,
|
||||
init/1,
|
||||
handle_event/3,
|
||||
handle_sync_event/4,
|
||||
|
@ -50,16 +50,14 @@
|
|||
|
||||
-record(http_poll, {id, pid}).
|
||||
|
||||
-define(NULL_PEER, {{0, 0, 0, 0}, 0}).
|
||||
|
||||
-record(state, {id,
|
||||
key,
|
||||
socket,
|
||||
output = "",
|
||||
input = "",
|
||||
waiting_input = false, %% {ReceiverPid, Tag}
|
||||
last_receiver,
|
||||
timer,
|
||||
ip = ?NULL_PEER }).
|
||||
timer}).
|
||||
|
||||
%-define(DBGFSM, true).
|
||||
|
||||
|
@ -77,19 +75,19 @@
|
|||
%%%----------------------------------------------------------------------
|
||||
%%% API
|
||||
%%%----------------------------------------------------------------------
|
||||
start(ID, Key) ->
|
||||
start(ID, Key, IP) ->
|
||||
mnesia:create_table(http_poll,
|
||||
[{ram_copies, [node()]},
|
||||
{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) ->
|
||||
gen_fsm:start_link(?MODULE, [ID, Key], ?FSMOPTS).
|
||||
start_link(ID, Key, IP) ->
|
||||
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}).
|
||||
|
||||
setopts({http_poll, FsmRef}, Opts) ->
|
||||
setopts({http_poll, FsmRef, _IP}, Opts) ->
|
||||
case lists:member({active, once}, Opts) of
|
||||
true ->
|
||||
gen_fsm:send_all_state_event(FsmRef, {activate, self()});
|
||||
|
@ -97,31 +95,27 @@ setopts({http_poll, FsmRef}, Opts) ->
|
|||
ok
|
||||
end.
|
||||
|
||||
sockname(_) ->
|
||||
{ok, ?NULL_PEER}.
|
||||
sockname(_Socket) ->
|
||||
{ok, {{0, 0, 0, 0}, 0}}.
|
||||
|
||||
peername({http_poll, FsmRef}) ->
|
||||
case catch gen_fsm:sync_send_all_state_event(FsmRef, peername, 1000) of
|
||||
{ok, IP} -> {ok, IP};
|
||||
_ -> {ok, ?NULL_PEER}
|
||||
end;
|
||||
peername(_) ->
|
||||
{ok, ?NULL_PEER}.
|
||||
peername({http_poll, _FsmRef, IP}) ->
|
||||
{ok, IP}.
|
||||
|
||||
controlling_process(_Socket, _Pid) ->
|
||||
ok.
|
||||
|
||||
close({http_poll, FsmRef}) ->
|
||||
close({http_poll, FsmRef, _IP}) ->
|
||||
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
|
||||
{ok, ID1, Key, NewKey, Packet} ->
|
||||
ID = if
|
||||
(ID1 == "0") or (ID1 == "mobile") ->
|
||||
NewID = sha:sha(term_to_binary({now(), make_ref()})),
|
||||
{ok, Pid} = start(NewID, ""),
|
||||
{ok, Pid} = start(NewID, "", IP),
|
||||
mnesia:transaction(
|
||||
fun() ->
|
||||
mnesia:write(#http_poll{id = NewID,
|
||||
|
@ -131,7 +125,7 @@ process([], #request{data = Data, ip = IP} = _Request) ->
|
|||
true ->
|
||||
ID1
|
||||
end,
|
||||
case http_put(ID, Key, NewKey, Packet, IP) of
|
||||
case http_put(ID, Key, NewKey, Packet) of
|
||||
{error, not_exists} ->
|
||||
{200, ?BAD_REQUEST, ""};
|
||||
{error, bad_key} ->
|
||||
|
@ -176,8 +170,8 @@ process(_, _Request) ->
|
|||
%% ignore |
|
||||
%% {stop, StopReason}
|
||||
%%----------------------------------------------------------------------
|
||||
init([ID, Key]) ->
|
||||
?INFO_MSG("started: ~p", [{ID, Key}]),
|
||||
init([ID, Key, IP]) ->
|
||||
?INFO_MSG("started: ~p", [{ID, Key, IP}]),
|
||||
|
||||
%% Read c2s options from the first ejabberd_c2s configuration in
|
||||
%% the config file listen section
|
||||
|
@ -187,12 +181,12 @@ init([ID, Key]) ->
|
|||
%% connector.
|
||||
Opts = ejabberd_c2s_config:get_c2s_limits(),
|
||||
|
||||
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),
|
||||
Socket = {http_poll, self(), IP},
|
||||
ejabberd_socket:start(ejabberd_c2s, ?MODULE, Socket, Opts),
|
||||
Timer = erlang:start_timer(?HTTP_POLL_TIMEOUT, self(), []),
|
||||
{ok, loop, #state{id = ID,
|
||||
key = Key,
|
||||
socket = Socket,
|
||||
timer = Timer}}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
|
@ -229,7 +223,7 @@ handle_event({activate, From}, StateName, StateData) ->
|
|||
StateData#state{waiting_input = {From, ok}}};
|
||||
Input ->
|
||||
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 = "",
|
||||
waiting_input = false,
|
||||
last_receiver = Receiver
|
||||
|
@ -257,7 +251,7 @@ handle_sync_event(stop, _From, _StateName, StateData) ->
|
|||
Reply = ok,
|
||||
{stop, normal, Reply, StateData};
|
||||
|
||||
handle_sync_event({http_put, Key, NewKey, Packet, IP},
|
||||
handle_sync_event({http_put, Key, NewKey, Packet},
|
||||
_From, StateName, StateData) ->
|
||||
Allow = case StateData#state.key of
|
||||
"" ->
|
||||
|
@ -279,10 +273,9 @@ handle_sync_event({http_put, Key, NewKey, Packet, IP},
|
|||
Input = [StateData#state.input|Packet],
|
||||
Reply = ok,
|
||||
{reply, Reply, StateName, StateData#state{input = Input,
|
||||
key = NewKey,
|
||||
ip = IP}};
|
||||
key = NewKey}};
|
||||
{Receiver, _Tag} ->
|
||||
Receiver ! {tcp, {http_poll, self()},
|
||||
Receiver ! {tcp, StateData#state.socket,
|
||||
list_to_binary(Packet)},
|
||||
cancel_timer(StateData#state.timer),
|
||||
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,
|
||||
last_receiver = Receiver,
|
||||
key = NewKey,
|
||||
timer = Timer,
|
||||
ip = IP}}
|
||||
timer = Timer}}
|
||||
end;
|
||||
true ->
|
||||
Reply = {error, bad_key},
|
||||
|
@ -303,10 +295,6 @@ handle_sync_event(http_get, _From, StateName, StateData) ->
|
|||
Reply = {ok, 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) ->
|
||||
Reply = ok,
|
||||
{reply, Reply, StateName, StateData}.
|
||||
|
@ -345,10 +333,10 @@ terminate(_Reason, _StateName, StateData) ->
|
|||
case StateData#state.last_receiver of
|
||||
undefined -> ok;
|
||||
Receiver ->
|
||||
Receiver ! {tcp_closed, {http_poll, self()}}
|
||||
Receiver ! {tcp_closed, StateData#state.socket}
|
||||
end;
|
||||
{Receiver, _Tag} ->
|
||||
Receiver ! {tcp_closed, {http_poll, self()}}
|
||||
Receiver ! {tcp_closed, StateData#state.socket}
|
||||
end,
|
||||
catch resend_messages(StateData#state.output),
|
||||
ok.
|
||||
|
@ -357,13 +345,13 @@ terminate(_Reason, _StateName, StateData) ->
|
|||
%%% Internal functions
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
http_put(ID, Key, NewKey, Packet, IP) ->
|
||||
http_put(ID, Key, NewKey, Packet) ->
|
||||
case mnesia:dirty_read({http_poll, ID}) of
|
||||
[] ->
|
||||
{error, not_exists};
|
||||
[#http_poll{pid = FsmRef}] ->
|
||||
gen_fsm:sync_send_all_state_event(
|
||||
FsmRef, {http_put, Key, NewKey, Packet, IP})
|
||||
FsmRef, {http_put, Key, NewKey, Packet})
|
||||
end.
|
||||
|
||||
http_get(ID) ->
|
||||
|
|
Loading…
Reference in New Issue