WebExtension 中的 TCP 服务器

TCP server in WebExtension

有没有办法启动使用 Firefox WebExtension 监听端口的 TCP 服务器?我知道存在以 XUL/XPCOM 扩展名启动服务器的方法,但它已过时,从 2017 年 11 月起将不再受支持(弃用)。 同样的问题兴趣和关于 google chrome.

否,Chrome 扩展/Firefox WebExtension 无法打开套接字进行侦听。

但是,您可以有一个单独的 Native Host 组件来为您完成。需要单独安装。

还没有

With the removal of XPCOM, add-ons access to UDP and TCP sockets will disappear, which will cause problems for a number of add-ons.
Adam Roach

Firefox bug FF#1435798 (libdweb):

  • Open
  • Type: enhancement
  • Priority: P5
    • TCP and UDP 个组件是 Priority: P3

It's been discussed and everyone seems to like the idea.

if somebody is motivated to work on this, sketching out a design that meets the requirements outlined above would be the first step.

we are all for a well thought out API and that's the next step for someone to take on.

您可以在 Git repo.

关注他们的进展,或伸出援手

当然,正如其他回答者指出的那样,本机主机/好友软件组件是目前唯一 解决方法;你有到运行某种privileged/native代码来打开套接字,直到或除非libdweb被释放。