Megapatch. Completely remove the multiparameter IM methods. Remove the insecure

fromAgentSession field.
0.6.1-post-fixes
Melanie Thielker 2008-11-16 22:04:01 +00:00
parent 78d42a7fc8
commit 5e2e05a1c1
11 changed files with 135 additions and 171 deletions

View File

@ -35,7 +35,6 @@ namespace OpenSim.Framework
{
public Guid fromAgentID;
public string fromAgentName;
public Guid fromAgentSession;
public Guid toAgentID;
public byte dialog;
public bool fromGroup;
@ -56,14 +55,13 @@ namespace OpenSim.Framework
}
public GridInstantMessage(IScene scene, UUID _fromAgentID,
string _fromAgentName, UUID _fromAgentSession, UUID _toAgentID,
string _fromAgentName, UUID _toAgentID,
byte _dialog, bool _fromGroup, string _message,
UUID _imSessionID, bool _offline, Vector3 _position,
byte[] _binaryBucket)
{
fromAgentID = _fromAgentID.Guid;
fromAgentName = _fromAgentName;
fromAgentSession = _fromAgentSession.Guid;
toAgentID = _toAgentID.Guid;
dialog = _dialog;
fromGroup = _fromGroup;
@ -88,7 +86,7 @@ namespace OpenSim.Framework
string _fromAgentName, UUID _toAgentID, byte _dialog,
string _message, bool _offline,
Vector3 _position) : this(scene, _fromAgentID, _fromAgentName,
UUID.Zero, _toAgentID, _dialog, false, _message,
_toAgentID, _dialog, false, _message,
_fromAgentID ^ _toAgentID, _offline, _position, new byte[0])
{
}

View File

@ -46,12 +46,7 @@ namespace OpenSim.Framework
public delegate void AvatarNowWearing(Object sender, AvatarWearingArgs e);
public delegate void ImprovedInstantMessage(IClientAPI remoteclient,
UUID fromAgentID, UUID fromAgentSession, UUID toAgentID,
UUID imSessionID, uint timestamp,
string fromAgentName, string message, byte dialog, bool fromGroup,
byte offline, uint ParentEstateID,
Vector3 Position, UUID RegionID, byte[] binaryBucket);
public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im);
// This shouldn't be cut down...
// especially if we're ever going to implement groups, presence, estate message dialogs...

View File

@ -4030,13 +4030,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (handlerInstantMessage != null)
{
handlerInstantMessage(this, msgpack.AgentData.AgentID, msgpack.AgentData.SessionID,
msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID,
msgpack.MessageBlock.Timestamp, IMfromName, IMmessage,
msgpack.MessageBlock.Dialog, msgpack.MessageBlock.FromGroup,
msgpack.MessageBlock.Offline, msgpack.MessageBlock.ParentEstateID,
msgpack.MessageBlock.Position, msgpack.MessageBlock.RegionID,
msgpack.MessageBlock.BinaryBucket);
GridInstantMessage im = new GridInstantMessage(Scene,
msgpack.AgentData.AgentID,
IMfromName,
msgpack.MessageBlock.ToAgentID,
msgpack.MessageBlock.Dialog,
msgpack.MessageBlock.FromGroup,
IMmessage,
msgpack.MessageBlock.ID,
msgpack.MessageBlock.Offline != 0 ? true : false,
msgpack.MessageBlock.Position,
msgpack.MessageBlock.BinaryBucket);
handlerInstantMessage(this, im);
}
break;

View File

