From 385fed08de8bf633da762a64dd77de3e4fd62254 Mon Sep 17 00:00:00 2001 From: vcptr <51714622+vcptr@users.noreply.github.com> Date: Fri, 25 Oct 2019 18:00:01 +0800 Subject: [PATCH] fix: allow tls outbound http proxy outbound --- app/proxyman/outbound/handler.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 3f5e0ada..af82f3f0 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -13,6 +13,7 @@ import ( "v2ray.com/core/proxy" "v2ray.com/core/transport" "v2ray.com/core/transport/internet" + "v2ray.com/core/transport/internet/tls" "v2ray.com/core/transport/pipe" ) @@ -139,7 +140,14 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn downlinkReader, downlinkWriter := pipe.New(opts...) go handler.Dispatch(ctx, &transport.Link{Reader: uplinkReader, Writer: downlinkWriter}) - return net.NewConnection(net.ConnectionInputMulti(uplinkWriter), net.ConnectionOutputMulti(downlinkReader)), nil + conn := net.NewConnection(net.ConnectionInputMulti(uplinkWriter), net.ConnectionOutputMulti(downlinkReader)) + + if config := tls.ConfigFromStreamSettings(h.streamSettings); config != nil { + tlsConfig := config.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("h2")) + conn = tls.Client(conn, tlsConfig) + } + + return conn, nil } newError("failed to get outbound handler with tag: ", tag).AtWarning().WriteToLog(session.ExportIDToError(ctx))