From e16920be5f44fcce1b53967590f4e39e55532bf1 Mon Sep 17 00:00:00 2001 From: "Arthur K." Date: Tue, 27 Jan 2026 15:24:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B7=D0=B0:=20=D0=BE=D0=B3=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=87=D1=8C=D1=82=D0=B5=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=87=D0=B8=D1=82=D0=B0=D0=BD=D0=BD=D1=8B=D0=B9=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D1=80=20=D1=82=D0=B5=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/proxy/main.go b/proxy/main.go index 7d01449..5f3cb14 100644 --- a/proxy/main.go +++ b/proxy/main.go @@ -13,6 +13,8 @@ import ( "strings" ) +const MAX_SIZE = 2 ^ 16 // 65kb + func main() { proxy := &httputil.ReverseProxy{ Rewrite: func(r *httputil.ProxyRequest) { @@ -42,12 +44,12 @@ func main() { switch r.Header.Get("Content-Encoding") { case "gzip": reader, _ := gzip.NewReader(r.Body) - data, _ = io.ReadAll(reader) - r.Body.Close() + data, _ = io.ReadAll(io.LimitReader(reader, MAX_SIZE)) + reader.Close() default: - data, _ = io.ReadAll(r.Body) - r.Body.Close() + data, _ = io.ReadAll(io.LimitReader(r.Body, MAX_SIZE)) } + r.Body.Close() // Rewrite 30x redirect location locHeader := r.Header.Get("Location")