EstateAccess do fill the fields(mySQL only); fix the response

0.9.1.0-post-fixes
UbitUmarov 2019-08-17 23:57:05 +01:00
parent eb9cf78e6b
commit db374112c6
5 changed files with 64 additions and 43 deletions

View File

@ -285,7 +285,7 @@ namespace OpenSim.Data.MySQL
using (MySqlCommand cmd = dbcon.CreateCommand()) using (MySqlCommand cmd = dbcon.CreateCommand())
{ {
cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; cmd.CommandText = "select * from estateban where EstateID = ?EstateID";
cmd.Parameters.AddWithValue("?EstateID", es.EstateID); cmd.Parameters.AddWithValue("?EstateID", es.EstateID);
using (IDataReader r = cmd.ExecuteReader()) using (IDataReader r = cmd.ExecuteReader())
@ -293,13 +293,11 @@ namespace OpenSim.Data.MySQL
while (r.Read()) while (r.Read())
{ {
EstateBan eb = new EstateBan(); EstateBan eb = new EstateBan();
eb.BannedUserID = DBGuid.FromDB(r["bannedUUID"]); ;
UUID uuid = new UUID();
UUID.TryParse(r["bannedUUID"].ToString(), out uuid);
eb.BannedUserID = uuid;
eb.BannedHostAddress = "0.0.0.0"; eb.BannedHostAddress = "0.0.0.0";
eb.BannedHostIPMask = "0.0.0.0"; eb.BannedHostIPMask = "0.0.0.0";
eb.BanningUserID = DBGuid.FromDB(r["banningUUID"]);
eb.BanTime = Convert.ToInt32(r["banTime"]);
es.AddBan(eb); es.AddBan(eb);
} }
} }
@ -323,12 +321,14 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.Clear(); cmd.Parameters.Clear();
cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask, banningUUID, banTime) values ( ?EstateID, ?bannedUUID, '', '', '', ?banningUUID, ?banTime)";
foreach (EstateBan b in es.EstateBans) foreach (EstateBan b in es.EstateBans)
{ {
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString());
cmd.Parameters.AddWithValue("?banningUUID", b.BanningUserID.ToString());
cmd.Parameters.AddWithValue("?banTime", b.BanTime);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
cmd.Parameters.Clear(); cmd.Parameters.Clear();

View File

@ -67,6 +67,9 @@ namespace OpenSim.Framework
} }
} }
public UUID BanningUserID { get; set; }
public int BanTime;
private string m_bannedHostAddress = string.Empty; private string m_bannedHostAddress = string.Empty;
/// <summary> /// <summary>
/// IP address or domain name of the banned client. /// IP address or domain name of the banned client.
@ -143,6 +146,8 @@ namespace OpenSim.Framework
p.SetValue(this, Boolean.Parse((string)map[p.Name]), null); p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
else if (value is UUID) else if (value is UUID)
p.SetValue(this, UUID.Parse((string)map[p.Name]), null); p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
else if (value is DateTime)
p.SetValue(this, DateTime.Parse((string)map[p.Name]), null);
} }
} }

View File