@ -263,7 +263,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
// to a user to 'add a friend' without causing dialog box spam
// Subscribe to instant messages
client.OnInstantMessage += OnInstantMessage;
// client.OnInstantMessage += OnInstantMessage;
// Friend list management
client.OnApproveFriendRequest += OnApproveFriendRequest;
@ -370,7 +370,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
#region FriendRequestHandling
private void OnInstantMessage(IClientAPI client, UUID fromAgentID,
UUID fromAgentSession, UUID toAgentID,
UUID toAgentID,
UUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog, bool fromGroup, byte offline,
uint ParentEstateID, Vector3 Position, UUID RegionID,
@ -393,86 +393,65 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
// some properties are misused here:
// fromAgentName is the *destination* name (the friend we offer friendship to)
if (fromAgentSession != UUID.Zero)
// (1)
// send the friendship-offer to the target
m_log.InfoFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}",
fromAgentID, fromAgentName, toAgentID, imSessionID, message, offline);
UUID transactionID = UUID.Random();
// 1.20 protocol sends an UUID in the message field, instead of the friendship offer text.
// For interoperability, we have to clear that
if (Util.isUUID(message)) message = "";
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = fromAgentID.Guid;
msg.toAgentID = toAgentID.Guid;
msg.imSessionID = transactionID.Guid; // Start new transaction
m_log.DebugFormat("[FRIEND]: new transactionID: {0}", msg.imSessionID);
msg.timestamp = timestamp;
if (client != null)
{
// (1)
// send the friendship-offer to the target
m_log.InfoFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}",
fromAgentID, fromAgentName, toAgentID, imSessionID, message, offline);
UUID transactionID = UUID.Random();
// 1.20 protocol sends an UUID in the message field, instead of the friendship offer text.
// For interoperability, we have to clear that
if (Util.isUUID(message)) message = "";
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = fromAgentID.Guid;
msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session
msg.toAgentID = toAgentID.Guid;
msg.imSessionID = transactionID.Guid; // Start new transaction
m_log.DebugFormat("[FRIEND]: new transactionID: {0}", msg.imSessionID);
msg.timestamp = timestamp;
if (client != null)
{
msg.fromAgentName = client.Name; // fromAgentName;
}
else
{
msg.fromAgentName = "(hippos)"; // Added for posterity. This means that we can't figure out who sent it
}
msg.message = message;
msg.dialog = dialog;
msg.fromGroup = fromGroup;
msg.offline = offline;
msg.ParentEstateID = ParentEstateID;
msg.Position = Position;
msg.RegionID = RegionID.Guid;
msg.binaryBucket = binaryBucket;
m_log.DebugFormat("[FRIEND]: storing transactionID {0} on sender side", transactionID);
lock (m_pendingFriendRequests)
{
m_pendingFriendRequests.Add(transactionID, new Transaction(fromAgentID, fromAgentName));
outPending();
}
// we don't want to get that new IM into here if we aren't local, as only on the destination
// should receive it. If we *are* local, *we* are the destination, so we have to receive it.
// As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here.
// We don't really care which local scene we pipe it through.
if (m_TransferModule != null)
{
m_TransferModule.SendInstantMessage(msg,
delegate(bool success) {}
);
}
msg.fromAgentName = client.Name; // fromAgentName;
}
else
{
// (2)
// we are on the receiving end here; just add the transactionID to the stored transactions for later lookup
m_log.DebugFormat("[FRIEND]: storing transactionID {0} on receiver side", imSessionID);
lock (m_pendingFriendRequests)
{
// if both are on the same region-server, the transaction is stored already, but we have to update the name
if (m_pendingFriendRequests.ContainsKey(imSessionID))
{
m_pendingFriendRequests[imSessionID].agentName = fromAgentName;
m_pendingFriendRequests[imSessionID].count++;
}
else m_pendingFriendRequests.Add(imSessionID, new Transaction(fromAgentID, fromAgentName));
outPending();
}
msg.fromAgentName = "(hippos)"; // Added for posterity. This means that we can't figure out who sent it
}
msg.message = message;
msg.dialog = dialog;
msg.fromGroup = fromGroup;
msg.offline = offline;
msg.ParentEstateID = ParentEstateID;
msg.Position = Position;
msg.RegionID = RegionID.Guid;
msg.binaryBucket = binaryBucket;
m_log.DebugFormat("[FRIEND]: storing transactionID {0} on sender side", transactionID);
lock (m_pendingFriendRequests)
{
m_pendingFriendRequests.Add(transactionID, new Transaction(fromAgentID, fromAgentName));
outPending();
}
// we don't want to get that new IM into here if we aren't local, as only on the destination
// should receive it. If we *are* local, *we* are the destination, so we have to receive it.
// As grid-IMs are routed to all modules (in contrast to local IMs), we have to decide here.
// We don't really care which local scene we pipe it through.
if (m_TransferModule != null)
{
m_TransferModule.SendInstantMessage(msg,
delegate(bool success) {}
);
}
}
else if (dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39
{
// accepting the friendship offer causes a type 39 IM being sent to the (possibly remote) initiator
// toAgentID is initiator, fromAgentID is new friend (which just approved)
m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agentSession {1}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})",
client != null ? client.AgentId.ToString() : "<null>", fromAgentSession,
m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})",
client != null ? client.AgentId.ToString() : "<null>",
fromAgentID, fromAgentName, imSessionID, toAgentID, message, dialog);
lock (m_pendingFriendRequests)
{
@ -520,8 +499,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
{
// declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator
// toAgentID is initiator, fromAgentID declined friendship
m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agentSession {1}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})",
client != null ? client.AgentId.ToString() : "<null>", fromAgentSession,
m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})",
client != null ? client.AgentId.ToString() : "<null>",
fromAgentID, fromAgentName, imSessionID, toAgentID, message, dialog);
// not much to do, just clean up the transaction...
@ -542,13 +521,42 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
private void OnGridInstantMessage(GridInstantMessage msg)
{
if (msg.dialog == (byte)InstantMessageDialog.FriendshipOffered)
{
// we are on the receiving end here; just add the transactionID
// to the stored transactions for later lookup
//
m_log.DebugFormat("[FRIEND]: storing transactionID {0} on "+
"receiver side", msg.imSessionID);
lock (m_pendingFriendRequests)
{
// if both are on the same region-server, the transaction
// is stored already, but we have to update the name
//
if (m_pendingFriendRequests.ContainsKey(
new UUID(msg.imSessionID)))
{
m_pendingFriendRequests[new UUID(msg.imSessionID)].agentName =
msg.fromAgentName;
m_pendingFriendRequests[new UUID(msg.imSessionID)].count++;
}
else m_pendingFriendRequests.Add(new UUID(msg.imSessionID),
new Transaction(new UUID(msg.fromAgentID),
msg.fromAgentName));
outPending();
}
return;
}
// Just call the IM handler above
// This event won't be raised unless we have that agent,
// so we can depend on the above not trying to send
// via grid again
//
OnInstantMessage(null, new UUID(msg.fromAgentID),
new UUID(msg.fromAgentSession),
new UUID(msg.toAgentID), new UUID(msg.imSessionID),
msg.timestamp, msg.fromAgentName, msg.message,
msg.dialog, msg.fromGroup, msg.offline,
@ -604,7 +612,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
msg.toAgentID = friendID.Guid;
msg.fromAgentID = agentID.Guid;
msg.fromAgentName = client.Name;
msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session
msg.fromGroup = false;
msg.imSessionID = transactionID.Guid;
msg.message = agentID.Guid.ToString();
@ -664,7 +671,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
msg.toAgentID = friendID.Guid;
msg.fromAgentID = agentID.Guid;
msg.fromAgentName = client.Name;
msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session
msg.fromGroup = false;
msg.imSessionID = transactionID.Guid;
msg.message = agentID.Guid.ToString();

View File

@ -178,27 +178,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
ActiveGroupTitle);
}
private void OnInstantMessage(IClientAPI client, UUID fromAgentID,
UUID fromAgentSession, UUID toAgentID,
UUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog, bool fromGroup, byte offline,
uint ParentEstateID, Vector3 Position, UUID RegionID,
byte[] binaryBucket)
private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
{
}
private void OnGridInstantMessage(GridInstantMessage msg)
{
// Trigger the above event handler
OnInstantMessage(null, new UUID(msg.fromAgentID),
new UUID(msg.fromAgentSession),
new UUID(msg.toAgentID), new UUID(msg.imSessionID),
msg.timestamp, msg.fromAgentName,
msg.message, msg.dialog, msg.fromGroup, msg.offline,
msg.ParentEstateID,
new Vector3(msg.Position.X, msg.Position.Y, msg.Position.Z),
new UUID(msg.RegionID),
msg.binaryBucket);
OnInstantMessage(null, msg);
}
private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client)

View File

@ -110,33 +110,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
#endregion
private void OnInstantMessage(IClientAPI client, UUID fromAgentID,
UUID fromAgentSession, UUID toAgentID,
UUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog, bool fromGroup, byte offline,
uint ParentEstateID, Vector3 Position, UUID RegionID,
byte[] binaryBucket)
{
// This module handles exclusively private text IM from user
// to user. All others will be caught in other modules
//
if ( dialog != (byte)InstantMessageDialog.MessageFromAgent
&& dialog != (byte)InstantMessageDialog.StartTyping
&& dialog != (byte)InstantMessageDialog.StopTyping)
{
return;
}
GridInstantMessage im = new GridInstantMessage(client.Scene,
fromAgentID, fromAgentName, fromAgentSession, toAgentID,
dialog, fromGroup, message, imSessionID,
offline != 0 ? true : false, Position,
binaryBucket);
ProcessInstantMessage(client, im);
}
private void ProcessInstantMessage(IClientAPI client, GridInstantMessage im)
public void OnInstantMessage(IClientAPI client, GridInstantMessage im)
{
byte dialog = im.dialog;
@ -183,7 +157,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
// so we can depend on the above not trying to send
// via grid again
//
ProcessInstantMessage(null, msg);
OnInstantMessage(null, msg);
}
}
}

