Skip to content

feat: set source address if remote is known - #289

Open
winter4j wants to merge 1 commit into
xtaci:masterfrom
winter4j:master
Open

feat: set source address if remote is known#289
winter4j wants to merge 1 commit into
xtaci:masterfrom
winter4j:master

Conversation

@winter4j

Copy link
Copy Markdown

当已知remote addr时(即UDPSession的remote字段被有效赋值),建议在readloop中直接设置src。
避免当同一个发送方在多次断连(disconnect)后建连的场景下,接收到上一次连接中远端(ip1)发来的包(可能因为网络波动等原因),导致readloop中src被脏写入,进一步导致后续真正的远端(ip2)的incoming包永远无法被处理。

@winter4j

Copy link
Copy Markdown
Author

补充:上述场景中,发送方在两次连接中本机port相同。即先disconnect释放了port,然后在下一次连接中复用了该port。

@xtaci

xtaci commented Dec 9, 2025

Copy link
Copy Markdown
Owner

如果实时设定,比较担心会不会出现连接被中间人劫持的情况。

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

Successfully merging this pull request may close these issues.

2 participants