Compare commits

...

22 Commits

Author SHA1 Message Date
Justin Clark-Casey (justincc)
1e64549acf Fix build break from last commit 9c65207. Mono 2.4 lacks string.join(string, List<string>), or some auto casting is missing 2013-09-04 00:47:51 +01:00
Justin Clark-Casey (justincc)
6570f5dcfe Show behaviours of pCampbot bots in "show bots" and "show bot" console commands 2013-09-04 00:47:34 +01:00
Justin Clark-Casey (justincc)
90907bf4fd minor simplification of some unix date functions in Util. No functional change. 2013-09-04 00:47:26 +01:00
Justin Clark-Casey (justincc)
dbbc260d1a Fix logic errors in "show grid users online" console command which didn't actually filter out users shown continuously online for more than 5 days
Remove confusion in command output.
2013-09-04 00:47:22 +01:00
Justin Clark-Casey (justincc)
49228f9855 Add experimental "show grid users online" console command to show grid users online from a standalone/robust instance.
This is not guaranteed to be accurate since users may be left "online" in certain situations.
For example, if a simulator crashes and they never login/logout again.
To counter this somewhat, only users continuously online for less than 5 days are shown.
2013-09-04 00:47:13 +01:00
Justin Clark-Casey (justincc)
8b7bcc8346 Allow one to specify a DefaultHGRegion flag in [GridService] in order to allow different default regions for HG and direct grid logins.
This requires a new GridService.GetDefaultHypergridRegions() so ROBUST services require updating but not simulators.
This method still returns regions flagged with just DefaultRegion after any DefaultHGRegions, so if no DefaultHGRegions are specified
then existing configured defaults will still work.
Immediate use is for conference where we need to be able to specify different defaults
However, this is also generally useful to send experienced HG users to one default location and local users whose specified region fails (e.g. no "home" or "last") to another.
2013-09-04 00:46:26 +01:00
Justin Clark-Casey (justincc)
3f8a99937e Fix exception thrown after a region has been restarted through scheduling.
This exception was very likely harmless since it occurred after the restart had taken place, but still misleading.
Thanks to SCGreyWolf for the code change suggestion in http://opensimulator.org/mantis/view.php?id=6747, though I did this in a slightly different way.
2013-09-04 00:45:32 +01:00
Diva Canto
b92128b715 Whitespace fubar. 2013-09-04 00:45:10 +01:00
Robert Adams
6eb1436c55 Fix a printing of exception error in InventoryArchiveModule that only
printed the error message and not the call stack.
2013-09-04 00:45:06 +01:00
Justin Clark-Casey (justincc)
41b33b6f0f Rename pCampbot.ini -> pCampBot.ini (and example file) to be consistent with other capitalizations of pCampBot 2013-09-04 00:45:00 +01:00
Justin Clark-Casey (justincc)
e05d11faa5 minor: shortern warning messages in EntityTransferModule when UpdateAgent() fails 2013-09-04 00:44:52 +01:00
Justin Clark-Casey (justincc)
803fa36b68 Make pCampbot "show bot" command take the bot number instead of the full bot name
Shorter and can do this because bot names are uniform
2013-09-04 00:44:47 +01:00
Justin Clark-Casey (justincc)
902c1f0009 remove redundant return at end of HandleDeregisterRegion() 2013-09-04 00:43:53 +01:00
Justin Clark-Casey (justincc)
b21f261008 Make it possible for the "deregister region id" command to accept more than one id 2013-09-04 00:43:48 +01:00
Justin Clark-Casey (justincc)
ab1c63b20c Remove old and unused ScenePresence.RestoreInCurrentScene() 2013-09-04 00:43:40 +01:00
Justin Clark-Casey (justincc)
5c35aa560e Refactor: merge SceneGraph.AddScenePresence() into CreateAndAddChildScenePresence() since the former was only ever called from the latter
This allows us to remove dead code relating to adding root agents directly to the scenegraph, which never happens.
2013-09-04 00:43:35 +01:00
Justin Clark-Casey (justincc)
63be8e3596 minor: Correct typo on "debug stats record start" message 2013-09-04 00:42:58 +01:00
Justin Clark-Casey (justincc)
62b12783df Fix bug where users teleporting to non-neighbour regions could continue to hear chat from their source region for some time after teleport completion.
This occurs on v2 teleport since the source region now waits 15 secs before closing the old child agent, which could still receive chat.
This commit introduces a ScenePresenceState.PreClose which is set before the wait, so that ChatModule can check for ScenePresenceState.Running.
This was theoretically also an issue on v1 teleport but since the pause before close was only 2 secs there, it was not noticed.
2013-09-02 19:21:53 +01:00
Justin Clark-Casey (justincc)
935888d6da Comment out warning about agent updating without valid session ID for now.
This causes extreme console spam if a simulator running latest master and one running 0.7.5 have adjacent regions occupied by avatars.
2013-09-02 17:47:04 +01:00
Justin Clark-Casey (justincc)
2e7f7c41a7 Also check user authorization if looking to upgrade from a child to a root agent.
Relevant if a child agent has been allowed into the region which should not be upgraded to a root agent.
2013-08-27 00:35:33 +01:00
Diva Canto
ed0ffae151 Potential fix for access control bug on login introduced with SeeIntoRegion commit. 2013-08-26 20:28:52 +01:00
Justin Clark-Casey (justincc)
ea5bab5107 For a Hypergrid user, delay estate access checks until NewUserConnection() so that they work.
This is necessary because the hypergrid groups checks (as referenced by estates) require an agent circuit to be present to construct the hypergrid ID.
However, this is not around until Scene.NewUserConnection(), as called by CreateAgent() in EntityTransferModule.
Therefore, if we're dealing with a hypergrid user, delay the check until NewUserConnection()/CreateAgent()
The entity transfer impact should be minimal since CreateAgent() is the next significant call after NewUserConnection()
However, to preserve the accuracy of query access we will only relax the check for HG users.
2013-08-26 20:04:07 +01:00
38 changed files with 441 additions and 132 deletions

View File

@@ -81,6 +81,7 @@ namespace OpenSim.Data
bool Delete(UUID regionID);
List<RegionData> GetDefaultRegions(UUID scopeID);
List<RegionData> GetDefaultHypergridRegions(UUID scopeID);
List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y);
List<RegionData> GetHyperlinks(UUID scopeID);
}

View File

@@ -315,6 +315,11 @@ namespace OpenSim.Data.MSSQL
return Get((int)RegionFlags.DefaultRegion, scopeID);
}
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
{
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
}
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
{
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);

View File

@@ -310,6 +310,11 @@ namespace OpenSim.Data.MySQL
return Get((int)RegionFlags.DefaultRegion, scopeID);
}
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
{
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
}
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
{
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);

View File

@@ -239,6 +239,11 @@ namespace OpenSim.Data.Null
return Get((int)RegionFlags.DefaultRegion, scopeID);
}
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
{
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
}
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
{
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);

View File

@@ -67,7 +67,7 @@ namespace OpenSim.Framework.Monitoring
if (cmd[3] == "start")
{
Start();
con.OutputFormat("Now recording all stats very {0}ms to file", m_statsLogIntervalMs);
con.OutputFormat("Now recording all stats to file every {0}ms", m_statsLogIntervalMs);
}
else if (cmd[3] == "stop")
{

View File

@@ -48,6 +48,7 @@ namespace OpenSim.Framework
NoMove = 64, // Don't allow moving this region
Reservation = 128, // This is an inactive reservation
Authenticate = 256, // Require authentication
Hyperlink = 512 // Record represents a HG link
Hyperlink = 512, // Record represents a HG link
DefaultHGRegion = 1024 // Record represents a default region for hypergrid teleports only.
}
}

View File

@@ -130,7 +130,7 @@ namespace OpenSim.Framework
private static SmartThreadPool m_ThreadPool;
// Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC.
private static readonly DateTime unixEpoch =
public static readonly DateTime UnixEpoch =
DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime();
private static readonly string rawUUIDPattern
@@ -521,20 +521,18 @@ namespace OpenSim.Framework
public static int ToUnixTime(DateTime stamp)
{
TimeSpan t = stamp.ToUniversalTime() - unixEpoch;
return (int) t.TotalSeconds;
TimeSpan t = stamp.ToUniversalTime() - UnixEpoch;
return (int)t.TotalSeconds;
}
public static DateTime ToDateTime(ulong seconds)
{
DateTime epoch = unixEpoch;
return epoch.AddSeconds(seconds);
return UnixEpoch.AddSeconds(seconds);
}
public static DateTime ToDateTime(int seconds)
{
DateTime epoch = unixEpoch;
return epoch.AddSeconds(seconds);
return UnixEpoch.AddSeconds(seconds);
}
/// <summary>

View File

@@ -76,7 +76,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
}
[Test]
public void AddForClient()
public void TestAddForClient()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
@@ -88,7 +88,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
}
[Test]
public void RemoveForClient()
public void TestRemoveForClient()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();

View File

