From 944b118c622159c87e7f89c05892458d88797d58 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 24 Nov 2007 03:28:42 +0000 Subject: * Added a way for the Region master user to kick individual users from their sim with a custom message. Their client says, "You've been logged off of secondlife, and logs them off. * Added a way for the Region master user to kick *ALL* users from *ALL* their regions in the estate with a custom message. --- OpenSim/Framework/IClientAPI.cs | 4 ++ OpenSim/Region/ClientStack/ClientView.API.cs | 1 + .../ClientStack/ClientView.ProcessPackets.cs | 17 ++++-- OpenSim/Region/ClientStack/ClientView.cs | 13 ++++ OpenSim/Region/Environment/Scenes/Scene.cs | 69 +++++++++++++++++++++- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 13 ---- .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 5 ++ 7 files changed, 101 insertions(+), 21 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index f7e3521..3f0c87a 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -268,6 +268,8 @@ namespace OpenSim.Framework public delegate void AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape); public delegate void RequestGodlikePowers(LLUUID AgentID, LLUUID SessionID, LLUUID token, IClientAPI remote_client); + + public delegate void GodKickUser(LLUUID GodAgentID, LLUUID GodSessionID, LLUUID AgentID, uint kickflags, byte[] reason); public delegate void CreateInventoryFolder( IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID); @@ -333,6 +335,7 @@ namespace OpenSim.Framework event AddNewPrim OnAddPrim; event RequestGodlikePowers OnRequestGodlikePowers; + event GodKickUser OnGodKickUser; event ObjectDuplicate OnObjectDuplicate; event UpdateVector OnGrabObject; @@ -472,6 +475,7 @@ namespace OpenSim.Framework void SetDebug(int newDebug); void InPacket(Packet NewPack); void Close(); + void Kick(string message); void Stop(); event ViewerEffectEventHandler OnViewerEffect; event Action OnLogout; diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index b046f0a..80111d9 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -66,6 +66,7 @@ namespace OpenSim.Region.ClientStack public event MoveObject OnGrabUpdate; public event AddNewPrim OnAddPrim; public event RequestGodlikePowers OnRequestGodlikePowers; + public event GodKickUser OnGodKickUser; public event ObjectExtraParams OnUpdateExtraParams; public event UpdateShape OnUpdatePrimShape; public event ObjectSelect OnObjectSelect; diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index ca7ba7f..f46c199 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -1075,11 +1075,18 @@ namespace OpenSim.Region.ClientStack break; case PacketType.GodKickUser: - //GodKickUserPacket gkupack = (GodKickUserPacket) Pack; - //gkupack.UserInfo.GodID; - //gkupack.UserInfo.AgentID; - //gkupack.UserInfo.KickFlags; - //gkupack.UserInfo.Reason; + OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); + + GodKickUserPacket gkupack = (GodKickUserPacket) Pack; + + if (gkupack.UserInfo.GodSessionID == SessionId && this.AgentId == gkupack.UserInfo.GodID) + { + OnGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, gkupack.UserInfo.AgentID, (uint) 0, gkupack.UserInfo.Reason); + } + else + { + SendAgentAlertMessage("Kick request denied", false); + } //KickUserPacket kupack = new KickUserPacket(); //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index e6712fe..fbe66db 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -308,7 +308,20 @@ namespace OpenSim.Region.ClientStack ClientThread.Abort(); } + public void Kick(string message) + { + KickUserPacket kupack = new KickUserPacket(); + + kupack.UserInfo.AgentID = AgentId; + kupack.UserInfo.SessionID = SessionId; + + kupack.TargetBlock.TargetIP = (uint)0; + kupack.TargetBlock.TargetPort = (ushort)0; + kupack.UserInfo.Reason = Helpers.StringToField(message); + OutPacket(kupack, ThrottleOutPacketType.Task); + + } public void Stop() { clientPingTimer.Stop(); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 234b12a..0883e5c 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -257,9 +257,15 @@ namespace OpenSim.Region.Environment.Scenes { ForEachScenePresence(delegate(ScenePresence avatar) { - avatar.Kick("The region is going down."); - avatar.ControllingClient.Stop(); + avatar.ControllingClient.Kick("The region is going down."); + }); + ForEachScenePresence(delegate(ScenePresence avatar) + { + avatar.ControllingClient.Stop(); + + }); + m_heartbeatTimer.Close(); m_innerScene.Close(); @@ -831,6 +837,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); client.OnRequestGodlikePowers += handleRequestGodlikePowers; + client.OnGodKickUser += handleGodlikeKickUser; client.OnCreateNewInventoryItem += CreateNewInventoryItem; client.OnCreateNewInventoryFolder += CommsManager.UserProfileCache.HandleCreateInventoryFolder; @@ -883,8 +890,19 @@ namespace OpenSim.Region.Environment.Scenes m_eventManager.TriggerOnRemovePresence(agentID); ScenePresence avatar = GetScenePresence(agentID); + + Broadcast(delegate(IClientAPI client) { + try + { + client.SendKillObject(avatar.RegionHandle, avatar.LocalId); + } + catch (NullReferenceException NE) + { + //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. + + } + }); - Broadcast(delegate(IClientAPI client) { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); }); ForEachScenePresence( delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); @@ -1209,6 +1227,51 @@ namespace OpenSim.Region.Environment.Scenes } + public void handleGodlikeKickUser(LLUUID godid, LLUUID sessionid, LLUUID agentid, uint kickflags, byte[] reason) + { + // For some reason the client sends the seemingly hard coded, 44e87126e7944ded05b37c42da3d5cdb + // for kicking everyone. Dun-know. + if (m_scenePresences.ContainsKey(agentid) || agentid == new LLUUID("44e87126e7944ded05b37c42da3d5cdb")) + { + if (godid == RegionInfo.MasterAvatarAssignedUUID) + { + if (agentid == new LLUUID("44e87126e7944ded05b37c42da3d5cdb")) + { + + ClientManager.ForEachClient(delegate (IClientAPI controller) + { + if (controller.AgentId != godid) // Do we really want to kick the initiator of this madness? + { + controller.Kick(Helpers.FieldToUTF8String(reason)); + } + } + ); + // This is a bit crude. It seems the client will be null before it actually stops the thread + // The thread will kill itself eventually :/ + // Is there another way to make sure *all* clients get this 'inter region' message? + ClientManager.ForEachClient(delegate (IClientAPI controller) + { + if (controller.AgentId != godid) // Do we really want to kick the initiator of this madness? + { + controller.Close(); + } + } + ); + } + else + { + m_scenePresences[agentid].ControllingClient.Kick(Helpers.FieldToUTF8String(reason)); + m_scenePresences[agentid].ControllingClient.Close(); + } + } + else + { + if (m_scenePresences.ContainsKey(godid)) + m_scenePresences[godid].ControllingClient.SendAgentAlertMessage("Kick request denied", false); + } + } + } + public void SendAlertToUser(string firstName, string lastName, string message, bool modal) { foreach (ScenePresence presence in m_scenePresences.Values) diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index f91913d..6117828 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -1219,20 +1219,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion - public void Kick(string message) - { - KickUserPacket kupack = new KickUserPacket(); - KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; - - kupack.UserInfo.AgentID = UUID; - kupack.UserInfo.SessionID = this.ControllingClient.SessionId; - kupack.TargetBlock.TargetIP = (uint)0; - kupack.TargetBlock.TargetPort = (ushort)0; - kupack.UserInfo.Reason = Helpers.StringToField(message); - ControllingClient.OutPacket(kupack, ThrottleOutPacketType.Task); - - } public void GrantGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token) { GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket(); diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index b8800a8..550b232 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -76,6 +76,7 @@ namespace SimpleApp public event Action OnRequestAvatarsData; public event AddNewPrim OnAddPrim; public event RequestGodlikePowers OnRequestGodlikePowers; + public event GodKickUser OnGodKickUser; public event ObjectDuplicate OnObjectDuplicate; public event UpdateVector OnGrabObject; public event ObjectSelect OnDeGrabObject; @@ -181,6 +182,10 @@ namespace SimpleApp { } + public virtual void Kick(string message) + { + } + public virtual void SendStartPingCheck(byte seq) { } -- cgit v1.1