2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
9 local function softreq(...) local ok
, lib
= pcall(require
, ...); if ok
then return lib
; else return nil, lib
; end end
11 -- Required to be able to find packages installed with luarocks
12 if not softreq
"luarocks.loader" then -- LuaRocks 2.x
13 softreq
"luarocks.require"; -- LuaRocks <1.x
16 local function missingdep(name
, sources
, msg
)
18 print("**************************");
19 print("Prosody was unable to find "..tostring(name
));
20 print("This package can be obtained in the following ways:");
22 local longest_platform
= 0;
23 for platform
in pairs(sources
) do
24 longest_platform
= math
.max(longest_platform
, #platform
);
26 for platform
, source
in pairs(sources
) do
27 print("", platform
..":"..(" "):rep(4+longest_platform
-#platform
)..source
);
30 print(msg
or (name
.." is required for Prosody to run, so we will now exit."));
31 print("More help can be found on our website, at https://prosody.im/doc/depends");
32 print("**************************");
36 local function check_dependencies()
37 if _VERSION
< "Lua 5.1" then
38 print "***********************************"
39 print("Unsupported Lua version: ".._VERSION
);
40 print("At least Lua 5.1 is required.");
41 print "***********************************"
47 local lxp
= softreq
"lxp"
50 missingdep("luaexpat", {
51 ["Debian/Ubuntu"] = "sudo apt-get install lua-expat";
52 ["luarocks"] = "luarocks install luaexpat";
53 ["Source"] = "http://matthewwild.co.uk/projects/luaexpat/";
58 local socket
= softreq
"socket"
61 missingdep("luasocket", {
62 ["Debian/Ubuntu"] = "sudo apt-get install lua-socket";
63 ["luarocks"] = "luarocks install luasocket";
64 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/";
67 elseif not socket
.tcp4
then
68 -- COMPAT LuaSocket before being IP-version agnostic
69 socket
.tcp4
= socket
.tcp
;
70 socket
.udp4
= socket
.udp
;
73 local lfs
, err
= softreq
"lfs"
75 missingdep("luafilesystem", {
76 ["luarocks"] = "luarocks install luafilesystem";
77 ["Debian/Ubuntu"] = "sudo apt-get install lua-filesystem";
78 ["Source"] = "http://www.keplerproject.org/luafilesystem/";
83 local ssl
= softreq
"ssl"
86 missingdep("LuaSec", {
87 ["Debian/Ubuntu"] = "sudo apt-get install lua-sec";
88 ["luarocks"] = "luarocks install luasec";
89 ["Source"] = "https://github.com/brunoos/luasec";
90 }, "SSL/TLS support will not be available");
93 local bit
= _G
.bit32
or softreq
"bit";
96 missingdep("lua-bitops", {
97 ["Debian/Ubuntu"] = "sudo apt-get install lua-bitop";
98 ["luarocks"] = "luarocks install luabitop";
99 ["Source"] = "http://bitop.luajit.org/";
100 }, "WebSocket support will not be available");
103 local encodings
, err
= softreq
"util.encodings"
104 if not encodings
then
105 if err
:match("module '[^']*' not found") then
106 missingdep("util.encodings", {
107 ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/";
108 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so";
111 print "***********************************"
112 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn");
114 print("The full error was:");
116 print "***********************************"
121 local hashes
, err
= softreq
"util.hashes"
123 if err
:match("module '[^']*' not found") then
124 missingdep("util.hashes", {
125 ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/";
126 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so";
129 print "***********************************"
130 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)");
132 print("The full error was:");
134 print "***********************************"
142 local function log_warnings()
143 if _VERSION
> "Lua 5.2" then
144 prosody
.log("warn", "Support for %s is experimental, please report any issues", _VERSION
);
146 local ssl
= softreq
"ssl";
148 local major
, minor
, veryminor
, patched
= ssl
._VERSION
:match("(%d+)%.(%d+)%.?(%d*)(M?)");
149 if not major
or ((tonumber(major
) == 0 and (tonumber(minor
) or 0) <= 3 and (tonumber(veryminor
) or 0) <= 2) and patched
~= "M") then
150 prosody
.log("error", "This version of LuaSec contains a known bug that causes disconnects, see https://prosody.im/doc/depends");
153 local lxp
= softreq
"lxp";
155 if not pcall(lxp
.new
, { StartDoctypeDecl
= false }) then
156 prosody
.log("error", "The version of LuaExpat on your system leaves Prosody "
157 .."vulnerable to denial-of-service attacks. You should upgrade to "
158 .."LuaExpat 1.3.0 or higher as soon as possible. See "
159 .."https://prosody.im/doc/depends#luaexpat for more information.");
161 if not lxp
.new({}).getcurrentbytecount
then
162 prosody
.log("error", "The version of LuaExpat on your system does not support "
163 .."stanza size limits, which may leave servers on untrusted "
164 .."networks (e.g. the internet) vulnerable to denial-of-service "
165 .."attacks. You should upgrade to LuaExpat 1.3.0 or higher as "
166 .."soon as possible. See "
167 .."https://prosody.im/doc/depends#luaexpat for more information.");
174 missingdep
= missingdep
;
175 check_dependencies
= check_dependencies
;
176 log_warnings
= log_warnings
;