From 0281902237df76442c24f3bd2cb9636fb6fe2370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E8=B5=B7?= <37897216+wikiZ@users.noreply.github.com> Date: Mon, 4 Jul 2022 11:20:23 +0800 Subject: [PATCH] Update ProxyHandler.go --- core/ProxyHandler.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/ProxyHandler.go b/core/ProxyHandler.go index 9af8cb7..c9dc54a 100644 --- a/core/ProxyHandler.go +++ b/core/ProxyHandler.go @@ -51,7 +51,7 @@ func modifyResponse(drop bool) func(*http.Response) error { logger.Warningf("[RESPONSE] HTTP %s, length: %d", resp.Status, resp.ContentLength) if drop { // DROP Request - logger.Alertf("[DROP] Source IP: %s", ip) + logger.Alertf("[DROP] Source IP: %s", req.RemoteAddr) _ = Body.Close() // Direct shutdown response return } @@ -79,10 +79,10 @@ func (h *baseHandle) ServeHTTP(write http.ResponseWriter, req *http.Request) { var proxy *httputil.ReverseProxy // Determine the URL to be redirected to redirectURL = lib.ReadConfig("proxy", "Redirect", cfg) - ip = lib.ConvertIP(req.RemoteAddr) + req.RemoteAddr = lib.ConvertIP(req.RemoteAddr) // Obtaining the real IP address if req.Header.Get("X-Forwarded-For") != "" { - ip = req.Header.Get("X-Forwarded-For") + req.RemoteAddr = req.Header.Get("X-Forwarded-For") } // Check whether the host is verified if IPHash := lib.EncodeMD5(req.JA3); arrays.ContainsString(_addressArray, req.JA3) == -1 { @@ -92,7 +92,7 @@ func (h *baseHandle) ServeHTTP(write http.ResponseWriter, req *http.Request) { if !ProxyFilterManger(req) { goto LOOK // Redirect to the specified site } - logger.Noticef("[REQUEST] %s - %s", ip, req.UserAgent()) + logger.Noticef("[REQUEST] %s - %s", req.RemoteAddr, req.UserAgent()) _addressArray = append(_addressArray, IPHash) // Add to the list after verification for the first time } // Fetch directly from cache @@ -137,7 +137,7 @@ LOOK: proxy.ServeHTTP(write, req) REDIRECT: // REDIRECT Request - logger.Alertf("[%s] Source IP: %s -> Destination Site: %s", strings.ToUpper(dropAction), ip, redirectURL) + logger.Alertf("[%s] Source IP: %s -> Destination Site: %s", strings.ToUpper(dropAction), req.RemoteAddr, redirectURL) } // ProxyManger Initialize the reverse proxy and pass in the address of the real back-end service