From 7a5ccff6da0957f38dbde2c66c899da455a735a4 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 7 Sep 2023 16:36:47 +0200 Subject: [PATCH] fix: Remove port before IP check --- internal/api/rest.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/api/rest.go b/internal/api/rest.go index 1cb2cac..11682ee 100644 --- a/internal/api/rest.go +++ b/internal/api/rest.go @@ -210,6 +210,10 @@ func securedCheck(r *http.Request) error { IPAddress = r.RemoteAddr } + if strings.Contains(IPAddress, ":") { + IPAddress = strings.Split(IPAddress, ":")[0] + } + // check if IP is allowed if !util.Contains(config.Keys.ApiAllowedIPs, IPAddress) { return fmt.Errorf("unknown ip: %v", IPAddress)