OSSL: stop reading configuration file on every script start.
parent
c7714d6320
commit
2abf375351
|
@ -28,6 +28,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.Remoting.Lifetime;
|
using System.Runtime.Remoting.Lifetime;
|
||||||
|
@ -142,99 +143,113 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
|
public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
|
||||||
{
|
{
|
||||||
|
public const string GridInfoServiceConfigSectionName = "GridInfoService";
|
||||||
|
|
||||||
|
// shared things
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
public const string GridInfoServiceConfigSectionName = "GridInfoService";
|
private static object m_OSSLLock = new object();
|
||||||
|
private static bool m_doneSharedInit = false;
|
||||||
|
internal static bool m_OSFunctionsEnabled = false;
|
||||||
|
internal static TimeZoneInfo PSTTimeZone = null;
|
||||||
|
internal static bool m_PermissionErrortoOwner = false;
|
||||||
|
internal static ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
|
||||||
|
internal static float m_ScriptDelayFactor = 1.0f;
|
||||||
|
internal static float m_ScriptDistanceFactor = 1.0f;
|
||||||
|
internal static IConfig m_osslconfig;
|
||||||
|
|
||||||
|
internal static ConcurrentDictionary<string, FunctionPerms> m_FunctionPerms = new ConcurrentDictionary<string, FunctionPerms>();
|
||||||
|
|
||||||
internal IScriptEngine m_ScriptEngine;
|
internal IScriptEngine m_ScriptEngine;
|
||||||
internal LSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
|
internal LSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there
|
||||||
internal SceneObjectPart m_host;
|
internal SceneObjectPart m_host;
|
||||||
internal TaskInventoryItem m_item;
|
internal TaskInventoryItem m_item;
|
||||||
internal bool m_OSFunctionsEnabled = false;
|
|
||||||
internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
|
|
||||||
internal float m_ScriptDelayFactor = 1.0f;
|
|
||||||
internal float m_ScriptDistanceFactor = 1.0f;
|
|
||||||
internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
|
|
||||||
protected IUrlModule m_UrlModule = null;
|
protected IUrlModule m_UrlModule = null;
|
||||||
protected ISoundModule m_SoundModule = null;
|
protected ISoundModule m_SoundModule = null;
|
||||||
internal IConfig m_osslconfig;
|
|
||||||
internal TimeZoneInfo PSTTimeZone = null;
|
|
||||||
internal bool m_PermissionErrortoOwner = false;
|
|
||||||
|
|
||||||
public void Initialize(
|
public void Initialize(IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item)
|
||||||
IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item)
|
|
||||||
{
|
{
|
||||||
|
//private init
|
||||||
m_ScriptEngine = scriptEngine;
|
m_ScriptEngine = scriptEngine;
|
||||||
m_host = host;
|
m_host = host;
|
||||||
m_item = item;
|
m_item = item;
|
||||||
|
|
||||||
m_osslconfig = m_ScriptEngine.ConfigSource.Configs["OSSL"];
|
|
||||||
if(m_osslconfig == null)
|
|
||||||
m_osslconfig = m_ScriptEngine.Config;
|
|
||||||
|
|
||||||
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
|
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
|
||||||
m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>();
|
m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>();
|
||||||
|
|
||||||
if (m_osslconfig.GetBoolean("AllowOSFunctions", false))
|
//private init
|
||||||
|
lock (m_OSSLLock)
|
||||||
{
|
{
|
||||||
|
if(m_doneSharedInit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_osslconfig = m_ScriptEngine.ConfigSource.Configs["OSSL"];
|
||||||
|
if(m_osslconfig == null)
|
||||||
|
m_osslconfig = m_ScriptEngine.Config;
|
||||||
|
|
||||||
|
if (m_osslconfig.GetBoolean("AllowOSFunctions", false))
|
||||||
|
{
|
||||||
m_OSFunctionsEnabled = true;
|
m_OSFunctionsEnabled = true;
|
||||||
// m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED");
|
// m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_PermissionErrortoOwner = m_osslconfig.GetBoolean("PermissionErrorToOwner", m_PermissionErrortoOwner);
|
m_PermissionErrortoOwner = m_osslconfig.GetBoolean("PermissionErrorToOwner", m_PermissionErrortoOwner);
|
||||||
|
|
||||||
m_ScriptDelayFactor = m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
|
m_ScriptDelayFactor = m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
|
||||||
m_ScriptDistanceFactor = m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f);
|
m_ScriptDistanceFactor = m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f);
|
||||||
|
|
||||||
string risk = m_osslconfig.GetString("OSFunctionThreatLevel", "VeryLow");
|
string risk = m_osslconfig.GetString("OSFunctionThreatLevel", "VeryLow");
|
||||||
switch (risk)
|
switch (risk)
|
||||||
{
|
{
|
||||||
case "NoAccess":
|
case "NoAccess":
|
||||||
m_MaxThreatLevel = ThreatLevel.NoAccess;
|
m_MaxThreatLevel = ThreatLevel.NoAccess;
|
||||||
break;
|
break;
|
||||||
case "None":
|
case "None":
|
||||||
m_MaxThreatLevel = ThreatLevel.None;
|
m_MaxThreatLevel = ThreatLevel.None;
|
||||||
break;
|
break;
|
||||||
case "VeryLow":
|
case "VeryLow":
|
||||||
m_MaxThreatLevel = ThreatLevel.VeryLow;
|
m_MaxThreatLevel = ThreatLevel.VeryLow;
|
||||||
break;
|
break;
|
||||||
case "Low":
|
case "Low":
|
||||||
m_MaxThreatLevel = ThreatLevel.Low;
|
m_MaxThreatLevel = ThreatLevel.Low;
|
||||||
break;
|
break;
|
||||||
case "Moderate":
|
case "Moderate":
|
||||||
m_MaxThreatLevel = ThreatLevel.Moderate;
|
m_MaxThreatLevel = ThreatLevel.Moderate;
|
||||||
break;
|
break;
|
||||||
case "High":
|
case "High":
|
||||||
m_MaxThreatLevel = ThreatLevel.High;
|
m_MaxThreatLevel = ThreatLevel.High;
|
||||||
break;
|
break;
|
||||||
case "VeryHigh":
|
case "VeryHigh":
|
||||||
m_MaxThreatLevel = ThreatLevel.VeryHigh;
|
m_MaxThreatLevel = ThreatLevel.VeryHigh;
|
||||||
break;
|
break;
|
||||||
case "Severe":
|
case "Severe":
|
||||||
m_MaxThreatLevel = ThreatLevel.Severe;
|
m_MaxThreatLevel = ThreatLevel.Severe;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PSTTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
PSTTimeZone = null;
|
|
||||||
}
|
|
||||||
if(PSTTimeZone == null)
|
|
||||||
{
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PSTTimeZone = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
|
PSTTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
PSTTimeZone = null;
|
PSTTimeZone = null;
|
||||||
}
|
}
|
||||||
|
if(PSTTimeZone == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PSTTimeZone = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
PSTTimeZone = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_doneSharedInit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue