From b0c50fb8e5d48ec108b32299136792b98bee0efd Mon Sep 17 00:00:00 2001 From: mrsoong Date: Mon, 17 Jul 2023 15:06:58 -0400 Subject: [PATCH] Fixed localhost IP ban (#3183) --- controllers/admin/chat.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/controllers/admin/chat.go b/controllers/admin/chat.go index 86d7c8ace..bfb44ad97 100644 --- a/controllers/admin/chat.go +++ b/controllers/admin/chat.go @@ -164,12 +164,17 @@ func UpdateUserEnabled(w http.ResponseWriter, r *http.Request) { disconnectedUser := user.GetUserByID(request.UserID) _ = chat.SendSystemAction(fmt.Sprintf("**%s** has been removed from chat.", disconnectedUser.DisplayName), true) + localIP4Address := "127.0.0.1" + localIP6Address := "::1" + // Ban this user's IP address. for _, client := range clients { ipAddress := client.IPAddress - reason := fmt.Sprintf("Banning of %s", disconnectedUser.DisplayName) - if err := data.BanIPAddress(ipAddress, reason); err != nil { - log.Errorln("error banning IP address: ", err) + if ipAddress != localIP4Address && ipAddress != localIP6Address { + reason := fmt.Sprintf("Banning of %s", disconnectedUser.DisplayName) + if err := data.BanIPAddress(ipAddress, reason); err != nil { + log.Errorln("error banning IP address: ", err) + } } } }