@@ -326,15 +326,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type,
string message, ChatSourceType src, bool ignoreDistance)
{
Vector3 fromRegionPos = fromPos + regionPos;
Vector3 toRegionPos = presence.AbsolutePosition +
new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);
if (presence.LifecycleState != ScenePresenceState.Running)
return false;
if (!ignoreDistance)
{
Vector3 fromRegionPos = fromPos + regionPos;
Vector3 toRegionPos = presence.AbsolutePosition +
new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize,
presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);
if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
type == ChatTypeEnum.Say && dis > m_saydistance ||
type == ChatTypeEnum.Shout && dis > m_shoutdistance)

View File

@@ -536,7 +536,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
catch (Exception e)
{
m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message);
m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e);
return null;
}
}

View File

@@ -832,8 +832,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
}
m_log.WarnFormat(
"[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.",
sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
"[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Keeping avatar in {2}",
sp.Name, finalDestination.RegionName, sp.Scene.Name);
Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established.");
return;
@@ -920,6 +920,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
{
if (!sp.Scene.IncomingPreCloseAgent(sp))
return;
// We need to delay here because Imprudence viewers, unlike v1 or v3, have a short (<200ms, <500ms) delay before
// they regard the new region as the current region after receiving the AgentMovementComplete
// response. If close is sent before then, it will cause the viewer to quit instead.
@@ -1053,8 +1056,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
}
m_log.WarnFormat(
"[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.",
sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
"[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Keeping avatar in {2}",
sp.Name, finalDestination.RegionName, sp.Scene.Name);
Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established.");
return;
@@ -1082,6 +1085,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
{
if (!sp.Scene.IncomingPreCloseAgent(sp))
return;
// RED ALERT!!!!
// PLEASE DO NOT DECREASE THIS WAIT TIME UNDER ANY CIRCUMSTANCES.
// THE VIEWERS SEEM TO NEED SOME TIME AFTER RECEIVING MoveAgentIntoRegion
@@ -1095,6 +1101,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// then this will be handled in IncomingCloseAgent under lock conditions
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Closing agent {0} in {1} after teleport", sp.Name, Scene.Name);
sp.Scene.IncomingCloseAgent(sp.UUID, false);
}
else

View File

@@ -235,6 +235,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return m_GridService.GetDefaultRegions(scopeID);
}
public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
{
return m_GridService.GetDefaultHypergridRegions(scopeID);
}
public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
{
return m_GridService.GetFallbackRegions(scopeID, x, y);

View File

@@ -277,6 +277,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return rinfo;
}
public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
{
List<GridRegion> rinfo = m_LocalGridService.GetDefaultHypergridRegions(scopeID);
//m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetDefaultHypergridRegions {0} found {1} regions", name, rinfo.Count);
List<GridRegion> grinfo = m_RemoteGridService.GetDefaultHypergridRegions(scopeID);
if (grinfo != null)
{
//m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetDefaultHypergridRegions {0} found {1} regions", name, grinfo.Count);
foreach (GridRegion r in grinfo)
{
m_RegionInfoCache.Cache(r);
if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null)
rinfo.Add(r);
}
}
return rinfo;
}
public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
{
List<GridRegion> rinfo = m_LocalGridService.GetFallbackRegions(scopeID, x, y);

View File

@@ -46,8 +46,8 @@ namespace OpenSim.Region.CoreModules.World.Region
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")]
public class RestartModule : INonSharedRegionModule, IRestartModule
{
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_Scene;
protected Timer m_CountdownTimer = null;
@@ -203,18 +203,30 @@ namespace OpenSim.Region.CoreModules.World.Region
public void SetTimer(int intervalSeconds)
{
m_CountdownTimer = new Timer();
m_CountdownTimer.AutoReset = false;
m_CountdownTimer.Interval = intervalSeconds * 1000;
m_CountdownTimer.Elapsed += OnTimer;
m_CountdownTimer.Start();
if (intervalSeconds > 0)
{
m_CountdownTimer = new Timer();
m_CountdownTimer.AutoReset = false;
m_CountdownTimer.Interval = intervalSeconds * 1000;
m_CountdownTimer.Elapsed += OnTimer;
m_CountdownTimer.Start();
}
else if (m_CountdownTimer != null)
{
m_CountdownTimer.Stop();
m_CountdownTimer = null;
}
else
{
m_log.WarnFormat(
"[RESTART MODULE]: Tried to set restart timer to {0} in {1}, which is not a valid interval",
intervalSeconds, m_Scene.Name);
}
}
private void OnTimer(object source, ElapsedEventArgs e)
{
int nextInterval = DoOneNotice();
SetTimer(nextInterval);
SetTimer(DoOneNotice());
}
public void AbortRestart(string message)

View File

@@ -3695,10 +3695,13 @@ namespace OpenSim.Region.Framework.Scenes
// We need to ensure that we are not already removing the scene presence before we ask it not to be
// closed.
if (sp != null && sp.IsChildAgent && sp.LifecycleState == ScenePresenceState.Running)
if (sp != null && sp.IsChildAgent
&& (sp.LifecycleState == ScenePresenceState.Running
|| sp.LifecycleState == ScenePresenceState.PreRemove))
{
m_log.DebugFormat(
"[SCENE]: Reusing existing child scene presence for {0} in {1}", sp.Name, Name);
"[SCENE]: Reusing existing child scene presence for {0}, state {1} in {2}",
sp.Name, sp.LifecycleState, Name);
// In the case where, for example, an A B C D region layout, an avatar may
// teleport from A -> D, but then -> C before A has asked B to close its old child agent. When C
@@ -3720,6 +3723,8 @@ namespace OpenSim.Region.Framework.Scenes
// }
// else if (EntityTransferModule.IsInTransit(sp.UUID))
sp.LifecycleState = ScenePresenceState.Running;
if (EntityTransferModule.IsInTransit(sp.UUID))
{
sp.DoNotCloseAfterTeleport = true;
@@ -3824,7 +3829,7 @@ namespace OpenSim.Region.Framework.Scenes
try
{
if (!AuthorizeUser(acd, SeeIntoRegion, out reason))
if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason))
{
m_authenticateHandler.RemoveCircuit(acd.circuitcode);
return false;
@@ -3855,6 +3860,19 @@ namespace OpenSim.Region.Framework.Scenes
// Let the SP know how we got here. This has a lot of interesting
// uses down the line.
sp.TeleportFlags = (TPFlags)teleportFlags;
// We must carry out a further authorization check if there's an
// attempt to make a child agent into a root agent, since SeeIntoRegion may have allowed a child
// agent to login to a region where a full avatar would not be allowed.
//
// We determine whether this is a CreateAgent for a future non-child agent by inspecting
// TeleportFlags, which will be default for a child connection. This relies on input from the source
// region.
if (sp.TeleportFlags != TPFlags.Default)
{
if (!AuthorizeUser(acd, false, out reason))
return false;
}
if (sp.IsChildAgent)
{
@@ -4346,10 +4364,10 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID);
if (childAgentUpdate != null)
{
if (childAgentUpdate.ControllingClient.SessionId != cAgentData.SessionID)
// Only warn for now
m_log.WarnFormat("[SCENE]: Attempt at updating position of agent {0} with invalid session id {1}. Neighbor running older version?",
childAgentUpdate.UUID, cAgentData.SessionID);
// if (childAgentUpdate.ControllingClient.SessionId != cAgentData.SessionID)
// // Only warn for now
// m_log.WarnFormat("[SCENE]: Attempt at updating position of agent {0} with invalid session id {1}. Neighbor running older version?",
// childAgentUpdate.UUID, cAgentData.SessionID);
// I can't imagine *yet* why we would get an update if the agent is a root agent..
// however to avoid a race condition crossing borders..
@@ -4440,6 +4458,50 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
/// <summary>
/// Tell a single agent to prepare to close.
/// </summary>
/// <remarks>
/// This should only be called if we may close the agent but there will be some delay in so doing. Meant for
/// internal use - other callers should almost certainly called IncomingCloseAgent().
/// </remarks>
/// <param name="sp"></param>
/// <returns>true if pre-close state notification was successful. false if the agent
/// was not in a state where it could transition to pre-close.</returns>
public bool IncomingPreCloseAgent(ScenePresence sp)
{
lock (m_removeClientLock)
{
// We need to avoid a race condition where in, for example, an A B C D region layout, an avatar may
// teleport from A -> D, but then -> C before A has asked B to close its old child agent. We do not
// want to obey this close since C may have renewed the child agent lease on B.
if (sp.DoNotCloseAfterTeleport)
{
m_log.DebugFormat(
"[SCENE]: Not pre-closing {0} agent {1} in {2} since another simulator has re-established the child connection",
sp.IsChildAgent ? "child" : "root", sp.Name, Name);
// Need to reset the flag so that a subsequent close after another teleport can succeed.
sp.DoNotCloseAfterTeleport = false;
return false;
}
if (sp.LifecycleState != ScenePresenceState.Running)
{
m_log.DebugFormat(
"[SCENE]: Called IncomingPreCloseAgent() for {0} in {1} but presence is already in state {2}",
sp.Name, Name, sp.LifecycleState);
return false;
}
sp.LifecycleState = ScenePresenceState.PreRemove;
return true;
}
}
/// <summary>
/// Tell a single agent to disconnect from the region.
/// </summary>
@@ -4459,16 +4521,16 @@ namespace OpenSim.Region.Framework.Scenes
if (sp == null)
{
m_log.DebugFormat(
"[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in {1}",
"[SCENE]: Called IncomingCloseAgent() with agent ID {0} but no such presence is in {1}",
agentID, Name);
return false;
}
if (sp.LifecycleState != ScenePresenceState.Running)
if (sp.LifecycleState != ScenePresenceState.Running && sp.LifecycleState != ScenePresenceState.PreRemove)
{
m_log.DebugFormat(
"[SCENE]: Called RemoveClient() for {0} in {1} but presence is already in state {2}",
"[SCENE]: Called IncomingCloseAgent() for {0} in {1} but presence is already in state {2}",
sp.Name, Name, sp.LifecycleState);
return false;
@@ -5739,9 +5801,13 @@ namespace OpenSim.Region.Framework.Scenes
try
{
if (!AuthorizeUser(aCircuit, false, out reason))
// If this is a hypergrid user, then we can't perform a successful groups access check here since this
// currently relies on a circuit being present in the AuthenticateHandler to construct a Hypergrid ID.
// This is only present in NewUserConnection() which entity transfer calls very soon after QueryAccess().
// Therefore, we'll defer to the check in NewUserConnection() instead.
if (!AuthorizeUser(aCircuit, !UserManagementModule.IsLocalGridUser(agentID), out reason))
{
// m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
//m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
return false;
}
}

View File

@@ -561,39 +561,15 @@ namespace OpenSim.Region.Framework.Scenes
protected internal ScenePresence CreateAndAddChildScenePresence(
IClientAPI client, AvatarAppearance appearance, PresenceType type)
{
ScenePresence newAvatar = null;
// ScenePresence always defaults to child agent
newAvatar = new ScenePresence(client, m_parentScene, appearance, type);
AddScenePresence(newAvatar);
return newAvatar;
}
/// <summary>
/// Add a presence to the scene
/// </summary>
/// <param name="presence"></param>
protected internal void AddScenePresence(ScenePresence presence)
{
// Always a child when added to the scene
bool child = presence.IsChildAgent;
if (child)
{
m_numChildAgents++;
}
else
{
m_numRootAgents++;
presence.AddToPhysicalScene(false);
}
ScenePresence presence = new ScenePresence(client, m_parentScene, appearance, type);
Entities[presence.UUID] = presence;
lock (m_presenceLock)
{
m_numChildAgents++;
Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap);
List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray);
@@ -604,7 +580,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
// Remember the old presene reference from the dictionary
// Remember the old presence reference from the dictionary
ScenePresence oldref = newmap[presence.UUID];
// Replace the presence reference in the dictionary with the new value
newmap[presence.UUID] = presence;
@@ -616,6 +592,8 @@ namespace OpenSim.Region.Framework.Scenes
m_scenePresenceMap = newmap;
m_scenePresenceArray = newlist;
}
return presence;
}
/// <summary>

View File

@@ -3243,11 +3243,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public void RestoreInCurrentScene()
{
AddToPhysicalScene(false); // not exactly false
}
public void Reset()
{
// m_log.DebugFormat("[SCENE PRESENCE]: Resetting {0} in {1}", Name, Scene.RegionInfo.RegionName);

View File

@@ -37,7 +37,8 @@ namespace OpenSim.Region.Framework.Scenes
/// This is a state machine.
///
/// [Entry] => Running
/// Running => Removing
/// Running => PreRemove, Removing
/// PreRemove => Running, Removing
/// Removing => Removed
///
/// All other methods should only see the scene presence in running state - this is the normal operational state
@@ -46,6 +47,7 @@ namespace OpenSim.Region.Framework.Scenes
public enum ScenePresenceState
{
Running, // Normal operation state. The scene presence is available.
PreRemove, // The presence is due to be removed but can still be returning to running.
Removing, // The presence is in the process of being removed from the scene via Scene.RemoveClient.
Removed, // The presence has been removed from the scene and is effectively dead.
// There is no exit from this state.
@@ -80,8 +82,17 @@ namespace OpenSim.Region.Framework.Scenes
lock (this)
{
if (newState == ScenePresenceState.Removing && m_state == ScenePresenceState.Running)
if (newState == m_state)
return;
else if (newState == ScenePresenceState.Running && m_state == ScenePresenceState.PreRemove)
transitionOkay = true;
else if (newState == ScenePresenceState.PreRemove && m_state == ScenePresenceState.Running)
transitionOkay = true;
else if (newState == ScenePresenceState.Removing)
{
if (m_state == ScenePresenceState.Running || m_state == ScenePresenceState.PreRemove)
transitionOkay = true;
}
else if (newState == ScenePresenceState.Removed && m_state == ScenePresenceState.Removing)
transitionOkay = true;
}

View File

@@ -106,6 +106,9 @@ namespace OpenSim.Server.Handlers.Grid
case "get_default_regions":
return GetDefaultRegions(request);
case "get_default_hypergrid_regions":
return GetDefaultHypergridRegions(request);
case "get_fallback_regions":
return GetFallbackRegions(request);
@@ -444,6 +447,36 @@ namespace OpenSim.Server.Handlers.Grid
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
}
byte[] GetDefaultHypergridRegions(Dictionary<string, object> request)
{
//m_log.DebugFormat("[GRID HANDLER]: GetDefaultRegions");
UUID scopeID = UUID.Zero;
if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"].ToString(), out scopeID);
else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
List<GridRegion> rinfos = m_GridService.GetDefaultHypergridRegions(scopeID);
Dictionary<string, object> result = new Dictionary<string, object>();
if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
result["result"] = "null";
else
{
int i = 0;
foreach (GridRegion rinfo in rinfos)
{
Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
result["region" + i] = rinfoDict;
i++;
}
}
string xmlString = ServerUtils.BuildXmlResponse(result);
//m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
}
byte[] GetFallbackRegions(Dictionary<string, object> request)
{
//m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");

View File

@@ -515,6 +515,57 @@ namespace OpenSim.Services.Connectors
return rinfos;
}
public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["SCOPEID"] = scopeID.ToString();
sendData["METHOD"] = "get_default_hypergrid_regions";
List<GridRegion> rinfos = new List<GridRegion>();
string reply = string.Empty;
string uri = m_ServerURI + "/grid";
try
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri,
ServerUtils.BuildQueryString(sendData));
//m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message);
return rinfos;
}
if (reply != string.Empty)
{
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if (replyData != null)
{
Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
foreach (object r in rinfosList)
{
if (r is Dictionary<string, object>)
{
GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
rinfos.Add(rinfo);
}
}
}
else
m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions {0} received null response",
scopeID);
}
else
m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions received null reply");
return rinfos;
}
public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();

View File

@@ -330,6 +330,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
return new List<GridRegion>(0);
}
public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
{
// TODO: Allow specifying the default grid location
return GetDefaultRegions(scopeID);
}
public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
{
GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true);

View File

@@ -86,7 +86,7 @@ namespace OpenSim.Services.GridService
{
MainConsole.Instance.Commands.AddCommand("Regions", true,
"deregister region id",
"deregister region id <Region UUID>",
"deregister region id <region-id>+",
"Deregister a region manually.",
String.Empty,
HandleDeregisterRegion);
@@ -265,8 +265,9 @@ namespace OpenSim.Services.GridService
m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
}
m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}",
regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY);
m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3} with flags {4}",
regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY,
(OpenSim.Framework.RegionFlags)flags);
return String.Empty;
}
@@ -478,6 +479,33 @@ namespace OpenSim.Services.GridService
return ret;
}
public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID)
{
List<GridRegion> ret = new List<GridRegion>();
List<RegionData> regions = m_Database.GetDefaultHypergridRegions(scopeID);
foreach (RegionData r in regions)
{
if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0)
ret.Add(RegionData2RegionInfo(r));
}
int hgDefaultRegionsFoundOnline = regions.Count;
// For now, hypergrid default regions will always be given precedence but we will also return simple default
// regions in case no specific hypergrid regions are specified.
ret.AddRange(GetDefaultRegions(scopeID));
int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline;
m_log.DebugFormat(
"[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions",
hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline);
return ret;
}
public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y)
{
List<GridRegion> ret = new List<GridRegion>();
@@ -526,40 +554,41 @@ namespace OpenSim.Services.GridService
private void HandleDeregisterRegion(string module, string[] cmd)
{
if (cmd.Length != 4)
if (cmd.Length < 4)
{
MainConsole.Instance.Output("Syntax: degregister region id <Region UUID>");
MainConsole.Instance.Output("Usage: degregister region id <region-id>+");
return;
}
string rawRegionUuid = cmd[3];
UUID regionUuid;
if (!UUID.TryParse(rawRegionUuid, out regionUuid))
for (int i = 3; i < cmd.Length; i++)
{
MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid);
return;
}
string rawRegionUuid = cmd[i];
UUID regionUuid;
GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid);
if (!UUID.TryParse(rawRegionUuid, out regionUuid))
{
MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid);
return;
}
if (region == null)
{
MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid);
return;
}
GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid);
if (DeregisterRegion(regionUuid))
{
MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid);
}
else
{
// I don't think this can ever occur if we know that the region exists.
MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid);
}
if (region == null)
{
MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid);
return;
}
return;
if (DeregisterRegion(regionUuid))
{
MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid);
}
else
{
// I don't think this can ever occur if we know that the region exists.
MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid);
}
}
}
private void HandleShowRegions(string module, string[] cmd)

