Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

0.7.4.1
Justin Clark-Casey (justincc) 2012-05-14 18:33:20 +01:00
commit 42557d7d4c
5 changed files with 188 additions and 67 deletions

View File

@ -64,6 +64,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
private TimeSpan m_QueueTimeout = new TimeSpan(2, 0, 0); // 2 hours without llGetNextEmail drops the queue private TimeSpan m_QueueTimeout = new TimeSpan(2, 0, 0); // 2 hours without llGetNextEmail drops the queue
private string m_InterObjectHostname = "lsl.opensim.local"; private string m_InterObjectHostname = "lsl.opensim.local";
private int m_MaxEmailSize = 4096; // largest email allowed by default, as per lsl docs.
// Scenes by Region Handle // Scenes by Region Handle
private Dictionary<ulong, Scene> m_Scenes = private Dictionary<ulong, Scene> m_Scenes =
new Dictionary<ulong, Scene>(); new Dictionary<ulong, Scene>();
@ -127,6 +129,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT);
SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN);
SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD);
m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize);
} }
catch (Exception e) catch (Exception e)
{ {
@ -176,18 +179,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
get { return true; } get { return true; }
} }
/// <summary>
/// Delay function using thread in seconds
/// </summary>
/// <param name="seconds"></param>
private void DelayInSeconds(int delay)
{
delay = (int)((float)delay * 1000);
if (delay == 0)
return;
System.Threading.Thread.Sleep(delay);
}
private bool IsLocal(UUID objectID) private bool IsLocal(UUID objectID)
{ {
string unused; string unused;
@ -267,10 +258,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address); m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address);
return; return;
} }
//FIXME:Check if subject + body = 4096 Byte if ((subject.Length + body.Length) > m_MaxEmailSize)
if ((subject.Length + body.Length) > 1024)
{ {
m_log.Error("[EMAIL] subject + body > 1024 Byte"); m_log.Error("[EMAIL] subject + body larger than limit of " + m_MaxEmailSize + " bytes");
return; return;
} }
@ -345,10 +335,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
// TODO FIX // TODO FIX
} }
} }
//DONE: Message as Second Life style
//20 second delay - AntiSpam System - for now only 10 seconds
DelayInSeconds(10);
} }
/// <summary> /// <summary>

View File

@ -569,6 +569,15 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_sceneGraph.Entities; } get { return m_sceneGraph.Entities; }
} }
// can be closest/random/sequence
private string m_SpawnPointRouting = "closest";
// used in sequence see: SpawnPoint()
private int m_SpawnPoint;
public string SpawnPointRouting
{
get { return m_SpawnPointRouting; }
}
#endregion Properties #endregion Properties
#region Constructors #region Constructors
@ -723,6 +732,8 @@ namespace OpenSim.Region.Framework.Scenes
m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
m_SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
IConfig packetConfig = m_config.Configs["PacketPool"]; IConfig packetConfig = m_config.Configs["PacketPool"];
if (packetConfig != null) if (packetConfig != null)
{ {
@ -3405,8 +3416,17 @@ namespace OpenSim.Region.Framework.Scenes
// Don't disable this log message - it's too helpful // Don't disable this log message - it's too helpful
m_log.DebugFormat( m_log.DebugFormat(
"[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})", "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})",
RegionInfo.RegionName, (agent.child ? "child" : "root"),agent.firstname, agent.lastname, RegionInfo.RegionName,
agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos); (agent.child ? "child" : "root"),
agent.firstname,
agent.lastname,
agent.AgentID,
agent.circuitcode,
agent.IPAddress,
agent.Viewer,
((TPFlags)teleportFlags).ToString(),
agent.startpos
);
if (LoginsDisabled) if (LoginsDisabled)
{ {
@ -3421,7 +3441,11 @@ namespace OpenSim.Region.Framework.Scenes
// We have a zombie from a crashed session. // We have a zombie from a crashed session.
// Or the same user is trying to be root twice here, won't work. // Or the same user is trying to be root twice here, won't work.
// Kill it. // Kill it.
m_log.DebugFormat("[SCENE]: Zombie scene presence detected for {0} in {1}", agent.AgentID, RegionInfo.RegionName); m_log.DebugFormat(
"[SCENE]: Zombie scene presence detected for {0} in {1}",
agent.AgentID,
RegionInfo.RegionName
);
sp.ControllingClient.Close(); sp.ControllingClient.Close();
sp = null; sp = null;
} }
@ -3445,8 +3469,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (!VerifyUserPresence(agent, out reason)) if (!VerifyUserPresence(agent, out reason))
return false; return false;
} } catch (Exception e)
catch (Exception e)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
@ -3458,8 +3481,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (!AuthorizeUser(agent, out reason)) if (!AuthorizeUser(agent, out reason))
return false; return false;
} } catch (Exception e)
catch (Exception e)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace);
@ -3476,8 +3498,7 @@ namespace OpenSim.Region.Framework.Scenes
CapsModule.SetAgentCapsSeeds(agent); CapsModule.SetAgentCapsSeeds(agent);
CapsModule.CreateCaps(agent.AgentID); CapsModule.CreateCaps(agent.AgentID);
} }
} } else
else
{ {
// Let the SP know how we got here. This has a lot of interesting // Let the SP know how we got here. This has a lot of interesting
// uses down the line. // uses down the line.
@ -3541,8 +3562,7 @@ namespace OpenSim.Region.Framework.Scenes
agent.startpos.Z = 720; agent.startpos.Z = 720;
} }
} }
} } else
else
{ {
if (agent.startpos.X > EastBorders[0].BorderLine.Z) if (agent.startpos.X > EastBorders[0].BorderLine.Z)
{ {
@ -3570,8 +3590,17 @@ namespace OpenSim.Region.Framework.Scenes
List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
if (spawnpoints.Count > 1) if (spawnpoints.Count > 1)
{ {
// We have multiple SpawnPoints, Route the agent to a random one // We have multiple SpawnPoints, Route the agent to a random or sequential one
agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count)].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); if (SpawnPointRouting == "random")
agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
else
agent.startpos = spawnpoints[SpawnPoint()].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
} }
else else
{ {
@ -5257,5 +5286,19 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} }
// manage and select spawn points in sequence
public int SpawnPoint()
{
int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count;
if (spawnpoints == 0)
return 0;
m_SpawnPoint++;
if (m_SpawnPoint > spawnpoints)
m_SpawnPoint = 1;
return m_SpawnPoint - 1;
}
} }
} }

