mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-06-18 00:39:54 -04:00
unified tproxy option
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package dokodemo
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import net "v2ray.com/core/common/net"
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
net "v2ray.com/core/common/net"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
|
||||
@@ -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