Compare commits

...

4 Commits

Author SHA1 Message Date
UbitUmarov
60a32d28e4 add AddOrUpdate to ExpiringKey 2026-06-16 21:41:15 +01:00
Ubit Umarov
8a95a4dfe0 Merge pull request #41 from holoneon/patch-3
Update AvatarFactoryModule.cs
2026-06-16 20:54:32 +01:00
UbitUmarov
282db7dd1e update libomv 2026-06-16 19:09:47 +01:00
Fiona Sweet
dae81f7bf5 Update AvatarFactoryModule.cs
in logs i have noticed thousands of 'rebake' requests happening extremely rapidly from a few hg visitors, (for example yesterday 2400 from one hg visitor in 3 minutes) a potential denial of service vector. this adds throttling limit 1 per 30 seconds.  please review
2026-06-15 12:53:52 -07:00
8 changed files with 49 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ using System;
using System.Threading;
using System.Collections.Generic;
using Timer = System.Threading.Timer ;
using System.Runtime.InteropServices;
namespace OpenSim.Framework
{
@@ -168,6 +169,28 @@ namespace OpenSim.Framework
finally { m_rwLock.ExitWriteLock(); }
}
public bool AddOrUpdate(Tkey1 key, int expireMS)
{
int now;
if (expireMS > 0)
{
expireMS = (expireMS > m_expire) ? expireMS : m_expire;
now = (int)(Util.GetTimeStampMS() - m_startTS) + expireMS;
}
else
now = int.MinValue;
m_rwLock.EnterWriteLock();
try
{
ref int entry = ref CollectionsMarshal.GetValueRefOrAddDefault(m_dictionary, key, out bool exists);
entry = now;
CheckTimer();
return exists;
}
finally { m_rwLock.ExitWriteLock(); }
}
public bool Remove(Tkey1 key)
{
m_rwLock.EnterWriteLock();

View File

@@ -67,6 +67,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
private object m_setAppearanceLock = new object();
// add throttle
private ConcurrentDictionary<string, long> m_rebakeThrottle = new ConcurrentDictionary<string, long>();
private const int REBAKE_THROTTLE_SECONDS = 30;
#region Region Module interface
public void Initialise(IConfigSource config)
@@ -451,10 +455,32 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
sp.Appearance.WearableCacheItems = wearableCache;
// throttle rebake requests
if (missing.Count > 0)
{
long now = DateTime.UtcNow.Ticks;
foreach (UUID id in missing)
{
string key = sp.UUID.ToString() + ":" + id.ToString();
long last;
if (m_rebakeThrottle.TryGetValue(key, out last))
{
TimeSpan age = new TimeSpan(now - last);
if (age.TotalSeconds < REBAKE_THROTTLE_SECONDS)
continue;
}
m_rebakeThrottle[key] = now;
m_log.DebugFormat(
"[AVFACTORY]: Missing baked texture {0} for {1}, requesting rebake",
id, sp.Name);
sp.ControllingClient.SendRebakeAvatarTextures(id);
}
}
bool changed = false;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.