private void PacketDispatcher_RequestPacketPunkbusterRecieved(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (packet.Words.Count >= 2) { bool blCommandProcessed = false; if (this.Privileges.CannotIssuePunkbusterCommands == true) { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); blCommandProcessed = true; } else { Match mtcMatch = Regex.Match(packet.Words[1], "^(?=(?<pb_sv_command>pb_sv_plist))|(?=(?<pb_sv_command>pb_sv_ban))|(?=(?<pb_sv_command>pb_sv_banguid))|(?=(?<pb_sv_command>pb_sv_banlist))|(?=(?<pb_sv_command>pb_sv_getss))|(?=(?<pb_sv_command>pb_sv_kick)[ ]+?.*?[ ]+?(?<pb_sv_kick_time>[0-9]+)[ ]+)|(?=(?<pb_sv_command>pb_sv_unban))|(?=(?<pb_sv_command>pb_sv_unbanguid))|(?=(?<pb_sv_command>pb_sv_reban))", RegexOptions.IgnoreCase); // IF they tried to issue a pb_sv_command that isn't on the safe list AND they don't have full access. if (mtcMatch.Success == false && this.Privileges.CanIssueAllPunkbusterCommands == false) { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); blCommandProcessed = true; } else { if (this.Privileges.CanPermanentlyBanPlayers == false && (System.String.Compare(mtcMatch.Groups["pb_sv_command"].Value, "pb_sv_ban", System.StringComparison.OrdinalIgnoreCase) == 0 || System.String.Compare(mtcMatch.Groups["pb_sv_command"].Value, "pb_sv_banguid", System.StringComparison.OrdinalIgnoreCase) == 0 || System.String.Compare(mtcMatch.Groups["pb_sv_command"].Value, "pb_sv_reban", System.StringComparison.OrdinalIgnoreCase) == 0)) { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); blCommandProcessed = true; } else if (this.Privileges.CanEditBanList == false && (System.String.Compare(mtcMatch.Groups["pb_sv_command"].Value, "pb_sv_unban", System.StringComparison.OrdinalIgnoreCase) == 0 || System.String.Compare(mtcMatch.Groups["pb_sv_command"].Value, "pb_sv_unbanguid", System.StringComparison.OrdinalIgnoreCase) == 0)) { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); blCommandProcessed = true; } else if (System.String.Compare(mtcMatch.Groups["pb_sv_command"].Value, "pb_sv_kick", System.StringComparison.OrdinalIgnoreCase) == 0) { int iBanLength = 0; // NOTE* Punkbuster uses minutes not seconds. if (int.TryParse(mtcMatch.Groups["pb_sv_kick_time"].Value, out iBanLength) == true) { // If they cannot punish players at all.. if (this.Privileges.CannotPunishPlayers == true) { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); blCommandProcessed = true; } // If they can temporary ban but not permanently ban BUT the banlength is over an hour (default) else if (this.Privileges.CanTemporaryBanPlayers == true && this.Privileges.CanPermanentlyBanPlayers == false && iBanLength > (this.Client.Variables.GetVariable("TEMP_BAN_CEILING", 3600) / 60)) { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); blCommandProcessed = true; } // If they can kick but not temp or perm ban players AND the banlength is over 0 (no ban time) else if (this.Privileges.CanKickPlayers == true && this.Privileges.CanTemporaryBanPlayers == false && this.Privileges.CanPermanentlyBanPlayers == false && iBanLength > 0) { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); blCommandProcessed = true; } // ELSE they have punkbuster access and full ban privs.. issue the command. } else { // Would rather stop it here than pass it on sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); blCommandProcessed = true; } } // ELSE they have permission to issue this command (full or partial) } } // Was not denied above, send it on to the PacketDispatcher server. if (blCommandProcessed == false) { this.Client.SendProconLayerPacket(this, packet); } } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconPluginEnableRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueLimitedProconPluginCommands == true) { bool blEnabled = false; if (packet.Words.Count >= 3 && bool.TryParse(packet.Words[2], out blEnabled) == true) { sender.SendResponse(packet, LayerClient.ResponseOk); if (blEnabled == true) { this.Client.PluginsManager.EnablePlugin(packet.Words[1]); } else { this.Client.PluginsManager.DisablePlugin(packet.Words[1]); } } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconAdminYellRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (packet.Words.Count >= 5) { // Append the admin to the adminstack and send it on its way.. if (packet.Words[1].Length > 0) { packet.Words[1] = String.Format("{0}|{1}", packet.Words[1], CPluginVariable.Encode(this.Username)); } else { packet.Words[1] = CPluginVariable.Encode(this.Username); } sender.SendResponse(packet, LayerClient.ResponseOk); this.Client.SendProconLayerPacket(this, packet); } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconBattlemapListZonesRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { List<String> listPacket = new List<String> { LayerClient.ResponseOk, this.Client.MapGeometry.MapZones.Count.ToString(CultureInfo.InvariantCulture) }; foreach (MapZoneDrawing zone in this.Client.MapGeometry.MapZones) { listPacket.Add(zone.UID); listPacket.Add(zone.LevelFileName); listPacket.Add(zone.Tags.ToString()); listPacket.Add(zone.ZonePolygon.Length.ToString(CultureInfo.InvariantCulture)); listPacket.AddRange(Point3D.ToStringList(zone.ZonePolygon)); } sender.SendResponse(packet, listPacket); } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconPluginListLoadedRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueLimitedProconPluginCommands == true) { if (packet.Words.Count == 1) { List<String> lstLoadedPlugins = this.GetListLoadedPlugins(); lstLoadedPlugins.Insert(0, LayerClient.ResponseOk); sender.SendResponse(packet, lstLoadedPlugins); } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconAccountSetPasswordRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueLimitedProconCommands == true) { if (packet.Words.Count >= 3 && packet.Words[2].Length > 0) { if (this.Application.AccountsList.Contains(packet.Words[1]) == true) { sender.SendResponse(packet, LayerClient.ResponseOk); this.Application.AccountsList[packet.Words[1]].Password = packet.Words[2]; } else { sender.SendResponse(packet, "AccountDoesNotExists"); } } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconBattlemapModifyZoneTagsRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanEditMapZones == true) { if (packet.Words.Count >= 3) { if (this.Client.MapGeometry.MapZones.Contains(packet.Words[1]) == true) { this.Client.MapGeometry.MapZones[packet.Words[1]].Tags.FromString(packet.Words[2]); } sender.SendResponse(packet, LayerClient.ResponseOk); } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconLoginUsernameRequest(ILayerPacketDispatcher sender, Packet packet) { this.Username = packet.Words[1]; // We send back any errors in the login process after they attempt to login. if (this.Application.AccountsList.Contains(this.Username) == true) { this.Privileges = this.GetAccountPrivileges(this.Username); this.Privileges.SetLowestPrivileges(this.Client.Privileges); sender.SendResponse(packet, this.Privileges.CanLogin == true ? LayerClient.ResponseOk : LayerClient.ResponseInsufficientPrivileges); } else { sender.SendResponse(packet, LayerClient.ResponseInvalidUsername); } }
private void DispatchProconRegisterUidRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { bool blEnabled = true; if (bool.TryParse(packet.Words[1], out blEnabled) == true) { if (blEnabled == false) { sender.SendResponse(packet, LayerClient.ResponseOk); this.ProconEventsUid = String.Empty; } else if (packet.Words.Count >= 3) { if (this.Layer.Clients.Any(client => client.Value.ProconEventsUid == packet.Words[2]) == false) { sender.SendResponse(packet, LayerClient.ResponseOk); this.ProconEventsUid = packet.Words[2]; var handler = this.UidRegistered; if (handler != null) { handler(this); } } else { sender.SendResponse(packet, "ProconUidConflict"); } } } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void PacketDispatcher_RequestPacketSquadIsPrivateReceived(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanMovePlayers == true) { this.Client.SendProconLayerPacket(this, packet); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
// DispatchProconApplicationShutdownRequest private void DispatchProconApplicationShutdownRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanShutdownServer == true) { sender.SendResponse(packet, LayerClient.ResponseOk, "but nothing will happen"); // shutdowns only the connection not the whole procon... this.m_praApplication.Shutdown(); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void PacketDispatcher_RequestPacketVarsRecieved(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanAlterServerSettings == true) { this.Client.SendProconLayerPacket(this, packet); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void PacketDispatcher_RequestPacketAlterTextMonderationListRecieved(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanEditTextChatModerationList == true) { this.Client.SendProconLayerPacket(this, packet); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void PacketDispatcher_RequestBanListAddRecieved(ILayerPacketDispatcher sender, Packet packet, CBanInfo newBan) { if (this.IsLoggedIn == true) { if (newBan.BanLength.Subset == TimeoutSubset.TimeoutSubsetType.Permanent && this.Privileges.CanPermanentlyBanPlayers == true) { this.Client.SendProconLayerPacket(this, packet); } else if (newBan.BanLength.Subset == TimeoutSubset.TimeoutSubsetType.Round && this.Privileges.CanTemporaryBanPlayers == true) { this.Client.SendProconLayerPacket(this, packet); } else if (newBan.BanLength.Subset == TimeoutSubset.TimeoutSubsetType.Seconds && this.Privileges.CanPermanentlyBanPlayers == true) { this.Client.SendProconLayerPacket(this, packet); } else if (newBan.BanLength.Subset == TimeoutSubset.TimeoutSubsetType.Seconds && this.Privileges.CanTemporaryBanPlayers == true) { if (newBan.BanLength.Seconds <= this.Client.Variables.GetVariable("TEMP_BAN_CEILING", 3600)) { this.Client.SendProconLayerPacket(this, packet); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconAccountCreateRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueLimitedProconCommands == true) { if (this.Application.AccountsList.Contains(packet.Words[1]) == false) { if (packet.Words[2].Length > 0) { sender.SendResponse(packet, LayerClient.ResponseOk); this.Application.AccountsList.CreateAccount(packet.Words[1], packet.Words[2]); //this.m_uscParent.LayerCreateAccount( } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, "AccountAlreadyExists"); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconVersionRequest(ILayerPacketDispatcher sender, Packet packet) { sender.SendResponse(packet, LayerClient.ResponseOk, Assembly.GetExecutingAssembly().GetName().Version.ToString()); }
private void DispatchProconAccountDeleteRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueLimitedProconCommands == true) { if (packet.Words.Count >= 2) { if (this.Application.AccountsList.Contains(packet.Words[1]) == true) { sender.SendResponse(packet, LayerClient.ResponseOk); this.Application.AccountsList.Remove(packet.Words[1]); //this.m_uscParent.LayerDeleteAccount(cpPacket.Words[1]); } else { sender.SendResponse(packet, "AccountDoesNotExists"); } } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconVarsRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (packet.Words.Count == 2) { sender.SendResponse(packet, LayerClient.ResponseOk, packet.Words[1], this.Client.Variables.GetVariable(packet.Words[1], "")); } else if (packet.Words.Count > 2) { if (this.Privileges.CanIssueLimitedProconCommands == true) { this.Client.Variables.SetVariable(packet.Words[1], packet.Words[2]); sender.SendResponse(packet, LayerClient.ResponseOk, packet.Words[1], this.Client.Variables.GetVariable(packet.Words[1], "")); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconBattlemapDeleteZoneRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanEditMapZones == true) { if (this.Client.MapGeometry.MapZones.Contains(packet.Words[1]) == true) { this.Client.MapGeometry.MapZones.Remove(packet.Words[1]); } sender.SendResponse(packet, LayerClient.ResponseOk); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconPrivilegesRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { sender.SendResponse(packet, LayerClient.ResponseOk, this.Privileges.PrivilegesFlags.ToString(CultureInfo.InvariantCulture)); } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconBattlemapModifyZonePointsRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanEditMapZones == true) { if (packet.Words.Count >= 3) { int iPoints = 0; if (int.TryParse(packet.Words[2], out iPoints) == true) { Point3D[] points = new Point3D[iPoints]; for (int i = 0; i < iPoints && i + 3 < packet.Words.Count; i++) { points[i] = new Point3D(packet.Words[2 + i * 3 + 1], packet.Words[2 + i * 3 + 2], packet.Words[2 + i * 3 + 3]); } if (this.Client.MapGeometry.MapZones.Contains(packet.Words[1]) == true) { this.Client.MapGeometry.MapZones.ModifyMapZonePoints(packet.Words[1], points); } } sender.SendResponse(packet, LayerClient.ResponseOk); } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconCompressionRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { bool enableCompress = false; if (packet.Words.Count == 2 && bool.TryParse(packet.Words[1], out enableCompress) == true) { this.GzipCompression = enableCompress; sender.SendResponse(packet, LayerClient.ResponseOk); } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconLayerSetPrivilegesRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueLimitedProconCommands == true) { UInt32 ui32Privileges = 0; if (packet.Words.Count >= 3 && UInt32.TryParse(packet.Words[2], out ui32Privileges) == true) { if (this.Application.AccountsList.Contains(packet.Words[1]) == true) { CPrivileges sprvPrivs = new CPrivileges(); sender.SendResponse(packet, LayerClient.ResponseOk); sprvPrivs.PrivilegesFlags = ui32Privileges; this.Layer.AccountPrivileges[packet.Words[1]].SetPrivileges(sprvPrivs); } else { sender.SendResponse(packet, "AccountDoesNotExists"); } } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconExecRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueAllProconCommands == true) { sender.SendResponse(packet, LayerClient.ResponseOk); packet.Words.RemoveAt(0); this.Application.ExecutePRoConCommand(this.Client, packet.Words, 0); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconPluginListEnabledRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueLimitedProconPluginCommands == true) { List<String> lstEnabledPlugins = this.Client.PluginsManager.Plugins.EnabledClassNames; lstEnabledPlugins.Insert(0, LayerClient.ResponseOk); sender.SendResponse(packet, lstEnabledPlugins); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconAccountListAccountsRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueLimitedProconCommands == true) { List<String> lstAccounts = new List<String> { LayerClient.ResponseOk }; foreach (String strAccountName in this.Application.AccountsList.ListAccountNames()) { if (this.Layer.AccountPrivileges.Contains(strAccountName) == true) { lstAccounts.Add(strAccountName); lstAccounts.Add(this.Layer.AccountPrivileges[strAccountName].Privileges.PrivilegesFlags.ToString(CultureInfo.InvariantCulture)); } } sender.SendResponse(packet, lstAccounts); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconPluginSetVariableRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { if (this.Privileges.CanIssueLimitedProconPluginCommands == true) { if (packet.Words.Count >= 4) { sender.SendResponse(packet, LayerClient.ResponseOk); this.Client.PluginsManager.SetPluginVariable(packet.Words[1], packet.Words[2], packet.Words[3]); } else { sender.SendResponse(packet, LayerClient.ResponseInvalidArguments); } } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void DispatchProconAccountListLoggedInRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.Privileges.CanIssueLimitedProconCommands == true) { List<String> lstLoggedInAccounts = this.Layer.GetLoggedInAccountUsernamesWithUids((packet.Words.Count >= 2 && String.CompareOrdinal(packet.Words[1], "uids") == 0)); //List<String> lstLoggedInAccounts = this.m_prcClient.Layer.GetLoggedInAccounts(); lstLoggedInAccounts.Insert(0, LayerClient.ResponseOk); sender.SendResponse(packet, lstLoggedInAccounts); } else { sender.SendResponse(packet, LayerClient.ResponseInsufficientPrivileges); } }
private void DispatchProconPlayerSyncPlayTimesRequest(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { List<String> lstPlayerJoinTimes = new List<String> { LayerClient.ResponseOk }; foreach ( CPlayerInfo player in Client.PlayerList) { lstPlayerJoinTimes.Add(player.SoldierName); lstPlayerJoinTimes.Add(player.JoinTime.ToString()); } sender.SendResponse(packet, lstPlayerJoinTimes); } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }
private void PacketDispatcher_RequestPacketSecureSafeListedRecieved(ILayerPacketDispatcher sender, Packet packet) { if (this.IsLoggedIn == true) { this.Client.SendProconLayerPacket(this, packet); } else { sender.SendResponse(packet, LayerClient.ResponseLoginRequired); } }