Record wireshark lua's bugs found by myself and some suggestion

1. Lua script can not get "data-text-lines" protocol data:

for example,

local dataline = Field.new("data-text-lines")

local data = dataline()

tostring(data.value)       is not ok "FT_" error

 

This is fixed in 1.3.4, but data.range() is not ok, report "expired tvb" error.

 

2. Trying to use Field.new("tcp.segments") to get reassembled TCP data is failed.

Try xxx.value or xxx() get nil.   I checked the source code, and find the reason is :

In packet-tcp.c, it set "tcp.segments" field to FT_NONE type;

Then in wslua_field.c, FT_NONE is converted to lua as nil.

My suggestion is to modify wslua_field.c->FieldInfo__call, to convert all FT_NONE to lua ByteArray just like FT_PROTOCOL that has been converted to ByteArray in 1.3.4.

 

Another bug about Field.new("tcp.segments") is xxx.range got "expired tvb" error too in reassembled tcp packet.

 

3. Suggest to expose http_dissector_add() of packet-http.c as a lua function. Such, user can use lua to write dissector to analyze protocol over http. Now we have to use the workaround to register http dissector to "tcp.port" dissectors table and register our own dissector to the same port in "http.port".

 

4. Suggest to expose pinfo.private_data as ByteArray of lua. Current Bug is tha wslua_pinfo.c exposes private_data as LIGHTUSERDATA. I think it is meaningless. Because that cause it can not be read by lua script.

 

5. Suggest to expose pinfo.match_string as ByteArray to lua script. Because some dissector, like http dissector, will put content-type to pinfo.match_string and content_type_parameters to pinfo.private_data, then invoke their subdissector (like "media_type" table's dissector). Certainly, now dissectors that register in "media_type" table can use Field.new("Content-Type") to get content-type value, and parsing it itself. But I think it is formal way to get it from  match_string and private_data.

 

6. Suggest to expose pinfo.can_desegment to lua script or set its default to true. Because sometime we invoke standard dissector like http dissector in our own dissector, and we hope http dissector will return negative (and set pinfo.desegment_offset and pinfo.desegment_len) when it found it needs more packet to complete its dissection. But now, it can not happen, because pinfo.can_desegment default is 0 in lua script. (I don't very sure about this point)

03-28
### MCP API 的文档与使用教程 MCP 是一种用于增强大型语言模型 (LLM) 功能的技术框架,它通过提示(Prompts)、资源(Resources)以及工具(Tools)这三种核心原语来扩展 LLM 能力[^2]。Apifox 平台也认识到 MCP 技术在 API 开发领域的重要作用,并将其应用于实际场景中[^1]。 为了实现将 `/Users/syw/project/wechatAr` 文件夹下的所有文件上传至远程服务器 `47.93.xx.xx` 用户名 `root` 下的 `/opt/ll` 目录的操作,可以基于 MCP 工具功能构建一个自定义的服务逻辑。以下是具体实现方法: #### 实现方案 利用 SCP 命令完成文件传输任务,并结合 MCP 的 Tool 功能封装此操作以便于后续调用。当关键词为“上传微信目录”时,触发该工具执行相应动作。 ```python import subprocess def upload_wechat_directory(): source_dir = "/Users/syw/project/wechatAr/*" target_server = "root@47.93.xx.xx:/opt/ll/" try: result = subprocess.run(["scp", "-r", source_dir, target_server], check=True) return {"status": "success", "message": f"All files from {source_dir} have been uploaded to {target_server}"} except Exception as e: return {"status": "error", "message": str(e)} # 将上述函数注册为 MCP 中的一个 tool tools = { "upload_wechat_directory_tool": upload_wechat_directory, } # 定义 prompt 和 resource 配置部分省略... ``` 以上代码片段展示了如何创建一个名为 `upload_wechat_directory_tool` 的工具并将其集成到 MCP 系统里去[^3]。每当接收到匹配条件的消息比如含有特定关键字的时候就会激活对应的行为即启动SCP进程从而达成目标需求。 #### 进一步学习资料推荐 对于希望深入研究或者实践更多关于 MCP 应用案例的人士来说,《MCP 教程进阶篇》提供了丰富的实例分析和技术细节值得参考阅读;另外《MCP 极简入门:超快速上手运行简单的 MCP 服务和 MCP 客户端》同样是非常好的起点材料之一可以帮助初学者迅速掌握基础概念及其运作机制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值