]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Vote kicks now ban the target's ip (#35131)
authornikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com>
Thu, 13 Feb 2025 22:03:55 +0000 (14:03 -0800)
committerErrant <35878406+Errant-4@users.noreply.github.com>
Thu, 13 Feb 2025 22:08:27 +0000 (23:08 +0100)
* Make vote kicks ban the target's ip address

* Make it stop crashing my game

Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs

index 187295a0734ea1edad39e51abbfca2e069ee3fbf..89f4acdef1ec5fac0e8f83465b48424257eb046e 100644 (file)
@@ -1,4 +1,6 @@
 using System.Linq;
+using System.Net;
+using System.Net.Sockets;
 using Content.Server.Administration;
 using Content.Server.Administration.Managers;
 using Content.Server.Discord.WebhookMessages;
@@ -48,6 +50,8 @@ namespace Content.Server.Voting.Managers
             else
                 _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Initiated a {voteType.ToString()} vote");
 
+            _gameTicker = _entityManager.EntitySysManager.GetEntitySystem<GameTicker>();
+
             bool timeoutVote = true;
 
             switch (voteType)
@@ -68,7 +72,6 @@ namespace Content.Server.Voting.Managers
                 default:
                     throw new ArgumentOutOfRangeException(nameof(voteType), voteType, null);
             }
-            _gameTicker = _entityManager.EntitySysManager.GetEntitySystem<GameTicker>();
             _gameTicker.UpdateInfoText();
             if (timeoutVote)
                 TimeoutStandardVote(voteType);
@@ -368,6 +371,15 @@ namespace Content.Server.Voting.Managers
             }
             var targetUid = located.UserId;
             var targetHWid = located.LastHWId;
+            (IPAddress, int)? targetIP = null;
+
+            if (located.LastAddress is not null)
+            {
+                targetIP = located.LastAddress.AddressFamily is AddressFamily.InterNetwork
+                    ? (located.LastAddress, 32) // People with ipv4 addresses get a /32 address so we ban that
+                    : (located.LastAddress, 64); // This can only be an ipv6 address. People with ipv6 address should get /64 addresses so we ban that.
+            }
+
             if (!_playerManager.TryGetSessionById(located.UserId, out ICommonSession? targetSession))
             {
                 _logManager.GetSawmill("admin.votekick")
@@ -532,7 +544,7 @@ namespace Content.Server.Voting.Managers
 
                         uint minutes = (uint)_cfg.GetCVar(CCVars.VotekickBanDuration);
 
-                        _bans.CreateServerBan(targetUid, target, null, null, targetHWid, minutes, severity, reason);
+                        _bans.CreateServerBan(targetUid, target, null, targetIP, targetHWid, minutes, severity, reason);
                     }
                 }
                 else