Example #1
0
        private static void HandleClientUpdate(ClientStatusUpdate <Client> clientStatus)
        {
            Client     clientObject = clientStatus.ClientObject;
            Connection connection   = GetConnection(clientObject);

            if (connection == null)
            {
                ConsoleSystem.LogError(string.Concat("EAC status update for invalid client: ", clientObject.ClientID));
            }
            else if (!ShouldIgnore(connection))
            {
                if (clientStatus.RequiresKick)
                {
                }
                else if (clientStatus.Status == ClientStatus.ClientAuthenticatedLocal)
                {
                    OnAuthenticatedLocal(connection);
                    easyAntiCheat.SetClientNetworkState(clientObject, false);
                }
                else if (clientStatus.Status == ClientStatus.ClientAuthenticatedRemote)
                {
                    OnAuthenticatedRemote(connection);
                }
                OnAuthenticatedLocal(connection);
                easyAntiCheat.SetClientNetworkState(clientObject, false);
            }
        }
Example #2
0
        public GeneralResponse UpdateClientStatus(int id, ClientStatusUpdate statusUpdate)
        {
            var client = GetOne <Client>(filter: x => x.Id == id,
                                         includeProperties: $"{nameof(User)},{nameof(Client.JobPostings)}");
            var response = new GeneralResponse();

            if (client == null)
            {
                response.Errors["Error"].Add(ErrorConstants.NullValue);
            }
            else
            {
                bool statusParse = Enum.TryParse(statusUpdate.Status, out ClientStatus statusToUpdate);

                if (statusParse)
                {
                    client.Status = statusToUpdate;
                    try
                    {
                        Update(client, RoleConstants.ADMIN);
                        response.Succeeded = true;
                    }catch (Exception e)
                    {
                        _logger.LogError(e.Message, client);
                        response.Errors["Error"].Add(e.Message);
                    }
                }
            }
            return(response);
        }
Example #3
0
 private static void HandleClientUpdate(ClientStatusUpdate <EasyAntiCheat.Server.Hydra.Client> clientStatus)
 {
     using (TimeWarning.New("AntiCheatKickPlayer", 10L))
     {
         EasyAntiCheat.Server.Hydra.Client client = clientStatus.get_Client();
         Connection connection = EACServer.GetConnection(client);
         if (connection == null)
         {
             Debug.LogError((object)("EAC status update for invalid client: " + (object)((EasyAntiCheat.Server.Hydra.Client) ref client).get_ClientID()));
         }
         else
         {
             if (EACServer.ShouldIgnore(connection))
             {
                 return;
             }
             if (clientStatus.get_RequiresKick())
             {
                 string message = clientStatus.get_Message();
                 if (string.IsNullOrEmpty(message))
                 {
                     message = clientStatus.get_Status().ToString();
                 }
                 Debug.Log((object)("[EAC] Kicking " + (object)(ulong)connection.userid + " (" + message + ")"));
                 connection.authStatus = (__Null)"eac";
                 ((Network.Server)Net.sv).Kick(connection, "EAC: " + message);
                 DateTime?nullable = new DateTime?();
                 if (clientStatus.IsBanned(ref nullable))
                 {
                     connection.authStatus = (__Null)"eacbanned";
                     Interface.CallHook("OnPlayerBanned", (object)connection, (object)connection.authStatus);
                     ConsoleNetwork.BroadcastToAllClients("chat.add", (object)0, (object)("<color=#fff>SERVER</color> Kicking " + (string)connection.username + " (banned by anticheat)"));
                     if (!nullable.HasValue)
                     {
                         Entity.DeleteBy((ulong)connection.userid);
                     }
                 }
                 EACServer.easyAntiCheat.UnregisterClient(client);
                 EACServer.client2connection.Remove(client);
                 EACServer.connection2client.Remove(connection);
                 EACServer.connection2status.Remove(connection);
             }
             else if (clientStatus.get_Status() == 2)
             {
                 EACServer.OnAuthenticatedLocal(connection);
                 EACServer.easyAntiCheat.SetClientNetworkState(client, false);
             }
             else
             {
                 if (clientStatus.get_Status() != 5)
                 {
                     return;
                 }
                 EACServer.OnAuthenticatedRemote(connection);
             }
         }
     }
 }
