Nginx Lua条目线程中止:运行时错误:表溢出
我是Lua和Nginx的新手。我有一个Lua文件,它对任何命中NGINX的请求进行身份验证Nginx Lua条目线程中止:运行时错误:表溢出,nginx,lua,openresty,Nginx,Lua,Openresty,我是Lua和Nginx的新手。我有一个Lua文件,它对任何命中NGINX的请求进行身份验证 local ffi = require("ffi") local cjson = require("cjson") local iam = ffi.load("/gateway/auth/main/libiam.so") ffi.cdef([[ typedef long long GoInt64; typedef GoInt64 GoI
local ffi = require("ffi")
local cjson = require("cjson")
local iam = ffi.load("/gateway/auth/main/libiam.so")
ffi.cdef([[
typedef long long GoInt64;
typedef GoInt64 GoInt;
typedef struct { const char *p; GoInt n; } GoString;
extern GoInt VerifyToken(GoString p0);
extern GoInt64 VerifyApiKey(GoString p0);
]]);
local accessToken = ""
local apiKey = ""
local result = 0
local typeString = ffi.typeof("GoString")
local unauthorizedJson={}
if ngx.var.http_Authorization and string.len(ngx.var.http_Authorization) > 0 then
if ngx.var.http_Authorization:sub(1, #"Bearer") == "Bearer" then
ngx.log(ngx.STDERR, 'Verifying bearer token.')
accessToken = string.sub(ngx.var.http_Authorization,8)
local accessTokenString= typeString(accessToken, string.len(accessToken))
result = iam.VerifyToken(accessTokenString)
else
apiKey = ngx.var.http_Authorization
local apiKeyString= typeString(apiKey, string.len(apiKey))
result = iam.VerifyApiKey(apiKeyString)
end
if tonumber(result)~=0 then
-- we are ok here and proceed to route to upstream
if string.len(apiKey) > 0 then
ngx.req.set_header("abc", result)
end
else
return ngx.exit(ngx.HTTP_UNAUTHORIZED)
end
else
return ngx.exit(ngx.HTTP_UNAUTHORIZED)
end
我间歇性地看到以下错误
Lua entry thread aborted: runtime error: table overflow
在这条线上
ffi.cdef([[
我正在使用openresty。有谁能告诉我这里有什么问题吗?我可以纠正。ffi[[和ffi([]都可以接受这并不能回答问题。若要评论或要求作者澄清,请在其帖子下方留下评论-