* Applied a patch that: Added estate ban table to migration scripts and nhibernate mapping. Refactored property getters and setters for estate ban object to support NHibernate.

* Added estate ban table to migration scripts of all supported databases.
* Added nhibernate mapping for EstateBans property of EstateSettings
* Refactored property accessors for EstateBan object.
* Added comments for EstateBan properties.
* Ensured that NHibernate tests pass with NUnitGUI.
* Ensured that nant test target passes.  

This fixes mantis #3210. Thank you, tlaukkan!
GenericGridServerConcept
lbsa71 2009-02-21 09:39:33 +00:00
parent 7a649a758d
commit 1cadad9ec6
13 changed files with 158 additions and 33 deletions

View File

@ -332,9 +332,9 @@ namespace OpenSim.Data.MSSQL
// UUID uuid;
// UUID.TryParse(reader["bannedUUID"].ToString(), out uuid);
eb.bannedUUID = new UUID((Guid)reader["bannedUUID"]); //uuid;
eb.bannedIP = "0.0.0.0";
eb.bannedIPHostMask = "0.0.0.0";
eb.BannedUserID = new UUID((Guid)reader["bannedUUID"]); //uuid;
eb.BannedHostAddress = "0.0.0.0";
eb.BannedHostIPMask = "0.0.0.0";
es.AddBan(eb);
}
}
@ -386,7 +386,7 @@ namespace OpenSim.Data.MSSQL
{
cmd.Parameters.Add(_Database.CreateParameter("@EstateID", es.EstateID));
cmd.Parameters.Add(_Database.CreateParameter("@bannedUUID", b.bannedUUID));
cmd.Parameters.Add(_Database.CreateParameter("@bannedUUID", b.BannedUserID));
cmd.ExecuteNonQuery();

View File

@ -314,9 +314,9 @@ namespace OpenSim.Data.MySQL
UUID uuid = new UUID();
UUID.TryParse(r["bannedUUID"].ToString(), out uuid);
eb.bannedUUID = uuid;
eb.bannedIP = "0.0.0.0";
eb.bannedIPHostMask = "0.0.0.0";
eb.BannedUserID = uuid;
eb.BannedHostAddress = "0.0.0.0";
eb.BannedHostIPMask = "0.0.0.0";
es.AddBan(eb);
}
r.Close();
@ -340,7 +340,7 @@ namespace OpenSim.Data.MySQL
foreach (EstateBan b in es.EstateBans)
{
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
cmd.Parameters.AddWithValue("?bannedUUID", b.bannedUUID.ToString());
cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString());
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();

View File

@ -52,6 +52,17 @@
<index column="ArrayIndex" />
<element column="GroupID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
</array>
<array name="EstateBans" table="EstateBans" cascade="all">
<key column="EstateID" />
<index column="ArrayIndex" />
<composite-element class="OpenSim.Framework.EstateBan, OpenSim.Framework">
<property name="BannedUserID" column="BannedUserID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate"/>
<property name="BannedHostAddress" column="BannedHostAddress" type="String" length="16"/>
<property name="BannedHostIPMask" column="BannedHostIPMask" type="String" length="16"/>
<property name="BannedHostNameMask" column="BannedHostNameMask" type="String" length="16"/>
</composite-element>
</array>
</class>
</hibernate-mapping>

View File

@ -59,4 +59,14 @@ CREATE TABLE EstateGroups (
GroupID NVARCHAR(36) NOT NULL,
ArrayIndex INT NOT NULL,
PRIMARY KEY (EstateID,ArrayIndex)
);
CREATE TABLE EstateBans (
EstateID INT NOT NULL,
ArrayIndex INT NOT NULL,
BannedUserID NVARCHAR(36) NOT NULL,
BannedHostAddress NVARCHAR(16) NOT NULL,
BannedHostIPMask NVARCHAR(16) NOT NULL,
BannedHostNameMask NVARCHAR(16) NOT NULL,
PRIMARY KEY (EstateID,ArrayIndex)
);

View File