Example #4
0
        public void SendStartRequest()
        {
            ClientStatusUpdate update = new ClientStatusUpdate(ClientUpdate.Ready);

            SendResponse(update);

            // Update status display
            Deployment.Current.Dispatcher.BeginInvoke(() => _mainState.DisplayStatusMessage("Waiting for players to be ready...\nYou are ready."));
        }
        public IActionResult UpdateClientStatus(int id, ClientStatusUpdate statusUpdate)
        {
            var result = _clientManager.UpdateClientStatus(id, statusUpdate);

            if (result.Succeeded)
            {
                return(Ok(result));
            }
            else
            {
                return(BadRequest(result));
            }
        }
 private static void HandleClientUpdate(ClientStatusUpdate <EasyAntiCheat.Server.Hydra.Client> clientStatus)
 {
     using (TimeWarning timeWarning = TimeWarning.New("AntiCheatKickPlayer", (long)10))
     {
         EasyAntiCheat.Server.Hydra.Client client = clientStatus.Client;
         Connection connection = EACServer.GetConnection(client);
         if (connection == null)
         {
             Debug.LogError(string.Concat("EAC status update for invalid client: ", client.ClientID));
         }
         else if (!EACServer.ShouldIgnore(connection))
         {
             if (clientStatus.RequiresKick)
             {
                 string message = clientStatus.Message;
                 if (string.IsNullOrEmpty(message))
                 {
                     message = clientStatus.Status.ToString();
                 }
                 Debug.Log(string.Concat(new object[] { "[EAC] Kicking ", connection.userid, " (", message, ")" }));
                 connection.authStatus = "eac";
                 Network.Net.sv.Kick(connection, string.Concat("EAC: ", message));
                 DateTime?nullable = null;
                 if (clientStatus.IsBanned(out nullable))
                 {
                     connection.authStatus = "eacbanned";
                     Interface.CallHook("OnPlayerBanned", connection, connection.authStatus);
                     ConsoleNetwork.BroadcastToAllClients("chat.add", new object[] { 0, string.Concat("<color=#fff>SERVER</color> Kicking ", connection.username, " (banned by anticheat)") });
                     if (!nullable.HasValue)
                     {
                         Entity.DeleteBy(connection.userid);
                     }
                 }
                 EACServer.easyAntiCheat.UnregisterClient(client);
                 EACServer.client2connection.Remove(client);
                 EACServer.connection2client.Remove(connection);
                 EACServer.connection2status.Remove(connection);
             }
             else if (clientStatus.Status == ClientStatus.ClientAuthenticatedLocal)
             {
                 EACServer.OnAuthenticatedLocal(connection);
                 EACServer.easyAntiCheat.SetClientNetworkState(client, false);
             }
             else if (clientStatus.Status == ClientStatus.ClientAuthenticatedRemote)
             {
                 EACServer.OnAuthenticatedRemote(connection);
             }
         }
     }
 }
Example #7
0
        private void ClientDataReceived(Client client, IClientUpdate update)
        {
            // Don't process input from dead players
            if (client.LocalPlayer.Dead)
            {
                return;
            }

            if (update is ClientPositionUpdate)
            {
                ClientPositionUpdate posUpdate = (ClientPositionUpdate)update;

                client.LocalPlayer.X         = posUpdate.X;
                client.LocalPlayer.Y         = posUpdate.Y;
                client.LocalPlayer.Direction = posUpdate.Direction;
                client.LocalPlayer.Moving    = posUpdate.Moving;
            }
            else if (update is ClientBombSet)
            {
                SetBomb(client, (ClientBombSet)update);
            }
            else if (update is ClientStatusUpdate)
            {
                ClientStatusUpdate statusUpdate = (ClientStatusUpdate)update;

                if (statusUpdate.Update == ClientUpdate.BombTrigger && client.LocalPlayer.ManualTrigger)
                {
                    lock (_bombs)
                    {
                        _bombs.ForEach(bomb =>
                        {
                            if (bomb.OwnerColor == client.LocalPlayer.Color)
                            {
                                bomb.Trigger();
                            }
                        });
                    }
                }
            }
        }
