+2004-08-23 Alexey Shchepin <alexey@sevcom.net>
+
+ * src/mod_offline.erl: Added entire table locking on large message
+ queue
+
+ * src/ejabberd_sm.erl: Added offline_subscription_hook
+ * src/mod_offline.erl: Use offline_subscription_hook
+
+ * src/configure.erl: Updated (thanks to Sergei Golovan)
+ * src/Makefile.win32: Likewise
+ * src/tls/Makefile.win32: Likewise
+ * src/win32/: Likewise
+
+ * src/mod_announce.erl: Added announce to all users (thanks to
+ Sergei Golovan)
+ * doc/guide.tex: Updated (thanks to Sergei Golovan)
+
2004-08-14 Alexey Shchepin <alexey@sevcom.net>
* src/msgs/nl.msg: Updated (thanks to Sander Devrieze)
<H3><A NAME="htoc32">A.2</A> <TT>mod_announce</TT></H3><!--SEC END -->
<A NAME="sec:modannounce"></A>
-This module adds support for broadcast announce messages and MOTD.<BR>
-<BR>
+This module adds support for broadcast announce messages and MOTD.
+When the module is loaded, it handles messages sent to the following JID's
+(suppose that main server has address <TT>example.org</TT>):
+<DL COMPACT=compact><DT>
+<B><TT>example.org/announce/all</TT></B><DD> Message is sent to all registered users.
+If the user is online and connected to several resources, only resource with
+the highest priority will receive the message. If the registered user is
+not connected, the message will be stored offline (if oflline storage is
+available).
+<DT><B><TT>example.org/announce/online</TT></B><DD> Message is sent to all connected users.
+If the user is online and connected to several resources, all resources
+will receive the message.
+<DT><B><TT>example.org/announce/motd</TT></B><DD> Message is set as MOTD (Message of the Day)
+and will be sent to users as they login. In addition the message is sent to
+all connected users (similar to <TT>announce/online</TT> resource).
+<DT><B><TT>example.org/announce/motd/update</TT></B><DD> Message is set as MOTD (Message of the Day)
+and will be sent to users as they login. The message is <EM>not sent</EM> to
+all connected users.
+<DT><B><TT>example.org/announce/motd/delete</TT></B><DD> Any message sent to this JID
+removes existing MOTD.
+</DL>
Options:
<DL COMPACT=compact><DT>
<B><TT>access</TT></B><DD> Specifies who is allowed to send announce messages
\label{sec:modannounce}
This module adds support for broadcast announce messages and MOTD.
+When the module is loaded, it handles messages sent to the following JID's
+(suppose that main server has address \jid{example.org}):
+\begin{description}
+\titem{example.org/announce/all} Message is sent to all registered users.
+If the user is online and connected to several resources, only resource with
+the highest priority will receive the message. If the registered user is
+not connected, the message will be stored offline (if oflline storage is
+available).
+\titem{example.org/announce/online} Message is sent to all connected users.
+If the user is online and connected to several resources, all resources
+will receive the message.
+\titem{example.org/announce/motd} Message is set as MOTD (Message of the Day)
+and will be sent to users as they login. In addition the message is sent to
+all connected users (similar to \term{announce/online} resource).
+\titem{example.org/announce/motd/update} Message is set as MOTD (Message of the Day)
+and will be sent to users as they login. The message is \emph{not sent} to
+all connected users.
+\titem{example.org/announce/motd/delete} Any message sent to this JID
+removes existing MOTD.
+\end{description}
Options:
\begin{description}
copy $(SYSTEMROOT)\system32\libeay32.dll $(EREL)
copy $(SYSTEMROOT)\system32\ssleay32.dll $(EREL)
copy win32\ejabberd.ico $(WIN32_DIR)
- mkdir $(WIN32_DIR)\5.3
- copy win32\5.3\*.beam $(WIN32_DIR)\5.3
mkdir $(SRC_DIR)
copy *.app $(SRC_DIR)
copy *.erl $(SRC_DIR)
copy stringprep\*.erl $(SRC_DIR)\stringprep
copy stringprep\*.c $(SRC_DIR)\stringprep
copy stringprep\*.tcl $(SRC_DIR)\stringprep
+ mkdir $(SRC_DIR)\tls
+ copy tls\*.erl $(SRC_DIR)\tls
mkdir $(SRC_DIR)\web
copy web\*.erl $(SRC_DIR)\web
- mkdir $(SRC_DIR)\win32
- mkdir $(SRC_DIR)\win32\5.3
- copy win32\5.3\*.erl $(SRC_DIR)\win32\5.3
mkdir $(DOC_DIR)
copy ..\doc\*.html $(DOC_DIR)
copy ..\doc\*.png $(DOC_DIR)
nmake -nologo -f Makefile.win32
cd ..\stringprep
nmake -nologo -f Makefile.win32
- cd ..\web
+ cd ..\tls
nmake -nologo -f Makefile.win32
- cd ..\win32\5.3
+ cd ..\web
nmake -nologo -f Makefile.win32
- cd ..\..
+ cd ..
compile-beam :
erl -s make all report -noinput -s erlang halt
nmake -nologo -f Makefile.win32 clean
cd ..\stringprep
nmake -nologo -f Makefile.win32 clean
- cd ..\web
+ cd ..\tls
nmake -nologo -f Makefile.win32 clean
- cd ..\win32\5.3
+ cd ..\web
nmake -nologo -f Makefile.win32 clean
- cd ..\..
+ cd ..
distclean : release_clean clean
-@erase $(NSIS_HEADER)
RootDirS = "ERLANG_DIR = " ++ code:root_dir() ++ "\n",
Version = "EJABBERD_VERSION = " ++ ?VERSION ++ "\n",
ExpatDir = "EXPAT_DIR = c:\\progra~1\\expat-1.95.7\n",
+ OpenSSLDir = "OPENSSL_DIR = c:\\progra~1\\OpenSSL\n",
SSLDir = "SSLDIR = " ++ code:lib_dir("ssl") ++ "\n",
StdLibDir = "STDLIBDIR = " ++ code:lib_dir("stdlib") ++ "\n",
Version ++
SSLDir ++
StdLibDir ++
+ OpenSSLDir ++
ExpatDir ++
ExpatLib ++
ExpatFlag ++
Subsc ->
case ejabberd_auth:is_user_exists(LUser) of
true ->
- catch mod_offline:store_packet(
- From, To, Packet);
+ ejabberd_hooks:run(
+ offline_subscription_hook,
+ [From, To, Packet]);
_ ->
Err = jlib:make_error_reply(
Packet, ?ERR_SERVICE_UNAVAILABLE),
loop() ->
receive
+ {announce_all, From, To, Packet} ->
+ announce_all(From, To, Packet),
+ loop();
{announce_online, From, To, Packet} ->
announce_online(From, To, Packet),
loop();
#jid{luser = "", lresource = Res} ->
{xmlelement, Name, _Attrs, _Els} = Packet,
case {Res, Name} of
+ {"announce/all", "message"} ->
+ ?PROCNAME ! {announce_all, From, To, Packet},
+ stop;
{"announce/online", "message"} ->
?PROCNAME ! {announce_online, From, To, Packet},
stop;
ok
end.
+announce_all(From, To, Packet) ->
+ Access = gen_mod:get_module_opt(?MODULE, access, none),
+ case acl:match_rule(Access, From) of
+ deny ->
+ Err = jlib:make_error_reply(Packet, ?ERR_NOT_ALLOWED),
+ ejabberd_router:route(To, From, Err);
+ allow ->
+ Server = ?MYNAME,
+ Local = jlib:make_jid("", Server, ""),
+ lists:foreach(
+ fun(U) ->
+ Dest = jlib:make_jid(U, Server, ""),
+ ejabberd_router:route(Local, Dest, Packet)
+ end, ejabberd_auth:dirty_get_registered_users())
+ end.
+
announce_online(From, To, Packet) ->
Access = gen_mod:get_module_opt(?MODULE, access, none),
case acl:match_rule(Access, From) of
-record(offline_msg, {user, timestamp, from, to, packet}).
-define(PROCNAME, ejabberd_offline).
+-define(OFFLINE_TABLE_LOCK_THRESHOLD, 1000).
start(_) ->
mnesia:create_table(offline_msg,
{attributes, record_info(fields, offline_msg)}]),
ejabberd_hooks:add(offline_message_hook,
?MODULE, store_packet, 50),
+ ejabberd_hooks:add(offline_subscription_hook,
+ ?MODULE, store_packet, 50),
ejabberd_hooks:add(resend_offline_messages_hook,
?MODULE, pop_offline_messages, 50),
register(?PROCNAME, spawn(?MODULE, init, [])).
receive
#offline_msg{} = Msg ->
Msgs = receive_all([Msg]),
+ Len = length(Msgs),
F = fun() ->
+ if
+ Len >= ?OFFLINE_TABLE_LOCK_THRESHOLD ->
+ mnesia:write_lock_table(offline_msg);
+ true ->
+ ok
+ end,
lists:foreach(fun(M) ->
mnesia:write(M)
end, Msgs)
[Settings]
-NumFields=1
+NumFields=2
[Field 1]
Type=label
Left=0
Right=-1
Top=10
-Bottom=-10
-Text="Erlang OTP R9C (version 5.3) is required to install Ejabberd.\r\n\r\nIt is not found on your computer.\r\n\r\nPlease install Erlang OTP R9C before installing Ejabberd.\r\n\r\nIt can be downloaded from http://www.erlang.org/download/otp_win32_R9C-0.exe."
+Bottom=70
+Text="Erlang OTP R9C-1 (version 5.3.6.2) or newer is required to install Ejabberd.\r\n\r\nIt is not found on your computer.\r\n\r\nPlease install Erlang OTP R9C-1 or newer before installing Ejabberd.\r\n\r\nIt can be downloaded from"
+
+[Field 2]
+Type=link
+Left=0
+Right=-1
+Top=74
+Bottom=88
+State=http://www.erlang.org/download.html
+Text=http://www.erlang.org/download.html
--- /dev/null
+[Settings]
+NumFields=3
+
+[Field 1]
+Type=label
+Left=0
+Right=-1
+Top=10
+Bottom=70
+Text="OpenSLL 0.9.7c or newer is not found on your computer.\r\n\r\nEjabberd includes required SSL libraries but if you don't have SSL certificate then without installed OpenSSL you will not be able to create your own SSL certificate and use SSL-enabled connections.\r\n\r\nOpenSLL can be downloaded from"
+
+[Field 2]
+Type=link
+Left=0
+Right=-1
+Top=74
+Bottom=88
+State=http://www.slproweb.com/products/Win32OpenSSL.html
+Text=http://www.slproweb.com/products/Win32OpenSSL.html
+
+[Field 3]
+Type=label
+Left=0
+Right=-1
+Top=93
+Bottom=-10
+Text="If you want to continue installation anyway, click Next."
+
--- /dev/null
+[Settings]
+NumFields=3
+
+[Field 1]
+Type=label
+Left=0
+Right=-1
+Top=10
+Bottom=70
+Text="OpenSLL 0.9.7c or newer is not found on your computer.\r\n\r\nEjabberd includes required SSL libraries but if you don't have SSL certificate then without installed OpenSSL you will not be able to create your own SSL certificate and use SSL-enabled connections.\r\n\r\nOpenSLL can be downloaded from"
+
+[Field 2]
+Type=link
+Left=0
+Right=-1
+Top=74
+Bottom=88
+State=http://www.slproweb.com/products/Win32OpenSSL.html
+Text=http://www.slproweb.com/products/Win32OpenSSL.html
+
+[Field 3]
+Type=checkbox
+Left=0
+Right=-1
+Top=93
+Bottom=105
+Text="Proceed with install"
+State=0
+Flags=NOTIFY
Left=0
Right=-1
Top=50
-Bottom=-10
+Bottom=62
Text="Proceed with install"
State=0
Flags=NOTIFY
% Host name:
{host, "localhost"}.
+% Default language:
+{language, "en"}.
% Listened ports:
{listen,
- [{5222, ejabberd_c2s, [{access, c2s}, {shaper, c2s_shaper}]},
-% {5223, ejabberd_c2s, [{access, c2s}, ssl, {certfile, "./ssl.pem"}]},
+ [
+ {5222, ejabberd_c2s, [{access, c2s},
+ {shaper, c2s_shaper}]},
+
+% To create selfsigned certificate run the following command form the
+% command prompt:
+%
+% openssl req -new -x509 -days 365 -nodes -out ejabberd.pem -keyout ejabberd.pem
+%
+% and answer the questions.
+% {5222, ejabberd_c2s, [{access, c2s},
+% starttls, {certfile, "./ejabberd.pem"}
+% {shaper, c2s_shaper}]},
+
+% When using SSL/TLS ssl option is not recommended (it requires patching
+% erlang ssl application). Use tls option instead (as shown below).
+% {5223, ejabberd_c2s, [{access, c2s},
+% tls, {certfile, "./ejabberd.pem"}]},
+
{5269, ejabberd_s2s_in, [{shaper, s2s_shaper}]},
+
% {5555, ejabberd_service, [{access, all},
% {host, "icq.localhost", [{password, "secret"}]}]},
+
{5280, ejabberd_http, [http_poll, web_admin]}
]}.
{mod_stats, []},
{mod_vcard, []},
{mod_offline, []},
+ {mod_announce, [{access, announce}]},
{mod_private, []},
{mod_irc, []},
{mod_muc, []},
!ifdef HACKED_INSTALLOPTIONS
ReserveFile "CheckUserH.ini"
+ ReserveFile "CheckReqs1H.ini"
!else
ReserveFile "CheckUser.ini"
+ ReserveFile "CheckReqs1.ini"
!endif
ReserveFile "CheckReqs.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
Var ERLANG_PATH
Var ERLANG_VERSION
Var REQUIRED_ERLANG_VERSION
+ Var OPENSSL_PATH
+ Var OPENSSL_VERSION
+ Var REQUIRED_OPENSSL_VERSION
Var ERLSRV
;----------------------------------------------------------
Function .onInit
- StrCpy $REQUIRED_ERLANG_VERSION "5.3"
+ StrCpy $REQUIRED_ERLANG_VERSION "5.3.6.2"
+ StrCpy $REQUIRED_OPENSSL_VERSION "0.9.7c"
;Default installation folder
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT}"
;Extract InstallOptions INI files
!ifdef HACKED_INSTALLOPTIONS
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "CheckUserH.ini"
+ !insertmacro MUI_INSTALLOPTIONS_EXTRACT "CheckReqs1H.ini"
!else
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "CheckUser.ini"
+ !insertmacro MUI_INSTALLOPTIONS_EXTRACT "CheckReqs1.ini"
!endif
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "CheckReqs.ini"
Page custom CheckUser LeaveCheckUser
!insertmacro MUI_PAGE_LICENSE "..\..\COPYING"
Page custom CheckReqs LeaveCheckReqs
+ Page custom CheckReqs1 LeaveCheckReqs1
;!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
File /r "${TESTDIR}\win32"
File "${TESTDIR}\libeay32.dll"
File "${TESTDIR}\ssleay32.dll"
+ File /oname=ejabberd.cfg.example "${TESTDIR}\ejabberd.cfg"
SetOverwrite off
File "${TESTDIR}\ejabberd.cfg"
SetOverwrite on
StrCpy $0 "$SMPROGRAMS\$STARTMENU_FOLDER"
CreateDirectory "$0"
CreateShortCut "$0\Start Ejabberd.lnk" "$ERLANG_PATH\bin\werl.exe" \
- '-sname ejabberd -pa ebin -pa win32/$ERLANG_VERSION \
+ '-sname ejabberd -pa ebin \
-env EJABBERD_SO_PATH priv/lib -env EJABBERD_MSGS_PATH msgs \
-env EJABBERD_LOG_PATH log/ejabberd.log \
- -s ejabberd -ejabberd config \"ejabberd.cfg\" -mnesia dir \"spool\"' \
+ -s ejabberd -ejabberd config \"ejabberd.cfg\" -mnesia dir \"spool\" \
+ -sasl sasl_error_logger {file,\"log/sasl.log\"}' \
$INSTDIR\win32\ejabberd.ico
CreateShortCut "$0\Edit Config.lnk" "%SystemRoot%\system32\notepad.exe" \
"$INSTDIR\ejabberd.cfg"
installsrv:
nsExec::ExecToLog '"$ERLSRV" add ejabberd -stopaction "init:stop()." \
-onfail reboot -workdir "$INSTDIR" \
- -args "-s ejabberd -pa ebin -pa win32/$ERLANG_VERSION \
+ -args "-s ejabberd -pa ebin \
-ejabberd config \\\"ejabberd.cfg\\\" \
-env EJABBERD_SO_PATH priv/lib -env EJABBERD_MSGS_PATH msgs \
-env EJABBERD_LOG_PATH log/ejabberd.log \
FunctionEnd
+Function CheckReqs1
+
+ Push "HKLM"
+ Call FindOpenSSL
+ Pop $OPENSSL_PATH
+ Pop $OPENSSL_VERSION
+ StrCmp $OPENSSL_PATH "" 0 abort
+ Push "HKCU"
+ Call FindOpenSSL
+ Pop $OPENSSL_PATH
+ Pop $OPENSSL_VERSION
+ StrCmp $OPENSSL_PATH "" 0 abort
+
+ !insertmacro MUI_HEADER_TEXT $(TEXT_CR_TITLE) $(TEXT_CR_SUBTITLE)
+
+ !ifdef HACKED_INSTALLOPTIONS
+ !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "CheckReqs1H.ini"
+ !insertmacro MUI_INSTALLOPTIONS_READ $0 "CheckReqs1H.ini" "Field 3" "State"
+ GetDlgItem $1 $HWNDPARENT 1
+ EnableWindow $1 $0
+ !else
+ !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "CheckReqs1.ini"
+ !endif
+
+ !insertmacro MUI_INSTALLOPTIONS_SHOW
+
+ abort:
+ Abort
+
+FunctionEnd
+
+Function LeaveCheckReqs1
+
+ !ifdef HACKED_INSTALLOPTIONS
+ !insertmacro MUI_INSTALLOPTIONS_READ $0 "CheckReqs1H.ini" "Settings" "State"
+ StrCmp $0 0 validate ;Next button?
+ StrCmp $0 3 checkbox ;checkbox?
+ Abort ;Return to the page
+
+ checkbox:
+ !insertmacro MUI_INSTALLOPTIONS_READ $0 "CheckReqs1H.ini" "Field 3" "State"
+ GetDlgItem $1 $HWNDPARENT 1
+ EnableWindow $1 $0
+ Abort
+
+ validate:
+ !endif
+
+FunctionEnd
+
Function FindErlang
Exch $R0
FunctionEnd
+Function FindOpenSSL
+
+ Exch $R0
+ Push $R1
+ Push $R2
+ Push $R3
+ Push $R4
+ Push $R5
+
+ StrCpy $R1 0
+ StrCpy $R2 "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenSSL_is1"
+
+ StrCmp $R0 HKLM h1
+ ReadRegStr $R3 HKCU "$R2" "DisplayName"
+ ReadRegStr $R4 HKCU "$R2" "Inno Setup: App Path"
+ Goto l1
+ h1:
+ ReadRegStr $R3 HKLM "$R2" "DisplayName"
+ ReadRegStr $R4 HKLM "$R2" "Inno Setup: App Path"
+ l1:
+
+ IfFileExists "$R4\bin\openssl.exe" 0 notfound
+ Goto get
+ ; TODO check version
+ ;Push $REQUIRED_OPENSSL_VERSION
+ ;Push $R3
+ ;Call CompareVersions
+ ;Pop $R5
+ ;StrCmp $R5 1 get
+
+ notfound:
+ StrCpy $R4 ""
+
+ get:
+ StrCpy $R0 $R4
+ StrCpy $R1 $R3
+
+ Pop $R5
+ Pop $R4
+ Pop $R3
+ Pop $R2
+ Exch $R1
+ Exch
+ Exch $R0
+
+FunctionEnd
+
;----------------------------------------------------------------------
; CompareVersions
; input: