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

Freedom: Fix PacketReader/PacketWriter type assertion #3734

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

dyhkwong
Copy link
Contributor

通过 UseAlternativeSystemDialerRegisterDialerController 使用自定义 dialer 替换 DefaultSystemDialer 后,自定义 dialer 返回的 net.Conn 没有保证可以断言为 *PacketConnWrapper

以 v2rayNG(AndroidLibXrayLite)为例,其自定义 dialer 返回的 net.Conn 可以被断言为 *net.UDPConn 但不能被断言为 *PacketConnWrapperNewPacketReaderNewPacketWriter 断言失败, PacketReaderPacketWriter 不会被使用。

上下文:#3711 (comment) ,需要由真正的 v2rayNG 用户测试这在 v2rayNG 上是否有效。

@yuhan6665 yuhan6665 changed the title Fix freedom PacketReader/PacketWriter type assertion Freedom: Fix PacketReader/PacketWriter type assertion Aug 27, 2024
@yuhan6665 yuhan6665 merged commit 815a959 into XTLS:main Aug 27, 2024
36 checks passed
@yuhan6665
Copy link
Member

感谢佬

zxspirit pushed a commit to zxspirit/Xray-core that referenced this pull request Aug 30, 2024
@dyhkwong
Copy link
Contributor Author

dyhkwong commented Sep 1, 2024

经测试这在 v2rayNG 上不工作,请 revert 掉吧。
unix.Connect 的 ReadFrom 不行(If the socket sockfd is of type SOCK_DGRAM, then addr is the address to which datagrams are sent by default, and the only address from which datagrams are received.)unix.Bind 只能 WriteTo 不能 Write。还是需要 AndroidLibXrayLite 使用 unix.Bind 然后把目标地址一起包装成 PacketConnWrapper 返回才行。

@dyhkwong
Copy link
Contributor Author

dyhkwong commented Sep 1, 2024

或者需要两边同时修改

https://github.com/2dust/AndroidLibXrayLite/blob/b0a4e81a6ccfa6e5480dc4e7199e800a6ebf90c6/libv2ray_support.go#L298 改成 UDP 用 unix.Bind,

n, err = w.Conn.Write(b.Bytes())
这里也改用 w.PacketConn.WriteTo

这样的话应该也可行 这样对 WireGuard 之类的不行

@mmmray
Copy link
Collaborator

mmmray commented Sep 1, 2024

OK, I reverted the PR and filed an issue for now, just so it's documented: #3750

@dyhkwong
Copy link
Contributor Author

dyhkwong commented Sep 1, 2024

I think under current API structure the fix has to to be done on AndroidLibXrayLite side. Unless new API is added, no further fix can be going on here. I raised a PR for AndroidLibXrayLite.

leninalive pushed a commit to amnezia-vpn/amnezia-xray-core that referenced this pull request Oct 29, 2024
leninalive pushed a commit to amnezia-vpn/amnezia-xray-core that referenced this pull request Oct 29, 2024
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.

3 participants