From 07b1210b50771e10fec1500a5cc1830d26de052f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Thu, 17 Jul 2008 15:33:50 +0000 Subject: [PATCH] Merge revisions from 1444 to revision 1457 from trunk. SVN Revision: 1458 --- ChangeLog | 39 ++++++++++ doc/guide.html | 23 +++--- doc/guide.tex | 23 +++--- src/Makefile.in | 11 ++- {include => src}/adhoc.hrl | 0 {include => src}/ejabberd.hrl | 0 src/ejabberd_auth_ldap.erl | 2 +- src/ejabberd_c2s.erl | 9 ++- {include => src}/ejabberd_config.hrl | 0 {include => src}/ejabberd_ctl.hrl | 0 src/ejabberd_receiver.erl | 6 +- src/ejabberd_sm.erl | 15 +--- src/ejabberd_zlib/Makefile.in | 3 +- src/ejabberdctl.template | 45 ++++++------ src/eldap/Makefile.in | 3 +- {include => src/eldap}/eldap.hrl | 0 {include => src}/jlib.hrl | 0 src/mod_irc/Makefile.in | 2 +- src/mod_muc/Makefile.in | 2 +- src/mod_offline.erl | 4 +- src/mod_offline_odbc.erl | 4 +- {include => src}/mod_privacy.hrl | 0 src/mod_proxy65/Makefile.in | 2 +- {include => src/mod_proxy65}/mod_proxy65.hrl | 0 src/mod_pubsub/Makefile.in | 2 +- {include => src/mod_pubsub}/pubsub.hrl | 0 src/mod_roster.erl | 4 +- {include => src}/mod_roster.hrl | 0 src/mod_roster_odbc.erl | 4 +- src/mod_shared_roster.erl | 4 +- src/mod_vcard_ldap.erl | 2 +- src/odbc/Makefile.in | 2 +- src/pam/Makefile.in | 2 +- src/stringprep/Makefile.in | 4 +- src/tls/Makefile.in | 2 +- src/web/Makefile.in | 3 +- {include => src/web}/ejabberd_http.hrl | 0 src/web/ejabberd_http_poll.erl | 76 +++++++++----------- {include => src/web}/ejabberd_web_admin.hrl | 0 39 files changed, 166 insertions(+), 132 deletions(-) rename {include => src}/adhoc.hrl (100%) rename {include => src}/ejabberd.hrl (100%) rename {include => src}/ejabberd_config.hrl (100%) rename {include => src}/ejabberd_ctl.hrl (100%) rename {include => src/eldap}/eldap.hrl (100%) rename {include => src}/jlib.hrl (100%) rename {include => src}/mod_privacy.hrl (100%) rename {include => src/mod_proxy65}/mod_proxy65.hrl (100%) rename {include => src/mod_pubsub}/pubsub.hrl (100%) rename {include => src}/mod_roster.hrl (100%) rename {include => src/web}/ejabberd_http.hrl (100%) rename {include => src/web}/ejabberd_web_admin.hrl (100%) diff --git a/ChangeLog b/ChangeLog index 8fe09d32c..07524ef9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,48 @@ +2008-07-17 Jean-Sébastien Pédron + + Merge revisions from 1444 to revision 1457 from trunk. + 2008-07-17 Jean-Sébastien Pédron * 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 + + * src/web/Makefile.in: use -DSSL39 if compiling with R12 + +2008-07-16 Badlop + + * 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 + + * 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 + + * 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 Merge revisions from 1434 to revision 1444 from trunk. diff --git a/doc/guide.html b/doc/guide.html index 735fc1f8c..02ea12132 100644 --- a/doc/guide.html +++ b/doc/guide.html @@ -637,9 +637,14 @@ This option can be used with ejabberd_service only. It is used to disable control on the from field on packets send by an external components. The option can be either true or false. The default value is true which conforms to XEP-0114. -
{hosts, [Hostnames], [HostOptions]}
This option -defines one or more hostnames of connected services and enables you to -specify additional options including {password, Secret}. +
{hosts, [Hostnames], [HostOptions]}
+This option of ejabberd_service allows to define one or more hostnames +of external Jabber components that provide a service. +In HostOptions it is possible to define the password required to those components +when attempt to connect to ejabberd: {password, Secret}. +Note that you cannot define in a single ejabberd_service components of +different services: add an ejabberd_service for each service, +as seen in an example below.
http_bind
This option enables HTTP Binding (XEP-0124 and XEP-0206) support. HTTP Bind enables access via HTTP requests to ejabberd from behind firewalls which @@ -818,19 +823,19 @@ connected to port 5237 with password ‘ggsecret’. 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}]} ] diff --git a/doc/guide.tex b/doc/guide.tex index 3831ac024..17cfbeb80 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -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}]} ] diff --git a/src/Makefile.in b/src/Makefile.in index 3d398f569..5dabf5431 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -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) diff --git a/include/adhoc.hrl b/src/adhoc.hrl similarity index 100% rename from include/adhoc.hrl rename to src/adhoc.hrl diff --git a/include/ejabberd.hrl b/src/ejabberd.hrl similarity index 100% rename from include/ejabberd.hrl rename to src/ejabberd.hrl diff --git a/src/ejabberd_auth_ldap.erl b/src/ejabberd_auth_ldap.erl index b9bf3b477..d576a82fd 100644 --- a/src/ejabberd_auth_ldap.erl +++ b/src/ejabberd_auth_ldap.erl @@ -58,7 +58,7 @@ ]). -include("ejabberd.hrl"). --include("eldap.hrl"). +-include("eldap/eldap.hrl"). -record(state, {host, eldap_id, diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 8c35273a7..da1239064 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -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, diff --git a/include/ejabberd_config.hrl b/src/ejabberd_config.hrl similarity index 100% rename from include/ejabberd_config.hrl rename to src/ejabberd_config.hrl diff --git a/include/ejabberd_ctl.hrl b/src/ejabberd_ctl.hrl similarity index 100% rename from include/ejabberd_ctl.hrl rename to src/ejabberd_ctl.hrl diff --git a/src/ejabberd_receiver.erl b/src/ejabberd_receiver.erl index 3b6c80439..5fdad76af 100644 --- a/src/ejabberd_receiver.erl +++ b/src/ejabberd_receiver.erl @@ -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. diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index ccf679386..9300958d5 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -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. diff --git a/src/ejabberd_zlib/Makefile.in b/src/ejabberd_zlib/Makefile.in index 3a70186bd..dd781d0ae 100644 --- a/src/ejabberd_zlib/Makefile.in +++ b/src/ejabberd_zlib/Makefile.in @@ -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 diff --git a/src/ejabberdctl.template b/src/ejabberdctl.template index fcf0a80cc..02ebd56b5 100644 --- a/src/ejabberdctl.template +++ b/src/ejabberdctl.template @@ -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 "";; diff --git a/src/eldap/Makefile.in b/src/eldap/Makefile.in index 4c9c33c22..22cdad48b 100644 --- a/src/eldap/Makefile.in +++ b/src/eldap/Makefile.in @@ -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 diff --git a/include/eldap.hrl b/src/eldap/eldap.hrl similarity index 100% rename from include/eldap.hrl rename to src/eldap/eldap.hrl diff --git a/include/jlib.hrl b/src/jlib.hrl similarity index 100% rename from include/jlib.hrl rename to src/jlib.hrl diff --git a/src/mod_irc/Makefile.in b/src/mod_irc/Makefile.in index 86212e45c..76a2d57f6 100644 --- a/src/mod_irc/Makefile.in +++ b/src/mod_irc/Makefile.in @@ -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. diff --git a/src/mod_muc/Makefile.in b/src/mod_muc/Makefile.in index 80725d33d..5ede5e521 100644 --- a/src/mod_muc/Makefile.in +++ b/src/mod_muc/Makefile.in @@ -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. diff --git a/src/mod_offline.erl b/src/mod_offline.erl index 3db29844b..3a751c328 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -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}). diff --git a/src/mod_offline_odbc.erl b/src/mod_offline_odbc.erl index 79d7c51ae..c3d0513d0 100644 --- a/src/mod_offline_odbc.erl +++ b/src/mod_offline_odbc.erl @@ -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}). diff --git a/include/mod_privacy.hrl b/src/mod_privacy.hrl similarity index 100% rename from include/mod_privacy.hrl rename to src/mod_privacy.hrl diff --git a/src/mod_proxy65/Makefile.in b/src/mod_proxy65/Makefile.in index 62ae77c9f..3fc94c662 100644 --- a/src/mod_proxy65/Makefile.in +++ b/src/mod_proxy65/Makefile.in @@ -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. diff --git a/include/mod_proxy65.hrl b/src/mod_proxy65/mod_proxy65.hrl similarity index 100% rename from include/mod_proxy65.hrl rename to src/mod_proxy65/mod_proxy65.hrl diff --git a/src/mod_pubsub/Makefile.in b/src/mod_pubsub/Makefile.in index 25dbf57a5..4088303cb 100644 --- a/src/mod_pubsub/Makefile.in +++ b/src/mod_pubsub/Makefile.in @@ -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. diff --git a/include/pubsub.hrl b/src/mod_pubsub/pubsub.hrl similarity index 100% rename from include/pubsub.hrl rename to src/mod_pubsub/pubsub.hrl diff --git a/src/mod_roster.erl b/src/mod_roster.erl index c1569bb61..038de586a 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -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) -> diff --git a/include/mod_roster.hrl b/src/mod_roster.hrl similarity index 100% rename from include/mod_roster.hrl rename to src/mod_roster.hrl diff --git a/src/mod_roster_odbc.erl b/src/mod_roster_odbc.erl index dfb76dcbe..d38121560 100644 --- a/src/mod_roster_odbc.erl +++ b/src/mod_roster_odbc.erl @@ -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) -> diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl index f363bd22e..ff378010d 100644 --- a/src/mod_shared_roster.erl +++ b/src/mod_shared_roster.erl @@ -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}). diff --git a/src/mod_vcard_ldap.erl b/src/mod_vcard_ldap.erl index 2225f7c86..2b5e7faac 100644 --- a/src/mod_vcard_ldap.erl +++ b/src/mod_vcard_ldap.erl @@ -50,7 +50,7 @@ ]). -include("ejabberd.hrl"). --include("eldap.hrl"). +-include("eldap/eldap.hrl"). -include("jlib.hrl"). -define(PROCNAME, ejabberd_mod_vcard_ldap). diff --git a/src/odbc/Makefile.in b/src/odbc/Makefile.in index 5bd130b6e..3f4898d3a 100644 --- a/src/odbc/Makefile.in +++ b/src/odbc/Makefile.in @@ -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. diff --git a/src/pam/Makefile.in b/src/pam/Makefile.in index 57c1ab78a..bde289402 100644 --- a/src/pam/Makefile.in +++ b/src/pam/Makefile.in @@ -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. diff --git a/src/stringprep/Makefile.in b/src/stringprep/Makefile.in index 248aee693..3ac6c24db 100644 --- a/src/stringprep/Makefile.in +++ b/src/stringprep/Makefile.in @@ -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 diff --git a/src/tls/Makefile.in b/src/tls/Makefile.in index db4a874e1..b6f10efc2 100644 --- a/src/tls/Makefile.in +++ b/src/tls/Makefile.in @@ -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. diff --git a/src/web/Makefile.in b/src/web/Makefile.in index 3a75f7e17..21f7c9348 100644 --- a/src/web/Makefile.in +++ b/src/web/Makefile.in @@ -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. diff --git a/include/ejabberd_http.hrl b/src/web/ejabberd_http.hrl similarity index 100% rename from include/ejabberd_http.hrl rename to src/web/ejabberd_http.hrl diff --git a/src/web/ejabberd_http_poll.erl b/src/web/ejabberd_http_poll.erl index ad6c46b77..2b36136cd 100644 --- a/src/web/ejabberd_http_poll.erl +++ b/src/web/ejabberd_http_poll.erl @@ -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) -> diff --git a/include/ejabberd_web_admin.hrl b/src/web/ejabberd_web_admin.hrl similarity index 100% rename from include/ejabberd_web_admin.hrl rename to src/web/ejabberd_web_admin.hrl