View File

@@ -79,7 +79,7 @@ namespace OpenSim.Services.GridService
{
if (m_DefaultRegion == null)
{
List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID);
List<GridRegion> defs = m_GridService.GetDefaultHypergridRegions(m_ScopeID);
if (defs != null && defs.Count > 0)
m_DefaultRegion = defs[0];
else

View File

@@ -171,7 +171,7 @@ namespace OpenSim.Services.HypergridService
m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to link to {0}", (regionName == string.Empty)? "default region" : regionName);
if (!m_AllowTeleportsToAnyRegion || regionName == string.Empty)
{
List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID);
List<GridRegion> defs = m_GridService.GetDefaultHypergridRegions(m_ScopeID);
if (defs != null && defs.Count > 0)
{
region = defs[0];

View File

@@ -97,6 +97,7 @@ namespace OpenSim.Services.Interfaces
List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax);
List<GridRegion> GetDefaultRegions(UUID scopeID);
List<GridRegion> GetDefaultHypergridRegions(UUID scopeID);
List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y);
List<GridRegion> GetHyperlinks(UUID scopeID);

View File

@@ -47,6 +47,44 @@ namespace OpenSim.Services.UserAccountService
public GridUserService(IConfigSource config) : base(config)
{
m_log.Debug("[GRID USER SERVICE]: Starting user grid service");
MainConsole.Instance.Commands.AddCommand(
"Users", false,
"show grid users online",
"show grid users online",
"Show number of grid users registered as online.",
"This number may not be accurate as a region may crash or not be cleanly shutdown and leave grid users shown as online\n."
+ "For this reason, users online for more than 5 days are not currently counted",
HandleShowGridUsersOnline);
}
protected void HandleShowGridUsersOnline(string module, string[] cmdparams)
{
// if (cmdparams.Length != 4)
// {
// MainConsole.Instance.Output("Usage: show grid users online");
// return;
// }
// int onlineCount;
int onlineRecentlyCount = 0;
DateTime now = DateTime.UtcNow;
foreach (GridUserData gu in m_Database.GetAll(""))
{
if (bool.Parse(gu.Data["Online"]))
{
// onlineCount++;
int unixLoginTime = int.Parse(gu.Data["Login"]);
if ((now - Util.ToDateTime(unixLoginTime)).Days < 5)
onlineRecentlyCount++;
}
}
MainConsole.Instance.OutputFormat("Users online: {0}", onlineRecentlyCount);
}
public virtual GridUserInfo GetGridUserInfo(string userID)

