mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
DialerProxy: Fix SplitHTTP H3 dialerProxy (#3570)
* wip * wip * formatting * cnc connection no longer needs to be a Packetconn * dialerProxy: do not cancel connection when Dial context is cancelled
This commit is contained in:
parent
0c7303960a
commit
498d8eb3cc
3 changed files with 44 additions and 7 deletions
|
@ -2,6 +2,7 @@ package internet
|
|||
|
||||
import (
|
||||
"context"
|
||||
"math/rand"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
|
@ -48,7 +49,7 @@ func hasBindAddr(sockopt *SocketConfig) bool {
|
|||
}
|
||||
|
||||
func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest net.Destination, sockopt *SocketConfig) (net.Conn, error) {
|
||||
errors.LogDebug(ctx, "dialing to " + dest.String())
|
||||
errors.LogDebug(ctx, "dialing to "+dest.String())
|
||||
|
||||
if dest.Network == net.Network_UDP && !hasBindAddr(sockopt) {
|
||||
srcAddr := resolveSrcAddr(net.Network_UDP, src)
|
||||
|
@ -221,3 +222,29 @@ func RegisterDialerController(ctl control.Func) error {
|
|||
dialer.controllers = append(dialer.controllers, ctl)
|
||||
return nil
|
||||
}
|
||||
|
||||
type FakePacketConn struct {
|
||||
net.Conn
|
||||
}
|
||||
|
||||
func (c *FakePacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
|
||||
n, err = c.Read(p)
|
||||
return n, c.RemoteAddr(), err
|
||||
}
|
||||
|
||||
func (c *FakePacketConn) WriteTo(p []byte, _ net.Addr) (n int, err error) {
|
||||
return c.Write(p)
|
||||
}
|
||||
|
||||
func (c *FakePacketConn) LocalAddr() net.Addr {
|
||||
return &net.TCPAddr{
|
||||
IP: net.IP{byte(rand.Intn(256)), byte(rand.Intn(256)), byte(rand.Intn(256)), byte(rand.Intn(256))},
|
||||
Port: rand.Intn(65536),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *FakePacketConn) SetReadBuffer(bytes int) error {
|
||||
// do nothing, this function is only there to suppress quic-go printing
|
||||
// random warnings about UDP buffers to stdout
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue