Skip to content

【求助】核心执行过程中的疑问求大佬解答 #165

Description

@taoeer

这个库非常的棒,我是个小白,想学习下:
首先仔细阅读了源码,发现核心流程如下:
1.1785 行 stun.get_mapping() 通过tcp获取到外网的ip+端口(localPort)
2. 1790 行 使用 1 中的tcp使用的本地端口(localPort)执行 一次 keepalive(本质是tcp访问百度)
3. 1812 行 继续使用之前的tcp端口启动一个http服务器.

有两个疑问:

  1. 为什么在不执行 1790 行 keepalive的情况下,就无法从外网访问 forwarder.start_forward()启动的http服务器。理论上 stun.get_mapping() 时路由器就已经建立了“外网端口 ↔ 本机端口”的映射条目,是可以使用获取到的外网ip+端口访问到的啊。
  2. keepalive 与 forwarder.start_forward() 使用的同一个 tcp端口,为什么不会报端口占用啊?且我查阅资料,windows不支持SO_REUSEPORT。(我使用的windows10)

求大佬指点

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions