Explorar o código

Adjust Trojan Outbound postRequest

RPRX %!s(int64=4) %!d(string=hai) anos
pai
achega
7427a55ef1
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      proxy/trojan/client.go

+ 8 - 1
proxy/trojan/client.go

@@ -7,6 +7,7 @@ import (
 
 
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/buf"
+	"github.com/xtls/xray-core/common/errors"
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/platform"
 	"github.com/xtls/xray-core/common/platform"
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/protocol"
@@ -145,12 +146,13 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
 	postRequest := func() error {
 	postRequest := func() error {
 		defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly)
 		defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly)
 
 
-		var bodyWriter buf.Writer
 		bufferWriter := buf.NewBufferedWriter(buf.NewWriter(conn))
 		bufferWriter := buf.NewBufferedWriter(buf.NewWriter(conn))
+
 		connWriter.Writer = bufferWriter
 		connWriter.Writer = bufferWriter
 		connWriter.Target = destination
 		connWriter.Target = destination
 		connWriter.Account = account
 		connWriter.Account = account
 
 
+		var bodyWriter buf.Writer
 		if destination.Network == net.Network_UDP {
 		if destination.Network == net.Network_UDP {
 			bodyWriter = &PacketWriter{Writer: connWriter, Target: destination}
 			bodyWriter = &PacketWriter{Writer: connWriter, Target: destination}
 		} else {
 		} else {
@@ -167,6 +169,11 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
 			return newError("failed to flush payload").Base(err).AtWarning()
 			return newError("failed to flush payload").Base(err).AtWarning()
 		}
 		}
 
 
+		// Send header if not sent yet
+		if _, err = connWriter.Write([]byte{}); err != nil {
+			return err.(*errors.Error).AtWarning()
+		}
+
 		if err = buf.Copy(link.Reader, bodyWriter, buf.UpdateActivity(timer)); err != nil {
 		if err = buf.Copy(link.Reader, bodyWriter, buf.UpdateActivity(timer)); err != nil {
 			return newError("failed to transfer request payload").Base(err).AtInfo()
 			return newError("failed to transfer request payload").Base(err).AtInfo()
 		}
 		}