@ -60,3 +60,12 @@ CREATE TABLE EstateGroups (
PRIMARY KEY (EstateID,ArrayIndex)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1';
CREATE TABLE EstateBans (
EstateID INT NOT NULL,
ArrayIndex INT NOT NULL,
BannedUserID VARCHAR(36) NOT NULL,
BannedHostAddress VARCHAR(16) NOT NULL,
BannedHostIPMask VARCHAR(16) NOT NULL,
BannedHostNameMask VARCHAR(16) NOT NULL,
PRIMARY KEY (EstateID,ArrayIndex)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rev. 1';

View File

@ -59,4 +59,14 @@ CREATE TABLE EstateGroups (
GroupID VARCHAR(36) NOT NULL,
ArrayIndex INT NOT NULL,
PRIMARY KEY (EstateID,ArrayIndex)
);
CREATE TABLE EstateBans (
EstateID INT NOT NULL,
ArrayIndex INT NOT NULL,
BannedUserID VARCHAR(36) NOT NULL,
BannedHostAddress VARCHAR(16) NOT NULL,
BannedHostIPMask VARCHAR(16) NOT NULL,
BannedHostNameMask VARCHAR(16) NOT NULL,
PRIMARY KEY (EstateID,ArrayIndex)
);

View File

@ -59,3 +59,13 @@ CREATE TABLE EstateGroups (
ArrayIndex INT NOT NULL,
PRIMARY KEY (EstateID,ArrayIndex)
);
CREATE TABLE EstateBans (
EstateID INT NOT NULL,
ArrayIndex INT NOT NULL,
BannedUserID VARCHAR(36) NOT NULL,
BannedHostAddress VARCHAR(16) NOT NULL,
BannedHostIPMask VARCHAR(16) NOT NULL,
BannedHostNameMask VARCHAR(16) NOT NULL,
PRIMARY KEY (EstateID,ArrayIndex)
);

View File

@ -258,9 +258,9 @@ namespace OpenSim.Data.SQLite
UUID uuid = new UUID();
UUID.TryParse(r["bannedUUID"].ToString(), out uuid);
eb.bannedUUID = uuid;
eb.bannedIP = "0.0.0.0";
eb.bannedIPHostMask = "0.0.0.0";
eb.BannedUserID = uuid;
eb.BannedHostAddress = "0.0.0.0";
eb.BannedHostIPMask = "0.0.0.0";
es.AddBan(eb);
}
r.Close();
@ -282,7 +282,7 @@ namespace OpenSim.Data.SQLite
foreach (EstateBan b in es.EstateBans)
{
cmd.Parameters.Add(":EstateID", es.EstateID.ToString());
cmd.Parameters.Add(":bannedUUID", b.bannedUUID.ToString());
cmd.Parameters.Add(":bannedUUID", b.BannedUserID.ToString());
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();

View File

@ -223,10 +223,10 @@ namespace OpenSim.Data.Tests
EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID);
EstateBan estateBan1 = new EstateBan();
estateBan1.bannedUUID = DataTestUtil.UUID_MIN;
estateBan1.BannedUserID = DataTestUtil.UUID_MIN;
EstateBan estateBan2 = new EstateBan();
estateBan2.bannedUUID = DataTestUtil.UUID_MAX;
estateBan2.BannedUserID = DataTestUtil.UUID_MAX;
originalSettings.EstateBans = new EstateBan[] { estateBan1, estateBan2 };
@ -237,9 +237,9 @@ namespace OpenSim.Data.Tests
EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID);
Assert.AreEqual(2, loadedSettings.EstateBans.Length);
Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].bannedUUID);
Assert.AreEqual(DataTestUtil.UUID_MIN, loadedSettings.EstateBans[0].BannedUserID);
Assert.AreEqual(DataTestUtil.UUID_MAX, loadedSettings.EstateBans[1].bannedUUID);
Assert.AreEqual(DataTestUtil.UUID_MAX, loadedSettings.EstateBans[1].BannedUserID);
}

View File

