mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-09-30 22:24:04 -04:00
Merge pull request #651 from v2ray/udpfollow
Added UDP TPROXY Transmit Support
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user