diff options
author | Chris Koeritz | 2012-05-13 16:58:47 -0400 |
---|---|---|
committer | BlueWall | 2012-05-13 17:34:20 -0400 |
commit | 30a272ba318c2cacc27f6244dcf829c37a789a7c (patch) | |
tree | 976beda77221f1d826a4b9c04b59fad0409f8930 | |
parent | Add configurable SpawnPointRouting (diff) | |
download | opensim-SC_OLD-30a272ba318c2cacc27f6244dcf829c37a789a7c.zip opensim-SC_OLD-30a272ba318c2cacc27f6244dcf829c37a789a7c.tar.gz opensim-SC_OLD-30a272ba318c2cacc27f6244dcf829c37a789a7c.tar.bz2 opensim-SC_OLD-30a272ba318c2cacc27f6244dcf829c37a789a7c.tar.xz |
Modifications for SMTP in OpenSimulator. Email size limit was fixed (was out of step with documentation at 1024, so boosted to 4096). Added configuration item for maximum email size. Redundant sleep inside email module was fixed (LSL Api was already sleeping). Added sleep time configuration item for snooze between email sending for LSL Api. Added two new configuration items (email_max_size and email_pause_time) into the example OpenSim.ini, plus fixed a spelling error (llimits) and odd tabbing.
Signed-off-by: BlueWall <jamesh@bluewallgroup.com>
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | 24 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 28 | ||||
-rwxr-xr-x | bin/OpenSim.ini.example | 11 |
3 files changed, 34 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index 9255791..e91e8b9 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | |||
@@ -64,6 +64,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
64 | private TimeSpan m_QueueTimeout = new TimeSpan(2, 0, 0); // 2 hours without llGetNextEmail drops the queue | 64 | private TimeSpan m_QueueTimeout = new TimeSpan(2, 0, 0); // 2 hours without llGetNextEmail drops the queue |
65 | private string m_InterObjectHostname = "lsl.opensim.local"; | 65 | private string m_InterObjectHostname = "lsl.opensim.local"; |
66 | 66 | ||
67 | private int m_MaxEmailSize = 4096; // largest email allowed by default, as per lsl docs. | ||
68 | |||
67 | // Scenes by Region Handle | 69 | // Scenes by Region Handle |
68 | private Dictionary<ulong, Scene> m_Scenes = | 70 | private Dictionary<ulong, Scene> m_Scenes = |
69 | new Dictionary<ulong, Scene>(); | 71 | new Dictionary<ulong, Scene>(); |
@@ -127,6 +129,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
127 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); | 129 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); |
128 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); | 130 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); |
129 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); | 131 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); |
132 | m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize); | ||
130 | } | 133 | } |
131 | catch (Exception e) | 134 | catch (Exception e) |
132 | { | 135 | { |
@@ -176,18 +179,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
176 | get { return true; } | 179 | get { return true; } |
177 | } | 180 | } |
178 | 181 | ||
179 | /// <summary> | ||
180 | /// Delay function using thread in seconds | ||
181 | /// </summary> | ||
182 | /// <param name="seconds"></param> | ||
183 | private void DelayInSeconds(int delay) | ||
184 | { | ||
185 | delay = (int)((float)delay * 1000); | ||
186 | if (delay == 0) | ||
187 | return; | ||
188 | System.Threading.Thread.Sleep(delay); | ||
189 | } | ||
190 | |||
191 | private bool IsLocal(UUID objectID) | 182 | private bool IsLocal(UUID objectID) |
192 | { | 183 | { |
193 | string unused; | 184 | string unused; |
@@ -267,10 +258,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
267 | m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address); | 258 | m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address); |
268 | return; | 259 | return; |
269 | } | 260 | } |
270 | //FIXME:Check if subject + body = 4096 Byte | 261 | if ((subject.Length + body.Length) > m_MaxEmailSize) |
271 | if ((subject.Length + body.Length) > 1024) | ||
272 | { | 262 | { |
273 | m_log.Error("[EMAIL] subject + body > 1024 Byte"); | 263 | m_log.Error("[EMAIL] subject + body larger than limit of " + m_MaxEmailSize + " bytes"); |
274 | return; | 264 | return; |
275 | } | 265 | } |
276 | 266 | ||
@@ -345,10 +335,6 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
345 | // TODO FIX | 335 | // TODO FIX |
346 | } | 336 | } |
347 | } | 337 | } |
348 | |||
349 | //DONE: Message as Second Life style | ||
350 | //20 second delay - AntiSpam System - for now only 10 seconds | ||
351 | DelayInSeconds(10); | ||
352 | } | 338 | } |
353 | 339 | ||
354 | /// <summary> | 340 | /// <summary> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5b5cab8..5bff2e9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -106,6 +106,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
106 | protected IUrlModule m_UrlModule = null; | 106 | protected IUrlModule m_UrlModule = null; |
107 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | 107 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = |
108 | new Dictionary<UUID, UserInfoCacheEntry>(); | 108 | new Dictionary<UUID, UserInfoCacheEntry>(); |
109 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | ||
109 | 110 | ||
110 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 111 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
111 | { | 112 | { |
@@ -113,6 +114,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
113 | m_host = host; | 114 | m_host = host; |
114 | m_item = item; | 115 | m_item = item; |
115 | 116 | ||
117 | LoadLimits(); // read script limits from config. | ||
118 | |||
119 | m_TransferModule = | ||
120 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); | ||
121 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | ||
122 | |||
123 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | ||
124 | } | ||
125 | |||
126 | /* load configuration items that affect script, object and run-time behavior. */ | ||
127 | private void LoadLimits() | ||
128 | { | ||
116 | m_ScriptDelayFactor = | 129 | m_ScriptDelayFactor = |
117 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); | 130 | m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); |
118 | m_ScriptDistanceFactor = | 131 | m_ScriptDistanceFactor = |
@@ -125,12 +138,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
125 | m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); | 138 | m_ScriptEngine.Config.GetInt("NotecardLineReadCharsMax", 255); |
126 | if (m_notecardLineReadCharsMax > 65535) | 139 | if (m_notecardLineReadCharsMax > 65535) |
127 | m_notecardLineReadCharsMax = 65535; | 140 | m_notecardLineReadCharsMax = 65535; |
128 | 141 | // load limits for particular subsystems. | |
129 | m_TransferModule = | 142 | IConfig SMTPConfig; |
130 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); | 143 | if ((SMTPConfig = m_ScriptEngine.ConfigSource.Configs["SMTP"]) != null) { |
131 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 144 | // there's an smtp config, so load in the snooze time. |
132 | 145 | EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME); | |
133 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | 146 | } |
134 | } | 147 | } |
135 | 148 | ||
136 | public override Object InitializeLifetimeService() | 149 | public override Object InitializeLifetimeService() |
@@ -2877,6 +2890,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2877 | 2890 | ||
2878 | public virtual void llSleep(double sec) | 2891 | public virtual void llSleep(double sec) |
2879 | { | 2892 | { |
2893 | // m_log.Info("llSleep snoozing " + sec + "s."); | ||
2880 | m_host.AddScriptLPS(1); | 2894 | m_host.AddScriptLPS(1); |
2881 | Thread.Sleep((int)(sec * 1000)); | 2895 | Thread.Sleep((int)(sec * 1000)); |
2882 | } | 2896 | } |
@@ -3130,7 +3144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3130 | } | 3144 | } |
3131 | 3145 | ||
3132 | emailModule.SendEmail(m_host.UUID, address, subject, message); | 3146 | emailModule.SendEmail(m_host.UUID, address, subject, message); |
3133 | ScriptSleep(20000); | 3147 | llSleep(EMAIL_PAUSE_TIME); |
3134 | } | 3148 | } |
3135 | 3149 | ||
3136 | public void llGetNextEmail(string address, string subject) | 3150 | public void llGetNextEmail(string address, string subject) |
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 50366a6..8e7e459 100755 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -273,6 +273,12 @@ | |||
273 | ;# {host_domain_header_from} {[Startup]emailmodule:DefaultEmailModule enabled:true} {From address to use in the sent email header?} {} 127.0.0.1 | 273 | ;# {host_domain_header_from} {[Startup]emailmodule:DefaultEmailModule enabled:true} {From address to use in the sent email header?} {} 127.0.0.1 |
274 | ; host_domain_header_from = "127.0.0.1" | 274 | ; host_domain_header_from = "127.0.0.1" |
275 | 275 | ||
276 | ;# {email_pause_time} {[Startup]emailmodule:DefaultEmailModule enabled:true} {Period in seconds to delay after an email is sent.} {} 20 | ||
277 | ; email_pause_time = 20 | ||
278 | |||
279 | ;# {email_max_size} {[Startup]emailmodule:DefaultEmailModule enabled:true} {Maximum total size of email in bytes.} {} 4096 | ||
280 | ; email_max_size = 4096 | ||
281 | |||
276 | ;# {SMTP_SERVER_HOSTNAME} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server name?} {} 127.0.0.1 | 282 | ;# {SMTP_SERVER_HOSTNAME} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server name?} {} 127.0.0.1 |
277 | ; SMTP_SERVER_HOSTNAME = "127.0.0.1" | 283 | ; SMTP_SERVER_HOSTNAME = "127.0.0.1" |
278 | 284 | ||
@@ -285,7 +291,6 @@ | |||
285 | ;# {SMTP_SERVER_PASSWORD} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server password} {} | 291 | ;# {SMTP_SERVER_PASSWORD} {[Startup]emailmodule:DefaultEmailModule enabled:true} {SMTP server password} {} |
286 | ; SMTP_SERVER_PASSWORD = "" | 292 | ; SMTP_SERVER_PASSWORD = "" |
287 | 293 | ||
288 | |||
289 | [Network] | 294 | [Network] |
290 | ;; Configure the remote console user here. This will not actually be used | 295 | ;; Configure the remote console user here. This will not actually be used |
291 | ;; unless you use -console=rest at startup. | 296 | ;; unless you use -console=rest at startup. |
@@ -677,7 +682,7 @@ | |||
677 | ;; Sets the multiplier for the scripting delays | 682 | ;; Sets the multiplier for the scripting delays |
678 | ; ScriptDelayFactor = 1.0 | 683 | ; ScriptDelayFactor = 1.0 |
679 | 684 | ||
680 | ;; The factor the 10 m distances llimits are multiplied by | 685 | ;; The factor the 10 m distances limits are multiplied by |
681 | ; ScriptDistanceLimitFactor = 1.0 | 686 | ; ScriptDistanceLimitFactor = 1.0 |
682 | 687 | ||
683 | ;; Maximum length of notecard line read | 688 | ;; Maximum length of notecard line read |
@@ -780,7 +785,7 @@ | |||
780 | ;; groups service if the service is using these keys | 785 | ;; groups service if the service is using these keys |
781 | ; XmlRpcServiceReadKey = 1234 | 786 | ; XmlRpcServiceReadKey = 1234 |
782 | ; XmlRpcServiceWriteKey = 1234 | 787 | ; XmlRpcServiceWriteKey = 1234 |
783 | 788 | ||
784 | [InterestManagement] | 789 | [InterestManagement] |
785 | ;# {UpdatePrioritizationScheme} {} {Update prioritization scheme?} {BestAvatarResponsiveness Time Distance SimpleAngularDistance FrontBack} BestAvatarResponsiveness | 790 | ;# {UpdatePrioritizationScheme} {} {Update prioritization scheme?} {BestAvatarResponsiveness Time Distance SimpleAngularDistance FrontBack} BestAvatarResponsiveness |
786 | ;; This section controls how state updates are prioritized for each client | 791 | ;; This section controls how state updates are prioritized for each client |