View File

@ -185,7 +185,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
bool successful = false;
// various rational defaults
UUID fromAgentID = UUID.Zero;
UUID fromAgentSession = UUID.Zero;
UUID toAgentID = UUID.Zero;
UUID imSessionID = UUID.Zero;
uint timestamp = 0;
@ -207,7 +206,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
Hashtable requestData = (Hashtable)request.Params[0];
// Check if it's got all the data
if (requestData.ContainsKey("from_agent_id") && requestData.ContainsKey("from_agent_session")
if (requestData.ContainsKey("from_agent_id")
&& requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id")
&& requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name")
&& requestData.ContainsKey("message") && requestData.ContainsKey("dialog")
@ -219,7 +218,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
{
// Do the easy way of validating the UUIDs
UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID);
UUID.TryParse((string)requestData["from_agent_session"], out fromAgentSession);
UUID.TryParse((string)requestData["to_agent_id"], out toAgentID);
UUID.TryParse((string)requestData["im_session_id"], out imSessionID);
UUID.TryParse((string)requestData["region_id"], out RegionID);
@ -337,7 +335,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
GridInstantMessage gim = new GridInstantMessage();
gim.fromAgentID = fromAgentID.Guid;
gim.fromAgentName = fromAgentName;
gim.fromAgentSession = fromAgentSession.Guid;
gim.fromGroup = fromGroup;
gim.imSessionID = imSessionID.Guid;
gim.RegionID = RegionID.Guid;
@ -598,7 +595,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
{
Hashtable gim = new Hashtable();
gim["from_agent_id"] = msg.fromAgentID.ToString();
gim["from_agent_session"] = msg.fromAgentSession.ToString();
// Kept for compatibility
gim["from_agent_session"] = UUID.Zero.ToString();
gim["to_agent_id"] = msg.toAgentID.ToString();
gim["im_session_id"] = msg.imSessionID.ToString();
gim["timestamp"] = msg.timestamp.ToString();

View File

@ -117,38 +117,34 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
return null;
}
private void OnInstantMessage(IClientAPI client, UUID fromAgentID,
UUID fromAgentSession, UUID toAgentID,
UUID imSessionID, uint timestamp, string fromAgentName,
string message, byte dialog, bool fromGroup, byte offline,
uint ParentEstateID, Vector3 Position, UUID RegionID,
byte[] binaryBucket)
private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
{
Scene scene = FindClientScene(client.AgentId);
if (scene == null) // Something seriously wrong here.
return;
if (dialog == (byte) InstantMessageDialog.InventoryOffered)
if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
{
ScenePresence user =
scene.GetScenePresence(toAgentID);
scene.GetScenePresence(new UUID(im.toAgentID));
// First byte of the array is probably the item type
// Next 16 bytes are the UUID
UUID itemID = new UUID(binaryBucket, 1);
UUID itemID = new UUID(im.binaryBucket, 1);
m_log.DebugFormat("[AGENT INVENTORY]: Inserting item {0} "+
"into agent {1}'s inventory",
itemID, toAgentID);
itemID, new UUID(im.toAgentID));
InventoryItemBase itemCopy = scene.GiveInventoryItem(toAgentID,
InventoryItemBase itemCopy = scene.GiveInventoryItem(
new UUID(im.toAgentID),
client.AgentId, itemID);
byte[] itemCopyID = itemCopy.ID.GetBytes();
Array.Copy(itemCopyID, 0, binaryBucket, 1, 16);
Array.Copy(itemCopyID, 0, im.binaryBucket, 1, 16);
// Send the IM to the recipient. The item is already
// in their inventory, so it will not be lost if
@ -164,9 +160,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
// same ID back on the reply so we know what to act on
//
user.ControllingClient.SendInstantMessage(
fromAgentID, message, toAgentID, fromAgentName,
dialog, timestamp, itemCopy.ID, false,
binaryBucket);
new UUID(im.fromAgentID), im.message,
new UUID(im.toAgentID),
im.fromAgentName, im.dialog, im.timestamp,
itemCopy.ID, false, im.binaryBucket);
return;
}
@ -177,15 +174,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
// TODO: Implement grid sending
}
}
else if (dialog == (byte) InstantMessageDialog.InventoryAccepted)
else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted)
{
ScenePresence user = scene.GetScenePresence(toAgentID);
ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
if (user != null) // Local
{
user.ControllingClient.SendInstantMessage(
fromAgentID, message, toAgentID, fromAgentName,
dialog, timestamp, UUID.Zero, false, binaryBucket);
new UUID(im.fromAgentID), im.message,
new UUID(im.toAgentID),
im.fromAgentName, im.dialog, im.timestamp,
UUID.Zero, false, im.binaryBucket);
}
else
{
@ -194,9 +193,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
// TODO: Implement sending via grid
}
}
else if (dialog == (byte) InstantMessageDialog.InventoryDeclined)
else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined)
{
UUID itemID = imSessionID; // The item, back from it's trip
UUID itemID = new UUID(im.imSessionID); // The item, back from it's trip
// Here, the recipient is local and we can assume that the
// inventory is loaded. Courtesy of the above bulk update,
@ -235,13 +234,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
}
}
ScenePresence user = scene.GetScenePresence(toAgentID);
ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
if (user != null) // Local
{
user.ControllingClient.SendInstantMessage(
fromAgentID, message, toAgentID, fromAgentName,
dialog, timestamp, UUID.Zero, false, binaryBucket);
new UUID(im.fromAgentID), im.message,
new UUID(im.toAgentID),
im.fromAgentName, im.dialog, im.timestamp,
UUID.Zero, false, im.binaryBucket);
}
else
{

View File

@ -84,9 +84,10 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
public void InstantMessage(UUID target, string message)
{
OnInstantMessage(this, m_uuid, SessionId, target, UUID.Combine(m_uuid, target),
(uint) Util.UnixTimeSinceEpoch(), Name, message, 0, false, 0, 0,
Position, m_scene.RegionInfo.RegionID, new byte[0]);
OnInstantMessage(this, new GridInstantMessage(m_scene,
m_uuid, m_firstname + " " + m_lastname,
target, 0, false, message,
UUID.Zero, false, Position, new byte[0]));
}
public void SendAgentOffline(UUID[] agentIDs)

View File

@ -977,7 +977,6 @@ namespace OpenSim.Region.Environment.Scenes
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = new Guid(UUID.Zero.ToString()); // From server
msg.fromAgentSession = new Guid(transaction.ToString());
msg.toAgentID = new Guid(ret.Key.ToString());
msg.imSessionID = new Guid(transaction.ToString());
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();

View File

@ -2623,7 +2623,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.Guid;
msg.fromAgentSession = new Guid(friendTransactionID.ToString());// fromAgentSession.UUID;
msg.toAgentID = new Guid(user); // toAgentID.Guid;
msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
// Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);