diff options
Diffstat (limited to '')
5 files changed, 105 insertions, 38 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index defaa9c..582df22 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | |||
@@ -1125,7 +1125,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
1125 | return null; | 1125 | return null; |
1126 | 1126 | ||
1127 | doc = new XmlDocument(); | 1127 | doc = new XmlDocument(); |
1128 | doc.XmlResolver = null; | ||
1129 | 1128 | ||
1130 | // Let's serialize all calls to Vivox. Most of these are driven by | 1129 | // Let's serialize all calls to Vivox. Most of these are driven by |
1131 | // the clients (CAPs), when the user arrives at the region. We don't | 1130 | // the clients (CAPs), when the user arrives at the region. We don't |
@@ -1147,10 +1146,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | |||
1147 | using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) | 1146 | using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) |
1148 | using (Stream s = rsp.GetResponseStream()) | 1147 | using (Stream s = rsp.GetResponseStream()) |
1149 | using (XmlTextReader rdr = new XmlTextReader(s)) | 1148 | using (XmlTextReader rdr = new XmlTextReader(s)) |
1150 | { | ||
1151 | rdr.ProhibitDtd = true; | ||
1152 | doc.Load(rdr); | 1149 | doc.Load(rdr); |
1153 | } | ||
1154 | } | 1150 | } |
1155 | catch (Exception e) | 1151 | catch (Exception e) |
1156 | { | 1152 | { |
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs index 50276ae..817170f 100644 --- a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs | |||
@@ -45,6 +45,7 @@ namespace OpenSim.Region.DataSnapshot | |||
45 | // private Scene m_scene = null; | 45 | // private Scene m_scene = null; |
46 | private DataSnapshotManager m_externalData = null; | 46 | private DataSnapshotManager m_externalData = null; |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | private ExpiringCache<string, int> throotleGen = new ExpiringCache<string, int>(); | ||
48 | 49 | ||
49 | public DataRequestHandler(Scene scene, DataSnapshotManager externalData) | 50 | public DataRequestHandler(Scene scene, DataSnapshotManager externalData) |
50 | { | 51 | { |
@@ -52,29 +53,91 @@ namespace OpenSim.Region.DataSnapshot | |||
52 | m_externalData = externalData; | 53 | m_externalData = externalData; |
53 | 54 | ||
54 | //Register HTTP handler | 55 | //Register HTTP handler |
55 | if (MainServer.Instance.AddHTTPHandler("collector", OnGetSnapshot)) | 56 | if (MainServer.UnSecureInstance.AddHTTPHandler("collector", OnGetSnapshot)) |
56 | { | 57 | { |
57 | m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); | 58 | m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); |
58 | } | 59 | } |
59 | // Register validation callback handler | 60 | // Register validation callback handler |
60 | MainServer.Instance.AddHTTPHandler("validate", OnValidate); | 61 | MainServer.UnSecureInstance.AddHTTPHandler("validate", OnValidate); |
61 | 62 | ||
62 | } | 63 | } |
63 | 64 | ||
65 | private string GetClientString(Hashtable request) | ||
66 | { | ||
67 | string clientstring = ""; | ||
68 | if (!request.ContainsKey("headers")) | ||
69 | return clientstring; | ||
70 | |||
71 | Hashtable requestinfo = (Hashtable)request["headers"]; | ||
72 | if (requestinfo.ContainsKey("x-forwarded-for")) | ||
73 | { | ||
74 | object str = requestinfo["x-forwarded-for"]; | ||
75 | if (str != null) | ||
76 | { | ||
77 | if (!string.IsNullOrEmpty(str.ToString())) | ||
78 | { | ||
79 | return str.ToString(); | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | if (!requestinfo.ContainsKey("remote_addr")) | ||
84 | return clientstring; | ||
85 | |||
86 | object remote_addrobj = requestinfo["remote_addr"]; | ||
87 | if (remote_addrobj != null) | ||
88 | { | ||
89 | if (!string.IsNullOrEmpty(remote_addrobj.ToString())) | ||
90 | { | ||
91 | clientstring = remote_addrobj.ToString(); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | return clientstring; | ||
96 | } | ||
97 | |||
64 | public Hashtable OnGetSnapshot(Hashtable keysvals) | 98 | public Hashtable OnGetSnapshot(Hashtable keysvals) |
65 | { | 99 | { |
66 | m_log.Debug("[DATASNAPSHOT] Received collection request"); | ||
67 | Hashtable reply = new Hashtable(); | 100 | Hashtable reply = new Hashtable(); |
68 | int statuscode = 200; | 101 | string reqtag; |
69 | |||
70 | string snapObj = (string)keysvals["region"]; | 102 | string snapObj = (string)keysvals["region"]; |
103 | if(string.IsNullOrWhiteSpace(snapObj)) | ||
104 | reqtag = GetClientString(keysvals); | ||
105 | else | ||
106 | reqtag = snapObj + GetClientString(keysvals); | ||
107 | |||
108 | |||
109 | if(!string.IsNullOrWhiteSpace(reqtag)) | ||
110 | { | ||
111 | if(throotleGen.Contains(reqtag)) | ||
112 | { | ||
113 | reply["str_response_string"] = "Please try your request again later"; | ||
114 | reply["int_response_code"] = 503; | ||
115 | reply["content_type"] = "text/plain"; | ||
116 | m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later"); | ||
117 | return reply; | ||
118 | } | ||
119 | |||
120 | throotleGen.AddOrUpdate(reqtag, 0, 60); | ||
121 | } | ||
122 | |||
123 | if(string.IsNullOrWhiteSpace(snapObj)) | ||
124 | m_log.DebugFormat("[DATASNAPSHOT] Received collection request for all"); | ||
125 | else | ||
126 | m_log.DebugFormat("[DATASNAPSHOT] Received collection request for {0}", snapObj); | ||
71 | 127 | ||
72 | XmlDocument response = m_externalData.GetSnapshot(snapObj); | 128 | XmlDocument response = m_externalData.GetSnapshot(snapObj); |
129 | if(response == null) | ||
130 | { | ||
131 | reply["str_response_string"] = "Please try your request again later"; | ||
132 | reply["int_response_code"] = 503; | ||
133 | reply["content_type"] = "text/plain"; | ||
134 | m_log.Debug("[DATASNAPSHOT] Collection request spam. reply try later"); | ||
135 | return reply; | ||
136 | } | ||
73 | 137 | ||
74 | reply["str_response_string"] = response.OuterXml; | 138 | reply["str_response_string"] = response.OuterXml; |
75 | reply["int_response_code"] = statuscode; | 139 | reply["int_response_code"] = 200; |
76 | reply["content_type"] = "text/xml"; | 140 | reply["content_type"] = "text/xml"; |
77 | |||
78 | return reply; | 141 | return reply; |
79 | } | 142 | } |
80 | 143 | ||
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs index 0436f96..fd841d4 100644 --- a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs | |||
@@ -32,6 +32,7 @@ using System.IO; | |||
32 | using System.Linq; | 32 | using System.Linq; |
33 | using System.Net; | 33 | using System.Net; |
34 | using System.Reflection; | 34 | using System.Reflection; |
35 | using System.Threading; | ||
35 | using System.Text; | 36 | using System.Text; |
36 | using System.Xml; | 37 | using System.Xml; |
37 | using log4net; | 38 | using log4net; |
@@ -64,6 +65,7 @@ namespace OpenSim.Region.DataSnapshot | |||
64 | //Various internal objects | 65 | //Various internal objects |
65 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 66 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
66 | internal object m_syncInit = new object(); | 67 | internal object m_syncInit = new object(); |
68 | private object m_serializeGen = new object(); | ||
67 | 69 | ||
68 | //DataServices and networking | 70 | //DataServices and networking |
69 | private string m_dataServices = "noservices"; | 71 | private string m_dataServices = "noservices"; |
@@ -148,11 +150,8 @@ namespace OpenSim.Region.DataSnapshot | |||
148 | m_enabled = false; | 150 | m_enabled = false; |
149 | return; | 151 | return; |
150 | } | 152 | } |
151 | |||
152 | } | 153 | } |
153 | |||
154 | } | 154 | } |
155 | |||
156 | } | 155 | } |
157 | 156 | ||
158 | public void AddRegion(Scene scene) | 157 | public void AddRegion(Scene scene) |
@@ -160,23 +159,14 @@ namespace OpenSim.Region.DataSnapshot | |||
160 | if (!m_enabled) | 159 | if (!m_enabled) |
161 | return; | 160 | return; |
162 | 161 | ||
163 | m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); | 162 | m_scenes.Add(scene); |
164 | 163 | ||
165 | if (!m_servicesNotified) | 164 | if (m_snapStore == null) |
166 | { | 165 | { |
167 | m_hostname = scene.RegionInfo.ExternalHostName; | 166 | m_hostname = scene.RegionInfo.ExternalHostName; |
168 | m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); | 167 | m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); |
169 | |||
170 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer | ||
171 | new DataRequestHandler(scene, this); | ||
172 | |||
173 | if (m_dataServices != "" && m_dataServices != "noservices") | ||
174 | NotifyDataServices(m_dataServices, "online"); | ||
175 | |||
176 | m_servicesNotified = true; | ||
177 | } | 168 | } |
178 | 169 | ||
179 | m_scenes.Add(scene); | ||
180 | m_snapStore.AddScene(scene); | 170 | m_snapStore.AddScene(scene); |
181 | 171 | ||
182 | Assembly currentasm = Assembly.GetExecutingAssembly(); | 172 | Assembly currentasm = Assembly.GetExecutingAssembly(); |
@@ -201,7 +191,7 @@ namespace OpenSim.Region.DataSnapshot | |||
201 | } | 191 | } |
202 | } | 192 | } |
203 | } | 193 | } |
204 | 194 | m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); | |
205 | } | 195 | } |
206 | 196 | ||
207 | public void RemoveRegion(Scene scene) | 197 | public void RemoveRegion(Scene scene) |
@@ -244,8 +234,16 @@ namespace OpenSim.Region.DataSnapshot | |||
244 | if (!m_enabled) | 234 | if (!m_enabled) |
245 | return; | 235 | return; |
246 | 236 | ||
247 | m_log.DebugFormat("[DATASNAPSHOT]: Marking scene {0} as stale.", scene.RegionInfo.RegionName); | 237 | if (!m_servicesNotified) |
248 | m_snapStore.ForceSceneStale(scene); | 238 | { |
239 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer | ||
240 | new DataRequestHandler(scene, this); | ||
241 | |||
242 | if (m_dataServices != "" && m_dataServices != "noservices") | ||
243 | NotifyDataServices(m_dataServices, "online"); | ||
244 | |||
245 | m_servicesNotified = true; | ||
246 | } | ||
249 | } | 247 | } |
250 | 248 | ||
251 | public void Close() | 249 | public void Close() |
@@ -257,7 +255,6 @@ namespace OpenSim.Region.DataSnapshot | |||
257 | NotifyDataServices(m_dataServices, "offline"); | 255 | NotifyDataServices(m_dataServices, "offline"); |
258 | } | 256 | } |
259 | 257 | ||
260 | |||
261 | public string Name | 258 | public string Name |
262 | { | 259 | { |
263 | get { return "External Data Generator"; } | 260 | get { return "External Data Generator"; } |
@@ -319,8 +316,14 @@ namespace OpenSim.Region.DataSnapshot | |||
319 | /** | 316 | /** |
320 | * Reply to the http request | 317 | * Reply to the http request |
321 | */ | 318 | */ |
319 | |||
322 | public XmlDocument GetSnapshot(string regionName) | 320 | public XmlDocument GetSnapshot(string regionName) |
323 | { | 321 | { |
322 | if(!Monitor.TryEnter(m_serializeGen,30000)) | ||
323 | { | ||
324 | return null; | ||
325 | } | ||
326 | |||
324 | CheckStale(); | 327 | CheckStale(); |
325 | 328 | ||
326 | XmlDocument requestedSnap = new XmlDocument(); | 329 | XmlDocument requestedSnap = new XmlDocument(); |
@@ -360,9 +363,13 @@ namespace OpenSim.Region.DataSnapshot | |||
360 | m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to load snapshot: " + e.StackTrace); | 363 | m_log.Warn("[DATASNAPSHOT]: Caught unknown exception while trying to load snapshot: " + e.StackTrace); |
361 | requestedSnap = GetErrorMessage(regionName, e); | 364 | requestedSnap = GetErrorMessage(regionName, e); |
362 | } | 365 | } |
363 | 366 | finally | |
367 | { | ||
368 | Monitor.Exit(m_serializeGen); | ||
369 | } | ||
364 | 370 | ||
365 | return requestedSnap; | 371 | return requestedSnap; |
372 | |||
366 | } | 373 | } |
367 | 374 | ||
368 | private XmlDocument GetErrorMessage(string regionName, Exception e) | 375 | private XmlDocument GetErrorMessage(string regionName, Exception e) |
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs b/OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs index 480aaaf..0ed421a 100644 --- a/OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/SnapshotStore.cs | |||
@@ -107,6 +107,7 @@ namespace OpenSim.Region.DataSnapshot | |||
107 | snapXWriter.WriteStartDocument(); | 107 | snapXWriter.WriteStartDocument(); |
108 | data.WriteTo(snapXWriter); | 108 | data.WriteTo(snapXWriter); |
109 | snapXWriter.WriteEndDocument(); | 109 | snapXWriter.WriteEndDocument(); |
110 | snapXWriter.Flush(); | ||
110 | } | 111 | } |
111 | } | 112 | } |
112 | catch (Exception e) | 113 | catch (Exception e) |
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index a14d819..64513a0 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs | |||
@@ -127,7 +127,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
127 | /// <summary> | 127 | /// <summary> |
128 | /// Identifies the module to the system. | 128 | /// Identifies the module to the system. |
129 | /// </summary> | 129 | /// </summary> |
130 | string IRegionModuleBase.Name | 130 | public string Name |
131 | { | 131 | { |
132 | get { return "AutoBackupModule"; } | 132 | get { return "AutoBackupModule"; } |
133 | } | 133 | } |
@@ -135,7 +135,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
135 | /// <summary> | 135 | /// <summary> |
136 | /// We don't implement an interface, this is a single-use module. | 136 | /// We don't implement an interface, this is a single-use module. |
137 | /// </summary> | 137 | /// </summary> |
138 | Type IRegionModuleBase.ReplaceableInterface | 138 | public Type ReplaceableInterface |
139 | { | 139 | { |
140 | get { return null; } | 140 | get { return null; } |
141 | } | 141 | } |
@@ -144,7 +144,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
144 | /// Called once in the lifetime of the module at startup. | 144 | /// Called once in the lifetime of the module at startup. |
145 | /// </summary> | 145 | /// </summary> |
146 | /// <param name="source">The input config source for OpenSim.ini.</param> | 146 | /// <param name="source">The input config source for OpenSim.ini.</param> |
147 | void IRegionModuleBase.Initialise(IConfigSource source) | 147 | public void Initialise(IConfigSource source) |
148 | { | 148 | { |
149 | // Determine if we have been enabled at all in OpenSim.ini -- this is part and parcel of being an optional module | 149 | // Determine if we have been enabled at all in OpenSim.ini -- this is part and parcel of being an optional module |
150 | m_configSource = source; | 150 | m_configSource = source; |
@@ -184,7 +184,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
184 | /// <summary> | 184 | /// <summary> |
185 | /// Called once at de-init (sim shutting down). | 185 | /// Called once at de-init (sim shutting down). |
186 | /// </summary> | 186 | /// </summary> |
187 | void IRegionModuleBase.Close() | 187 | public void Close() |
188 | { | 188 | { |
189 | if (!m_enabled) | 189 | if (!m_enabled) |
190 | return; | 190 | return; |
@@ -197,7 +197,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
197 | /// Currently a no-op for AutoBackup because we have to wait for region to be fully loaded. | 197 | /// Currently a no-op for AutoBackup because we have to wait for region to be fully loaded. |
198 | /// </summary> | 198 | /// </summary> |
199 | /// <param name="scene"></param> | 199 | /// <param name="scene"></param> |
200 | void IRegionModuleBase.AddRegion (Scene scene) | 200 | public void AddRegion (Scene scene) |
201 | { | 201 | { |
202 | if (!m_enabled) | 202 | if (!m_enabled) |
203 | return; | 203 | return; |
@@ -210,7 +210,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
210 | /// Here we just clean up some resources and stop the OAR backup (if any) for the given scene. | 210 | /// Here we just clean up some resources and stop the OAR backup (if any) for the given scene. |
211 | /// </summary> | 211 | /// </summary> |
212 | /// <param name="scene">The scene (region) to stop performing AutoBackup on.</param> | 212 | /// <param name="scene">The scene (region) to stop performing AutoBackup on.</param> |
213 | void IRegionModuleBase.RemoveRegion(Scene scene) | 213 | public void RemoveRegion(Scene scene) |
214 | { | 214 | { |
215 | if (m_enabled) | 215 | if (m_enabled) |
216 | return; | 216 | return; |
@@ -228,7 +228,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
228 | /// We read lots of Nini config, maybe set a timer, add members to state tracking Dictionaries, etc. | 228 | /// We read lots of Nini config, maybe set a timer, add members to state tracking Dictionaries, etc. |
229 | /// </summary> | 229 | /// </summary> |
230 | /// <param name="scene">The scene to (possibly) perform AutoBackup on.</param> | 230 | /// <param name="scene">The scene to (possibly) perform AutoBackup on.</param> |
231 | void IRegionModuleBase.RegionLoaded(Scene scene) | 231 | public void RegionLoaded(Scene scene) |
232 | { | 232 | { |
233 | if (!m_enabled) | 233 | if (!m_enabled) |
234 | return; | 234 | return; |
@@ -258,7 +258,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
258 | /// <summary> | 258 | /// <summary> |
259 | /// Currently a no-op. | 259 | /// Currently a no-op. |
260 | /// </summary> | 260 | /// </summary> |
261 | void ISharedRegionModule.PostInitialise() | 261 | public void PostInitialise() |
262 | { | 262 | { |
263 | } | 263 | } |
264 | 264 | ||