绑定到 iPhone 模拟器中的特权端口

发布于 2024-12-01 06:36:10 字数 254 浏览 1 评论 0 原文

我有一个用例,我需要在 iOS 上运行一个简单的 HTTP 服务器,侦听端口 80。

在设备上工作正常,但在模拟器上我收到一个绑定错误,表明端口 80 具有特权。这并不重要,但会使测试变得比需要的更加复杂。

在 Linux 上,似乎可以通过“setcap 'cap_net_bind_service=+ep' /path/to/program”让各个应用程序访问特权端口。

这在 OSX 上如何工作,以便 iPhone 模拟器可以绑定到特权端口?

I have a use-case where I need to run a simple HTTP server on iOS listening on port 80.

On the device that works fine however on the simulator I get a bind error that port 80 is privileged. This is not critical but makes testing more complicated than needed.

On linux it seems possible to give individual apps access to privileged ports via "setcap 'cap_net_bind_service=+ep' /path/to/program".

How would this work on OSX so that the iPhone Simulator could bind to a privileged port?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杆小烟枪 2024-12-08 06:36:11

这不是答案,但您可以使用 20080 上启动 HTTP 服务器)重定向到端口 80 >ssh:

ssh -L 80:<iOS Device IP>:20080 localhost

或者socat

socat TCP-LISTEN:80,fork TCP:<iOS Device IP:20080

然后你就可以访问(你可以用一个花哨的名字编辑/etc/hosts):

http://localhost/

This is not the answer but you can redirect the traffic from other ports (if you are able for example to start an HTTP server on port 20080) to port 80 using ssh:

ssh -L 80:<iOS Device IP>:20080 localhost

Or socat:

socat TCP-LISTEN:80,fork TCP:<iOS Device IP:20080

Then you can access (you could edit /etc/hosts with a fancy name):

http://localhost/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文