Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
commit
3321f9d745
|
@ -338,11 +338,30 @@ namespace OpenSim.Framework
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsBanned(UUID avatarID)
|
public bool IsBanned(UUID avatarID, int userFlags)
|
||||||
{
|
{
|
||||||
foreach (EstateBan ban in l_EstateBans)
|
foreach (EstateBan ban in l_EstateBans)
|
||||||
if (ban.BannedUserID == avatarID)
|
if (ban.BannedUserID == avatarID)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!IsEstateManager(avatarID) && !HasAccess(avatarID))
|
||||||
|
{
|
||||||
|
if (DenyMinors)
|
||||||
|
{
|
||||||
|
if ((userFlags & 32) == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (DenyAnonymous)
|
||||||
|
{
|
||||||
|
if ((userFlags & 4) == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +369,7 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
if (ban == null)
|
if (ban == null)
|
||||||
return;
|
return;
|
||||||
if (!IsBanned(ban.BannedUserID))
|
if (!IsBanned(ban.BannedUserID, 32)) //Ignore age-based bans
|
||||||
l_EstateBans.Add(ban);
|
l_EstateBans.Add(ban);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,12 +217,12 @@ namespace OpenSim.Framework.Tests
|
||||||
BannedHostNameMask = string.Empty,
|
BannedHostNameMask = string.Empty,
|
||||||
BannedUserID = bannedUserId}
|
BannedUserID = bannedUserId}
|
||||||
);
|
);
|
||||||
Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not.");
|
Assert.IsTrue(es.IsBanned(bannedUserId, 32), "User Should be banned but is not.");
|
||||||
Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is.");
|
Assert.IsFalse(es.IsBanned(UUID.Zero, 32), "User Should not be banned but is.");
|
||||||
|
|
||||||
es.RemoveBan(bannedUserId);
|
es.RemoveBan(bannedUserId);
|
||||||
|
|
||||||
Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is.");
|
Assert.IsFalse(es.IsBanned(bannedUserId, 32), "User Should not be banned but is.");
|
||||||
|
|
||||||
es.AddEstateManager(UUID.Zero);
|
es.AddEstateManager(UUID.Zero);
|
||||||
|
|
||||||
|
|
|
@ -409,19 +409,25 @@ namespace OpenSim.Framework
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
||||||
public static string Md5Hash(string data)
|
public static string Md5Hash(string data)
|
||||||
{
|
{
|
||||||
byte[] dataMd5 = ComputeMD5Hash(data);
|
return Md5Hash(data, Encoding.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Md5Hash(string data, Encoding encoding)
|
||||||
|
{
|
||||||
|
byte[] dataMd5 = ComputeMD5Hash(data, encoding);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < dataMd5.Length; i++)
|
for (int i = 0; i < dataMd5.Length; i++)
|
||||||
sb.AppendFormat("{0:x2}", dataMd5[i]);
|
sb.AppendFormat("{0:x2}", dataMd5[i]);
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] ComputeMD5Hash(string data)
|
private static byte[] ComputeMD5Hash(string data, Encoding encoding)
|
||||||
{
|
{
|
||||||
MD5 md5 = MD5.Create();
|
MD5 md5 = MD5.Create();
|
||||||
return md5.ComputeHash(Encoding.Default.GetBytes(data));
|
return md5.ComputeHash(encoding.GetBytes(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -429,16 +435,22 @@ namespace OpenSim.Framework
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
||||||
public static string SHA1Hash(string data)
|
public static string SHA1Hash(string data)
|
||||||
{
|
{
|
||||||
byte[] hash = ComputeSHA1Hash(data);
|
return SHA1Hash(data, Encoding.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string SHA1Hash(string data, Encoding encoding)
|
||||||
|
{
|
||||||
|
byte[] hash = ComputeSHA1Hash(data, encoding);
|
||||||
return BitConverter.ToString(hash).Replace("-", String.Empty);
|
return BitConverter.ToString(hash).Replace("-", String.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] ComputeSHA1Hash(string src)
|
private static byte[] ComputeSHA1Hash(string src, Encoding encoding)
|
||||||
{
|
{
|
||||||
SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
|
SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
|
||||||
return SHA1.ComputeHash(Encoding.Default.GetBytes(src));
|
return SHA1.ComputeHash(encoding.GetBytes(src));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int fast_distance2d(int x, int y)
|
public static int fast_distance2d(int x, int y)
|
||||||
|
@ -1161,7 +1173,7 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
public static Guid GetHashGuid(string data, string salt)
|
public static Guid GetHashGuid(string data, string salt)
|
||||||
{
|
{
|
||||||
byte[] hash = ComputeMD5Hash(data + salt);
|
byte[] hash = ComputeMD5Hash(data + salt, Encoding.Default);
|
||||||
|
|
||||||
//string s = BitConverter.ToString(hash);
|
//string s = BitConverter.ToString(hash);
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,8 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
|
||||||
|
|
||||||
public void AddCapsHandler(UUID agentId)
|
public void AddCapsHandler(UUID agentId)
|
||||||
{
|
{
|
||||||
if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId))
|
int flags = m_scene.GetUserFlags(agentId);
|
||||||
|
if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String capsObjectPath = GetCapsPath(agentId);
|
String capsObjectPath = GetCapsPath(agentId);
|
||||||
|
|
|
@ -2443,7 +2443,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// If the user is banned, we won't let any of their objects
|
// If the user is banned, we won't let any of their objects
|
||||||
// enter. Period.
|
// enter. Period.
|
||||||
//
|
//
|
||||||
if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID))
|
int flags = GetUserFlags(sceneObject.OwnerID);
|
||||||
|
if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
|
||||||
{
|
{
|
||||||
m_log.Info("[INTERREGION]: Denied prim crossing for " +
|
m_log.Info("[INTERREGION]: Denied prim crossing for " +
|
||||||
"banned avatar");
|
"banned avatar");
|
||||||
|
@ -2547,6 +2548,22 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
return 2; // StateSource.PrimCrossing
|
return 2; // StateSource.PrimCrossing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetUserFlags(UUID user)
|
||||||
|
{
|
||||||
|
//Unfortunately the SP approach means that the value is cached until region is restarted
|
||||||
|
/*
|
||||||
|
ScenePresence sp;
|
||||||
|
if (TryGetScenePresence(user, out sp))
|
||||||
|
{
|
||||||
|
return sp.UserFlags;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*/
|
||||||
|
UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
|
||||||
|
return uac.UserFlags;
|
||||||
|
//}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Add/Remove Avatar Methods
|
#region Add/Remove Avatar Methods
|
||||||
|
@ -3626,10 +3643,26 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
if (m_regInfo.EstateSettings != null)
|
if (m_regInfo.EstateSettings != null)
|
||||||
{
|
{
|
||||||
if (m_regInfo.EstateSettings.IsBanned(agentID))
|
int flags = GetUserFlags(agent.AgentID);
|
||||||
|
if (m_regInfo.EstateSettings.IsBanned(agentID, flags))
|
||||||
{
|
{
|
||||||
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user is on the banlist",
|
//Add some more info to help users
|
||||||
|
if (!m_regInfo.EstateSettings.IsBanned(agentID, 32))
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification",
|
||||||
agentID, RegionInfo.RegionName);
|
agentID, RegionInfo.RegionName);
|
||||||
|
reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!m_regInfo.EstateSettings.IsBanned(agentID, 4))
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file",
|
||||||
|
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
|
||||||
|
reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist",
|
||||||
|
agent.AgentID, RegionInfo.RegionName);
|
||||||
reason = String.Format("Denied access to region {0}: You have been banned from that region.",
|
reason = String.Format("Denied access to region {0}: You have been banned from that region.",
|
||||||
RegionInfo.RegionName);
|
RegionInfo.RegionName);
|
||||||
return false;
|
return false;
|
||||||
|
@ -3788,7 +3821,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
// We have to wait until the viewer contacts this region after receiving EAC.
|
// We have to wait until the viewer contacts this region after receiving EAC.
|
||||||
// That calls AddNewClient, which finally creates the ScenePresence
|
// That calls AddNewClient, which finally creates the ScenePresence
|
||||||
if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID))
|
int flags = GetUserFlags(cAgentData.AgentID);
|
||||||
|
if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
|
m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -113,6 +113,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
get { return m_attachments; }
|
get { return m_attachments; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
|
protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
|
||||||
|
|
||||||
private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
|
private Dictionary<UUID, ScriptControllers> scriptedcontrols = new Dictionary<UUID, ScriptControllers>();
|
||||||
|
@ -136,6 +137,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
private bool m_updateflag;
|
private bool m_updateflag;
|
||||||
private byte m_movementflag;
|
private byte m_movementflag;
|
||||||
private Vector3? m_forceToApply;
|
private Vector3? m_forceToApply;
|
||||||
|
private int m_userFlags;
|
||||||
|
public int UserFlags
|
||||||
|
{
|
||||||
|
get { return m_userFlags; }
|
||||||
|
}
|
||||||
|
|
||||||
private uint m_requestedSitTargetID;
|
private uint m_requestedSitTargetID;
|
||||||
private UUID m_requestedSitTargetUUID;
|
private UUID m_requestedSitTargetUUID;
|
||||||
public bool SitGround = false;
|
public bool SitGround = false;
|
||||||
|
@ -763,6 +770,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_localId = m_scene.AllocateLocalId();
|
m_localId = m_scene.AllocateLocalId();
|
||||||
|
|
||||||
UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
|
UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
|
||||||
|
m_userFlags = account.UserFlags;
|
||||||
|
|
||||||
if (account != null)
|
if (account != null)
|
||||||
m_userLevel = account.UserLevel;
|
m_userLevel = account.UserLevel;
|
||||||
|
|
|
@ -6938,13 +6938,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
public LSL_String llMD5String(string src, int nonce)
|
public LSL_String llMD5String(string src, int nonce)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()));
|
return Util.Md5Hash(String.Format("{0}:{1}", src, nonce.ToString()), Encoding.UTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LSL_String llSHA1String(string src)
|
public LSL_String llSHA1String(string src)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
return Util.SHA1Hash(src).ToLower();
|
return Util.SHA1Hash(src, Encoding.UTF8).ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)
|
protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist)
|
||||||
|
|
Loading…
Reference in New Issue