View File

@@ -35,6 +35,11 @@ namespace pCampBot
{
public class AbstractBehaviour : IBehaviour
{
/// <summary>
/// Abbreviated name of this behaviour.
/// </summary>
public string AbbreviatedName { get; protected set; }
public string Name { get; protected set; }
public Bot Bot { get; protected set; }

View File

@@ -47,7 +47,11 @@ namespace pCampBot
public const int m_regionCrossingTimeout = 1000 * 60;
public CrossBehaviour() { Name = "Cross"; }
public CrossBehaviour()
{
AbbreviatedName = "c";
Name = "Cross";
}
public override void Action()
{

View File

@@ -41,7 +41,11 @@ namespace pCampBot
/// </remarks>
public class GrabbingBehaviour : AbstractBehaviour
{
public GrabbingBehaviour() { Name = "Grabbing"; }
public GrabbingBehaviour()
{
AbbreviatedName = "g";
Name = "Grabbing";
}
public override void Action()
{

View File

@@ -38,6 +38,10 @@ namespace pCampBot
/// </summary>
public class NoneBehaviour : AbstractBehaviour
{
public NoneBehaviour() { Name = "None"; }
public NoneBehaviour()
{
AbbreviatedName = "n";
Name = "None";
}
}
}

View File

@@ -46,6 +46,7 @@ namespace pCampBot
public PhysicsBehaviour()
{
AbbreviatedName = "p";
Name = "Physics";
talkarray = readexcuses();
}

View File

@@ -42,7 +42,11 @@ namespace pCampBot
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public TeleportBehaviour() { Name = "Teleport"; }
public TeleportBehaviour()
{
AbbreviatedName = "t";
Name = "Teleport";
}
public override void Action()
{

View File

@@ -212,7 +212,7 @@ namespace pCampBot
"bot", false, "show bots", "show bots", "Shows the status of all bots", HandleShowBotsStatus);
m_console.Commands.AddCommand(
"bot", false, "show bot", "show bot <first-name> <last-name>",
"bot", false, "show bot", "show bot <n>",
"Shows the detailed status and settings of a particular bot.", HandleShowBotStatus);
m_bots = new List<Bot>();
@@ -572,10 +572,11 @@ namespace pCampBot
private void HandleShowBotsStatus(string module, string[] cmd)
{
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
cdt.AddColumn("Name", 30);
cdt.AddColumn("Region", 30);
cdt.AddColumn("Status", 14);
cdt.AddColumn("Connections", 11);
cdt.AddColumn("Name", 24);
cdt.AddColumn("Region", 24);
cdt.AddColumn("Status", 13);
cdt.AddColumn("Conns", 5);
cdt.AddColumn("Behaviours", 20);
Dictionary<ConnectionState, int> totals = new Dictionary<ConnectionState, int>();
foreach (object o in Enum.GetValues(typeof(ConnectionState)))
@@ -583,13 +584,17 @@ namespace pCampBot
lock (m_bots)
{
foreach (Bot pb in m_bots)
foreach (Bot bot in m_bots)
{
Simulator currentSim = pb.Client.Network.CurrentSim;
totals[pb.ConnectionState]++;
Simulator currentSim = bot.Client.Network.CurrentSim;
totals[bot.ConnectionState]++;
cdt.AddRow(
pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState, pb.SimulatorsCount);
bot.Name,
currentSim != null ? currentSim.Name : "(none)",
bot.ConnectionState,
bot.SimulatorsCount,
string.Join(",", bot.Behaviours.ConvertAll<string>(behaviour => behaviour.AbbreviatedName).ToArray()));
}
}
@@ -605,13 +610,18 @@ namespace pCampBot
private void HandleShowBotStatus(string module, string[] cmd)
{
if (cmd.Length != 4)
if (cmd.Length != 3)
{
MainConsole.Instance.Output("Usage: show bot <first-name> <last-name>");
MainConsole.Instance.Output("Usage: show bot <n>");
return;
}
string name = string.Format("{0} {1}", cmd[2], cmd[3]);
int botNumber;
if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, cmd[2], out botNumber))
return;
string name = string.Format("{0} {1}_{2}", m_firstName, m_lastNameStem, botNumber);
Bot bot;
@@ -640,6 +650,7 @@ namespace pCampBot
MainConsole.Instance.Output("Settings");
ConsoleDisplayList statusCdl = new ConsoleDisplayList();
statusCdl.AddRow("Behaviours", string.Join(", ", bot.Behaviours.ConvertAll<string>(b => b.Name)));
GridClient botClient = bot.Client;
statusCdl.AddRow("SEND_AGENT_UPDATES", botClient.Settings.SEND_AGENT_UPDATES);

View File

@@ -31,6 +31,11 @@ namespace pCampBot.Interfaces
{
public interface IBehaviour
{
/// <summary>
/// Abbreviated name of this behaviour.
/// </summary>
string AbbreviatedName { get; }
/// <summary>
/// Name of this behaviour.
/// </summary>

View File

@@ -51,7 +51,7 @@ namespace pCampBot
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public const string ConfigFileName = "pCampbot.ini";
public const string ConfigFileName = "pCampBot.ini";
[STAThread]
public static void Main(string[] args)

View File

@@ -151,7 +151,8 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset
; *
[GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
HypergridLinker = true
HypergridLinker = true
; Realm = "regions"
; AllowDuplicateNames = "True"
@@ -168,16 +169,16 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset
;; Next, we can specify properties of regions, including default and fallback regions
;; The syntax is: Region_<RegionName> = "<flags>"
;; or: Region_<RegionID> = "<flags>"
;; where <flags> can be DefaultRegion, FallbackRegion, NoDirectLogin, Persistent, LockedOut,Reservation,NoMove,Authenticate
;; where <flags> can be DefaultRegion, DefaultHGRegion, FallbackRegion, NoDirectLogin, Persistent, LockedOut, Reservation, NoMove, Authenticate
;; For example:
; Region_Welcome_Area = "DefaultRegion, FallbackRegion"
; (replace spaces with underscore)
;; Allow Hyperlinks to be created at the console
;; Allow Hyperlinks to be created at the console
HypergridLinker = true
;; If you have this set under [Hypergrid], no need to set it here, leave it commented
; GatekeeperURI = "http://127.0.0.1:8002"
;; If you have this set under [Hypergrid], no need to set it here, leave it commented
; GatekeeperURI = "http://127.0.0.1:8002"
; * This is the configuration for the freeswitch server in grid mode

View File

@@ -2,4 +2,4 @@ Not all of the files in this directory are licensed under the BSD license. Some
These files are:
- avataranimations.xml (Derivative work of viewerart.ini, Creative Commons Attribution+Share-Alike v2.5 License)
- avataranimations.xml (Derivative work of viewerart.ini, Creative Commons Attribution+Share-Alike v2.5 License)