public bool LoggedOut(string userID, UUID sessionID, UUID region, Vector3 position, Vector3 lookat)
        {
            if (m_Infos.Contains(userID))
            {
                m_Infos.Remove(userID);
            }

            return(m_RemoteConnector.LoggedOut(userID, sessionID, region, position, lookat));
        }
        public Hashtable OnGetSnapshot(Hashtable keysvals)
        {
            Hashtable reply = new Hashtable();
            string    reqtag;
            string    snapObj = (string)keysvals["region"];

            if (string.IsNullOrWhiteSpace(snapObj))
            {
                reqtag = GetClientString(keysvals);
            }
            else
            {
                reqtag = snapObj + GetClientString(keysvals);
            }


            if (!string.IsNullOrWhiteSpace(reqtag))
            {
                if (throotleGen.Contains(reqtag))
                {
                    reply["str_response_string"] = "Please try your request again later";
                    reply["int_response_code"]   = 503;
                    reply["content_type"]        = "text/plain";
                    m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later");
                    return(reply);
                }

                throotleGen.AddOrUpdate(reqtag, 0, 60);
            }

            if (string.IsNullOrWhiteSpace(snapObj))
            {
                m_log.DebugFormat("[DATASNAPSHOT] Received collection request for all");
            }
            else
            {
                m_log.DebugFormat("[DATASNAPSHOT] Received collection request for {0}", snapObj);
            }

            XmlDocument response = m_externalData.GetSnapshot(snapObj);

            if (response == null)
            {
                reply["str_response_string"] = "Please try your request again later";
                reply["int_response_code"]   = 503;
                reply["content_type"]        = "text/plain";
                m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later");
                return(reply);
            }

            reply["str_response_string"] = response.OuterXml;
            reply["int_response_code"]   = 200;
            reply["content_type"]        = "text/xml";
            return(reply);
        }
Exemple #3
0
        public UserAccount Get(string name, out bool inCache)
        {
            inCache = false;
            if (!m_NameCache.Contains(name))
            {
                return(null);
            }

            UserAccount account = null;
            UUID        uuid    = UUID.Zero;

            if (m_NameCache.TryGetValue(name, out uuid))
            {
                if (m_UUIDCache.TryGetValue(uuid, out account))
                {
                    inCache = true;
                    return(account);
                }
            }

            return(null);
        }
Exemple #4
0
        public void OnGetSnapshot(IOSHttpRequest req, IOSHttpResponse resp)
        {
            Hashtable reply = new Hashtable();
            string    reqtag;

            if (req.QueryAsDictionary.TryGetValue("region", out string snapObj) && !string.IsNullOrWhiteSpace(snapObj))
            {
                reqtag = snapObj + req.RemoteIPEndPoint.Address.ToString();
            }
            else
            {
                reqtag = req.RemoteIPEndPoint.Address.ToString();
            }

            if (!string.IsNullOrWhiteSpace(reqtag))
            {
                if (throotleGen.Contains(reqtag))
                {
                    resp.StatusCode        = (int)HttpStatusCode.ServiceUnavailable;
                    resp.StatusDescription = "Please try again later";
                    resp.ContentType       = "text/plain";
                    m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later");
                    return;
                }

                throotleGen.AddOrUpdate(reqtag, 0, 60);
            }

            if (string.IsNullOrWhiteSpace(snapObj))
            {
                m_log.DebugFormat("[DATASNAPSHOT] Received collection request for all");
            }
            else
            {
                m_log.DebugFormat("[DATASNAPSHOT] Received collection request for {0}", snapObj);
            }

            XmlDocument response = m_externalData.GetSnapshot(snapObj);

            if (response == null)
            {
                resp.StatusCode  = (int)HttpStatusCode.ServiceUnavailable;
                resp.ContentType = "text/plain";
                m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later");
                return;
            }

            resp.RawBuffer   = Util.UTF8NBGetbytes(response.OuterXml);
            resp.ContentType = "text/xml";
            resp.StatusCode  = (int)HttpStatusCode.OK;
        }
Exemple #5
0
 public void RemoveAll(UUID userID)
 {
     if (m_RootFolders.Contains(userID))
     {
         m_RootFolders.Remove(userID);
     }
     if (m_FolderTypes.Contains(userID))
     {
         m_FolderTypes.Remove(userID);
     }
     if (m_Inventories.Contains(userID))
     {
         m_Inventories.Remove(userID);
     }
 }
