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

SplitHTTP h3 panics on v2rayNG #3556

Closed
mmmray opened this issue Jul 19, 2024 · 7 comments
Closed

SplitHTTP h3 panics on v2rayNG #3556

mmmray opened this issue Jul 19, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@mmmray
Copy link
Collaborator

mmmray commented Jul 19, 2024

#3554 (comment)

@mmmray mmmray added the bug Something isn't working label Jul 19, 2024
@ll11l1lIllIl1lll
Copy link
Contributor

ll11l1lIllIl1lll commented Jul 19, 2024

经测试在 xray 配置设置 h3 SplitHTTP 后,在 Chromium 126.0.6478.126 通过 http/1.1 或 h2 或通过 --origin-to-force-quic-on= 强制要求的 h3 都无法复现这个问题。

@dyhkwong
Copy link
Contributor

When using proxy chain (not supported under current structure), conn is cnc.connection, not *internet.PacketConnWrapper.

In AndroidLibV2rayLite, where effectiveSystemDialer is altered by internet.UseAlternativeSystemDialer, conn is *net.UDPConn.

So type assertion in

return quic.DialEarly(ctx, conn.(*internet.PacketConnWrapper).Conn.(*net.UDPConn), udpAddr, tlsCfg, cfg)
will just fail and you need hack like
var udpConn *net.UDPConn
switch conn := rawConn.(type) {
case *net.UDPConn:
udpConn = conn
case *internet.PacketConnWrapper:
udpConn = conn.Conn.(*net.UDPConn)
default:
// TODO: Support sockopt for QUIC
rawConn.Close()
return nil, errors.New("QUIC with sockopt is unsupported").AtWarning()
}
or maybe wrap net.Conn to fit net.PacketConn.

And, net.ListenUDP need to be replaced by internet.ListenSystemPacket in https://github.com/XTLS/Xray-core/pull/3554/files#diff-c0d111c26ebe8b3a6a004695c434204a67726f8b6af44d01b601c60573e45601R283 so that internet.RegisterListenerController can take effect.

ll11l1lIllIl1lll pushed a commit to ll11l1lIllIl1lll/Xray-core that referenced this issue Jul 19, 2024
ll11l1lIllIl1lll pushed a commit to ll11l1lIllIl1lll/Xray-core that referenced this issue Jul 19, 2024
ll11l1lIllIl1lll pushed a commit to ll11l1lIllIl1lll/Xray-core that referenced this issue Jul 19, 2024
@ll11l1lIllIl1lll
Copy link
Contributor

ll11l1lIllIl1lll commented Jul 19, 2024

我想我可能知道指的是什么了,虽然我 PR 的代码就是一坨混乱的 (我不应侮辱任何事物),但是感觉不是从 Xray-core 触发的。我可能要去 quic-go 交 PR (虽然我应该没有这个能力去修,试试)

panic: connection already exists

goroutine 18747 [running]:
github.com/quic-go/quic-go.(*connMultiplexer).AddConn(0xc00046c060, {0x7fca9f8c98c0?, 0xc0007087e0?})
        github.com/quic-go/[email protected]/multiplexer.go:59 +0x165
github.com/quic-go/quic-go.(*Transport).init.func1()
        github.com/quic-go/[email protected]/transport.go:266 +0x3f0
sync.(*Once).doSlow(0xc0004ec498?, 0xe?)
        sync/once.go:74 +0xc2
sync.(*Once).Do(...)
        sync/once.go:65
github.com/quic-go/quic-go.(*Transport).init(0xc0002c4d00, 0x98?)
        github.com/quic-go/[email protected]/transport.go:225 +0x4d
github.com/quic-go/quic-go.(*Transport).dial(0xc0002c4d00, {0x1558628, 0xc000959450}, {0x154eb90, 0xc000968240}, {0x0, 0x0}, 0xc000d5e9c0, 0xc0012c2000, 0x1)
        github.com/quic-go/[email protected]/transport.go:212 +0xa5
github.com/quic-go/quic-go.(*Transport).DialEarly(...)
        github.com/quic-go/[email protected]/transport.go:204
github.com/quic-go/quic-go.DialEarly({0x1558628, 0xc000959450}, {0x155edf0?, 0xc0007087e0?}, {0x154eb90, 0xc000968240}, 0xc000d5e9c0, 0xc0012c2000)
        github.com/quic-go/[email protected]/client.go:95 +0x12a
github.com/xtls/xray-core/transport/internet/splithttp.getHTTPClient.func2({0x1558628, 0xc000959450}, {0xc001851b60?, 0xc001cdb920?}, 0xc000d5e9c0, 0xc0012c2000)
        github.com/xtls/xray-core/transport/internet/splithttp/dialer.go:129 +0x19d
github.com/quic-go/quic-go/http3.(*RoundTripper).dial(0xc000e5f260, {0x1558628, 0xc000959450}, {0xc0005b4930, 0x30})
        github.com/quic-go/[email protected]/http3/roundtrip.go:312 +0x27a
github.com/quic-go/quic-go/http3.(*RoundTripper).getClient.func1()
        github.com/quic-go/[email protected]/http3/roundtrip.go:249 +0x77
created by github.com/quic-go/quic-go/http3.(*RoundTripper).getClient in goroutine 18746
        github.com/quic-go/[email protected]/http3/roundtrip.go:246 +0x289

@dyhkwong
Copy link
Contributor

dyhkwong commented Jul 19, 2024 via email

@mmmray
Copy link
Collaborator Author

mmmray commented Jul 19, 2024

Thank you @dyhkwong @ll11l1lIllIl1lll for fixing this quickly!

Are there any recommendations for how to prevent this situation in the future? Can write a testcase that calls UseAlternativeSystemDialer and runs the splithttp transport tests, but I'm not sure if it's meaningful since it's separate from the v2rayNG one.

@mmmray mmmray changed the title SplitHTTP h3 panics when dialerProxy is used SplitHTTP h3 panics on v2rayNG Jul 19, 2024
@dyhkwong
Copy link
Contributor

dyhkwong commented Jul 20, 2024

Are there any recommendations for how to prevent this situation in the future? Can write a testcase that calls UseAlternativeSystemDialer and runs the splithttp transport tests, but I'm not sure if it's meaningful since it's separate from the v2rayNG one.

Because effectiveSystemDialer is alterable, internet.DialSystem may return anything that wrapped as a net.Conn. v2rayNG is only a special case. For dialerProxy and other cases You can wrap net.Conn to fit net.PacketConn.

Note that you need to generate some random LocalAddr() to bypass the annoying panic check in quic-go/quic-go@8189e75#diff-4c6aaadced390f3ce9bec0a9c9bb5203d5fa85df79023e3e0eec423dc9baa946R48-R62. quic-go says this panic check needs to be kept for a year and refuses to remove it (see quic-go#4079).

@RPRX
Copy link
Member

RPRX commented Jul 20, 2024

@dyhkwong 我也发现了 #3560 (comment) ,才发现你们说的就是这个,蚌

leninalive pushed a commit to amnezia-vpn/amnezia-xray-core that referenced this issue Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants