From db374112c6ce406fafe30a5da3a16d327dcb7a03 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 17 Aug 2019 23:57:05 +0100 Subject: [PATCH] EstateAccess do fill the fields(mySQL only); fix the response --- OpenSim/Data/MySQL/MySQLEstateData.cs | 14 ++--- OpenSim/Framework/EstateBan.cs | 5 ++ OpenSim/Framework/LLSDxmlEncode.cs | 31 ++++++----- .../ClientStack/Linden/Caps/EstateAccess.cs | 51 ++++++++++++------- .../World/Estate/EstateManagementModule.cs | 6 ++- 5 files changed, 64 insertions(+), 43 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index eeedf02b29..2406ee6a6e 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -285,7 +285,7 @@ namespace OpenSim.Data.MySQL 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); using (IDataReader r = cmd.ExecuteReader()) @@ -293,13 +293,11 @@ namespace OpenSim.Data.MySQL while (r.Read()) { EstateBan eb = new EstateBan(); - - UUID uuid = new UUID(); - UUID.TryParse(r["bannedUUID"].ToString(), out uuid); - - eb.BannedUserID = uuid; + eb.BannedUserID = DBGuid.FromDB(r["bannedUUID"]); ; eb.BannedHostAddress = "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); } } @@ -323,12 +321,14 @@ namespace OpenSim.Data.MySQL 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) { cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); + cmd.Parameters.AddWithValue("?banningUUID", b.BanningUserID.ToString()); + cmd.Parameters.AddWithValue("?banTime", b.BanTime); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); diff --git a/OpenSim/Framework/EstateBan.cs b/OpenSim/Framework/EstateBan.cs index 12a92bb0e2..81a56d747e 100644 --- a/OpenSim/Framework/EstateBan.cs +++ b/OpenSim/Framework/EstateBan.cs @@ -67,6 +67,9 @@ namespace OpenSim.Framework } } + public UUID BanningUserID { get; set; } + public int BanTime; + private string m_bannedHostAddress = string.Empty; /// /// 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); else if (value is UUID) 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); } } diff --git a/OpenSim/Framework/LLSDxmlEncode.cs b/OpenSim/Framework/LLSDxmlEncode.cs index ac9b4686db..97b3ca18bf 100644 --- a/OpenSim/Framework/LLSDxmlEncode.cs +++ b/OpenSim/Framework/LLSDxmlEncode.cs @@ -315,13 +315,9 @@ namespace OpenSim.Framework public static void AddRawElem(string e, StringBuilder sb) { if(String.IsNullOrEmpty(e)) - sb.Append(""); - else - { - sb.Append(""); - sb.Append(e); - sb.Append(""); - } + return; + + sb.Append(e); } 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) { + if (String.IsNullOrEmpty(e)) + return; + sb.Append(""); sb.Append(name); sb.Append(""); - - if(String.IsNullOrEmpty(e)) - sb.Append(""); - else - { - sb.Append(""); - sb.Append(e); - sb.Append(""); - } + sb.Append(e); } public static void AddElem(string name, Uri e, StringBuilder sb) @@ -723,6 +714,14 @@ namespace OpenSim.Framework sb.Append(e); } + public static void AddLLSD(string name, string e, StringBuilder sb) + { + sb.Append(""); + sb.Append(name); + sb.Append(""); + sb.Append(e); + } + public static void EscapeToXML(string s, StringBuilder sb) { int i; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs index c3a48d9d7d..3a4d9a5f72 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.Text; using log4net; @@ -166,59 +167,73 @@ namespace OpenSim.Region.ClientStack.Linden EstateBan[] EstateBans = regionSettings.EstateBans; StringBuilder sb = LLSDxmlEncode.Start(); - LLSDxmlEncode.AddArray(sb); + LLSDxmlEncode.AddMap(sb); if (allowed != null && allowed.Length > 0) { - LLSDxmlEncode.AddMap("AllowedAgents", sb); + LLSDxmlEncode.AddArray("AllowedAgents", sb); for (int i = 0; i < allowed.Length; ++i) { UUID id = allowed[i]; if (id == UUID.Zero) continue; - LLSDxmlEncode.AddElem("id", id, sb); + LLSDxmlEncode.AddMap(sb); + LLSDxmlEncode.AddElem("id", id, sb); + LLSDxmlEncode.AddEndMap(sb); } - LLSDxmlEncode.AddEndMap(sb); + LLSDxmlEncode.AddEndArray(sb); } if (groups != null && groups.Length > 0) { - LLSDxmlEncode.AddMap("AllowedGroups", sb); + LLSDxmlEncode.AddArray("AllowedGroups", sb); for (int i = 0; i < groups.Length; ++i) { UUID id = groups[i]; if (id == UUID.Zero) continue; - LLSDxmlEncode.AddElem("id", id, sb); + LLSDxmlEncode.AddMap(sb); + LLSDxmlEncode.AddElem("id", id, sb); + LLSDxmlEncode.AddEndMap(sb); } - LLSDxmlEncode.AddEndMap(sb); + LLSDxmlEncode.AddEndArray(sb); } if (EstateBans != null && EstateBans.Length > 0) { - LLSDxmlEncode.AddMap("BannedAgents", sb); + LLSDxmlEncode.AddArray("BannedAgents", sb); 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) continue; - LLSDxmlEncode.AddElem("id", id, sb); - LLSDxmlEncode.AddElem("last_login_date", "0000-00-00 00:00:00", sb); // We will not have this - LLSDxmlEncode.AddElem("ban_date", "0000-00-00 00:00:00", sb); // We will have this - LLSDxmlEncode.AddElem("banning_id", UUID.Zero, sb); // we will have this one day + LLSDxmlEncode.AddMap(sb); + LLSDxmlEncode.AddElem("id", id, sb); + LLSDxmlEncode.AddElem("banning_id", ban.BanningUserID, sb); + LLSDxmlEncode.AddElem("last_login_date", "na", sb); // We will not have this. This information is far at grid + 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) { - LLSDxmlEncode.AddMap("Managers", sb); + LLSDxmlEncode.AddArray("Managers", sb); for (int i = 0; i < managers.Length; ++i) - LLSDxmlEncode.AddElem("id", managers[i], sb); - LLSDxmlEncode.AddEndMap(sb); + { + LLSDxmlEncode.AddMap(sb); + LLSDxmlEncode.AddElem("id", managers[i], sb); + LLSDxmlEncode.AddEndMap(sb); + } + LLSDxmlEncode.AddEndArray(sb); } - LLSDxmlEncode.AddEndArray(sb); + LLSDxmlEncode.AddEndMap(sb); responsedata["str_response_string"] = LLSDxmlEncode.End(sb); return responsedata; diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index c91933ffc8..00c77d7a60 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -969,11 +969,12 @@ namespace OpenSim.Region.CoreModules.World.Estate continue; EstateBan bitem = new EstateBan(); - bitem.BannedUserID = user; bitem.EstateID = estateSettings.EstateID; bitem.BannedHostAddress = "0.0.0.0"; bitem.BannedHostIPMask = "0.0.0.0"; + bitem.BanningUserID = remote_client.AgentId; + bitem.BanTime = Util.UnixTimeSinceEpoch(); estateSettings.AddBan(bitem); estateSettings.RemoveEstateUser(user); @@ -982,11 +983,12 @@ namespace OpenSim.Region.CoreModules.World.Estate } EstateBan item = new EstateBan(); - item.BannedUserID = user; item.EstateID = Scene.RegionInfo.EstateSettings.EstateID; item.BannedHostAddress = "0.0.0.0"; item.BannedHostIPMask = "0.0.0.0"; + item.BanningUserID = remote_client.AgentId; + item.BanTime = Util.UnixTimeSinceEpoch(); thisSettings.AddBan(item); thisSettings.RemoveEstateUser(user);