public bool IsNPC(UUID agentId, Scene scene) { // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect // that directly). ScenePresence sp = scene.GetScenePresence(agentId); if (sp == null || sp.IsChildAgent) return false; lock (m_avatars) return m_avatars.ContainsKey(agentId); }
void EventManager_OnClientClosed(UUID clientID, Scene scene) { ScenePresence sp = scene.GetScenePresence(clientID); if (sp != null) { if (m_SeenMapBlocks.ContainsKey(clientID)) { List<MapBlockData> mapBlocks = m_SeenMapBlocks[clientID]; foreach (MapBlockData b in mapBlocks) { b.Name = string.Empty; b.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's } m_log.DebugFormat("[HG MAP]: Reseting {0} blocks", mapBlocks.Count); sp.ControllingClient.SendMapBlock(mapBlocks, 0); m_SeenMapBlocks.Remove(clientID); } } }
public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) { ScenePresence sp = scene.GetScenePresence(agentId); if (sp == null || sp.IsChildAgent) return false; lock (m_avatars) if (!m_avatars.ContainsKey(agentId)) return false; scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); sp.Appearance = npcAppearance; scene.AttachmentsModule.RezAttachments(sp); IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>(); module.SendAppearance(sp.UUID); return true; }
private AvatarAppearance GetAppearance(UUID target, Scene scene) { if (m_appearanceCache.ContainsKey(target)) return m_appearanceCache[target]; ScenePresence originalPresence = scene.GetScenePresence(target); if (originalPresence != null) { AvatarAppearance originalAppearance = originalPresence.Appearance; m_appearanceCache.Add(target, originalAppearance); return originalAppearance; } else { m_log.DebugFormat( "[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target); return new AvatarAppearance(); } }
public void OnClosingClient(UUID clientID, Scene scene) { //Clear out the auth speakers list lock (m_authorizedSpeakers) { if (m_authorizedSpeakers.Contains(clientID)) m_authorizedSpeakers.Remove(clientID); } ScenePresence presence = scene.GetScenePresence(clientID); //Announce the closing agent if enabled if (m_announceClosedAgents) { scene.ForEachScenePresence(delegate(ScenePresence SP) { if (SP.UUID != clientID && !SP.IsChildAgent) { IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule>(); if (entityCountModule != null) SP.ControllingClient.SendChatMessage(presence.Name + " has left the region. Total Agents: " + entityCountModule.RootAgents, 1, SP.AbsolutePosition, "System", UUID.Zero, (byte)ChatSourceType.System, (byte)ChatAudibleLevel.Fully); } } ); } }
/// <summary> /// Installs terrain brush hook to IClientAPI /// </summary> /// <param name="client"></param> private void EventManager_OnClientClosed(UUID client, Scene scene) { ScenePresence presence = scene.GetScenePresence(client); if (presence != null) { presence.ControllingClient.OnModifyTerrain -= client_OnModifyTerrain; presence.ControllingClient.OnBakeTerrain -= client_OnBakeTerrain; presence.ControllingClient.OnLandUndo -= client_OnLandUndo; presence.ControllingClient.OnUnackedTerrain -= client_OnUnackedTerrain; } }
/// Callback for a client request for Voice Account Details. public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { try { m_log.Info("[MurmurVoice]: Calling ProvisionVoiceAccountRequest..."); ScenePresence avatar = null; if (scene == null) throw new Exception("[MurmurVoice] Invalid scene."); avatar = scene.GetScenePresence(agentID); while(avatar == null) { avatar = scene.GetScenePresence(agentID); Thread.Sleep(100); } Agent agent = m_manager.Agent.GetOrCreate(agentID); LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agent.web, agent.pass, m_murmurd_exthost, String.Format("tcp://{0}:{1}", m_murmurd_exthost, m_murmurd_port) ); string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); m_log.InfoFormat("[MurmurVoice]: VoiceAccount: {0}", r); return r; } catch (Exception e) { m_log.DebugFormat("[MurmurVoice]: {0} failed", e.ToString()); return "<llsd><undef /></llsd>"; } }
/// Callback for a client request for a private chat channel public string ChatSessionRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); string avatarName = avatar.Name; m_log.DebugFormat("[MurmurVoice] Chat Session: avatar \"{0}\": request: {1}, path: {2}, param: {3}", avatarName, request, path, param); return "<llsd>true</llsd>"; }
/// <summary> /// Callback for a client request for Voice Account Details /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { m_log.DebugFormat( "[FreeSwitchVoice][PROVISIONVOICE]: ProvisionVoiceAccountRequest() request: {0}, path: {1}, param: {2}", request, path, param); ScenePresence avatar = scene.GetScenePresence(agentID); if (avatar == null) { System.Threading.Thread.Sleep(2000); avatar = scene.GetScenePresence(agentID); if (avatar == null) return "<llsd>undef</llsd>"; } string avatarName = avatar.Name; try { //XmlElement resp; string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); string password = "******";//temp hack//new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16); // XXX: we need to cache the voice credentials, as // FreeSwitch is later going to come and ask us for // those agentname = agentname.Replace('+', '-').Replace('/', '_'); lock (m_UUIDName) { if (m_UUIDName.ContainsKey(agentname)) { m_UUIDName[agentname] = avatarName; } else { m_UUIDName.Add(agentname, avatarName); } } // LLSDVoiceAccountResponse voiceAccountResponse = // new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, "http://etsvc02.hursley.ibm.com/api"); LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agentname, password, m_freeSwitchRealm, String.Format("http://{0}:{1}{2}/", m_openSimWellKnownHTTPAddress, m_freeSwitchServicePort, m_freeSwitchAPIPrefix)); string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); // m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); return r; } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1}, retry later", avatarName, e.Message); m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: avatar \"{0}\": {1} failed", avatarName, e.ToString()); return "<llsd>undef</llsd>"; } }
private bool CanDeedObject(UUID user, UUID group, Scene scene) { DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; ScenePresence sp = scene.GetScenePresence(user); IClientAPI client = sp.ControllingClient; if ((client.GetGroupPowers(group) & (ulong)GroupPowers.DeedObject) == 0) return false; return true; }
private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene) { DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; GroupPowers powers; ILandObject l; ScenePresence sp = scene.GetScenePresence(user); if (sp == null) return false; IClientAPI client = sp.ControllingClient; foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects)) { // Any user can return their own objects at any time // if (GenericObjectPermission(user, g.UUID, false)) continue; // This is a short cut for efficiency. If land is non-null, // then all objects are on that parcel and we can save // ourselves the checking for each prim. Much faster. // if (land != null) { l = land; } else { Vector3 pos = g.AbsolutePosition; l = scene.LandChannel.GetLandObject(pos.X, pos.Y); } // If it's not over any land, then we can't do a thing if (l == null) { objects.Remove(g); continue; } // If we own the land outright, then allow // if (l.LandData.OwnerID == user) continue; // Group voodoo // if (l.LandData.IsGroupOwned) { powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID); // Not a group member, or no rights at all // if (powers == (GroupPowers)0) { objects.Remove(g); continue; } // Group deeded object? // if (g.OwnerID == l.LandData.GroupID && (powers & GroupPowers.ReturnGroupOwned) == (GroupPowers)0) { objects.Remove(g); continue; } // Group set object? // if (g.GroupID == l.LandData.GroupID && (powers & GroupPowers.ReturnGroupSet) == (GroupPowers)0) { objects.Remove(g); continue; } if ((powers & GroupPowers.ReturnNonGroup) == (GroupPowers)0) { objects.Remove(g); continue; } // So we can remove all objects from this group land. // Fine. // continue; } // By default, we can't remove // objects.Remove(g); } if (objects.Count == 0) return false; return true; }
public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) { ScenePresence npc = scene.GetScenePresence(agentId); if (npc == null || npc.IsChildAgent) return false; lock (m_avatars) if (!m_avatars.ContainsKey(agentId)) return false; // Delete existing npc attachments scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); npc.Appearance = npcAppearance; // Rez needed npc attachments scene.AttachmentsModule.RezAttachments(npc); IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>(); module.SendAppearance(npc.UUID); return true; }
public PollServiceInventoryEventArgs(Scene scene, string url, UUID pId) : base(null, url, null, null, null, pId, int.MaxValue) { m_scene = scene; HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; GetEvents = (x, y) => { lock (responses) { try { return responses[x]; } finally { responses.Remove(x); } } }; Request = (x, y) => { ScenePresence sp = m_scene.GetScenePresence(Id); if (sp == null) { m_log.ErrorFormat("[INVENTORY]: Unable to find ScenePresence for {0}", Id); return; } aPollRequest reqinfo = new aPollRequest(); reqinfo.thepoll = this; reqinfo.reqID = x; reqinfo.request = y; reqinfo.presence = sp; reqinfo.folders = new List<UUID>(); // Decode the request here string request = y["body"].ToString(); request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); request = request.Replace("<key>fetch_folders</key><integer>0</integer>", "<key>fetch_folders</key><boolean>0</boolean>"); request = request.Replace("<key>fetch_folders</key><integer>1</integer>", "<key>fetch_folders</key><boolean>1</boolean>"); Hashtable hash = new Hashtable(); try { hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); } catch (LLSD.LLSDParseException e) { m_log.ErrorFormat("[INVENTORY]: Fetch error: {0}{1}" + e.Message, e.StackTrace); m_log.Error("Request: " + request); return; } catch (System.Xml.XmlException) { m_log.ErrorFormat("[INVENTORY]: XML Format error"); } ArrayList foldersrequested = (ArrayList)hash["folders"]; bool highPriority = false; for (int i = 0; i < foldersrequested.Count; i++) { Hashtable inventoryhash = (Hashtable)foldersrequested[i]; string folder = inventoryhash["folder_id"].ToString(); UUID folderID; if (UUID.TryParse(folder, out folderID)) { if (!reqinfo.folders.Contains(folderID)) { //TODO: Port COF handling from Avination reqinfo.folders.Add(folderID); } } } if (highPriority) m_queue.EnqueueHigh(reqinfo); else m_queue.EnqueueLow(reqinfo); }; NoEvents = (x, y) => { /* lock (requests) { Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); requests.Remove(request); } */ Hashtable response = new Hashtable(); response["int_response_code"] = 500; response["str_response_string"] = "Script timeout"; response["content_type"] = "text/plain"; response["keepalive"] = false; response["reusecontext"] = false; return response; }; }
private bool OnAllowedIncomingAgent(Scene scene, AgentCircuitData agent, bool isRootAgent, out string reason) { #region Incoming Agent Checks Vector3 Position = agent.startpos; UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, agent.AgentID); ScenePresence Sp = scene.GetScenePresence(agent.AgentID); if (account == null) { reason = "Failed authentication."; return false; //NO! } if (LoginsDisabled) { reason = "Logins Disabled"; return false; } //Check how long its been since the last TP if (m_enabledBlockTeleportSeconds && Sp != null && !Sp.IsChildAgent) { if (TimeSinceLastTeleport.ContainsKey(Sp.Scene.RegionInfo.RegionID)) { if (TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] > Util.UnixTimeSinceEpoch()) { reason = "Too many teleports. Please try again soon."; return false; // Too soon since the last TP } } TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] = Util.UnixTimeSinceEpoch() + ((int)(SecondsBeforeNextTeleport)); } //Gods tp freely if ((Sp != null && Sp.GodLevel != 0) || account.UserLevel != 0) { reason = ""; return true; } //Check whether they fit any ban criteria if (Sp != null) { foreach (string banstr in BanCriteria) { if (Sp.Name.Contains(banstr)) { reason = "You have been banned from this region."; return false; } else if (((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString().Contains(banstr)) { reason = "You have been banned from this region."; return false; } } //Make sure they exist in the grid right now IPresenceService presence = scene.RequestModuleInterface<IPresenceService>(); if (presence == null) { reason = String.Format("Failed to verify user presence in the grid for {0} in region {1}. Presence service does not exist.", account.Name, scene.RegionInfo.RegionName); return false; } OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID); if (pinfo == null) { reason = String.Format("Failed to verify user presence in the grid for {0}, access denied to region {1}.", account.Name, scene.RegionInfo.RegionName); return false; } } EstateSettings ES = scene.RegionInfo.EstateSettings; IEntityCountModule entityCountModule = scene.RequestModuleInterface<IEntityCountModule>(); if (entityCountModule != null && scene.RegionInfo.RegionSettings.AgentLimit < entityCountModule.RootAgents + 1) { reason = "Too many agents at this time. Please come back later."; return false; } List<EstateBan> EstateBans = new List<EstateBan>(ES.EstateBans); int i = 0; //Check bans foreach (EstateBan ban in EstateBans) { if (ban.BannedUserID == agent.AgentID) { if (Sp != null) { string banIP = ((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString(); if (ban.BannedHostIPMask != banIP) //If it changed, ban them again { //Add the ban with the new hostname ES.AddBan(new EstateBan() { BannedHostIPMask = banIP, BannedUserID = ban.BannedUserID, EstateID = ban.EstateID, BannedHostAddress = ban.BannedHostAddress, BannedHostNameMask = ban.BannedHostNameMask }); //Update the database ES.Save(); } } reason = "Banned from this region."; return false; } if (Sp != null) { IPAddress end = Sp.ControllingClient.EndPoint; IPHostEntry rDNS = null; try { rDNS = Dns.GetHostEntry(end); } catch (System.Net.Sockets.SocketException) { m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end); rDNS = null; } if (ban.BannedHostIPMask == agent.IPAddress || (rDNS != null && rDNS.HostName.Contains(ban.BannedHostIPMask)) || end.ToString().StartsWith(ban.BannedHostIPMask)) { //Ban the new user ES.AddBan(new EstateBan() { EstateID = ES.EstateID, BannedHostIPMask = agent.IPAddress, BannedUserID = agent.AgentID, BannedHostAddress = agent.IPAddress, BannedHostNameMask = agent.IPAddress }); ES.Save(); reason = "Banned from this region."; return false; } } i++; } //Estate owners/managers/access list people/access groups tp freely as well if (ES.EstateOwner == agent.AgentID || new List<UUID>(ES.EstateManagers).Contains(agent.AgentID) || new List<UUID>(ES.EstateAccess).Contains(agent.AgentID) || (Sp != null && new List<UUID>(ES.EstateGroups).Contains(Sp.ControllingClient.ActiveGroupId))) { reason = ""; return true; } if (ES.DenyAnonymous && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile)) { reason = "You may not enter this region."; return false; } if (ES.DenyIdentified && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile)) { reason = "You may not enter this region."; return false; } if (ES.DenyTransacted && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse) == (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse)) { reason = "You may not enter this region."; return false; } long m_Day = 25 * 60 * 60; //Find out day length in seconds if (scene.RegionInfo.RegionSettings.MinimumAge != 0 && (account.Created - Util.UnixTimeSinceEpoch()) < (scene.RegionInfo.RegionSettings.MinimumAge * m_Day)) { reason = "You may not enter this region."; return false; } if (!ES.PublicAccess) { reason = "You may not enter this region."; return false; } IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin<IAgentConnector>(); IAgentInfo agentInfo = null; if (AgentConnector != null) { agentInfo = AgentConnector.GetAgent(agent.AgentID); if (agentInfo == null) { AgentConnector.CreateNewAgent(agent.AgentID); agentInfo = AgentConnector.GetAgent(agent.AgentID); } } if (agentInfo != null && scene.RegionInfo.AccessLevel > Util.ConvertMaturityToAccessLevel((uint)agentInfo.MaturityRating)) { reason = "The region has too high of a maturity level. Blocking teleport."; return false; } if (agentInfo != null && ES.DenyMinors && (agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor) { reason = "The region has too high of a maturity level. Blocking teleport."; return false; } #endregion reason = ""; return true; }
private bool OnAllowedIncomingTeleport(UUID userID, Scene scene, Vector3 Position, out Vector3 newPosition, out string reason) { newPosition = Position; UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID); ScenePresence Sp = scene.GetScenePresence(userID); if (account == null) { reason = "Failed authentication."; return false; //NO! } //Make sure that this user is inside the region as well if (Position.X < 0f || Position.Y < 0f || Position.X > scene.RegionInfo.RegionSizeX || Position.Y > scene.RegionInfo.RegionSizeY) { m_log.DebugFormat( "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping", Position, Name, userID); bool changedX = false; bool changedY = false; while (Position.X < 0) { Position.X += scene.RegionInfo.RegionSizeX; changedX = true; } while (Position.X > scene.RegionInfo.RegionSizeX) { Position.X -= scene.RegionInfo.RegionSizeX; changedX = true; } while (Position.Y < 0) { Position.Y += scene.RegionInfo.RegionSizeY; changedY = true; } while (Position.Y > scene.RegionInfo.RegionSizeY) { Position.Y -= scene.RegionInfo.RegionSizeY; changedY = true; } if (changedX) Position.X = scene.RegionInfo.RegionSizeX - Position.X; if(changedY) Position.Y = scene.RegionInfo.RegionSizeY - Position.Y; } //Check that we are not underground as well float posZLimit = (float)scene.RequestModuleInterface<ITerrainChannel>()[(int)Position.X, (int)Position.Y]; if (posZLimit >= (Position.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit))) { Position.Z = posZLimit; } IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin<IAgentConnector>(); IAgentInfo agentInfo = null; if (AgentConnector != null) agentInfo = AgentConnector.GetAgent(userID); ILandObject ILO = null; IParcelManagementModule parcelManagement = scene.RequestModuleInterface<IParcelManagementModule>(); if (parcelManagement != null) ILO = parcelManagement.GetLandObject(Position.X, Position.Y); if (ILO == null) { //Can't find land, give them the first parcel in the region and find a good position for them ILO = parcelManagement.AllParcels()[0]; Position = parcelManagement.GetParcelCenterAtGround(ILO); } //parcel permissions if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block { if (Sp == null) { reason = "Banned from this parcel."; return true; } if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { //We found a place for them, but we don't need to check any further return true; } } //Move them out of banned parcels ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags; if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup && (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList && (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { //One of these is in play then if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup) { if (Sp == null) { reason = "Banned from this parcel."; return true; } if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } } else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList) { if (Sp == null) { reason = "Banned from this parcel."; return true; } //All but the people on the access list are banned if (ILO.IsRestrictedFromLand(userID)) if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { if (Sp == null) { reason = "Banned from this parcel."; return true; } //All but the people on the pass/access list are banned if (ILO.IsRestrictedFromLand(Sp.UUID)) if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } } EstateSettings ES = scene.RegionInfo.EstateSettings; //Move them to the nearest landing point if (!ES.AllowDirectTeleport) { Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID); if (telehub != null) { if (telehub.SpawnPos.Count == 0) { newPosition = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); } else { int LastTelehubNum = 0; if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum)) LastTelehubNum = 0; newPosition = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); LastTelehubNum++; if (LastTelehubNum == telehub.SpawnPos.Count) LastTelehubNum = 0; LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum; } } else { reason = "Teleport has been blocked for this region."; return false; } } else { //If they are owner, they don't have to have permissions checked if (!scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None)) { if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land { //Find a new parcel for them List<ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position); if (Parcels.Count == 0) { ScenePresence SP; scene.TryGetScenePresence(userID, out SP); newPosition = parcelManagement.GetNearestRegionEdgePosition(SP); } else { bool found = false; //We need to check here as well for bans, can't toss someone into a parcel they are banned from foreach (ILandObject Parcel in Parcels) { if (!Parcel.IsBannedFromLand(userID)) { //Now we have to check their userloc if (ILO.LandData.LandingType == 2) continue; //Blocked, check next one else if (ILO.LandData.LandingType == 1) //Use their landing spot newPosition = Parcel.LandData.UserLocation; else //They allow for anywhere, so dump them in the center at the ground newPosition = parcelManagement.GetParcelCenterAtGround(Parcel); found = true; } } if (!found) //Dump them at the edge { if (Sp != null) newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp); else { reason = "Banned from this parcel."; return true; } } } } else if (ILO.LandData.LandingType == 1) //Move to tp spot if (ILO.LandData.UserLocation != Vector3.Zero) newPosition = ILO.LandData.UserLocation; else // Dump them at the nearest region corner since they havn't set a landing point newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp); } } //Can only enter prelude regions once! int flags = scene.GridService.GetRegionFlags(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionID); //We assume that our own region isn't null.... if (agentInfo != null) { if (((flags & (int)Aurora.Framework.RegionFlags.Prelude) == (int)Aurora.Framework.RegionFlags.Prelude) && agentInfo != null) { if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID)) { reason = "You may not enter this region as you have already been to this prelude region."; return false; } else { agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID, OSD.FromInteger((int)IAgentFlags.PastPrelude)); AgentConnector.UpdateAgent(agentInfo); //This only works for standalones... and thats ok } } } if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0) { if ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) { reason = "You may not enter this region."; return false; } } if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null) { if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor) { reason = "You may not enter this region."; return false; } } newPosition = Position; reason = ""; return true; }
void OnClientClosed(UUID AgentId, Scene scene) { ScenePresence sp = scene.GetScenePresence(AgentId); IClientAPI client = sp.ControllingClient; if (client == null) return; //Profile client.OnRequestAvatarProperties -= RequestAvatarProperties; client.OnUpdateAvatarProperties -= AvatarPropertiesUpdate; client.OnAvatarInterestUpdate -= AvatarInterestsUpdate; // Classifieds // client.r GenericPacketHandler("avatarclassifiedsrequest", ClassifiedsRequest); client.OnClassifiedInfoUpdate -= ClassifiedInfoUpdate; client.OnClassifiedInfoRequest -= ClassifiedInfoRequest; client.OnClassifiedDelete -= ClassifiedDelete; // Picks // client.AddGenericPacketHandler("avatarpicksrequest", PicksRequest); // client.AddGenericPacketHandler("pickinforequest", PickInfoRequest); client.OnPickInfoUpdate -= PickInfoUpdate; client.OnPickDelete -= PickDelete; // Notes // client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest); client.OnAvatarNotesUpdate -= NotesUpdate; // Preferences client.OnUserInfoRequest -= UserPreferencesRequest; client.OnUpdateUserInfo -= UpdateUserPreferences; }
public void SendSelectedParcelUpdate(ILandObject parcel, Scene scene, UUID agentID) { ScenePresence SP = scene.GetScenePresence(agentID); IClientAPI client = (SP == null) ? null : SP.ControllingClient; if (client != null) parcel.SendSelectedLandUpdate(client); }
public void Populate(Scene scene) { SceneObjectPart part = scene.GetSceneObjectPart(Key); if (part == null) // Avatar, maybe? { ScenePresence presence = scene.GetScenePresence(Key); if (presence == null) return; Name = presence.Firstname + " " + presence.Lastname; Owner = Key; Position = new LSL_Types.Vector3(presence.AbsolutePosition); Rotation = new LSL_Types.Quaternion( presence.Rotation.X, presence.Rotation.Y, presence.Rotation.Z, presence.Rotation.W); Velocity = new LSL_Types.Vector3(presence.Velocity); if (presence.PresenceType != PresenceType.Npc) { Type = AGENT; } else { Type = OS_NPC; INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); if (npcData.SenseAsAgent) { Type |= AGENT; } } if (presence.Velocity != Vector3.Zero) Type |= ACTIVE; Group = presence.ControllingClient.ActiveGroupId; return; } part = part.ParentGroup.RootPart; // We detect objects only LinkNum = 0; // Not relevant Group = part.GroupID; Name = part.Name; Owner = part.OwnerID; if (part.Velocity == Vector3.Zero) Type = PASSIVE; else Type = ACTIVE; foreach (SceneObjectPart p in part.ParentGroup.Parts) { if (p.Inventory.ContainsScripts()) { Type |= SCRIPTED; // Scripted break; } } Position = new LSL_Types.Vector3(part.AbsolutePosition); Quaternion wr = part.ParentGroup.GroupRotation; Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); Velocity = new LSL_Types.Vector3(part.Velocity); }
private void OnClientClosed(UUID agentID, Scene scene) { ScenePresence sp = scene.GetScenePresence(agentID); if (sp != null && !sp.IsChildAgent) { // do this for root agents closing out StatusChange(agentID, false); } lock (m_Friends) { UserFriendData friendsData; if (m_Friends.TryGetValue(agentID, out friendsData)) { friendsData.Refcount--; if (friendsData.Refcount <= 0) m_Friends.Remove(agentID); } } }
private bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene) { DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); if (m_bypassPermissions) return m_bypassPermissionsValue; if (parcel.LandData.OwnerID != user) // Only the owner can deed! return false; ScenePresence sp = scene.GetScenePresence(user); IClientAPI client = sp.ControllingClient; if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0) return false; return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed); }
/// <summary> /// Callback for a client request for ParcelVoiceInfo /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { ScenePresence avatar = scene.GetScenePresence(agentID); if (avatar == null) // seen on the main grid, perhaps on user disconnect or viewer crash return EMPTY_RESPONSE; string avatarName = avatar.Name; // - check whether we have a region channel in our cache // - if not: // create it and cache it // - send it to the client // - send channel_uri: as "sip:regionID@m_sipDomain" try { LLSDParcelVoiceInfoResponse parcelVoiceInfo; string channel_uri; if (null == scene.LandChannel) throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatarName)); // If the avatar is in transit between regions, avatar.AbsolutePosition calls below can return undefined values. if (avatar.IsInTransit) { m_log.WarnFormat("[VivoxVoice][PARCELVOICE]: Cannot process voice info request - avatar {0} is still in transit between regions.", avatarName); return EMPTY_RESPONSE; } // get channel_uri: check first whether estate // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel // voice channel LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); if (land == null) { // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar\"{1}\" at ({2}): Land parcel not found.", // scene.RegionInfo.RegionName, avatarName, avatar.AbsolutePosition.ToString()); return EMPTY_RESPONSE; } // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: avatar \"{0}\": location: {1} {2} {3}", // avatarName, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); // TODO: EstateSettings don't seem to get propagated... if (!scene.RegionInfo.EstateSettings.AllowVoice) { m_log.InfoFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings", scene.RegionInfo.RegionName); channel_uri = String.Empty; } if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) { m_log.InfoFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); channel_uri = String.Empty; } else { channel_uri = RegionGetOrCreateChannel(scene, land); } // fill in our response to the client Hashtable creds = new Hashtable(); creds["channel_uri"] = channel_uri; parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerializeLLSDReply(parcelVoiceInfo); // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); return r; } catch (Exception e) { m_log.ErrorFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", scene.RegionInfo.RegionName, avatarName, e.Message); m_log.ErrorFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} exception", scene.RegionInfo.RegionName, avatarName, e.ToString()); return EMPTY_RESPONSE; } }
private void OnClientClosed(UUID AgentId, Scene scene) { if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (scene == null) return; ScenePresence sp = scene.GetScenePresence(AgentId); IClientAPI client = sp.ControllingClient; if (client != null) { client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest; client.OnRequestAvatarProperties -= OnRequestAvatarProperties; // make child possible not called? client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest; client.OnInstantMessage -= OnInstantMessage; } /* lock (m_ActiveClients) { if (m_ActiveClients.ContainsKey(AgentId)) { IClientAPI client = m_ActiveClients[AgentId]; client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest; client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest; client.OnDirFindQuery -= OnDirFindQuery; client.OnInstantMessage -= OnInstantMessage; m_ActiveClients.Remove(AgentId); } else { if (m_debugEnabled) m_log.WarnFormat("[Groups]: Client closed that wasn't registered here."); } } */ }
/// <summary> /// Add a root agent. /// </summary> /// /// This function /// /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the /// userserver if grid) would give initial login data back to the client and separately tell the scene that the /// agent was coming. /// /// 2) Connects the agent with the scene /// /// This function performs actions equivalent with notifying the scene that an agent is /// coming and then actually connecting the agent to the scene. The one step missed out is the very first /// /// <param name="scene"></param> /// <param name="agentData"></param> /// <returns></returns> public static TestClient AddRootAgent(Scene scene, AgentCircuitData agentData) { string reason; // We emulate the proper login sequence here by doing things in three stages // Stage 1: simulate login by telling the scene to expect a new user connection scene.NewUserConnection(agentData, out reason); // Stage 2: add the new client as a child agent to the scene TestClient client = new TestClient(agentData, scene); scene.AddNewClient(client); // Stage 3: Invoke agent crossing, which converts the child agent into a root agent (with appearance, // inventory, etc.) //scene.AgentCrossing(agentData.AgentID, new Vector3(90, 90, 90), false); OBSOLETE ScenePresence scp = scene.GetScenePresence(agentData.AgentID); scp.MakeRootAgent(new Vector3(90,90,90), true); return client; }
/// <summary> /// Callback for a client request for ParcelVoiceInfo /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { m_log.DebugFormat( "[FreeSwitchVoice][PARCELVOICE]: ParcelVoiceInfoRequest() on {0} for {1}", scene.RegionInfo.RegionName, agentID); ScenePresence avatar = scene.GetScenePresence(agentID); string avatarName = avatar.Name; // - check whether we have a region channel in our cache // - if not: // create it and cache it // - send it to the client // - send channel_uri: as "sip:regionID@m_sipDomain" try { LLSDParcelVoiceInfoResponse parcelVoiceInfo; string channelUri; if (null == scene.LandChannel) throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatarName)); // get channel_uri: check first whether estate // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel // voice channel LandData land = scene.GetLandData(avatar.AbsolutePosition); //m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); // TODO: EstateSettings don't seem to get propagated... // if (!scene.RegionInfo.EstateSettings.AllowVoice) // { // m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings", // scene.RegionInfo.RegionName); // channel_uri = String.Empty; // } // else if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) { // m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); channelUri = String.Empty; } else { channelUri = ChannelUri(scene, land); } // fill in our response to the client Hashtable creds = new Hashtable(); creds["channel_uri"] = channelUri; parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); // m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); return r; } catch (Exception e) { m_log.ErrorFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", scene.RegionInfo.RegionName, avatarName, e.Message); m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", scene.RegionInfo.RegionName, avatarName, e.ToString()); return "<llsd>undef</llsd>"; } }
/// <summary> /// Introduce an agent into the scene by adding a new client. /// </summary> /// <returns>The scene presence added</returns> /// <param name='scene'></param> /// <param name='testClient'></param> /// <param name='agentData'></param> /// <param name='tf'></param> private static ScenePresence IntroduceClientToScene( Scene scene, IClientAPI client, AgentCircuitData agentData, TeleportFlags tf) { string reason; // Stage 1: tell the scene to expect a new user connection if (!scene.NewUserConnection(agentData, (uint)tf, null, out reason)) Console.WriteLine("NewUserConnection failed: " + reason); // Stage 2: add the new client as a child agent to the scene scene.AddNewAgent(client, PresenceType.User); return scene.GetScenePresence(client.AgentId); }
/// Callback for a client request for ParcelVoiceInfo public string ParcelVoiceInfoRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { m_log.Info("[MurmurVoice]: Calling ParcelVoiceInfoRequest..."); try { ScenePresence avatar = scene.GetScenePresence(agentID); LLSDParcelVoiceInfoResponse parcelVoiceInfo; string channel_uri = String.Empty; if (null == scene.LandChannel) throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", scene.RegionInfo.RegionName, avatar.Name)); // get channel_uri: check first whether estate // settings allow voice, then whether parcel allows // voice, if all do retrieve or obtain the parcel // voice channel LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); m_log.DebugFormat("[MurmurVoice]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", scene.RegionInfo.RegionName, land.Name, land.LocalID, avatar.Name, request, path, param); if ( ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) > 0) && scene.RegionInfo.EstateSettings.AllowVoice ) { Agent agent = m_manager.Agent.GetOrCreate(agentID); string RegionName = scene.RegionInfo.RegionName; if(m_RegionParents.ContainsKey(RegionName)) { int RParent = m_RegionParents[RegionName]; agent.channel = m_manager.Channel.GetOrCreate(ChannelName(scene, land),RParent); // Host/port pair for voice server channel_uri = String.Format("{0}:{1}", m_murmurd_exthost, m_murmurd_port); m_log.InfoFormat("[MurmurVoice]: {0}", channel_uri); m_callback.AddUserToChan(agent); } else m_log.DebugFormat("[MurmurVoice]: Region Parent channel not found: {0}",RegionName); } else { m_log.DebugFormat("[MurmurVoice]: Voice not enabled."); } Hashtable creds = new Hashtable(); creds["channel_uri"] = channel_uri; parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); m_log.InfoFormat("[MurmurVoice]: Parcel: {0}", r); return r; } catch (Exception e) { m_log.ErrorFormat("[MurmurVoice]: Exception: " + e.ToString()); return "<llsd><undef /></llsd>"; } }
public bool AllowTeleport(UUID userID, Scene scene, Vector3 Position, AgentCircuitData ACD, out Vector3 newPosition, out string reason) { newPosition = Position; UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID); ScenePresence Sp = scene.GetScenePresence(userID); if (account == null) { reason = "Failed authentication."; return false; //NO! } //Check how long its been since the last TP if (m_enabledBlockTeleportSeconds && Sp != null && !Sp.IsChildAgent) { if (TimeSinceLastTeleport.ContainsKey(Sp.Scene.RegionInfo.RegionID)) { if (TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] > Util.UnixTimeSinceEpoch()) { reason = "Too many teleports. Please try again soon."; return false; // Too soon since the last TP } } TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] = Util.UnixTimeSinceEpoch() + ((int)(SecondsBeforeNextTeleport)); } //Gods tp freely if ((Sp != null && Sp.GodLevel != 0) || account.UserLevel != 0) { reason = ""; return true; } //Check whether they fit any ban criteria if (Sp != null) { foreach (string banstr in BanCriteria) { if (Sp.Name.Contains(banstr)) { reason = "You have been banned from this region."; return false; } else if (((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString().Contains(banstr)) { reason = "You have been banned from this region."; return false; } } } EstateSettings ES = scene.RegionInfo.EstateSettings; if (scene.RegionInfo.RegionSettings.AgentLimit < scene.GetRootAgentCount() + 1) { reason = "Too many agents at this time. Please come back later."; return false; } List<EstateBan> EstateBans = new List<EstateBan>(ES.EstateBans); int i = 0; //Check bans foreach (EstateBan ban in EstateBans) { if (ban.BannedUserID == userID) { string banIP = ((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString(); if (ban.BannedHostIPMask != banIP) //If it changed, ban them again { //Add the ban with the new hostname ES.AddBan(new EstateBan() { BannedHostIPMask = banIP, BannedUserID = ban.BannedUserID, EstateID = ban.EstateID, BannedHostAddress = ban.BannedHostAddress, BannedHostNameMask = ban.BannedHostNameMask }); //Update the database ES.Save(); } reason = "Banned from this region."; return false; } if (ban.BannedHostIPMask == ACD.IPAddress) { //Ban the new user ES.AddBan(new EstateBan() { EstateID = ES.EstateID, BannedHostIPMask = ACD.IPAddress, BannedUserID = userID, BannedHostAddress = ACD.IPAddress, BannedHostNameMask = ACD.IPAddress }); ES.Save(); reason = "Banned from this region."; return false; } i++; } //Estate owners/managers/access list people/access groups tp freely as well if (ES.EstateOwner == userID || new List<UUID>(ES.EstateManagers).Contains(userID) || new List<UUID>(ES.EstateAccess).Contains(userID) || (Sp != null && new List<UUID>(ES.EstateGroups).Contains(Sp.ControllingClient.ActiveGroupId))) { reason = ""; return true; } if (ES.DenyAnonymous && ((account.UserFlags & (int)ProfileFlags.NoPaymentInfoOnFile) == (int)ProfileFlags.NoPaymentInfoOnFile)) { reason = "You may not enter this region."; return false; } if (ES.DenyIdentified && ((account.UserFlags & (int)ProfileFlags.PaymentInfoOnFile) == (int)ProfileFlags.PaymentInfoOnFile)) { reason = "You may not enter this region."; return false; } if (ES.DenyTransacted && ((account.UserFlags & (int)ProfileFlags.PaymentInfoInUse) == (int)ProfileFlags.PaymentInfoInUse)) { reason = "You may not enter this region."; return false; } long m_Day = 25 * 60 * 60; //Find out day length in seconds if (scene.RegionInfo.RegionSettings.MinimumAge != 0 && (account.Created - Util.UnixTimeSinceEpoch()) < (scene.RegionInfo.RegionSettings.MinimumAge * m_Day)) { reason = "You may not enter this region."; return false; } if (!ES.PublicAccess) { reason = "You may not enter this region."; return false; } IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin<IAgentConnector>(); IAgentInfo agentInfo = null; if (AgentConnector != null) { agentInfo = AgentConnector.GetAgent(userID); if (agentInfo == null) { AgentConnector.CreateNewAgent(userID); agentInfo = AgentConnector.GetAgent(userID); } } if (agentInfo != null && scene.RegionInfo.RegionSettings.Maturity > agentInfo.MaturityRating) { reason = "The region has too high of a maturity level. Blocking teleport."; return false; } if (agentInfo != null && ES.DenyMinors && (agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor) { reason = "The region has too high of a maturity level. Blocking teleport."; return false; } ILandObject ILO = scene.LandChannel.GetLandObject(Position.X, Position.Y); if (ILO == null) // Can't teleport into a parcel that doesn't exist { reason = "Failed authentication."; return false; } //parcel permissions if (ILO.IsEitherBannedOrRestricted(userID)) { if (Sp == null) { reason = "Banned from this parcel."; return true; } if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) { //We found a place for them, but we don't need to check any further return true; } } //Move them out of banned parcels ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags; if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup && (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList && (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { //One of these is in play then if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup) { if (Sp == null) { reason = "Banned from this parcel."; return true; } if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID) { if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } } else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList) { if (Sp == null) { reason = "Banned from this parcel."; return true; } //All but the people on the access list are banned if (!ILO.CreateAccessListArrayByFlag(AccessList.Access).Contains(Sp.UUID)) if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList) { if (Sp == null) { reason = "Banned from this parcel."; return true; } //All but the people on the pass/access list are banned if (!ILO.CreateAccessListArrayByFlag(AccessList.Access).Contains(Sp.UUID)) if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason)) //We found a place for them, but we don't need to check any further return true; } } //Move them to the nearest landing point if (!ES.AllowDirectTeleport) { Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID); if (telehub != null) { if (telehub.SpawnPos.Count == 0) { newPosition = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); } else { int LastTelehubNum = 0; if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum)) LastTelehubNum = 0; newPosition = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ); LastTelehubNum++; if (LastTelehubNum == telehub.SpawnPos.Count) LastTelehubNum = 0; LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum; } } else { reason = "Teleport has been blocked for this region."; return false; } } else { //If they are owner, they don't have to have permissions checked if (!m_scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None)) { if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land { //Find a new parcel for them List<ILandObject> Parcels = m_scene.LandChannel.ParcelsNearPoint(Position); if (Parcels.Count == 0) { ScenePresence SP; scene.TryGetScenePresence(userID, out SP); newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(SP); } else { bool found = false; //We need to check here as well for bans, can't toss someone into a parcel they are banned from foreach (ILandObject Parcel in Parcels) { if (!Parcel.IsBannedFromLand(userID)) { //Now we have to check their userloc if (ILO.LandData.LandingType == 2) continue; //Blocked, check next one else if (ILO.LandData.LandingType == 1) //Use their landing spot newPosition = Parcel.LandData.UserLocation; else //They allow for anywhere, so dump them in the center at the ground newPosition = m_scene.LandChannel.GetParcelCenterAtGround(Parcel); found = true; } } if (!found) //Dump them at the edge { if(Sp != null) newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(Sp); else { reason = "Banned from this parcel."; return true; } } } } else if (ILO.LandData.LandingType == 1) //Move to tp spot newPosition = ILO.LandData.UserLocation; } } //Can only enter prelude regions once! int flags = m_scene.GridService.GetRegionFlags(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); //We assume that our own region isn't null.... if (((flags & (int)OpenSim.Data.RegionFlags.Prelude) == (int)OpenSim.Data.RegionFlags.Prelude) && agentInfo != null) { if (((agentInfo.Flags & IAgentFlags.PastPrelude) == IAgentFlags.PastPrelude)) { reason = "You may not enter this region as you have already been to a prelude region."; return false; } else { agentInfo.Flags |= IAgentFlags.PastPrelude; AgentConnector.UpdateAgent(agentInfo); //This only works for standalones... and thats ok } } if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0) { if ((account.UserFlags & (int)ProfileFlags.NoPaymentInfoOnFile) == (int)ProfileFlags.NoPaymentInfoOnFile) { reason = "You may not enter this region."; return false; } } if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null) { if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor) { reason = "You may not enter this region."; return false; } } reason = ""; return true; }
public void Populate(Scene scene) { SceneObjectPart part = scene.GetSceneObjectPart(Key); if (part == null) // Avatar, maybe? { ScenePresence presence = scene.GetScenePresence(Key); if (presence == null) return; Name = presence.Firstname + " " + presence.Lastname; Owner = Key; Position = new LSL_Types.Vector3( presence.AbsolutePosition.X, presence.AbsolutePosition.Y, presence.AbsolutePosition.Z); Rotation = new LSL_Types.Quaternion( presence.Rotation.X, presence.Rotation.Y, presence.Rotation.Z, presence.Rotation.W); Velocity = new LSL_Types.Vector3( presence.Velocity.X, presence.Velocity.Y, presence.Velocity.Z); Type = 0x01; // Avatar if (presence.Velocity != Vector3.Zero) Type |= 0x02; // Active Group = presence.ControllingClient.ActiveGroupId; return; } part=part.ParentGroup.RootPart; // We detect objects only LinkNum = 0; // Not relevant Group = part.GroupID; Name = part.Name; Owner = part.OwnerID; if (part.Velocity == Vector3.Zero) Type = 0x04; // Passive else Type = 0x02; // Passive foreach (SceneObjectPart p in part.ParentGroup.ChildrenList) { if (p.Inventory.ContainsScripts()) { Type |= 0x08; // Scripted break; } } Position = new LSL_Types.Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); Quaternion wr = part.ParentGroup.GroupRotation; Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); Velocity = new LSL_Types.Vector3(part.Velocity.X, part.Velocity.Y, part.Velocity.Z); }
/// <summary> /// Callback for a client request for Voice Account Details /// </summary> /// <param name="scene">current scene object of the client</param> /// <param name="request"></param> /// <param name="path"></param> /// <param name="param"></param> /// <param name="agentID"></param> /// <param name="caps"></param> /// <returns></returns> public string ProvisionVoiceAccountRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { try { ScenePresence avatar = null; string avatarName = null; if (scene == null) throw new Exception("[VivoxVoice][PROVISIONVOICE] Invalid scene"); avatar = scene.GetScenePresence(agentID); while (avatar == null) { Thread.Sleep(100); avatar = scene.GetScenePresence(agentID); } avatarName = avatar.Name; m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: scene = {0}, agentID = {1}", scene, agentID); m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", request, path, param); XmlElement resp; bool retry = false; string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); string password = new UUID(Guid.NewGuid()).ToString().Replace('-','Z').Substring(0,16); string code = String.Empty; agentname = agentname.Replace('+', '-').Replace('/', '_'); do { resp = VivoxGetAccountInfo(agentname); if (XmlFind(resp, "response.level0.status", out code)) { if (code != "OK") { if (XmlFind(resp, "response.level0.body.code", out code)) { // If the request was recognized, then this should be set to something switch (code) { case "201" : // Account expired m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : expired credentials", avatarName); m_adminConnected = false; retry = DoAdminLogin(); break; case "202" : // Missing credentials m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : missing credentials", avatarName); break; case "212" : // Not authorized m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : not authorized", avatarName); break; case "300" : // Required parameter missing m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : parameter missing", avatarName); break; case "403" : // Account does not exist resp = VivoxCreateAccount(agentname,password); // Note: This REALLY MUST BE status. Create Account does not return code. if (XmlFind(resp, "response.level0.status", out code)) { switch (code) { case "201" : // Account expired m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : expired credentials", avatarName); m_adminConnected = false; retry = DoAdminLogin(); break; case "202" : // Missing credentials m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : missing credentials", avatarName); break; case "212" : // Not authorized m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : not authorized", avatarName); break; case "300" : // Required parameter missing m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : parameter missing", avatarName); break; case "400" : // Create failed m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : create failed", avatarName); break; } } break; case "404" : // Failed to retrieve account m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : retrieve failed"); // [AMW] Sleep and retry for a fixed period? Or just abandon? break; } } } } } while (retry); if (code != "OK") { m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: Get Account Request failed for \"{0}\"", avatarName); throw new Exception("Unable to execute request"); } // Unconditionally change the password on each request VivoxPassword(agentname, password); LLSDVoiceAccountResponse voiceAccountResponse = new LLSDVoiceAccountResponse(agentname, password, m_vivoxSipUri, m_vivoxVoiceAccountApi); string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); return r; } catch (Exception e) { m_log.ErrorFormat("[VivoxVoice][PROVISIONVOICE]: : {0}, retry later", e.Message); m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: : {0} failed", e.ToString()); return "<llsd><undef /></llsd>"; } }