This repository was archived by the owner on Jul 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinit.lua
More file actions
101 lines (89 loc) · 3.13 KB
/
Copy pathinit.lua
File metadata and controls
101 lines (89 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
local ie = minetest.request_insecure_environment()
if ie == nil and (debug.getupvalue == nil and debug.getlocal == nil) then
minetest.log(
"warning",
[[
====Hello, this message is for server owners====
Libox needs to be a trusted mod for weighing of coroutine sandboxes to work properly.
If it isn't, coroutine sandboxes could fill up your server's memory with local variables and upvalues.
Libox can re-use debug.getlocal and debug.getupvalue if it is already avaliable in the environment
When adding libox to secure.trusted_mods, be aware that it will expose debug.getlocal and debug.getupvalue
================================================
]]
)
elseif debug.getlocal == nil or debug.getupvalue == nil and ie ~= nil then
-- luacheck:ignore
debug.getlocal = ie.debug.getlocal
debug.getupvalue = ie.debug.getupvalue
end
if ie and jit then
local MP = core.get_modpath("libox")
local lib
if jit.os == "Windows" then
lib = MP .. "/autohook/libautohook.dll"
else -- Linux/Unix-like
lib = MP .. "/autohook/libautohook.so"
end
-- Use package.loadlib() instad of require() to prevent using
-- system/other apps' libraries with the same name
local load_func = ie.package.loadlib(lib, "luaopen_autohook")
if load_func then
local errmsg
libox_autohook_module, errmsg = load_func()
while true do
if not libox_autohook_module or errmsg then
core.log(
"error",
("[libox] Autohook feature NOT available. Failed loading autohook C module %s:\n%s"):format(
lib,
errmsg
)
)
libox_autohook_module = nil
break
end
local version_file = io.open(MP .. "/autohook/module-version.txt")
local module_version = libox_autohook_module.version
if not version_file or not module_version then
core.log("error", "[libox] Autohook feature NOT available, could not verify its C module compatibility")
libox_autohook_module = nil
break
end
local current_version = version_file:read("*l")
version_file:close()
local module_version, jit_version = module_version()
if current_version ~= module_version then
core.log(
"error",
"[libox] Autohook feature NOT available, its C module version is incompatible\n"
.. ("current: %s | available: %s"):format(current_version, module_version)
)
libox_autohook_module = nil
break
end
if jit_version ~= jit.version then
core.log(
"error",
"[libox] Autohook feature NOT available, its compiled against a different LuaJIT version than Luanti\n"
.. ("Luanti: %s | autohook: %s"):format(jit.version, jit_version)
)
libox_autohook_module = nil
end
core.log("info", "[libox] Autohook feature available")
break
end
end
else
core.log("info", "[libox] Autohook feature NOT available")
end
local MP = minetest.get_modpath(minetest.get_current_modname())
dofile(MP .. "/main.lua")
-- Files that are executed sync only, coroutine.lua and *.test.lua
dofile(MP .. "/coroutine.lua")
libox_autohook_module = nil
-- async files
minetest.register_async_dofile(MP .. "/main.lua")
local test = MP .. "/test"
dofile(test .. "/basic_testing.lua")
dofile(test .. "/coroutine.test.lua")
dofile(test .. "/normal.test.lua")