|
@@ -15,6 +15,7 @@ import (
|
|
|
"github.com/xtls/xray-core/common/session"
|
|
"github.com/xtls/xray-core/common/session"
|
|
|
"github.com/xtls/xray-core/common/signal"
|
|
"github.com/xtls/xray-core/common/signal"
|
|
|
"github.com/xtls/xray-core/common/task"
|
|
"github.com/xtls/xray-core/common/task"
|
|
|
|
|
+ "github.com/xtls/xray-core/common/vudp"
|
|
|
core "github.com/xtls/xray-core/core"
|
|
core "github.com/xtls/xray-core/core"
|
|
|
"github.com/xtls/xray-core/features/policy"
|
|
"github.com/xtls/xray-core/features/policy"
|
|
|
"github.com/xtls/xray-core/proxy/vmess"
|
|
"github.com/xtls/xray-core/proxy/vmess"
|
|
@@ -122,6 +123,12 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle)
|
|
timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle)
|
|
|
|
|
|
|
|
|
|
+ if request.Command == protocol.RequestCommandUDP {
|
|
|
|
|
+ request.Command = protocol.RequestCommandMux
|
|
|
|
|
+ request.Address = net.DomainAddress("v1.mux.cool")
|
|
|
|
|
+ request.Port = net.Port(666)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
requestDone := func() error {
|
|
requestDone := func() error {
|
|
|
defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly)
|
|
defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly)
|
|
|
|
|
|
|
@@ -131,6 +138,10 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bodyWriter := session.EncodeRequestBody(request, writer)
|
|
bodyWriter := session.EncodeRequestBody(request, writer)
|
|
|
|
|
+ bodyWriter2 := bodyWriter
|
|
|
|
|
+ if request.Command == protocol.RequestCommandMux && request.Port == 666 {
|
|
|
|
|
+ bodyWriter = vudp.NewPacketWriter(bodyWriter, target)
|
|
|
|
|
+ }
|
|
|
if err := buf.CopyOnceTimeout(input, bodyWriter, time.Millisecond*100); err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout {
|
|
if err := buf.CopyOnceTimeout(input, bodyWriter, time.Millisecond*100); err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout {
|
|
|
return newError("failed to write first payload").Base(err)
|
|
return newError("failed to write first payload").Base(err)
|
|
|
}
|
|
}
|
|
@@ -144,7 +155,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if request.Option.Has(protocol.RequestOptionChunkStream) {
|
|
if request.Option.Has(protocol.RequestOptionChunkStream) {
|
|
|
- if err := bodyWriter.WriteMultiBuffer(buf.MultiBuffer{}); err != nil {
|
|
|
|
|
|
|
+ if err := bodyWriter2.WriteMultiBuffer(buf.MultiBuffer{}); err != nil {
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -163,6 +174,9 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
|
|
|
h.handleCommand(rec.Destination(), header.Command)
|
|
h.handleCommand(rec.Destination(), header.Command)
|
|
|
|
|
|
|
|
bodyReader := session.DecodeResponseBody(request, reader)
|
|
bodyReader := session.DecodeResponseBody(request, reader)
|
|
|
|
|
+ if request.Command == protocol.RequestCommandMux && request.Port == 666 {
|
|
|
|
|
+ bodyReader = vudp.NewPacketReader(&buf.BufferedReader{Reader: bodyReader})
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return buf.Copy(bodyReader, output, buf.UpdateActivity(timer))
|
|
return buf.Copy(bodyReader, output, buf.UpdateActivity(timer))
|
|
|
}
|
|
}
|