mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-28 13:05:28 -05:00
unified tproxy option
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
"v2ray.com/core/common/task"
|
||||
"v2ray.com/core/proxy"
|
||||
"v2ray.com/core/transport/internet"
|
||||
"v2ray.com/core/transport/internet/udp"
|
||||
"v2ray.com/core/transport/pipe"
|
||||
)
|
||||
|
||||
@@ -111,12 +110,18 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
||||
if !d.config.FollowRedirect {
|
||||
writer = &buf.SequentialWriter{Writer: conn}
|
||||
} else {
|
||||
srca := net.UDPAddr{IP: dest.Address.IP(), Port: int(dest.Port.Value())}
|
||||
origsend, err := udp.TransmitSocket(&srca, conn.RemoteAddr())
|
||||
tCtx := internet.ContextWithBindAddress(context.Background(), dest)
|
||||
tCtx = internet.ContextWithStreamSettings(tCtx, &internet.MemoryStreamConfig{
|
||||
ProtocolName: "udp",
|
||||
SocketSettings: &internet.SocketConfig{
|
||||
Tproxy: internet.SocketConfig_TProxy,
|
||||
},
|
||||
})
|
||||
tConn, err := internet.DialSystem(tCtx, nil, net.DestinationFromAddr(conn.RemoteAddr()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
writer = &buf.SequentialWriter{Writer: origsend}
|
||||
writer = &buf.SequentialWriter{Writer: tConn}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user