Browse Source

Fix reverse proxy with the HTTP optimization

And any other protocol that require the connection initializer to send first, E.g. freedom with TFO.
Anonymous-Someneese 5 years ago
parent
commit
82dee01833
1 changed files with 8 additions and 0 deletions
  1. 8 0
      app/reverse/bridge.go

+ 8 - 0
app/reverse/bridge.go

@@ -7,6 +7,7 @@ import (
 	"time"
 	"time"
 
 
 	"github.com/golang/protobuf/proto"
 	"github.com/golang/protobuf/proto"
+	"v2ray.com/core/common/buf"
 	"v2ray.com/core/common/mux"
 	"v2ray.com/core/common/mux"
 	"v2ray.com/core/common/net"
 	"v2ray.com/core/common/net"
 	"v2ray.com/core/common/session"
 	"v2ray.com/core/common/session"
@@ -119,6 +120,13 @@ func NewBridgeWorker(domain string, tag string, d routing.Dispatcher) (*BridgeWo
 		tag:        tag,
 		tag:        tag,
 	}
 	}
 
 
+	// Initialize the connection by sending a Keepalive frame
+	keepalive := buf.New()
+	mux.FrameMetadata{SessionStatus: mux.SessionStatusKeepAlive}.WriteTo(keepalive)
+	err = link.Writer.WriteMultiBuffer(buf.MultiBuffer{keepalive})
+	if err != nil {
+		return nil, err
+	}
 	worker, err := mux.NewServerWorker(context.Background(), w, link)
 	worker, err := mux.NewServerWorker(context.Background(), w, link)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err