Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add configurable port range for P2P mode #4602

Open
3 of 11 tasks
stleon opened this issue Dec 20, 2024 · 4 comments
Open
3 of 11 tasks

[Feature Request] Add configurable port range for P2P mode #4602

stleon opened this issue Dec 20, 2024 · 4 comments

Comments

@stleon
Copy link

stleon commented Dec 20, 2024

Describe the feature request

I would like to request a feature that allows explicitly defining a range of ports for P2P mode.

Currently, ports are selected using:

port := rand.IntN(65535-1024) + 1024

source

This approach may result in conflicts if some ports in this range are already in use. Being able to specify a custom port range would provide more control and prevent such issues.

Why this feature should be added

  1. Avoid port conflicts: users can prevent runtime issues by limiting the range to known available ports.
  2. Flexibility: allows adaptation to specific environments or network policies.

Proposed Solution

Introduce a configuration option, such as p2pPortRange, where users can specify the allowed range of ports:

p2pPortRange = "29160-29200"

If not set, the default behavior remains unchanged (random selection from 1024–65535), ensuring backward compatibility.

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
@xqzr
Copy link

xqzr commented Dec 21, 2024

这么做也许不再需要 UPnP #4112
frpc 指定范围后,在路由器“端口映射”指定的范围,来获得“全锥 NAT(1)”。

@fatedier
Copy link
Owner

I'm not quite sure what specific issue you're encountering. The code you posted is probing the port number on the peer's side. The exit port of the peer's NAT could be any arbitrary port.

@xqzr
Copy link

xqzr commented Dec 23, 2024

例如 XTCP 类型,在 frpc 增加一个 bindSrcPort 字段,并设置值为 3478
之后,所有的发包(STUN、数据传输...)都使用 3478 作为端口发送。

@stleon
Copy link
Author

stleon commented Dec 29, 2024

I was specifically referring to the ability to define a port range on the client side (frpc). Allowing this configuration would simplify operations in environments with restricted port access, such as when using Docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants