通过 JavaScript 访问 TCP 连接
我的目标是识别 firefox 插件中的 TCP 连接。
为此,我需要为每个连接设置一个唯一的 ID。我的问题是,是否可能并且有人知道如何从 HTTP 请求访问 TCP 连接的对象?然后我可以为其设置一个唯一的 ID,并且每个请求/响应对都将唯一地设置为一个连接。
My goal is it to identify the TCP-Connections in a firefox-plugin.
For that I need to set a unique ID to every connection. My question is, if its possible and someone knows how to get access to the Object of the TCP-Connection from a HTTP-Request? Then I could set a unique ID to it and every request/response pair would be uniquely set to a connection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
虽然我不知道您问题的直接答案,但我建议您查看源代码Firebug,它似乎至少可以访问网络堆栈的HTTP请求级别,甚至可能更低。
希望这有帮助,祝你好运!
While I don't know the direct answer to your question, I would suggest taking a look at the source code for Firebug, it seems to have access to at least the HTTP request level of the network stack, maybe even lower.
Hope this helps, good luck!
假设您正在谈论客户端 JavaScript,有一些项目可以帮助您实现此功能。
希望有帮助。
Assuming that you are talking about client side javascript, there are some projects which will help you to achieve this functionality.
Hope it helps.
来自 MDN:如何监控 HTTP 活动
这是他们的示例代码
From MDN: How to monitor HTTP activity
Here's their sample code
我在我自己的 ff 插件中做了一些非常类似的事情。我假设您需要对与连接关联的
nsiHttpChannel
的引用。但是,我不确定您是否可以向其添加属性(并让它们保留),因为它可能由本机代码支持,我不确定哪种方式。但是您可以将nsiHttpChannel
存储在其他地方并以这种方式保留一个ID。这是我用来监视插件中的 http 流量的一些简化代码,它应该可以解决您的问题。
I do something very similar in my own ff addon. I'm assuming that you want a reference to the
nsiHttpChannel
associated with the connection. However, I'm not sure you can just add properties to it (and have them persist), since its probably backed by native code, I'm not sure either way. But you can store thensiHttpChannel
elsewhere and keep an id on it that way.Here's some simplified code that I use to monitor http traffic in my addon, which should solve your problem.