Example #8
0
        private IClientUpdate GetUpdate(byte[] buffer, int offset, int length)
        {
            MemoryStream ms = new MemoryStream(buffer, offset, length);

            ClientMessageTypes msgType = (ClientMessageTypes)ms.ReadByte();

            switch (msgType)
            {
            case ClientMessageTypes.StatusUpdate:
                ClientStatusUpdate statusUpdate = Serializer.DeserializeWithLengthPrefix <ClientStatusUpdate>(ms, PrefixStyle.Base128);
                return(statusUpdate);

            case ClientMessageTypes.PositionUpdate:
                ClientPositionUpdate positionUpdate = Serializer.DeserializeWithLengthPrefix <ClientPositionUpdate>(ms, PrefixStyle.Base128);
                return(positionUpdate);

            case ClientMessageTypes.BombSet:
                ClientBombSet bombSetUpdate = Serializer.DeserializeWithLengthPrefix <ClientBombSet>(ms, PrefixStyle.Base128);
                return(bombSetUpdate);
            }

            return(null);
        }
Example #9
0
        public void SendTriggerCommand()
        {
            ClientStatusUpdate update = new ClientStatusUpdate(ClientUpdate.BombTrigger);

            SendResponse(update);
        }
Example #10
0
 private static void HandleClientUpdate(ClientStatusUpdate <EasyAntiCheat.Server.Hydra.Client> clientStatus)
 {
     using (TimeWarning.New("AntiCheatKickPlayer", 10))
     {
         EasyAntiCheat.Server.Hydra.Client client = clientStatus.Client;
         Connection connection = GetConnection(client);
         if (connection == null)
         {
             Debug.LogError("EAC status update for invalid client: " + client.ClientID);
         }
         else
         {
             if (ShouldIgnore(connection))
             {
                 return;
             }
             if (clientStatus.RequiresKick)
             {
                 string text = clientStatus.Message;
                 if (string.IsNullOrEmpty(text))
                 {
                     text = clientStatus.Status.ToString();
                 }
                 Debug.Log($"[EAC] Kicking {connection.userid} / {connection.username} ({text})");
                 connection.authStatus = "eac";
                 Network.Net.sv.Kick(connection, "EAC: " + text);
                 Interface.CallHook("OnPlayerKicked", connection, text);
                 DateTime?timeBanExpires;
                 if (clientStatus.IsBanned(out timeBanExpires))
                 {
                     connection.authStatus = "eacbanned";
                     object[] args = new object[3]
                     {
                         2,
                         0,
                         "<color=#fff>SERVER</color> Kicking " + connection.username + " (banned by anticheat)"
                     };
                     Interface.CallHook("OnPlayerBanned", connection, text);
                     ConsoleNetwork.BroadcastToAllClients("chat.add", args);
                     if (!timeBanExpires.HasValue)
                     {
                         Entity.DeleteBy(connection.userid);
                     }
                 }
                 easyAntiCheat.UnregisterClient(client);
                 client2connection.Remove(client);
                 connection2client.Remove(connection);
                 connection2status.Remove(connection);
             }
             else if (clientStatus.Status == ClientStatus.ClientAuthenticatedLocal)
             {
                 OnAuthenticatedLocal(connection);
                 easyAntiCheat.SetClientNetworkState(client, false);
             }
             else if (clientStatus.Status == ClientStatus.ClientAuthenticatedRemote)
             {
                 OnAuthenticatedRemote(connection);
             }
             return;
         }
     }
 }