From accb09ef3404fcfbaab39e6b5f5970737117fa0e Mon Sep 17 00:00:00 2001 From: bboysoul <31786046+bboysoulcn@users.noreply.github.com> Date: Tue, 29 Jun 2021 12:28:22 +0800 Subject: [PATCH] Update https.go --- server/proxy/https.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/server/proxy/https.go b/server/proxy/https.go index a95783d..b7ea526 100644 --- a/server/proxy/https.go +++ b/server/proxy/https.go @@ -104,7 +104,7 @@ func (https *HttpsServer) NewHttps(l net.Listener, certFile string, keyFile stri func (https *HttpsServer) handleHttps(c net.Conn) { hostName, rb := GetServerNameFromClientHello(c) var targetAddr string - r := buildHttpsRequest(hostName) + r := buildMyHttpsRequest(hostName,c) var host *file.Host var err error if host, err = file.GetDb().GetInfoByHost(hostName, r); err != nil { @@ -125,7 +125,6 @@ func (https *HttpsServer) handleHttps(c net.Conn) { if targetAddr, err = host.Target.GetRandomTarget(); err != nil { logs.Warn(err.Error()) } - common.ChangeHostAndHeader(r, host.HostChange, host.HeaderChange, c.RemoteAddr().String(), https.addOrigin) logs.Trace("new https connection,clientId %d,host %s,remote address %s", host.Client.Id, r.Host, c.RemoteAddr().String()) https.DealClient(conn.NewConn(c), host.Client, targetAddr, rb, common.CONN_TCP, nil, host.Flow, host.Target.LocalProxy) } @@ -185,3 +184,16 @@ func buildHttpsRequest(hostName string) *http.Request { r.Host = hostName return r } + +func buildMyHttpsRequest(hostName string, c net.Conn) *http.Request { + r := new(http.Request) + r.RequestURI = "/" + r.URL = new(url.URL) + r.URL.Scheme = "https" + r.Host = hostName + logs.Trace("start add header") + r.Header.Set("X-Forwarded-For", '1.1.1.1') + r.Header.Set("X-Real-IP", '1.1.1.1') + return r +} +