]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_core/commitdiff
Adapt to Lua 5.3 and API removals master
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 24 Oct 2020 18:50:17 +0000 (19:50 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 24 Oct 2020 18:50:17 +0000 (19:50 +0100)
init.lua
net/nwfnet-go.lua

index 386ea62a50d5ce48ce448859a21ff46512d140be..654b68bd1ee6e19c296552813c2c0407ae72c5d2 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -4,18 +4,15 @@
 -- 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)
@@ -25,22 +22,16 @@ local ovl_t = {
 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
index b2f87b23f91c3a04e47ca5013bb895dac2dfb888..3a1bdd3c8715f44afebae0d7601d9ca100b0cea8 100644 (file)
@@ -14,7 +14,7 @@ if file.open("nwfnet.cert","r") then
   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.")
@@ -55,7 +55,7 @@ if file.open("nwfnet.conf","r") then
     end
 
     if conf["tls_verify"] == 1 then
-      pcall(net.cert.verify,true)
+      pcall(tls.cert.verify,true)
     end
 
    else print("nwfnet.conf malformed")