diff options
author | MW | 2009-02-27 14:50:49 +0000 |
---|---|---|
committer | MW | 2009-02-27 14:50:49 +0000 |
commit | 95230c244c5d22f1d84ec5cb4519e52055edc71d (patch) | |
tree | 20b1fc5912b59a762ab9505ba07913e8308240d3 /OpenSim | |
parent | Added support for reading ini files from a (optional) config folder. This all... (diff) | |
download | opensim-SC-95230c244c5d22f1d84ec5cb4519e52055edc71d.zip opensim-SC-95230c244c5d22f1d84ec5cb4519e52055edc71d.tar.gz opensim-SC-95230c244c5d22f1d84ec5cb4519e52055edc71d.tar.bz2 opensim-SC-95230c244c5d22f1d84ec5cb4519e52055edc71d.tar.xz |
Applied patch from Mantis# 3240, thanks tlaukkan/Tommil
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 120 | ||||
-rw-r--r-- | OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs | 59 |
2 files changed, 126 insertions, 53 deletions
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 3d734ad..db60622 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs | |||
@@ -46,30 +46,38 @@ namespace OpenSim.Client.MXP.ClientStack | |||
46 | { | 46 | { |
47 | internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private readonly Session mxpSession; | 49 | private readonly Session m_session; |
50 | private readonly UUID mxpSessionID; | 50 | private readonly UUID m_sessionID; |
51 | private readonly IScene mxpHostBubble; | 51 | private readonly UUID m_userID; |
52 | private readonly string mxpUsername; | 52 | private readonly IScene m_hostBubble; |
53 | private readonly string m_firstName; | ||
54 | private readonly string m_lastName; | ||
53 | 55 | ||
54 | private int debugLevel; | 56 | private Vector3 m_startPosition=new Vector3(128f, 128f, 128f); |
57 | private int m_debugLevel; | ||
58 | |||
55 | 59 | ||
56 | public MXPClientView(Session mxpSession, UUID mxpSessionID, IScene mxpHostBubble, string mxpUsername) | 60 | public MXPClientView(Session mxpSession, UUID mxpSessionID, UUID userID, IScene mxpHostBubble, string mxpFirstName, string mxpLastName) |
57 | { | 61 | { |
58 | this.mxpSession = mxpSession; | 62 | this.m_session = mxpSession; |
59 | this.mxpUsername = mxpUsername; | 63 | this.m_userID = userID; |
60 | this.mxpHostBubble = mxpHostBubble; | 64 | this.m_firstName = mxpFirstName; |
61 | this.mxpSessionID = mxpSessionID; | 65 | this.m_lastName = mxpLastName; |
66 | this.m_hostBubble = mxpHostBubble; | ||
67 | this.m_sessionID = mxpSessionID; | ||
62 | } | 68 | } |
63 | 69 | ||
64 | public Session Session | 70 | public Session Session |
65 | { | 71 | { |
66 | get { return mxpSession; } | 72 | get { return m_session; } |
67 | } | 73 | } |
68 | 74 | ||
69 | public bool ProcessMXPPacket(Message msg) | 75 | public bool ProcessMXPPacket(Message msg) |
70 | { | 76 | { |
71 | if (debugLevel > 0) | 77 | if (m_debugLevel > 0) |
72 | m_log.Warn("[MXP] Got Action/Command Packet: " + msg); | 78 | { |
79 | m_log.Warn("[MXP] Received messaged unhandled: " + msg); | ||
80 | } | ||
73 | 81 | ||
74 | return false; | 82 | return false; |
75 | } | 83 | } |
@@ -78,23 +86,23 @@ namespace OpenSim.Client.MXP.ClientStack | |||
78 | 86 | ||
79 | public Vector3 StartPos | 87 | public Vector3 StartPos |
80 | { | 88 | { |
81 | get { return new Vector3(128f, 128f, 128f); } | 89 | get { return m_startPosition; } |
82 | set { } // TODO: Implement Me | 90 | set { m_startPosition = value; } |
83 | } | 91 | } |
84 | 92 | ||
85 | public UUID AgentId | 93 | public UUID AgentId |
86 | { | 94 | { |
87 | get { return mxpSessionID; } | 95 | get { return m_userID; } |
88 | } | 96 | } |
89 | 97 | ||
90 | public UUID SessionId | 98 | public UUID SessionId |
91 | { | 99 | { |
92 | get { return mxpSessionID; } | 100 | get { return m_sessionID; } |
93 | } | 101 | } |
94 | 102 | ||
95 | public UUID SecureSessionId | 103 | public UUID SecureSessionId |
96 | { | 104 | { |
97 | get { return mxpSessionID; } | 105 | get { return m_sessionID; } |
98 | } | 106 | } |
99 | 107 | ||
100 | public UUID ActiveGroupId | 108 | public UUID ActiveGroupId |
@@ -124,17 +132,17 @@ namespace OpenSim.Client.MXP.ClientStack | |||
124 | 132 | ||
125 | public string FirstName | 133 | public string FirstName |
126 | { | 134 | { |
127 | get { return mxpUsername; } | 135 | get { return m_firstName; } |
128 | } | 136 | } |
129 | 137 | ||
130 | public string LastName | 138 | public string LastName |
131 | { | 139 | { |
132 | get { return "@mxp://" + Session.RemoteEndPoint.Address; } | 140 | get { return m_lastName; } |
133 | } | 141 | } |
134 | 142 | ||
135 | public IScene Scene | 143 | public IScene Scene |
136 | { | 144 | { |
137 | get { return mxpHostBubble; } | 145 | get { return m_hostBubble; } |
138 | } | 146 | } |
139 | 147 | ||
140 | public int NextAnimationSequenceNumber | 148 | public int NextAnimationSequenceNumber |
@@ -165,7 +173,7 @@ namespace OpenSim.Client.MXP.ClientStack | |||
165 | 173 | ||
166 | public uint CircuitCode | 174 | public uint CircuitCode |
167 | { | 175 | { |
168 | get { return mxpSessionID.CRC(); } | 176 | get { return m_sessionID.CRC(); } |
169 | } | 177 | } |
170 | 178 | ||
171 | public event GenericMessage OnGenericMessage; | 179 | public event GenericMessage OnGenericMessage; |
@@ -348,7 +356,7 @@ namespace OpenSim.Client.MXP.ClientStack | |||
348 | 356 | ||
349 | public void SetDebugPacketLevel(int newDebug) | 357 | public void SetDebugPacketLevel(int newDebug) |
350 | { | 358 | { |
351 | debugLevel = newDebug; | 359 | m_debugLevel = newDebug; |
352 | } | 360 | } |
353 | 361 | ||
354 | public void InPacket(object NewPack) | 362 | public void InPacket(object NewPack) |
@@ -560,14 +568,42 @@ namespace OpenSim.Client.MXP.ClientStack | |||
560 | // Need to translate to MXP somehow | 568 | // Need to translate to MXP somehow |
561 | } | 569 | } |
562 | 570 | ||
563 | public void SendAvatarData(ulong regionHandle, string firstName, string lastName, string grouptitle, UUID avatarID, uint avatarLocalID, Vector3 Pos, byte[] textureEntry, uint parentID, Quaternion rotation) | 571 | public void SendAvatarData(ulong regionHandle, string firstName, string lastName, string grouptitle, UUID avatarID, uint avatarLocalID, Vector3 pos, byte[] textureEntry, uint parentID, Quaternion rotation) |
564 | { | 572 | { |
565 | // TODO: This needs handling - to display other avatars | 573 | m_log.Info("[MXP] Transmitting Avatar Data " + firstName + " " + lastName); |
574 | |||
575 | PerceptionEventMessage pe = new PerceptionEventMessage(); | ||
576 | |||
577 | pe.ObjectFragment.ObjectId = avatarID.Guid; | ||
578 | // TODO Resolve ParentID | ||
579 | pe.ObjectFragment.ParentObjectId = Guid.Empty; | ||
580 | pe.ObjectFragment.ObjectIndex = avatarLocalID; | ||
581 | pe.ObjectFragment.ObjectName = firstName+" "+lastName; | ||
582 | pe.ObjectFragment.OwnerId = Guid.Empty; | ||
583 | pe.ObjectFragment.TypeId = Guid.Empty; | ||
584 | pe.ObjectFragment.TypeName = "Avatar"; | ||
585 | pe.ObjectFragment.Acceleration = new float[3]; | ||
586 | pe.ObjectFragment.AngularAcceleration = new float[4]; | ||
587 | pe.ObjectFragment.AngularVelocity = new float[4]; | ||
588 | pe.ObjectFragment.BoundingSphereRadius = 1; // TODO Fill in appropriate value | ||
589 | |||
590 | pe.ObjectFragment.Location = new float[] { pos.X, pos.Y, pos.Z }; | ||
591 | |||
592 | pe.ObjectFragment.Mass = 1.0f; // TODO Fill in appropriate value | ||
593 | pe.ObjectFragment.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; | ||
594 | pe.ObjectFragment.Velocity = new float[3]; | ||
595 | |||
596 | Session.Send(pe); | ||
566 | } | 597 | } |
567 | 598 | ||
568 | public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, Vector3 position, Vector3 velocity, Quaternion rotation) | 599 | public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, Vector3 position, Vector3 velocity, Quaternion rotation) |
569 | { | 600 | { |
570 | // TODO: This probably needs handling - update other avatar positions | 601 | MovementEventMessage me = new MovementEventMessage(); |
602 | me.ObjectIndex = localID; | ||
603 | me.Location = new float[] { position.X, position.Y, position.Z }; | ||
604 | me.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; | ||
605 | |||
606 | Session.Send(me); | ||
571 | } | 607 | } |
572 | 608 | ||
573 | public void SendCoarseLocationUpdate(List<Vector3> CoarseLocations) | 609 | public void SendCoarseLocationUpdate(List<Vector3> CoarseLocations) |
@@ -610,20 +646,17 @@ namespace OpenSim.Client.MXP.ClientStack | |||
610 | pe.ObjectFragment.AngularVelocity = new float[] { rvel.X, rvel.Y, rvel.Z, 0.0f }; | 646 | pe.ObjectFragment.AngularVelocity = new float[] { rvel.X, rvel.Y, rvel.Z, 0.0f }; |
611 | pe.ObjectFragment.BoundingSphereRadius = primShape.Scale.Length(); | 647 | pe.ObjectFragment.BoundingSphereRadius = primShape.Scale.Length(); |
612 | 648 | ||
613 | pe.ObjectFragment.Location = new float[] { pos.X - 120.0f, pos.Z, pos.Y - 128.0f }; | 649 | pe.ObjectFragment.Location = new float[] { pos.X , pos.Y, pos.Z }; |
614 | 650 | ||
615 | pe.ObjectFragment.Mass = 1.0f; | 651 | pe.ObjectFragment.Mass = 1.0f; |
616 | pe.ObjectFragment.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; | 652 | pe.ObjectFragment.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; |
617 | pe.ObjectFragment.Velocity = new float[] { vel.X, vel.Y, vel.Z }; | 653 | pe.ObjectFragment.Velocity = new float[] { vel.X, vel.Y, vel.Z }; |
618 | 654 | ||
655 | ObjectExtFragment ext = new ObjectExtFragment(); | ||
656 | |||
619 | if (!((primShape.PCode == (byte)PCode.NewTree) || (primShape.PCode == (byte)PCode.Tree) || (primShape.PCode == (byte)PCode.Grass))) | 657 | if (!((primShape.PCode == (byte)PCode.NewTree) || (primShape.PCode == (byte)PCode.Tree) || (primShape.PCode == (byte)PCode.Grass))) |
620 | { | 658 | { |
621 | ObjectExtFragment ext = new ObjectExtFragment(); | ||
622 | ext.UpdateFlags = flags; | ||
623 | 659 | ||
624 | ext.TextureEntry = primShape.TextureEntry; | ||
625 | ext.TextureAnim = textureanim; | ||
626 | ext.State = primShape.State; | ||
627 | ext.PathBegin = primShape.PathBegin; | 660 | ext.PathBegin = primShape.PathBegin; |
628 | ext.PathEnd = primShape.PathEnd; | 661 | ext.PathEnd = primShape.PathEnd; |
629 | ext.PathScaleX = primShape.PathScaleX; | 662 | ext.PathScaleX = primShape.PathScaleX; |
@@ -633,7 +666,6 @@ namespace OpenSim.Client.MXP.ClientStack | |||
633 | ext.PathSkew = primShape.PathSkew; | 666 | ext.PathSkew = primShape.PathSkew; |
634 | ext.ProfileBegin = primShape.ProfileBegin; | 667 | ext.ProfileBegin = primShape.ProfileBegin; |
635 | ext.ProfileEnd = primShape.ProfileEnd; | 668 | ext.ProfileEnd = primShape.ProfileEnd; |
636 | ext.Scale = EncodeVector(primShape.Scale); | ||
637 | ext.PathCurve = primShape.PathCurve; | 669 | ext.PathCurve = primShape.PathCurve; |
638 | ext.ProfileCurve = primShape.ProfileCurve; | 670 | ext.ProfileCurve = primShape.ProfileCurve; |
639 | ext.ProfileHollow = primShape.ProfileHollow; | 671 | ext.ProfileHollow = primShape.ProfileHollow; |
@@ -643,18 +675,24 @@ namespace OpenSim.Client.MXP.ClientStack | |||
643 | ext.PathTaperY = primShape.PathTaperY; | 675 | ext.PathTaperY = primShape.PathTaperY; |
644 | ext.PathTwist = primShape.PathTwist; | 676 | ext.PathTwist = primShape.PathTwist; |
645 | ext.PathTwistBegin = primShape.PathTwistBegin; | 677 | ext.PathTwistBegin = primShape.PathTwistBegin; |
646 | ext.ExtraParams = primShape.ExtraParams; | ||
647 | 678 | ||
648 | ext.Text = text; | ||
649 | ext.TextColor = EncodeColor(textColor); | ||
650 | ext.PSBlock = particleSystem; | ||
651 | ext.ClickAction = clickAction; | ||
652 | ext.Material = material; | ||
653 | |||
654 | pe.SetExtension<ObjectExtFragment>(ext); | ||
655 | 679 | ||
656 | } | 680 | } |
657 | 681 | ||
682 | ext.UpdateFlags = flags; | ||
683 | ext.ExtraParams = primShape.ExtraParams; | ||
684 | ext.State = primShape.State; | ||
685 | ext.TextureEntry = primShape.TextureEntry; | ||
686 | ext.TextureAnim = textureanim; | ||
687 | ext.Scale = EncodeVector(primShape.Scale); | ||
688 | ext.Text = text; | ||
689 | ext.TextColor = EncodeColor(textColor); | ||
690 | ext.PSBlock = particleSystem; | ||
691 | ext.ClickAction = clickAction; | ||
692 | ext.Material = material; | ||
693 | |||
694 | pe.SetExtension<ObjectExtFragment>(ext); | ||
695 | |||
658 | Session.Send(pe); | 696 | Session.Send(pe); |
659 | } | 697 | } |
660 | 698 | ||
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs index e540286..1eceef6 100644 --- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs +++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs | |||
@@ -216,8 +216,8 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
216 | m_log.Info("Pending Sessions: " + PendingSessionCount); | 216 | m_log.Info("Pending Sessions: " + PendingSessionCount); |
217 | m_log.Info("Sessions: " + SessionCount + " (Clients: " + Clients.Count + " )"); | 217 | m_log.Info("Sessions: " + SessionCount + " (Clients: " + Clients.Count + " )"); |
218 | m_log.Info("Transmitter Alive?: " + IsTransmitterAlive); | 218 | m_log.Info("Transmitter Alive?: " + IsTransmitterAlive); |
219 | m_log.Info("Packets Sent/Recieved: " + PacketsSent + " / " + PacketsReceived); | 219 | m_log.Info("Packets Sent/Received: " + PacketsSent + " / " + PacketsReceived); |
220 | m_log.Info("Bytes Sent/Recieved: " + BytesSent + " / " + BytesReceived); | 220 | m_log.Info("Bytes Sent/Received: " + BytesSent + " / " + BytesReceived); |
221 | m_log.Info("Send/Recieve Rate (bps): " + SendRate + " / " + ReceiveRate); | 221 | m_log.Info("Send/Recieve Rate (bps): " + SendRate + " / " + ReceiveRate); |
222 | } | 222 | } |
223 | 223 | ||
@@ -247,12 +247,43 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
247 | sessionsToRemove.Clear(); | 247 | sessionsToRemove.Clear(); |
248 | } | 248 | } |
249 | 249 | ||
250 | public bool AuthoriseUser(string participantName, string pass, UUID scene) | 250 | public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UUID userId, out string firstName, out string lastName) |
251 | { | 251 | { |
252 | if (Scenes.ContainsKey(scene)) | 252 | userId = UUID.Zero; |
253 | return true; | 253 | firstName = ""; |
254 | lastName = ""; | ||
254 | 255 | ||
255 | return false; | 256 | if (!Scenes.ContainsKey(sceneId)) |
257 | { | ||
258 | m_log.Info("Login failed as region was not found: " + sceneId); | ||
259 | return false; | ||
260 | } | ||
261 | |||
262 | string[] nameParts=participantName.Split(' '); | ||
263 | if(nameParts.Length!=2) | ||
264 | { | ||
265 | m_log.Info("Login failed as user name is not formed of first and last name separated by space: " + participantName); | ||
266 | return false; | ||
267 | } | ||
268 | firstName = nameParts[0]; | ||
269 | lastName = nameParts[1]; | ||
270 | |||
271 | UserProfileData userProfile = Scenes[sceneId].CommsManager.UserService.GetUserProfile(firstName, lastName); | ||
272 | if (userProfile == null) | ||
273 | { | ||
274 | m_log.Info("Login failed as user was not found: " + participantName); | ||
275 | return false; | ||
276 | } | ||
277 | userId = userProfile.ID; | ||
278 | |||
279 | if (!password.StartsWith("$1$")) | ||
280 | { | ||
281 | password = "$1$" + Util.Md5Hash(password); | ||
282 | } | ||
283 | password = password.Remove(0, 3); //remove $1$ | ||
284 | string s = Util.Md5Hash(password + ":" + userProfile.PasswordSalt); | ||
285 | return (userProfile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) | ||
286 | || userProfile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); | ||
256 | } | 287 | } |
257 | 288 | ||
258 | public void ProcessMessages() | 289 | public void ProcessMessages() |
@@ -278,9 +309,13 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
278 | 309 | ||
279 | JoinRequestMessage joinRequestMessage = (JoinRequestMessage) message; | 310 | JoinRequestMessage joinRequestMessage = (JoinRequestMessage) message; |
280 | 311 | ||
312 | UUID userId; | ||
313 | string firstName; | ||
314 | string lastName; | ||
315 | |||
281 | bool authorized = AuthoriseUser(joinRequestMessage.ParticipantName, | 316 | bool authorized = AuthoriseUser(joinRequestMessage.ParticipantName, |
282 | joinRequestMessage.ParticipantPassphrase, | 317 | joinRequestMessage.ParticipantPassphrase, |
283 | new UUID(joinRequestMessage.BubbleId)); | 318 | new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName); |
284 | 319 | ||
285 | if (authorized) | 320 | if (authorized) |
286 | { | 321 | { |
@@ -292,10 +327,10 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
292 | (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + | 327 | (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + |
293 | session.RemoteEndPoint.Port + ")"); | 328 | session.RemoteEndPoint.Port + ")"); |
294 | 329 | ||
295 | AcceptConnection(session, joinRequestMessage, mxpSessionID); | 330 | AcceptConnection(session, joinRequestMessage, mxpSessionID,userId); |
296 | 331 | ||
297 | MXPClientView client = new MXPClientView(session, mxpSessionID, target, | 332 | MXPClientView client = new MXPClientView(session, mxpSessionID,userId, target, |
298 | joinRequestMessage.ParticipantName); | 333 | firstName, lastName); |
299 | m_log.Info("[MXP ClientStack] Created Client"); | 334 | m_log.Info("[MXP ClientStack] Created Client"); |
300 | Clients.Add(client); | 335 | Clients.Add(client); |
301 | 336 | ||
@@ -393,7 +428,7 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
393 | } | 428 | } |
394 | } | 429 | } |
395 | 430 | ||
396 | private void AcceptConnection(Session session, JoinRequestMessage joinRequestMessage, UUID mxpSessionID) | 431 | private void AcceptConnection(Session session, JoinRequestMessage joinRequestMessage, UUID mxpSessionID, UUID userId) |
397 | { | 432 | { |
398 | JoinResponseMessage joinResponseMessage = (JoinResponseMessage)MessageFactory.Current.ReserveMessage( | 433 | JoinResponseMessage joinResponseMessage = (JoinResponseMessage)MessageFactory.Current.ReserveMessage( |
399 | typeof(JoinResponseMessage)); | 434 | typeof(JoinResponseMessage)); |
@@ -401,7 +436,7 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
401 | joinResponseMessage.RequestMessageId = joinRequestMessage.MessageId; | 436 | joinResponseMessage.RequestMessageId = joinRequestMessage.MessageId; |
402 | joinResponseMessage.FailureCode = 0; | 437 | joinResponseMessage.FailureCode = 0; |
403 | 438 | ||
404 | joinResponseMessage.ParticipantId = mxpSessionID.Guid; | 439 | joinResponseMessage.ParticipantId = userId.Guid; |
405 | joinResponseMessage.CloudUrl = cloudUrl; | 440 | joinResponseMessage.CloudUrl = cloudUrl; |
406 | 441 | ||
407 | joinResponseMessage.BubbleName = Scenes[new UUID(joinRequestMessage.BubbleId)].RegionInfo.RegionName; | 442 | joinResponseMessage.BubbleName = Scenes[new UUID(joinRequestMessage.BubbleId)].RegionInfo.RegionName; |