aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
diff options
context:
space:
mode:
authorMW2009-02-27 14:50:49 +0000
committerMW2009-02-27 14:50:49 +0000
commit95230c244c5d22f1d84ec5cb4519e52055edc71d (patch)
tree20b1fc5912b59a762ab9505ba07913e8308240d3 /OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
parentAdded support for reading ini files from a (optional) config folder. This all... (diff)
downloadopensim-SC_OLD-95230c244c5d22f1d84ec5cb4519e52055edc71d.zip
opensim-SC_OLD-95230c244c5d22f1d84ec5cb4519e52055edc71d.tar.gz
opensim-SC_OLD-95230c244c5d22f1d84ec5cb4519e52055edc71d.tar.bz2
opensim-SC_OLD-95230c244c5d22f1d84ec5cb4519e52055edc71d.tar.xz
Applied patch from Mantis# 3240, thanks tlaukkan/Tommil
Diffstat (limited to 'OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs')
-rw-r--r--OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs59
1 files changed, 47 insertions, 12 deletions
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;