openresty lua 文件处理的一些技巧

luajit 字节码加载

  • 功能
    代码j简单防护处理,以及一些优化,注意jit编译的字节码,明文很容易看到大致的处理,
  • 参考使用
 
./luajit -bg  /opt/lua/acc.lua /opt/lua/acc.ljbc // 可以按照实际添加g 参数,时候保留debug 信息

静态链接

对于的确需要隐藏处理的,可以在编译时带入
参考

 
./luajit -bg foo.lua foo.o

编译openresty 时

 ./configure --with-ld-opt="/path/to/foo.o" ...

使用

 local foo = require "foo"
 foo.go()

对于包含. 的处理,比如 resty.foo
文件需要命名为resty_foo.lua

说明

luajit 的字节码以及静态链接需要使用的luajit 版本与openresty 的一致,否则会有加载的问题

参考资料

https://github.com/openresty/lua-nginx-module#nginx-api-for-lua
https://luajit.org/running.html#opt_b

posted on 2022-05-01 18:26  荣锋亮  阅读(70)  评论(0编辑  收藏  举报

导航