@ -315,13 +315,9 @@ namespace OpenSim.Framework
public static void AddRawElem(string e, StringBuilder sb) public static void AddRawElem(string e, StringBuilder sb)
{ {
if(String.IsNullOrEmpty(e)) if(String.IsNullOrEmpty(e))
sb.Append("<string />"); return;
else
{
sb.Append("<string>");
sb.Append(e); sb.Append(e);
sb.Append("</string>");
}
} }
public static void AddElem(Uri e, StringBuilder sb) public static void AddElem(Uri e, StringBuilder sb)
@ -652,18 +648,13 @@ namespace OpenSim.Framework
public static void AddRawElem(string name, string e, StringBuilder sb) public static void AddRawElem(string name, string e, StringBuilder sb)
{ {
if (String.IsNullOrEmpty(e))
return;
sb.Append("<key>"); sb.Append("<key>");
sb.Append(name); sb.Append(name);
sb.Append("</key>"); sb.Append("</key>");
if(String.IsNullOrEmpty(e))
sb.Append("<string />");
else
{
sb.Append("<string>");
sb.Append(e); sb.Append(e);
sb.Append("</string>");
}
} }
public static void AddElem(string name, Uri e, StringBuilder sb) public static void AddElem(string name, Uri e, StringBuilder sb)
@ -723,6 +714,14 @@ namespace OpenSim.Framework
sb.Append(e); sb.Append(e);
} }
public static void AddLLSD(string name, string e, StringBuilder sb)
{
sb.Append("<key>");
sb.Append(name);
sb.Append("</key>");
sb.Append(e);
}
public static void EscapeToXML(string s, StringBuilder sb) public static void EscapeToXML(string s, StringBuilder sb)
{ {
int i; int i;

View File

@ -28,6 +28,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Text; using System.Text;
using log4net; using log4net;
@ -166,59 +167,73 @@ namespace OpenSim.Region.ClientStack.Linden
EstateBan[] EstateBans = regionSettings.EstateBans; EstateBan[] EstateBans = regionSettings.EstateBans;
StringBuilder sb = LLSDxmlEncode.Start(); StringBuilder sb = LLSDxmlEncode.Start();
LLSDxmlEncode.AddArray(sb); LLSDxmlEncode.AddMap(sb);
if (allowed != null && allowed.Length > 0) if (allowed != null && allowed.Length > 0)
{ {
LLSDxmlEncode.AddMap("AllowedAgents", sb); LLSDxmlEncode.AddArray("AllowedAgents", sb);
for (int i = 0; i < allowed.Length; ++i) for (int i = 0; i < allowed.Length; ++i)
{ {
UUID id = allowed[i]; UUID id = allowed[i];
if (id == UUID.Zero) if (id == UUID.Zero)
continue; continue;
LLSDxmlEncode.AddMap(sb);
LLSDxmlEncode.AddElem("id", id, sb); LLSDxmlEncode.AddElem("id", id, sb);
}
LLSDxmlEncode.AddEndMap(sb); LLSDxmlEncode.AddEndMap(sb);
} }
LLSDxmlEncode.AddEndArray(sb);
}
if (groups != null && groups.Length > 0) if (groups != null && groups.Length > 0)
{ {
LLSDxmlEncode.AddMap("AllowedGroups", sb); LLSDxmlEncode.AddArray("AllowedGroups", sb);
for (int i = 0; i < groups.Length; ++i) for (int i = 0; i < groups.Length; ++i)
{ {
UUID id = groups[i]; UUID id = groups[i];
if (id == UUID.Zero) if (id == UUID.Zero)
continue; continue;
LLSDxmlEncode.AddMap(sb);
LLSDxmlEncode.AddElem("id", id, sb); LLSDxmlEncode.AddElem("id", id, sb);
}
LLSDxmlEncode.AddEndMap(sb); LLSDxmlEncode.AddEndMap(sb);
} }
LLSDxmlEncode.AddEndArray(sb);
}
if (EstateBans != null && EstateBans.Length > 0) if (EstateBans != null && EstateBans.Length > 0)
{ {
LLSDxmlEncode.AddMap("BannedAgents", sb); LLSDxmlEncode.AddArray("BannedAgents", sb);
for (int i = 0; i < EstateBans.Length; ++i) for (int i = 0; i < EstateBans.Length; ++i)
{ {
UUID id = EstateBans[i].BannedUserID; EstateBan ban = EstateBans[i];
UUID id = ban.BannedUserID;
if (id == UUID.Zero) if (id == UUID.Zero)
continue; continue;
LLSDxmlEncode.AddMap(sb);
LLSDxmlEncode.AddElem("id", id, sb); LLSDxmlEncode.AddElem("id", id, sb);
LLSDxmlEncode.AddElem("last_login_date", "0000-00-00 00:00:00", sb); // We will not have this LLSDxmlEncode.AddElem("banning_id", ban.BanningUserID, sb);
LLSDxmlEncode.AddElem("ban_date", "0000-00-00 00:00:00", sb); // We will have this LLSDxmlEncode.AddElem("last_login_date", "na", sb); // We will not have this. This information is far at grid
LLSDxmlEncode.AddElem("banning_id", UUID.Zero, sb); // we will have this one day if (ban.BanTime == 0)
} LLSDxmlEncode.AddElem("ban_date", "0000-00-00 00:00", sb);
else
LLSDxmlEncode.AddElem("ban_date", (Util.ToDateTime(ban.BanTime)).ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture), sb);
LLSDxmlEncode.AddEndMap(sb); LLSDxmlEncode.AddEndMap(sb);
} }
LLSDxmlEncode.AddEndArray(sb);
}
if (managers != null && managers.Length > 0) if (managers != null && managers.Length > 0)
{ {
LLSDxmlEncode.AddMap("Managers", sb); LLSDxmlEncode.AddArray("Managers", sb);
for (int i = 0; i < managers.Length; ++i) for (int i = 0; i < managers.Length; ++i)
{
LLSDxmlEncode.AddMap(sb);
LLSDxmlEncode.AddElem("id", managers[i], sb); LLSDxmlEncode.AddElem("id", managers[i], sb);
LLSDxmlEncode.AddEndMap(sb); LLSDxmlEncode.AddEndMap(sb);
} }
LLSDxmlEncode.AddEndArray(sb); LLSDxmlEncode.AddEndArray(sb);
}
LLSDxmlEncode.AddEndMap(sb);
responsedata["str_response_string"] = LLSDxmlEncode.End(sb); responsedata["str_response_string"] = LLSDxmlEncode.End(sb);
return responsedata; return responsedata;

View File

@ -969,11 +969,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
continue; continue;
EstateBan bitem = new EstateBan(); EstateBan bitem = new EstateBan();
bitem.BannedUserID = user; bitem.BannedUserID = user;
bitem.EstateID = estateSettings.EstateID; bitem.EstateID = estateSettings.EstateID;
bitem.BannedHostAddress = "0.0.0.0"; bitem.BannedHostAddress = "0.0.0.0";
bitem.BannedHostIPMask = "0.0.0.0"; bitem.BannedHostIPMask = "0.0.0.0";
bitem.BanningUserID = remote_client.AgentId;
bitem.BanTime = Util.UnixTimeSinceEpoch();
estateSettings.AddBan(bitem); estateSettings.AddBan(bitem);
estateSettings.RemoveEstateUser(user); estateSettings.RemoveEstateUser(user);
@ -982,11 +983,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
} }
EstateBan item = new EstateBan(); EstateBan item = new EstateBan();
item.BannedUserID = user; item.BannedUserID = user;
item.EstateID = Scene.RegionInfo.EstateSettings.EstateID; item.EstateID = Scene.RegionInfo.EstateSettings.EstateID;
item.BannedHostAddress = "0.0.0.0"; item.BannedHostAddress = "0.0.0.0";
item.BannedHostIPMask = "0.0.0.0"; item.BannedHostIPMask = "0.0.0.0";
item.BanningUserID = remote_client.AgentId;
item.BanTime = Util.UnixTimeSinceEpoch();
thisSettings.AddBan(item); thisSettings.AddBan(item);
thisSettings.RemoveEstateUser(user); thisSettings.RemoveEstateUser(user);