@ -31,10 +31,85 @@ namespace OpenSim.Framework
{
public class EstateBan
{
public uint estateID = 1;
public UUID bannedUUID = UUID.Zero;
public string bannedIP = string.Empty;
public string bannedIPHostMask = string.Empty;
public string bannedNameMask = string.Empty;
private uint m_estateID = 1;
/// <summary>
/// ID of the estate this ban limits access to.
/// </summary>
public uint EstateID
{
get
{
return m_estateID;
}
set
{
m_estateID = value;
}
}
private UUID m_bannedUserID = UUID.Zero;
/// <summary>
/// ID of the banned user.
/// </summary>
public UUID BannedUserID
{
get
{
return m_bannedUserID;
}
set
{
m_bannedUserID = value;
}
}
private string m_bannedHostAddress = string.Empty;
/// <summary>
/// IP address or domain name of the banned client.
/// </summary>
public string BannedHostAddress
{
get
{
return m_bannedHostAddress;
}
set
{
m_bannedHostAddress = value;
}
}
private string m_bannedHostIPMask = string.Empty;
/// <summary>
/// IP address mask for banning group of client hosts.
/// </summary>
public string BannedHostIPMask
{
get
{
return m_bannedHostIPMask;
}
set
{
m_bannedHostIPMask = value;
}
}
private string m_bannedHostNameMask = string.Empty;
/// <summary>
/// Domain name mask for banning group of client hosts.
/// </summary>
public string BannedHostNameMask
{
get
{
return m_bannedHostNameMask;
}
set
{
m_bannedHostNameMask = value;
}
}
}
}

View File

@ -333,7 +333,7 @@ namespace OpenSim.Framework
public bool IsBanned(UUID avatarID)
{
foreach (EstateBan ban in l_EstateBans)
if (ban.bannedUUID == avatarID)
if (ban.BannedUserID == avatarID)
return true;
return false;
}
@ -342,7 +342,7 @@ namespace OpenSim.Framework
{
if (ban == null)
return;
if (!IsBanned(ban.bannedUUID))
if (!IsBanned(ban.BannedUserID))
l_EstateBans.Add(ban);
}
@ -354,7 +354,7 @@ namespace OpenSim.Framework
public void RemoveBan(UUID avatarID)
{
foreach (EstateBan ban in new List<EstateBan>(l_EstateBans))
if (ban.bannedUUID == avatarID)
if (ban.BannedUserID == avatarID)
l_EstateBans.Remove(ban);
}

View File

@ -2992,9 +2992,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
if (bl[i] == null)
continue;
if (bl[i].bannedUUID == UUID.Zero)
if (bl[i].BannedUserID == UUID.Zero)
continue;
BannedUsers.Add(bl[i].bannedUUID);
BannedUsers.Add(bl[i].BannedUserID);
}
EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();

View File

@ -241,7 +241,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
for (int i = 0; i < banlistcheck.Length; i++)
{
if (user == banlistcheck[i].bannedUUID)
if (user == banlistcheck[i].BannedUserID)
{
alreadyInList = true;
break;
@ -253,10 +253,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
EstateBan item = new EstateBan();
item.bannedUUID = user;
item.estateID = m_scene.RegionInfo.EstateSettings.EstateID;
item.bannedIP = "0.0.0.0";
item.bannedIPHostMask = "0.0.0.0";
item.BannedUserID = user;
item.EstateID = m_scene.RegionInfo.EstateSettings.EstateID;
item.BannedHostAddress = "0.0.0.0";
item.BannedHostIPMask = "0.0.0.0";
m_scene.RegionInfo.EstateSettings.AddBan(item);
m_scene.RegionInfo.EstateSettings.Save();
@ -294,7 +294,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
for (int i = 0; i < banlistcheck.Length; i++)
{
if (user == banlistcheck[i].bannedUUID)
if (user == banlistcheck[i].BannedUserID)
{
alreadyInList = true;
listitem = banlistcheck[i];
@ -304,7 +304,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
}
if (alreadyInList && listitem != null)
{
m_scene.RegionInfo.EstateSettings.RemoveBan(listitem.bannedUUID);
m_scene.RegionInfo.EstateSettings.RemoveBan(listitem.BannedUserID);
m_scene.RegionInfo.EstateSettings.Save();
}
else