Fixed localhost IP ban (#3183)
This commit is contained in:
parent
4b1ad40cb0
commit
b0c50fb8e5
@ -164,12 +164,17 @@ func UpdateUserEnabled(w http.ResponseWriter, r *http.Request) {
|
|||||||
disconnectedUser := user.GetUserByID(request.UserID)
|
disconnectedUser := user.GetUserByID(request.UserID)
|
||||||
_ = chat.SendSystemAction(fmt.Sprintf("**%s** has been removed from chat.", disconnectedUser.DisplayName), true)
|
_ = 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.
|
// Ban this user's IP address.
|
||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
ipAddress := client.IPAddress
|
ipAddress := client.IPAddress
|
||||||
reason := fmt.Sprintf("Banning of %s", disconnectedUser.DisplayName)
|
if ipAddress != localIP4Address && ipAddress != localIP6Address {
|
||||||
if err := data.BanIPAddress(ipAddress, reason); err != nil {
|
reason := fmt.Sprintf("Banning of %s", disconnectedUser.DisplayName)
|
||||||
log.Errorln("error banning IP address: ", err)
|
if err := data.BanIPAddress(ipAddress, reason); err != nil {
|
||||||
|
log.Errorln("error banning IP address: ", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user