|
|
@@ -7,6 +7,8 @@ import (
|
|
|
"runtime"
|
|
|
"time"
|
|
|
|
|
|
+ gonet "net"
|
|
|
+
|
|
|
"v2ray.com/core/app"
|
|
|
"v2ray.com/core/app/dispatcher"
|
|
|
"v2ray.com/core/app/log"
|
|
|
@@ -16,6 +18,7 @@ import (
|
|
|
"v2ray.com/core/common/signal"
|
|
|
"v2ray.com/core/proxy"
|
|
|
"v2ray.com/core/transport/internet"
|
|
|
+ "v2ray.com/core/transport/internet/udp"
|
|
|
)
|
|
|
|
|
|
type DokodemoDoor struct {
|
|
|
@@ -88,7 +91,18 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
|
|
if network == net.Network_TCP {
|
|
|
writer = buf.NewWriter(conn)
|
|
|
} else {
|
|
|
- writer = buf.NewSequentialWriter(conn)
|
|
|
+ //if we are in TPROXY mode, use linux's udp forging functionality
|
|
|
+ if !d.config.FollowRedirect {
|
|
|
+ writer = buf.NewSequentialWriter(conn)
|
|
|
+ } else {
|
|
|
+ srca := gonet.UDPAddr{IP: dest.Address.IP(), Port: int(dest.Port.Value())}
|
|
|
+ origsend, err := udp.TransmitSocket(&srca, conn.RemoteAddr())
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ writer = buf.NewSequentialWriter(origsend)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if err := buf.Copy(inboundRay.InboundOutput(), writer, buf.UpdateActivity(timer)); err != nil {
|