Browse Source

some changes to PresenceServerPostHandler

UbitUmarov 2 months ago
parent
commit
81cfd6e956
1 changed files with 14 additions and 8 deletions
  1. 14 8
      OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs

+ 14 - 8
OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs

@@ -69,18 +69,24 @@ namespace OpenSim.Server.Handlers.Presence
             string method = string.Empty;
             string method = string.Empty;
             try
             try
             {
             {
-                Dictionary<string, object> request =
-                        ServerUtils.ParseQueryString(body);
+                Dictionary<string, object> request = ServerUtils.ParseQueryString(body);
 
 
-                if (!request.ContainsKey("METHOD"))
+                if (!request.TryGetValue("METHOD", out object tmpobj) || tmpobj is not string)
                     return FailureResult();
                     return FailureResult();
 
 
-                method = request["METHOD"].ToString();
-
+                method = (string)tmpobj;
                 switch (method)
                 switch (method)
                 {
                 {
                     case "login":
                     case "login":
-                        return LoginAgent(request);
+                        {
+                            //return LoginAgent(request); this is ilegal
+                            if (request.TryGetValue("UserID", out object uo) && uo is string user)
+                                m_log.Debug($"[PRESENCE HANDLER]: ilegal login try from {httpRequest.RemoteIPEndPoint} for userID {user}");
+                            else
+                                m_log.Debug($"[PRESENCE HANDLER]: ilegal login try from {httpRequest.RemoteIPEndPoint} for unkown user");
+
+                            return FailureResult();
+                        }
                     case "logout":
                     case "logout":
                         return LogoutAgent(request);
                         return LogoutAgent(request);
                     case "logoutregion":
                     case "logoutregion":
@@ -92,11 +98,11 @@ namespace OpenSim.Server.Handlers.Presence
                     case "getagents":
                     case "getagents":
                         return GetAgents(request);
                         return GetAgents(request);
                 }
                 }
-                m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method);
+                m_log.Debug($"[PRESENCE HANDLER]: unknown method request: {method}");
             }
             }
             catch (Exception e)
             catch (Exception e)
             {
             {
-                m_log.DebugFormat("[PRESENCE HANDLER]: Exception in method {0}: {1}", method, e);
+                m_log.Debug($"[PRESENCE HANDLER]: Exception in method {method}: {e.Message}");
             }
             }
 
 
             return FailureResult();
             return FailureResult();