View File

@ -3934,12 +3934,22 @@ namespace OpenSim.Region.Framework.Scenes
if (spawnPoints.Length == 0) if (spawnPoints.Length == 0)
return; return;
int index;
bool selected = false;
switch (m_scene.SpawnPointRouting)
{
case "closest":
float distance = 9999; float distance = 9999;
int closest = -1; int closest = -1;
for (int i = 0; i < spawnPoints.Length; i++) for (int i = 0; i < spawnPoints.Length; i++)
{ {
Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); Vector3 spawnPosition = spawnPoints[i].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
Vector3 offset = spawnPosition - pos; Vector3 offset = spawnPosition - pos;
float d = Vector3.Mag(offset); float d = Vector3.Mag(offset);
if (d >= distance) if (d >= distance)
@ -3956,6 +3966,61 @@ namespace OpenSim.Region.Framework.Scenes
return; return;
pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
return;
case "random":
do
{
index = Util.RandomClass.Next(spawnPoints.Length - 1);
Vector3 spawnPosition = spawnPoints[index].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
// SpawnPoint sp = spawnPoints[index];
ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
if (land == null || land.IsEitherBannedOrRestricted(UUID))
selected = false;
else
selected = true;
} while ( selected == false);
pos = spawnPoints[index].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
return;
case "sequence":
do
{
index = m_scene.SpawnPoint();
Vector3 spawnPosition = spawnPoints[index].GetLocation(
telehub.AbsolutePosition,
telehub.GroupRotation
);
// SpawnPoint sp = spawnPoints[index];
ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
if (land == null || land.IsEitherBannedOrRestricted(UUID))
selected = false;
else
selected = true;
} while (selected == false);
pos = spawnPoints[index].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
;
return;
default:
return;
}
} }
} }
} }

View File

@ -106,6 +106,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected IUrlModule m_UrlModule = null; protected IUrlModule m_UrlModule = null;
protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
new Dictionary<UUID, UserInfoCacheEntry>(); new Dictionary<UUID, UserInfoCacheEntry>();
protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
{ {
@ -113,6 +114,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host = host; m_host = host;
m_item = item; m_item = item;
LoadLimits(); // read script limits from config.
m_TransferModule =
m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
AsyncCommands = new AsyncCommandManager(ScriptEngine);
}
/* load configuration items that affect script, object and run-time behavior. */
private void LoadLimits()
{
m_ScriptDelayFactor = m_ScriptDelayFactor =
m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
m_ScriptDistanceFactor = m_ScriptDistanceFactor =
@ -125,12 +138,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255);
if (m_notecardLineReadCharsMax > 65535) if (m_notecardLineReadCharsMax > 65535)
m_notecardLineReadCharsMax = 65535; m_notecardLineReadCharsMax = 65535;
// load limits for particular subsystems.
m_TransferModule = IConfig SMTPConfig;
m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) {
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); // there's an smtp config, so load in the snooze time.
EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME);
AsyncCommands = new AsyncCommandManager(ScriptEngine); }
} }
public override Object InitializeLifetimeService() public override Object InitializeLifetimeService()
@ -2877,6 +2890,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public virtual void llSleep(double sec) public virtual void llSleep(double sec)
{ {
// m_log.Info("llSleep snoozing " + sec + "s.");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Thread.Sleep((int)(sec * 1000)); Thread.Sleep((int)(sec * 1000));
} }
@ -3130,7 +3144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
emailModule.SendEmail(m_host.UUID, address, subject, message); emailModule.SendEmail(m_host.UUID, address, subject, message);
ScriptSleep(20000); llSleep(EMAIL_PAUSE_TIME);
} }
public void llGetNextEmail(string address, string subject) public void llGetNextEmail(string address, string subject)

View File

@ -241,6 +241,14 @@
;; server to send mail through. ;; server to send mail through.
; emailmodule = DefaultEmailModule ; emailmodule = DefaultEmailModule
;# {SpawnPointRouting} {} {Set routing method for Telehub Spawnpoints} {closest random sequential} closest
;; SpawnPointRouting adjusts the landing for incoming avatars.
;; "closest" will place the avatar at the SpawnPoint located in the closest
;; available spot to the destination (typically map click/landmark).
;; "random" will place the avatar on a randomly selected spawnpoint;
;; "sequential" will place the avatar on the next sequential SpawnPoint
; SpawnPointRouting = closest
[Estates] [Estates]
; If these values are commented out then the user will be asked for estate details when required (this is the normal case). ; If these values are commented out then the user will be asked for estate details when required (this is the normal case).
; If these values are uncommented then they will be used to create a default estate as necessary. ; If these values are uncommented then they will be used to create a default estate as necessary.
@ -273,6 +281,12 @@
;# {host_domain_header_from} {[Startup]emailmodule:DefaultEmailModule enabled:true} {From address to use in the sent email header?} {} 127.0.0.1 ;# {host_domain_header_from} {[Startup]emailmodule:DefaultEmailModule enabled:true} {From address to use in the sent email header?} {} 127.0.0.1
; host_domain_header_from = "127.0.0.1" ; host_domain_header_from = "127.0.0.1"
;# {email_pause_time} {[Startup]emailmodule:DefaultEmailModule enabled:true} {Period in seconds to delay after an email is sent.} {} 20
; email_pause_time = 20
;# {email_max_size} {[Startup]emailmodule:DefaultEmailModule enabled:true} {Maximum total size of email in bytes.} {} 4096
; email_max_size = 4096
;# {SMTP_SERVER_HOSTNAME} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server name?} {} 127.0.0.1 ;# {SMTP_SERVER_HOSTNAME} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server name?} {} 127.0.0.1
; SMTP_SERVER_HOSTNAME = "127.0.0.1" ; SMTP_SERVER_HOSTNAME = "127.0.0.1"
@ -285,7 +299,6 @@
;# {SMTP_SERVER_PASSWORD} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server password} {} ;# {SMTP_SERVER_PASSWORD} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server password} {}
; SMTP_SERVER_PASSWORD = "" ; SMTP_SERVER_PASSWORD = ""
[Network] [Network]
;; Configure the remote console user here. This will not actually be used ;; Configure the remote console user here. This will not actually be used
;; unless you use -console=rest at startup. ;; unless you use -console=rest at startup.
@ -677,7 +690,7 @@
;; Sets the multiplier for the scripting delays ;; Sets the multiplier for the scripting delays
; ScriptDelayFactor = 1.0 ; ScriptDelayFactor = 1.0
;; The factor the 10 m distances llimits are multiplied by ;; The factor the 10 m distances limits are multiplied by
; ScriptDistanceLimitFactor = 1.0 ; ScriptDistanceLimitFactor = 1.0
;; Maximum length of notecard line read ;; Maximum length of notecard line read