aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares2008-06-21 06:50:38 +0000
committerTeravus Ovares2008-06-21 06:50:38 +0000
commit2758bc81ad79c6110777ceb6cc714c7b40014359 (patch)
tree6bf47a5c7ecd64a821a5339cf68f90204e1413d9 /OpenSim
parent* Adds Region ban capability to Regions. You access this by going to World->... (diff)
downloadopensim-SC_OLD-2758bc81ad79c6110777ceb6cc714c7b40014359.zip
opensim-SC_OLD-2758bc81ad79c6110777ceb6cc714c7b40014359.tar.gz
opensim-SC_OLD-2758bc81ad79c6110777ceb6cc714c7b40014359.tar.bz2
opensim-SC_OLD-2758bc81ad79c6110777ceb6cc714c7b40014359.tar.xz
* Persists region banlists across reboots for the sqlite datastore also now.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/SQLite/Resources/002_RegionStore.sql10
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs85
-rw-r--r--OpenSim/Framework/RegionBanListItem.cs27
3 files changed, 119 insertions, 3 deletions
diff --git a/OpenSim/Data/SQLite/Resources/002_RegionStore.sql b/OpenSim/Data/SQLite/Resources/002_RegionStore.sql
new file mode 100644
index 0000000..c5c7c99
--- /dev/null
+++ b/OpenSim/Data/SQLite/Resources/002_RegionStore.sql
@@ -0,0 +1,10 @@
1BEGIN TRANSACTION;
2
3CREATE TABLE regionban(
4 regionUUID varchar (255),
5 bannedUUID varchar (255),
6 bannedIp varchar (255),
7 bannedIpHostMask varchar (255)
8 );
9
10COMMIT; \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index ab4d283..8212691 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -50,6 +50,7 @@ namespace OpenSim.Data.SQLite
50 private const string terrainSelect = "select * from terrain limit 1"; 50 private const string terrainSelect = "select * from terrain limit 1";
51 private const string landSelect = "select * from land"; 51 private const string landSelect = "select * from land";
52 private const string landAccessListSelect = "select distinct * from landaccesslist"; 52 private const string landAccessListSelect = "select distinct * from landaccesslist";
53 private const string regionbanListSelect = "select * from regionban";
53 54
54 private DataSet ds; 55 private DataSet ds;
55 private SqliteDataAdapter primDa; 56 private SqliteDataAdapter primDa;
@@ -58,6 +59,7 @@ namespace OpenSim.Data.SQLite
58 private SqliteDataAdapter terrainDa; 59 private SqliteDataAdapter terrainDa;
59 private SqliteDataAdapter landDa; 60 private SqliteDataAdapter landDa;
60 private SqliteDataAdapter landAccessListDa; 61 private SqliteDataAdapter landAccessListDa;
62 private SqliteDataAdapter regionBanListDa;
61 63
62 private SqliteConnection m_conn; 64 private SqliteConnection m_conn;
63 65
@@ -106,6 +108,9 @@ namespace OpenSim.Data.SQLite
106 SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); 108 SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn);
107 landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); 109 landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd);
108 110
111 SqliteCommand regionBanListSelectCmd = new SqliteCommand(regionbanListSelect, m_conn);
112 regionBanListDa = new SqliteDataAdapter(regionBanListSelectCmd);
113
109 // This actually does the roll forward assembly stuff 114 // This actually does the roll forward assembly stuff
110 Assembly assem = GetType().Assembly; 115 Assembly assem = GetType().Assembly;
111 Migration m = new Migration(m_conn, assem, "RegionStore"); 116 Migration m = new Migration(m_conn, assem, "RegionStore");
@@ -141,6 +146,10 @@ namespace OpenSim.Data.SQLite
141 ds.Tables.Add(createLandAccessListTable()); 146 ds.Tables.Add(createLandAccessListTable());
142 setupLandAccessCommands(landAccessListDa, m_conn); 147 setupLandAccessCommands(landAccessListDa, m_conn);
143 148
149 ds.Tables.Add(createRegionBanListTable());
150 setupRegionBanCommands(regionBanListDa, m_conn);
151
152
144 // WORKAROUND: This is a work around for sqlite on 153 // WORKAROUND: This is a work around for sqlite on
145 // windows, which gets really unhappy with blob columns 154 // windows, which gets really unhappy with blob columns
146 // that have no sample data in them. At some point we 155 // that have no sample data in them. At some point we
@@ -180,6 +189,16 @@ namespace OpenSim.Data.SQLite
180 { 189 {
181 m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); 190 m_log.Info("[REGION DB]: Caught fill error on landaccesslist table");
182 } 191 }
192
193 try
194 {
195 regionBanListDa.Fill(ds.Tables["regionban"]);
196 }
197 catch (Exception)
198 {
199 m_log.Info("[REGION DB]: Caught fill error on regionban table");
200 }
201
183 return; 202 return;
184 } 203 }
185 } 204 }
@@ -790,6 +809,17 @@ namespace OpenSim.Data.SQLite
790 return landaccess; 809 return landaccess;
791 } 810 }
792 811
812 private static DataTable createRegionBanListTable()
813 {
814 DataTable regionbanlist = new DataTable("regionban");
815 createCol(regionbanlist, "regionUUID", typeof(String));
816 createCol(regionbanlist, "bannedUUID", typeof(String));
817 createCol(regionbanlist, "bannedIp", typeof(String));
818 createCol(regionbanlist, "bannedIpHostMask", typeof(String));
819
820 return regionbanlist;
821 }
822
793 /*********************************************************************** 823 /***********************************************************************
794 * 824 *
795 * Convert between ADO.NET <=> OpenSim Objects 825 * Convert between ADO.NET <=> OpenSim Objects
@@ -1036,21 +1066,60 @@ namespace OpenSim.Data.SQLite
1036 return entry; 1066 return entry;
1037 } 1067 }
1038 1068
1039 1069
1070
1040 public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID) 1071 public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID)
1041 { 1072 {
1042 List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>(); 1073 List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>();
1074 lock (ds)
1075 {
1076 DataTable regionban = ds.Tables["regionban"];
1077 string searchExp = "regionUUID = '" + regionUUID.ToString() + "'";
1078 DataRow[] rawbanlist = regionban.Select(searchExp);
1079 foreach (DataRow rawbanrow in rawbanlist)
1080 {
1081 RegionBanListItem rbli = new RegionBanListItem();
1082 LLUUID tmpvalue = LLUUID.Zero;
1083
1084 rbli.regionUUID = regionUUID;
1085
1086 if (Helpers.TryParse((string)rawbanrow["bannedUUID"], out tmpvalue))
1087 rbli.bannedUUID = tmpvalue;
1088
1089 rbli.bannedIP = (string)rawbanrow["bannedIp"];
1090 rbli.bannedIPHostMask = (string)rawbanrow["bannedIpHostMask"];
1091 regionbanlist.Add(rbli);
1092 }
1093 }
1043 return regionbanlist; 1094 return regionbanlist;
1044 } 1095 }
1045 1096
1046 public void AddToRegionBanlist(RegionBanListItem item) 1097 public void AddToRegionBanlist(RegionBanListItem item)
1047 { 1098 {
1048 1099 lock (ds)
1100 {
1101 using (SqliteCommand cmd = new SqliteCommand("insert into regionban (regionUUID, bannedUUID, bannedIp, bannedIpHostMask) values (:regionUUID,:bannedUUID,:bannedIp,:bannedIpHostMask)", m_conn))
1102 {
1103 cmd.Parameters.Add(new SqliteParameter(":regionUUID", item.regionUUID.ToString()));
1104 cmd.Parameters.Add(new SqliteParameter(":bannedUUID", item.bannedUUID.ToString()));
1105 cmd.Parameters.Add(new SqliteParameter(":bannedIp", item.bannedIP));
1106 cmd.Parameters.Add(new SqliteParameter(":bannedIpHostMask", item.bannedIPHostMask));
1107 cmd.ExecuteNonQuery();
1108 }
1109 }
1049 } 1110 }
1050 1111
1051 public void RemoveFromRegionBanlist(RegionBanListItem item) 1112 public void RemoveFromRegionBanlist(RegionBanListItem item)
1052 { 1113 {
1053 1114 lock (ds)
1115 {
1116 using (SqliteCommand cmd = new SqliteCommand("delete from regionban where regionUUID=:regionUUID AND bannedUUID=:bannedUUID", m_conn))
1117 {
1118 cmd.Parameters.Add(new SqliteParameter(":regionUUID", item.regionUUID.ToString()));
1119 cmd.Parameters.Add(new SqliteParameter(":bannedUUID", item.bannedUUID.ToString()));
1120 cmd.ExecuteNonQuery();
1121 }
1122 }
1054 } 1123 }
1055 1124
1056 private static Array serializeTerrain(double[,] val) 1125 private static Array serializeTerrain(double[,] val)
@@ -1536,6 +1605,16 @@ namespace OpenSim.Data.SQLite
1536 da.InsertCommand.Connection = conn; 1605 da.InsertCommand.Connection = conn;
1537 } 1606 }
1538 1607
1608 private void setupRegionBanCommands(SqliteDataAdapter da, SqliteConnection conn)
1609 {
1610 da.InsertCommand = createInsertCommand("regionban", ds.Tables["regionban"]);
1611 da.InsertCommand.Connection = conn;
1612
1613 da.UpdateCommand = createUpdateCommand("regionban", "regionUUID=:regionUUID AND bannedUUID=:bannedUUID", ds.Tables["regionban"]);
1614 da.UpdateCommand.Connection = conn;
1615 }
1616
1617
1539 private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) 1618 private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn)
1540 { 1619 {
1541 da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); 1620 da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]);
diff --git a/OpenSim/Framework/RegionBanListItem.cs b/OpenSim/Framework/RegionBanListItem.cs
index 60383fb..edf6a22 100644
--- a/OpenSim/Framework/RegionBanListItem.cs
+++ b/OpenSim/Framework/RegionBanListItem.cs
@@ -1,3 +1,30 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
1using libsecondlife; 28using libsecondlife;
2using System; 29using System;
3using System.Collections.Generic; 30using System.Collections.Generic;