-- that, unlike require, doesn't cause them to "stick" in RAM.
--
-- Based on lua_examples/lfs/_init.lua
-local G=getfenv()
-local flashindex = node.flashindex
+local G=_ENV or getfenv()
+local flashindex = (node.LFS and node.LFS.get) or node.flashindex
local ovl_t = {
__index = function(_, name)
local f = loadfile(name..".lua")
if f then return f end
local f = loadfile(name..".lc")
if f then return f end
- if flashindex then
- local fn_ut, ba, ma, size, modules = flashindex(name)
- if not ba then return fn_ut end
- end
+ if flashindex then return flashindex(name) end
return nil
end,
__newindex = function(_, name, value)
G.OVL = setmetatable(ovl_t,ovl_t)
-- Install LFS as a package loader, as suggested by lua_examples/lfs/_init.lua
-if flashindex then
- table.insert(package.loaders,function(module)
- local fn, ba = flashindex(module)
- return ba and "Module not in LFS" or fn
- end)
-end
+if flashindex then table.insert(package.loaders,flashindex) end
-- Save some bytes, as suggested by lua_examples/lfs/_init.lua
-G.module = nil
package.seeall = nil
if rtctime then rtctime.set(0) end -- set time to 0 until someone corrects us
-- See if there's any early startup to do.
local ie = OVL["init-early"]
-if ie then ie() end
+if ie then pcall(ie) end
local gotmr = tmr.create()
got = gotmr
local cert = ""
local chunk = file.read()
while chunk ~= nil do cert = cert..chunk; chunk = file.read() end
- ok, res = pcall(net.cert.verify,cert)
+ ok, res = pcall(tls.cert.verify,cert)
file.close()
if ok then
print("Loaded cert from nwfnet.cert, which will now be removed.")
end
if conf["tls_verify"] == 1 then
- pcall(net.cert.verify,true)
+ pcall(tls.cert.verify,true)
end
else print("nwfnet.conf malformed")