Exemple #6
0
        public void Remove(UUID id)
        {
            lock (accessLock)
            {
                if (!m_UUIDCache.Contains(id))
                {
                    return;
                }

                UserAccount account = null;
                if (m_UUIDCache.TryGetValue(id, out account) && account != null)
                {
                    m_NameCache.Remove(account.Name);
                }
                m_UUIDCache.Remove(id);
            }
        }
Exemple #7
0
        public bool Get(string name, out UserAccount account)
        {
            account = null;
            if (!m_NameCache.Contains(name))
            {
                return(false);
            }

            UUID uuid = UUID.Zero;

            if (m_NameCache.TryGetValue(name, out uuid))
            {
                if (m_UUIDCache.TryGetValue(uuid, out account))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #8
0
        void OnIncomingInstantMessage(GridInstantMessage im)
        {
            if (im.dialog == (byte)InstantMessageDialog.RequestTeleport)
            {
                UUID sessionID = new UUID(im.imSessionID);

                if (!m_PendingLures.Contains(sessionID))
                {
                    m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", im.imSessionID, im.RegionID, im.message);
                    m_PendingLures.Add(sessionID, im, 7200); // 2 hours
                }

                // Forward. We do this, because the IM module explicitly rejects
                // IMs of this type
                if (m_TransferModule != null)
                {
                    m_TransferModule.SendInstantMessage(im, delegate(bool success) { });
                }
            }
        }
Exemple #9
0
        public bool TryGetSessionInfo(Request request, out SessionInfo sinfo)
        {
            bool success = false;

            sinfo = new SessionInfo();
            if (request.Query.ContainsKey("sid"))
            {
                string sid = request.Query["sid"].ToString();
                if (m_Sessions.Contains(sid))
                {
                    SessionInfo session;
                    if (m_Sessions.TryGetValue(sid, out session) &&
                        session.IpAddress == request.IPEndPoint.Address.ToString())
                    {
                        sinfo = session;
                        m_Sessions.AddOrUpdate(sid, session, m_WebApp.SessionTimeout);
                        success = true;
                    }
                }
            }

            return(success);
        }
        public void AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, BooleanDelegate d)
        {
            if (d())
            {
                lock (m_Cache)
                {
                    // update the cached role
                    string cacheKey = "role-" + RoleID.ToString();
                    object obj;
                    if (m_Cache.TryGetValue(cacheKey, out obj))
                    {
                        GroupRolesData r = (GroupRolesData)obj;
                        r.Members++;
                    }

                    // add this agent to the list of role members
                    cacheKey = "rolemembers-" + RequestingAgentID.ToString() + "-" + GroupID.ToString();
                    if (m_Cache.TryGetValue(cacheKey, out obj))
                    {
                        try
                        {
                            // This may throw an exception, in which case the agentID is not a UUID but a full ID
                            // In that case, let's just remove the whoe things from the cache
                            UUID id = new UUID(AgentID);
                            List <ExtendedGroupRoleMembersData> xx     = (List <ExtendedGroupRoleMembersData>)obj;
                            List <GroupRoleMembersData>         rmlist = xx.ConvertAll <GroupRoleMembersData>(m_ForeignImporter.ConvertGroupRoleMembersData);
                            GroupRoleMembersData rm = new GroupRoleMembersData();
                            rm.MemberID = id;
                            rm.RoleID   = RoleID;
                            rmlist.Add(rm);
                        }
                        catch
                        {
                            m_Cache.Remove(cacheKey);
                        }
                    }

                    // Remove the cached info about this agent's roles
                    // because we don't have enough local info about the new role
                    cacheKey = "roles-" + GroupID.ToString() + "-" + AgentID.ToString();
                    if (m_Cache.Contains(cacheKey))
                    {
                        m_Cache.Remove(cacheKey);
                    }
                }
            }
        }
        public UUID CreateGroup(UUID RequestingAgentID, GroupRecordDelegate d)
        {
            //m_log.DebugFormat("[Groups.RemoteConnector]: Creating group {0}", name);
            //reason = string.Empty;

            //ExtendedGroupRecord group = m_GroupsService.CreateGroup(RequestingAgentID.ToString(), name, charter, showInList, insigniaID,
            //    membershipFee, openEnrollment, allowPublish, maturePublish, founderID, out reason);
            ExtendedGroupRecord group = d();

            if (group == null)
            {
                return(UUID.Zero);
            }

            if (group.GroupID != UUID.Zero)
            {
                lock (m_Cache)
                {
                    m_Cache.Add("group-" + group.GroupID.ToString(), group, GROUPS_CACHE_TIMEOUT);
                    if (m_Cache.Contains("memberships-" + RequestingAgentID.ToString()))
                    {
                        m_Cache.Remove("memberships-" + RequestingAgentID.ToString());
                    }
                }
            }

            return(group.GroupID);
        }
Exemple #12
0
 private bool CheckFromMemoryCache(string id)
 {
     return(m_MemoryCache.Contains(id));
 }
Exemple #13
0
 public bool Contains(string id)
 {
     return((m_MemoryCacheEnabled && m_MemoryCache.Contains(id)) || (File.Exists(GetFileName(id))));
 }
        public bool TryGetSessionInfo(Request request, out SessionInfo sinfo)
        {
            bool success = false;

            sinfo = new SessionInfo();
            if (request.Query.ContainsKey("sid"))
            {
                string sid = request.Query["sid"].ToString();
                if (m_Sessions.Contains(sid))
                {
                    SessionInfo session;
                    if (m_Sessions.TryGetValue(sid, out session) &&
                        session.IpAddress == request.IPEndPoint.Address.ToString())
                    {
                        sinfo = session;
                        m_Sessions.AddOrUpdate(sid, session, m_WebApp.SessionTimeout);
                        success = true;
                    }
                }
                else
                {
                    UUID sessionid = UUID.Zero;
                    if (UUID.TryParse(request.Query["sid"].ToString(), out sessionid))
                    {
                        PresenceInfo pinfo = m_PresenceService.GetAgent(sessionid);
                        if (pinfo != null)
                        {
                            m_log.DebugFormat("[Wifi]: User is present in the grid");
                            success = true;

                            UserAccount account = null;
                            if (request.Query.ContainsKey("uid"))
                            {
                                UUID userID = UUID.Zero;
                                if (UUID.TryParse(request.Query["uid"].ToString(), out userID))
                                {
                                    account = m_UserAccountService.GetUserAccount(UUID.Zero, userID);
                                }
                            }
                            else
                            {
                                m_log.DebugFormat("[Wifi]: No uid in Query");
                            }

                            sinfo.IpAddress = request.IPEndPoint.Address.ToString();
                            sinfo.Sid       = request.Query["sid"].ToString();
                            sinfo.Account   = account;
                            sinfo.Notify    = new NotificationData();

                            m_Sessions.Add(sinfo.Sid, sinfo, m_WebApp.SessionTimeout);
                        }
                        else
                        {
                            m_log.DebugFormat("[Wifi]: User is not present in the grid");
                        }
                    }
                    else
                    {
                        m_log.DebugFormat("[Wifi]: Unable o parse sid {0}", request.Query["sid"].ToString());
                    }
                }
            }
            //else
            //    m_log.DebugFormat("[Wifi]: no sid in Query");

            return(success);
        }
        public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
        {
            ulong regionHandle = Util.UIntsToLong((uint)x, (uint)y);

            if (m_regionCache.Contains(regionHandle))
            {
                return((GridRegion)m_regionCache[regionHandle]);
            }

            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["SCOPEID"] = scopeID.ToString();
            sendData["X"]       = x.ToString();
            sendData["Y"]       = y.ToString();

            sendData["METHOD"] = "get_region_by_position";
            string reply = string.Empty;
            string uri   = m_ServerURI + "/grid";

            try
            {
                reply = SynchronousRestFormsRequester.MakeRequest("POST",
                                                                  uri,
                                                                  ServerUtils.BuildQueryString(sendData), m_Auth);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
                return(null);
            }

            GridRegion rinfo = null;

            if (reply != string.Empty)
            {
                Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply);

                if ((replyData != null) && (replyData["result"] != null))
                {
                    if (replyData["result"] is Dictionary <string, object> )
                    {
                        rinfo = new GridRegion((Dictionary <string, object>)replyData["result"]);
                    }
                    //else
                    //    m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received no region",
                    //        scopeID, x, y);
                }
                else
                {
                    m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
                                      scopeID, x, y);
                }
            }
            else
            {
                m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
            }

            m_regionCache.Add(regionHandle, rinfo, TimeSpan.FromSeconds(600));

            return(rinfo);
        }