理解 Lua 错误 “尝试索引全局 ‘ftypes’(一个空值)”。

huangapple go评论84阅读模式
英文:

Understanding an "attempt to index global 'ftypes' (a nil value)" Lua error

问题

我尝试使用ZMTP Wireshark分析器与我当前的Wireshark副本(v4.0.6)一起使用,该副本在我的Ubuntu 20.04机器上使用Lua 5.2.4来分析zeromq。

我将Lua文件放在了适当的位置供Wireshark使用,当我启动Wireshark时,它显然能够识别它,但会引发“尝试索引全局'ftypes'(一个nil值)”的错误。

错误的截图

对我来说,这意味着Lua分析器对代码本身不满意(所以不是Wireshark的问题,而是Lua的问题)。这个分析器来自的存储库最后更新于2020年,所以我猜测Lua的一些小更新导致代码无法跟上。

我认为只有少数几行对于这个错误很重要,它们是:

-- zmq协议示例
-- 声明我们的协议
local zmtp_proto = Proto("zmtp", "ZMTP", "ZeroMQ消息传输协议")

-- 设置协议字段。

vs_stype = {
    [0] = "pair",
    [1] = "publish",
    [2] = "subscribe",
    [3] = "request",
    [4] = "reply",
    [5] = "dealer",
    [6] = "router",
    [7] = "pull",
    [8] = "push"
}

zmtp_proto.fields = {}
local fds = zmtp_proto.fields
fds.greeting = ProtoField.new("Signature", "zmtp.greeting", ftypes.BYTES)

最后一行是错误消息中引用的第41行。这些Lua proto字段是否应该以不同的方式设置?

我已经尝试将可疑的行变成了本地行并去掉了fds,但似乎没有帮助。

英文:

I was attempting to use the ZMTP Wireshark Dissector with my current copy of Wireshark (v4.0.6) which uses Lua 5.2.4 on my Ubuntu 20.04 machine to dissect zeromq.

I put the lua file in the proper place for Wireshark, and when I start wireshark it obviously sees it, but it throws an "attempt to index global 'ftypes' (a nil value)" error.

screenshot of error

To me, this means that the Lua dissector was not happy with the code itself (so not a Wireshark problem per say, but a Lua one). The repo this dissector came from was last updated in 2020, so I am guessing that something small has been updated on the Lua side and has caused the code to not keep pace.

I believe there are only a handful of lines that matter for this error, and they are:

-- zmq protocol example
-- declare our protocol
local zmtp_proto = Proto("zmtp", "ZMTP", "ZeroMQ Message Transport Protocol")

-- setup protocol fields.

vs_stype = {
    [0] = "pair",
    [1] = "publish",
    [2] = "subscribe",
    [3] = "request",
    [4] = "reply",
    [5] = "dealer",
    [6] = "router",
    [7] = "pull",
    [8] = "push"
}

zmtp_proto.fields = {}
local fds = zmtp_proto.fields
fds.greeting = ProtoField.new("Signature", "zmtp.greeting", ftypes.BYTES)

With that last line being like 41 that was referenced in the error message. Is there some way that these Lua proto fields should be setup differently?

I have tried making the suspect line a local and taking away the fds, but that seemed to not help any.

答案1

得分: 2

"ftypes"表在"init.lua"文件中定义,应安装在Wireshark的"全局安装目录"中。

您的系统是否有该文件?

英文:

The ftypes table is defined in the init.lua file, which should be installed in the Wireshark "global installation directory".

Does your system have that file?

huangapple
  • 本文由 发表于 2023年6月22日 02:19:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76526116.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定