1
0
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:
Darien Raymond
2018-09-17 15:12:58 +02:00
parent 7f697661cd
commit 383b84e7dd
66 changed files with 504 additions and 336 deletions

View File

@@ -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}
}
}