From 82dee01833764f2ea1a376b9a868420e897cf55e Mon Sep 17 00:00:00 2001 From: Anonymous-Someneese Date: Sun, 5 Jan 2020 07:11:54 +0800 Subject: [PATCH] Fix reverse proxy with the HTTP optimization And any other protocol that require the connection initializer to send first, E.g. freedom with TFO. --- app/reverse/bridge.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/reverse/bridge.go b/app/reverse/bridge.go index 50274548..9dc4a178 100644 --- a/app/reverse/bridge.go +++ b/app/reverse/bridge.go @@ -7,6 +7,7 @@ import ( "time" "github.com/golang/protobuf/proto" + "v2ray.com/core/common/buf" "v2ray.com/core/common/mux" "v2ray.com/core/common/net" "v2ray.com/core/common/session" @@ -119,6 +120,13 @@ func NewBridgeWorker(domain string, tag string, d routing.Dispatcher) (*BridgeWo 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) if err != nil { return nil, err