Skip to content

Commit

Permalink
Used ipAddress.IsLocalhost API to grant admin to local player
Browse files Browse the repository at this point in the history
Previously this only worked for 127.x.x.x range IPs but now also works for LAN ipv4 and ipv6 IPs.
  • Loading branch information
Measurity authored and Measurity committed Jul 2, 2023
1 parent 4959531 commit c2627f9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Numerics;
using NitroxModel.DataStructures;
using NitroxModel.DataStructures.GameLogic;
using NitroxModel.DataStructures.GameLogic.Entities;
using NitroxModel.DataStructures.Unity;
using NitroxModel.DataStructures.Util;
using NitroxModel.Helper;
using NitroxModel.MultiplayerSession;
using NitroxModel.Packets;
using NitroxServer.Communication.Packets.Processors.Abstract;
Expand Down Expand Up @@ -51,8 +50,9 @@ public override void Process(PlayerJoiningMultiplayerSession packet, NitroxConne
playerManager.SendPacketToOtherPlayers(playerJoinedPacket, player);

// Make players on localhost admin by default.
if (IPAddress.IsLoopback(connection.Endpoint.Address))
if (connection.Endpoint.Address.IsLocalhost())
{
Log.Info($"Granted admin to '{player.Name}' because they're playing on the host machine");
player.Permissions = Perms.ADMIN;
}

Expand Down

0 comments on commit c2627f9

Please sign in to comment.