diff options
Diffstat (limited to '')
24 files changed, 737 insertions, 502 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs index 53ed115..0f3f48e 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | |||
@@ -30,6 +30,7 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Linq; | 31 | using System.Linq; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text; | ||
33 | using log4net; | 34 | using log4net; |
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -60,7 +61,6 @@ namespace OpenSim.Capabilities.Handlers | |||
60 | m_Scene = s; | 61 | m_Scene = s; |
61 | } | 62 | } |
62 | 63 | ||
63 | |||
64 | public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 64 | public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
65 | { | 65 | { |
66 | //m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request); | 66 | //m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request); |
@@ -93,8 +93,8 @@ namespace OpenSim.Capabilities.Handlers | |||
93 | 93 | ||
94 | ArrayList foldersrequested = (ArrayList)hash["folders"]; | 94 | ArrayList foldersrequested = (ArrayList)hash["folders"]; |
95 | 95 | ||
96 | string response = ""; | 96 | StringBuilder tmpresponse = new StringBuilder(1024); |
97 | string bad_folders_response = ""; | 97 | StringBuilder tmpbadfolders = new StringBuilder(1024); |
98 | 98 | ||
99 | List<LLSDFetchInventoryDescendents> folders = new List<LLSDFetchInventoryDescendents>(); | 99 | List<LLSDFetchInventoryDescendents> folders = new List<LLSDFetchInventoryDescendents>(); |
100 | for (int i = 0; i < foldersrequested.Count; i++) | 100 | for (int i = 0; i < foldersrequested.Count; i++) |
@@ -113,10 +113,7 @@ namespace OpenSim.Capabilities.Handlers | |||
113 | continue; | 113 | continue; |
114 | } | 114 | } |
115 | 115 | ||
116 | // Filter duplicate folder ids that bad viewers may send | 116 | folders.Add(llsdRequest); |
117 | if (folders.Find(f => f.folder_id == llsdRequest.folder_id) == null) | ||
118 | folders.Add(llsdRequest); | ||
119 | |||
120 | } | 117 | } |
121 | 118 | ||
122 | if (folders.Count > 0) | 119 | if (folders.Count > 0) |
@@ -136,49 +133,44 @@ namespace OpenSim.Capabilities.Handlers | |||
136 | string inventoryitemstr = string.Empty; | 133 | string inventoryitemstr = string.Empty; |
137 | foreach (InventoryCollectionWithDescendents icoll in invcollSet) | 134 | foreach (InventoryCollectionWithDescendents icoll in invcollSet) |
138 | { | 135 | { |
139 | LLSDInventoryDescendents reply = ToLLSD(icoll.Collection, icoll.Descendents); | 136 | LLSDInventoryFolderContents thiscontents = contentsToLLSD(icoll.Collection, icoll.Descendents); |
140 | 137 | inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(thiscontents); | |
141 | inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); | 138 | // inventoryitemstr = inventoryitemstr.Replace("<llsd>", ""); |
142 | inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", ""); | 139 | // inventoryitemstr = inventoryitemstr.Replace("</llsd>", ""); |
143 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); | 140 | // inventoryitemstr = inventoryitemstr.Substring(6,inventoryitemstr.Length - 13); |
144 | 141 | // tmpresponse.Append(inventoryitemstr); | |
145 | response += inventoryitemstr; | 142 | tmpresponse.Append(inventoryitemstr.Substring(6,inventoryitemstr.Length - 13)); |
146 | } | 143 | } |
147 | 144 | ||
148 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders)); | 145 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders)); |
149 | foreach (UUID bad in bad_folders) | 146 | foreach (UUID bad in bad_folders) |
150 | bad_folders_response += "<uuid>" + bad + "</uuid>"; | 147 | { |
148 | tmpbadfolders.Append("<map><key>folder_id</key><uuid>"); | ||
149 | tmpbadfolders.Append(bad.ToString()); | ||
150 | tmpbadfolders.Append("</uuid><key>error</key><string>Unknown</string></map>"); | ||
151 | } | ||
151 | } | 152 | } |
152 | 153 | ||
153 | if (response.Length == 0) | 154 | StringBuilder lastresponse = new StringBuilder(1024); |
155 | lastresponse.Append("<llsd>"); | ||
156 | if(tmpresponse.Length > 0) | ||
154 | { | 157 | { |
155 | /* Viewers expect a bad_folders array when not available */ | 158 | lastresponse.Append("<map><key>folders</key><array>"); |
156 | if (bad_folders_response.Length != 0) | 159 | lastresponse.Append(tmpresponse.ToString()); |
157 | { | 160 | lastresponse.Append("</array></map>"); |
158 | response = "<llsd><map><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | response = "<llsd><map><key>folders</key><array /></map></llsd>"; | ||
163 | } | ||
164 | } | 161 | } |
165 | else | 162 | else |
163 | lastresponse.Append("<map><key>folders</key><array /></map>"); | ||
164 | |||
165 | if(tmpbadfolders.Length > 0) | ||
166 | { | 166 | { |
167 | if (bad_folders_response.Length != 0) | 167 | lastresponse.Append("<map><key>bad_folders</key><array>"); |
168 | { | 168 | lastresponse.Append(tmpbadfolders.ToString()); |
169 | response = "<llsd><map><key>folders</key><array>" + response + "</array><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; | 169 | lastresponse.Append("</array></map>"); |
170 | } | ||
171 | else | ||
172 | { | ||
173 | response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; | ||
174 | } | ||
175 | } | 170 | } |
171 | lastresponse.Append("</llsd>"); | ||
176 | 172 | ||
177 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request for {0} folders. Item count {1}", folders.Count, item_count); | 173 | return lastresponse.ToString(); |
178 | //m_log.Debug("[WEB FETCH INV DESC HANDLER] " + response); | ||
179 | |||
180 | return response; | ||
181 | |||
182 | } | 174 | } |
183 | 175 | ||
184 | /// <summary> | 176 | /// <summary> |
@@ -240,24 +232,19 @@ namespace OpenSim.Capabilities.Handlers | |||
240 | return reply; | 232 | return reply; |
241 | } | 233 | } |
242 | 234 | ||
243 | private LLSDInventoryDescendents ToLLSD(InventoryCollection inv, int descendents) | 235 | private LLSDInventoryFolderContents contentsToLLSD(InventoryCollection inv, int descendents) |
244 | { | 236 | { |
245 | LLSDInventoryDescendents reply = new LLSDInventoryDescendents(); | ||
246 | LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); | 237 | LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents(); |
247 | contents.agent_id = inv.OwnerID; | 238 | contents.agent_id = inv.OwnerID; |
248 | contents.owner_id = inv.OwnerID; | 239 | contents.owner_id = inv.OwnerID; |
249 | contents.folder_id = inv.FolderID; | 240 | contents.folder_id = inv.FolderID; |
250 | 241 | ||
251 | reply.folders.Array.Add(contents); | ||
252 | |||
253 | if (inv.Folders != null) | 242 | if (inv.Folders != null) |
254 | { | 243 | { |
255 | foreach (InventoryFolderBase invFolder in inv.Folders) | 244 | foreach (InventoryFolderBase invFolder in inv.Folders) |
256 | { | 245 | { |
257 | contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); | 246 | contents.categories.Array.Add(ConvertInventoryFolder(invFolder)); |
258 | } | 247 | } |
259 | |||
260 | descendents += inv.Folders.Count; | ||
261 | } | 248 | } |
262 | 249 | ||
263 | if (inv.Items != null) | 250 | if (inv.Items != null) |
@@ -271,7 +258,7 @@ namespace OpenSim.Capabilities.Handlers | |||
271 | contents.descendents = descendents; | 258 | contents.descendents = descendents; |
272 | contents.version = inv.Version; | 259 | contents.version = inv.Version; |
273 | 260 | ||
274 | return reply; | 261 | return contents; |
275 | } | 262 | } |
276 | /// <summary> | 263 | /// <summary> |
277 | /// Old style. Soon to be deprecated. | 264 | /// Old style. Soon to be deprecated. |
@@ -285,8 +272,8 @@ namespace OpenSim.Capabilities.Handlers | |||
285 | { | 272 | { |
286 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request for {0} folders", foldersrequested.Count); | 273 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request for {0} folders", foldersrequested.Count); |
287 | 274 | ||
288 | string response = ""; | 275 | StringBuilder tmpresponse = new StringBuilder(1024); |
289 | string bad_folders_response = ""; | 276 | StringBuilder tmpbadfolders = new StringBuilder(1024); |
290 | 277 | ||
291 | for (int i = 0; i < foldersrequested.Count; i++) | 278 | for (int i = 0; i < foldersrequested.Count; i++) |
292 | { | 279 | { |
@@ -308,7 +295,9 @@ namespace OpenSim.Capabilities.Handlers | |||
308 | 295 | ||
309 | if (null == reply) | 296 | if (null == reply) |
310 | { | 297 | { |
311 | bad_folders_response += "<uuid>" + llsdRequest.folder_id.ToString() + "</uuid>"; | 298 | tmpbadfolders.Append("<map><key>folder_id</key><uuid>"); |
299 | tmpbadfolders.Append(llsdRequest.folder_id.ToString()); | ||
300 | tmpbadfolders.Append("</uuid><key>error</key><string>Unknown</string></map>"); | ||
312 | } | 301 | } |
313 | else | 302 | else |
314 | { | 303 | { |
@@ -317,39 +306,29 @@ namespace OpenSim.Capabilities.Handlers | |||
317 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); | 306 | inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", ""); |
318 | } | 307 | } |
319 | 308 | ||
320 | response += inventoryitemstr; | 309 | tmpresponse.Append(inventoryitemstr); |
321 | } | 310 | } |
322 | 311 | ||
323 | if (response.Length == 0) | 312 | StringBuilder lastresponse = new StringBuilder(1024); |
313 | lastresponse.Append("<llsd>"); | ||
314 | if(tmpresponse.Length > 0) | ||
324 | { | 315 | { |
325 | /* Viewers expect a bad_folders array when not available */ | 316 | lastresponse.Append("<map><key>folders</key><array>"); |
326 | if (bad_folders_response.Length != 0) | 317 | lastresponse.Append(tmpresponse.ToString()); |
327 | { | 318 | lastresponse.Append("</array></map>"); |
328 | response = "<llsd><map><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; | ||
329 | } | ||
330 | else | ||
331 | { | ||
332 | response = "<llsd><map><key>folders</key><array /></map></llsd>"; | ||
333 | } | ||
334 | } | 319 | } |
335 | else | 320 | else |
321 | lastresponse.Append("<map><key>folders</key><array /></map>"); | ||
322 | |||
323 | if(tmpbadfolders.Length > 0) | ||
336 | { | 324 | { |
337 | if (bad_folders_response.Length != 0) | 325 | lastresponse.Append("<map><key>bad_folders</key><array>"); |
338 | { | 326 | lastresponse.Append(tmpbadfolders.ToString()); |
339 | response = "<llsd><map><key>folders</key><array>" + response + "</array><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>"; | 327 | lastresponse.Append("</array></map>"); |
340 | } | ||
341 | else | ||
342 | { | ||
343 | response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; | ||
344 | } | ||
345 | } | 328 | } |
329 | lastresponse.Append("</llsd>"); | ||
346 | 330 | ||
347 | // m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request"); | 331 | return lastresponse.ToString(); |
348 | //m_log.Debug("[WEB FETCH INV DESC HANDLER] "+response); | ||
349 | |||
350 | return response; | ||
351 | |||
352 | // } | ||
353 | } | 332 | } |
354 | 333 | ||
355 | /// <summary> | 334 | /// <summary> |
@@ -436,108 +415,7 @@ namespace OpenSim.Capabilities.Handlers | |||
436 | itemsToReturn.Insert(0, linkedItem); | 415 | itemsToReturn.Insert(0, linkedItem); |
437 | } | 416 | } |
438 | } | 417 | } |
439 | |||
440 | // Now scan for folder links and insert the items they target and those links at the head of the return data | ||
441 | |||
442 | /* dont send contents of LinkFolders. | ||
443 | from docs seems this was never a spec | ||
444 | |||
445 | foreach (InventoryItemBase item in originalItems) | ||
446 | { | ||
447 | if (item.AssetType == (int)AssetType.LinkFolder) | ||
448 | { | ||
449 | InventoryCollection linkedFolderContents = m_InventoryService.GetFolderContent(ownerID, item.AssetID); | ||
450 | List<InventoryItemBase> links = linkedFolderContents.Items; | ||
451 | |||
452 | itemsToReturn.InsertRange(0, links); | ||
453 | |||
454 | foreach (InventoryItemBase link in linkedFolderContents.Items) | ||
455 | { | ||
456 | // Take care of genuinely broken links where the target doesn't exist | ||
457 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | ||
458 | // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles | ||
459 | // rather than having to keep track of every folder requested in the recursion. | ||
460 | if (link != null) | ||
461 | { | ||
462 | // m_log.DebugFormat( | ||
463 | // "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3}", | ||
464 | // link.Name, (AssetType)link.AssetType, item.AssetID, containingFolder.Name); | ||
465 | |||
466 | InventoryItemBase linkedItem | ||
467 | = m_InventoryService.GetItem(new InventoryItemBase(link.AssetID)); | ||
468 | |||
469 | if (linkedItem != null) | ||
470 | itemsToReturn.Insert(0, linkedItem); | ||
471 | } | ||
472 | } | ||
473 | } | ||
474 | } | ||
475 | */ | ||
476 | } | 418 | } |
477 | |||
478 | // foreach (InventoryItemBase item in contents.Items) | ||
479 | // { | ||
480 | // m_log.DebugFormat( | ||
481 | // "[WEB FETCH INV DESC HANDLER]: Returning item {0}, type {1}, parent {2} in {3} {4}", | ||
482 | // item.Name, (AssetType)item.AssetType, item.Folder, containingFolder.Name, containingFolder.ID); | ||
483 | // } | ||
484 | |||
485 | // ===== | ||
486 | |||
487 | // | ||
488 | // foreach (InventoryItemBase linkedItem in linkedItemsToAdd) | ||
489 | // { | ||
490 | // m_log.DebugFormat( | ||
491 | // "[WEB FETCH INV DESC HANDLER]: Inserted linked item {0} for link in folder {1} for agent {2}", | ||
492 | // linkedItem.Name, folderID, agentID); | ||
493 | // | ||
494 | // contents.Items.Add(linkedItem); | ||
495 | // } | ||
496 | // | ||
497 | // // If the folder requested contains links, then we need to send those folders first, otherwise the links | ||
498 | // // will be broken in the viewer. | ||
499 | // HashSet<UUID> linkedItemFolderIdsToSend = new HashSet<UUID>(); | ||
500 | // foreach (InventoryItemBase item in contents.Items) | ||
501 | // { | ||
502 | // if (item.AssetType == (int)AssetType.Link) | ||
503 | // { | ||
504 | // InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); | ||
505 | // | ||
506 | // // Take care of genuinely broken links where the target doesn't exist | ||
507 | // // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | ||
508 | // // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles | ||
509 | // // rather than having to keep track of every folder requested in the recursion. | ||
510 | // if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) | ||
511 | // { | ||
512 | // // We don't need to send the folder if source and destination of the link are in the same | ||
513 | // // folder. | ||
514 | // if (linkedItem.Folder != containingFolder.ID) | ||
515 | // linkedItemFolderIdsToSend.Add(linkedItem.Folder); | ||
516 | // } | ||
517 | // } | ||
518 | // } | ||
519 | // | ||
520 | // foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend) | ||
521 | // { | ||
522 | // m_log.DebugFormat( | ||
523 | // "[WEB FETCH INV DESC HANDLER]: Recursively fetching folder {0} linked by item in folder {1} for agent {2}", | ||
524 | // linkedItemFolderId, folderID, agentID); | ||
525 | // | ||
526 | // int dummyVersion; | ||
527 | // InventoryCollection linkedCollection | ||
528 | // = Fetch( | ||
529 | // agentID, linkedItemFolderId, ownerID, fetchFolders, fetchItems, sortOrder, out dummyVersion); | ||
530 | // | ||
531 | // InventoryFolderBase linkedFolder = new InventoryFolderBase(linkedItemFolderId); | ||
532 | // linkedFolder.Owner = agentID; | ||
533 | // linkedFolder = m_InventoryService.GetFolder(linkedFolder); | ||
534 | // | ||
535 | //// contents.Folders.AddRange(linkedCollection.Folders); | ||
536 | // | ||
537 | // contents.Folders.Add(linkedFolder); | ||
538 | // contents.Items.AddRange(linkedCollection.Items); | ||
539 | // } | ||
540 | // } | ||
541 | } | 419 | } |
542 | } | 420 | } |
543 | else | 421 | else |
@@ -550,33 +428,26 @@ from docs seems this was never a spec | |||
550 | 428 | ||
551 | } | 429 | } |
552 | 430 | ||
553 | private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> fetchFolders, List<InventoryCollectionWithDescendents> result) | 431 | private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> libFolders, List<InventoryCollectionWithDescendents> result) |
554 | { | 432 | { |
555 | InventoryFolderImpl fold; | 433 | InventoryFolderImpl fold; |
556 | if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null) | 434 | foreach (LLSDFetchInventoryDescendents f in libFolders) |
557 | { | 435 | { |
558 | List<LLSDFetchInventoryDescendents> libfolders = fetchFolders.FindAll(f => f.owner_id == m_LibraryService.LibraryRootFolder.Owner); | 436 | if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null) |
559 | fetchFolders.RemoveAll(f => libfolders.Contains(f)); | ||
560 | |||
561 | //m_log.DebugFormat("[XXX]: Found {0} library folders in request", libfolders.Count); | ||
562 | |||
563 | foreach (LLSDFetchInventoryDescendents f in libfolders) | ||
564 | { | 437 | { |
565 | if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null) | 438 | InventoryCollectionWithDescendents ret = new InventoryCollectionWithDescendents(); |
566 | { | 439 | ret.Collection = new InventoryCollection(); |
567 | InventoryCollectionWithDescendents ret = new InventoryCollectionWithDescendents(); | 440 | // ret.Collection.Folders = new List<InventoryFolderBase>(); |
568 | ret.Collection = new InventoryCollection(); | 441 | ret.Collection.Folders = fold.RequestListOfFolders(); |
569 | ret.Collection.Folders = new List<InventoryFolderBase>(); | 442 | ret.Collection.Items = fold.RequestListOfItems(); |
570 | ret.Collection.Items = fold.RequestListOfItems(); | 443 | ret.Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner; |
571 | ret.Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner; | 444 | ret.Collection.FolderID = f.folder_id; |
572 | ret.Collection.FolderID = f.folder_id; | 445 | ret.Collection.Version = fold.Version; |
573 | ret.Collection.Version = fold.Version; | 446 | |
574 | 447 | ret.Descendents = ret.Collection.Items.Count + ret.Collection.Folders.Count; | |
575 | ret.Descendents = ret.Collection.Items.Count; | 448 | result.Add(ret); |
576 | result.Add(ret); | 449 | |
577 | 450 | //m_log.DebugFormat("[XXX]: Added libfolder {0} ({1}) {2}", ret.Collection.FolderID, ret.Collection.OwnerID); | |
578 | //m_log.DebugFormat("[XXX]: Added libfolder {0} ({1}) {2}", ret.Collection.FolderID, ret.Collection.OwnerID); | ||
579 | } | ||
580 | } | 451 | } |
581 | } | 452 | } |
582 | } | 453 | } |
@@ -589,57 +460,97 @@ from docs seems this was never a spec | |||
589 | // FIXME MAYBE: We're not handling sortOrder! | 460 | // FIXME MAYBE: We're not handling sortOrder! |
590 | 461 | ||
591 | List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>(); | 462 | List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>(); |
463 | if(fetchFolders.Count <= 0) | ||
464 | return result; | ||
465 | |||
466 | List<LLSDFetchInventoryDescendents> libFolders = new List<LLSDFetchInventoryDescendents>(); | ||
467 | List<LLSDFetchInventoryDescendents> otherFolders = new List<LLSDFetchInventoryDescendents>(); | ||
468 | HashSet<UUID> libIDs = new HashSet<UUID>(); | ||
469 | HashSet<UUID> otherIDs = new HashSet<UUID>(); | ||
592 | 470 | ||
593 | AddLibraryFolders(fetchFolders, result); | 471 | bool dolib = (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null); |
472 | UUID libOwner = UUID.Zero; | ||
473 | if(dolib) | ||
474 | libOwner = m_LibraryService.LibraryRootFolder.Owner; | ||
594 | 475 | ||
595 | // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense | 476 | // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense |
596 | // and can kill the sim (all root folders have parent_id Zero) | 477 | // and can kill the sim (all root folders have parent_id Zero) |
597 | LLSDFetchInventoryDescendents zero = fetchFolders.Find(f => f.folder_id == UUID.Zero); | 478 | // send something. |
598 | if (zero != null) | 479 | foreach(LLSDFetchInventoryDescendents f in fetchFolders) |
599 | { | 480 | { |
600 | fetchFolders.Remove(zero); | 481 | if (f.folder_id == UUID.Zero) |
601 | BadFolder(zero, null, bad_folders); | 482 | { |
483 | InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents(); | ||
484 | zeroColl.Collection = new InventoryCollection(); | ||
485 | zeroColl.Collection.OwnerID = f.owner_id; | ||
486 | zeroColl.Collection.Version = 0; | ||
487 | zeroColl.Collection.FolderID = f.folder_id; | ||
488 | zeroColl.Descendents = 0; | ||
489 | result.Add(zeroColl); | ||
490 | continue; | ||
491 | } | ||
492 | if(dolib && f.owner_id == libOwner) | ||
493 | { | ||
494 | if(libIDs.Contains(f.folder_id)) | ||
495 | continue; | ||
496 | libIDs.Add(f.folder_id); | ||
497 | libFolders.Add(f); | ||
498 | continue; | ||
499 | } | ||
500 | if(otherIDs.Contains(f.folder_id)) | ||
501 | continue; | ||
502 | otherIDs.Add(f.folder_id); | ||
503 | otherFolders.Add(f); | ||
602 | } | 504 | } |
603 | 505 | ||
604 | if (fetchFolders.Count > 0) | 506 | |
605 | { | 507 | if(otherFolders.Count > 0) |
606 | UUID[] fids = new UUID[fetchFolders.Count]; | 508 | { |
509 | UUID[] fids = new UUID[otherFolders.Count]; | ||
607 | int i = 0; | 510 | int i = 0; |
608 | foreach (LLSDFetchInventoryDescendents f in fetchFolders) | 511 | foreach (LLSDFetchInventoryDescendents f in otherFolders) |
609 | fids[i++] = f.folder_id; | 512 | fids[i++] = f.folder_id; |
610 | 513 | ||
611 | //m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids)); | 514 | //m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids)); |
612 | 515 | ||
613 | InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(fetchFolders[0].owner_id, fids); | 516 | InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(otherFolders[0].owner_id, fids); |
614 | 517 | ||
615 | if (fetchedContents == null || (fetchedContents != null && fetchedContents.Length == 0)) | 518 | if (fetchedContents == null) |
519 | return null; | ||
520 | |||
521 | if (fetchedContents.Length == 0) | ||
616 | { | 522 | { |
617 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Could not get contents of multiple folders for user {0}", fetchFolders[0].owner_id); | 523 | foreach (LLSDFetchInventoryDescendents freq in otherFolders) |
618 | foreach (LLSDFetchInventoryDescendents freq in fetchFolders) | ||
619 | BadFolder(freq, null, bad_folders); | 524 | BadFolder(freq, null, bad_folders); |
620 | return null; | ||
621 | } | 525 | } |
622 | 526 | else | |
623 | i = 0; | ||
624 | // Do some post-processing. May need to fetch more from inv server for links | ||
625 | foreach (InventoryCollection contents in fetchedContents) | ||
626 | { | 527 | { |
627 | // Find the original request | 528 | i = 0; |
628 | LLSDFetchInventoryDescendents freq = fetchFolders[i++]; | 529 | // Do some post-processing. May need to fetch more from inv server for links |
530 | foreach (InventoryCollection contents in fetchedContents) | ||
531 | { | ||
532 | // Find the original request | ||
533 | LLSDFetchInventoryDescendents freq = otherFolders[i++]; | ||
629 | 534 | ||
630 | InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents(); | 535 | InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents(); |
631 | coll.Collection = contents; | 536 | coll.Collection = contents; |
632 | 537 | ||
633 | if (BadFolder(freq, contents, bad_folders)) | 538 | if (BadFolder(freq, contents, bad_folders)) |
634 | continue; | 539 | continue; |
635 | 540 | ||
636 | // Next: link management | 541 | // Next: link management |
637 | ProcessLinks(freq, coll); | 542 | ProcessLinks(freq, coll); |
638 | 543 | ||
639 | result.Add(coll); | 544 | result.Add(coll); |
545 | } | ||
640 | } | 546 | } |
641 | } | 547 | } |
642 | 548 | ||
549 | if(dolib && libFolders.Count > 0) | ||
550 | { | ||
551 | AddLibraryFolders(libFolders, result); | ||
552 | } | ||
553 | |||
643 | return result; | 554 | return result; |
644 | } | 555 | } |
645 | 556 | ||
@@ -666,35 +577,8 @@ from docs seems this was never a spec | |||
666 | } | 577 | } |
667 | else | 578 | else |
668 | { | 579 | { |
669 | // Was it really a request for folder Zero? | 580 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id); |
670 | // This is an overkill, but Firestorm really asks for folder Zero. | 581 | bad_folders.Add(freq.folder_id); |
671 | // I'm leaving the code here for the time being, but commented. | ||
672 | if (freq.folder_id == UUID.Zero) | ||
673 | { | ||
674 | //coll.Collection.OwnerID = freq.owner_id; | ||
675 | //coll.Collection.FolderID = contents.FolderID; | ||
676 | //containingFolder = m_InventoryService.GetRootFolder(freq.owner_id); | ||
677 | //if (containingFolder != null) | ||
678 | //{ | ||
679 | // m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Request for parent of folder {0}", containingFolder.ID); | ||
680 | // coll.Collection.Folders.Clear(); | ||
681 | // coll.Collection.Folders.Add(containingFolder); | ||
682 | // if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null) | ||
683 | // { | ||
684 | // InventoryFolderBase lib = new InventoryFolderBase(m_LibraryService.LibraryRootFolder.ID, m_LibraryService.LibraryRootFolder.Owner); | ||
685 | // lib.Name = m_LibraryService.LibraryRootFolder.Name; | ||
686 | // lib.Type = m_LibraryService.LibraryRootFolder.Type; | ||
687 | // lib.Version = m_LibraryService.LibraryRootFolder.Version; | ||
688 | // coll.Collection.Folders.Add(lib); | ||
689 | // } | ||
690 | // coll.Collection.Items.Clear(); | ||
691 | //} | ||
692 | } | ||
693 | else | ||
694 | { | ||
695 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id); | ||
696 | bad_folders.Add(freq.folder_id); | ||
697 | } | ||
698 | bad = true; | 582 | bad = true; |
699 | } | 583 | } |
700 | } | 584 | } |
@@ -708,42 +592,21 @@ from docs seems this was never a spec | |||
708 | 592 | ||
709 | if (freq.fetch_items && contents.Items != null) | 593 | if (freq.fetch_items && contents.Items != null) |
710 | { | 594 | { |
711 | List<InventoryItemBase> itemsToReturn = contents.Items; | 595 | // viewers are lasy and want a copy of the linked item sent before the link to it |
712 | 596 | ||
713 | // descendents must only include the links, not the linked items we add | 597 | // descendents must only include the links, not the linked items we add |
714 | coll.Descendents = itemsToReturn.Count; | 598 | coll.Descendents = contents.Items.Count + contents.Folders.Count; |
715 | 599 | ||
716 | // Add target items for links in this folder before the links themselves. | 600 | // look for item links |
717 | List<UUID> itemIDs = new List<UUID>(); | 601 | List<UUID> itemIDs = new List<UUID>(); |
718 | List<UUID> folderIDs = new List<UUID>(); | 602 | foreach (InventoryItemBase item in contents.Items) |
719 | foreach (InventoryItemBase item in itemsToReturn) | ||
720 | { | 603 | { |
721 | //m_log.DebugFormat("[XXX]: {0} {1}", item.Name, item.AssetType); | 604 | //m_log.DebugFormat("[XXX]: {0} {1}", item.Name, item.AssetType); |
722 | if (item.AssetType == (int)AssetType.Link) | 605 | if (item.AssetType == (int)AssetType.Link) |
723 | itemIDs.Add(item.AssetID); | 606 | itemIDs.Add(item.AssetID); |
724 | |||
725 | // else if (item.AssetType == (int)AssetType.LinkFolder) | ||
726 | // folderIDs.Add(item.AssetID); | ||
727 | } | ||
728 | |||
729 | //m_log.DebugFormat("[XXX]: folder {0} has {1} links and {2} linkfolders", contents.FolderID, itemIDs.Count, folderIDs.Count); | ||
730 | |||
731 | // Scan for folder links and insert the items they target and those links at the head of the return data | ||
732 | if (folderIDs.Count > 0) | ||
733 | { | ||
734 | InventoryCollection[] linkedFolders = m_InventoryService.GetMultipleFoldersContent(coll.Collection.OwnerID, folderIDs.ToArray()); | ||
735 | foreach (InventoryCollection linkedFolderContents in linkedFolders) | ||
736 | { | ||
737 | if (linkedFolderContents == null) | ||
738 | continue; | ||
739 | |||
740 | List<InventoryItemBase> links = linkedFolderContents.Items; | ||
741 | |||
742 | itemsToReturn.InsertRange(0, links); | ||
743 | |||
744 | } | ||
745 | } | 607 | } |
746 | 608 | ||
609 | // get the linked if any | ||
747 | if (itemIDs.Count > 0) | 610 | if (itemIDs.Count > 0) |
748 | { | 611 | { |
749 | InventoryItemBase[] linked = m_InventoryService.GetMultipleItems(freq.owner_id, itemIDs.ToArray()); | 612 | InventoryItemBase[] linked = m_InventoryService.GetMultipleItems(freq.owner_id, itemIDs.ToArray()); |
@@ -758,13 +621,11 @@ from docs seems this was never a spec | |||
758 | linked[i++] = m_InventoryService.GetItem(freq.owner_id, id); | 621 | linked[i++] = m_InventoryService.GetItem(freq.owner_id, id); |
759 | } | 622 | } |
760 | } | 623 | } |
761 | 624 | ||
762 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Processing folder {0}. Existing items:", freq.folder_id); | ||
763 | //foreach (InventoryItemBase item in itemsToReturn) | ||
764 | // m_log.DebugFormat("[XXX]: {0} {1} {2}", item.Name, item.AssetType, item.Folder); | ||
765 | |||
766 | if (linked != null) | 625 | if (linked != null) |
767 | { | 626 | { |
627 | List<InventoryItemBase> linkedItems = new List<InventoryItemBase>(); | ||
628 | // check for broken | ||
768 | foreach (InventoryItemBase linkedItem in linked) | 629 | foreach (InventoryItemBase linkedItem in linked) |
769 | { | 630 | { |
770 | // Take care of genuinely broken links where the target doesn't exist | 631 | // Take care of genuinely broken links where the target doesn't exist |
@@ -773,14 +634,16 @@ from docs seems this was never a spec | |||
773 | // rather than having to keep track of every folder requested in the recursion. | 634 | // rather than having to keep track of every folder requested in the recursion. |
774 | if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) | 635 | if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) |
775 | { | 636 | { |
776 | itemsToReturn.Insert(0, linkedItem); | 637 | linkedItems.Add(linkedItem); |
777 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Added {0} {1} {2}", linkedItem.Name, linkedItem.AssetType, linkedItem.Folder); | 638 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Added {0} {1} {2}", linkedItem.Name, linkedItem.AssetType, linkedItem.Folder); |
778 | } | 639 | } |
779 | } | 640 | } |
641 | // insert them | ||
642 | if(linkedItems.Count > 0) | ||
643 | contents.Items.InsertRange(0,linkedItems); | ||
780 | } | 644 | } |
781 | } | 645 | } |
782 | } | 646 | } |
783 | |||
784 | } | 647 | } |
785 | 648 | ||
786 | /// <summary> | 649 | /// <summary> |
diff --git a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs index a9b81f3..a0471bb 100644 --- a/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetMesh/GetMeshHandler.cs | |||
@@ -64,10 +64,7 @@ namespace OpenSim.Capabilities.Handlers | |||
64 | Hashtable ret = new Hashtable(); | 64 | Hashtable ret = new Hashtable(); |
65 | ret["int_response_code"] = (int)System.Net.HttpStatusCode.NotFound; | 65 | ret["int_response_code"] = (int)System.Net.HttpStatusCode.NotFound; |
66 | ret["content_type"] = "text/plain"; | 66 | ret["content_type"] = "text/plain"; |
67 | ret["keepalive"] = false; | ||
68 | ret["reusecontext"] = false; | ||
69 | ret["int_bytes"] = 0; | 67 | ret["int_bytes"] = 0; |
70 | ret["int_lod"] = 0; | ||
71 | string MeshStr = (string)request["mesh_id"]; | 68 | string MeshStr = (string)request["mesh_id"]; |
72 | 69 | ||
73 | 70 | ||
@@ -76,6 +73,8 @@ namespace OpenSim.Capabilities.Handlers | |||
76 | if (m_assetService == null) | 73 | if (m_assetService == null) |
77 | { | 74 | { |
78 | m_log.Error("[GETMESH]: Cannot fetch mesh " + MeshStr + " without an asset service"); | 75 | m_log.Error("[GETMESH]: Cannot fetch mesh " + MeshStr + " without an asset service"); |
76 | ret["keepalive"] = false; | ||
77 | return ret; | ||
79 | } | 78 | } |
80 | 79 | ||
81 | UUID meshID; | 80 | UUID meshID; |
@@ -101,10 +100,7 @@ namespace OpenSim.Capabilities.Handlers | |||
101 | Hashtable responsedata = new Hashtable(); | 100 | Hashtable responsedata = new Hashtable(); |
102 | responsedata["int_response_code"] = 400; //501; //410; //404; | 101 | responsedata["int_response_code"] = 400; //501; //410; //404; |
103 | responsedata["content_type"] = "text/plain"; | 102 | responsedata["content_type"] = "text/plain"; |
104 | responsedata["keepalive"] = false; | ||
105 | responsedata["str_response_string"] = "Request wasn't what was expected"; | 103 | responsedata["str_response_string"] = "Request wasn't what was expected"; |
106 | responsedata["reusecontext"] = false; | ||
107 | responsedata["int_lod"] = 0; | ||
108 | responsedata["int_bytes"] = 0; | 104 | responsedata["int_bytes"] = 0; |
109 | 105 | ||
110 | string meshStr = string.Empty; | 106 | string meshStr = string.Empty; |
@@ -118,10 +114,8 @@ namespace OpenSim.Capabilities.Handlers | |||
118 | if (m_assetService == null) | 114 | if (m_assetService == null) |
119 | { | 115 | { |
120 | responsedata["int_response_code"] = 404; //501; //410; //404; | 116 | responsedata["int_response_code"] = 404; //501; //410; //404; |
121 | responsedata["content_type"] = "text/plain"; | ||
122 | responsedata["keepalive"] = false; | 117 | responsedata["keepalive"] = false; |
123 | responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; | 118 | responsedata["str_response_string"] = "The asset service is unavailable. So is your mesh."; |
124 | responsedata["reusecontext"] = false; | ||
125 | return responsedata; | 119 | return responsedata; |
126 | } | 120 | } |
127 | 121 | ||
@@ -155,10 +149,7 @@ namespace OpenSim.Capabilities.Handlers | |||
155 | { | 149 | { |
156 | responsedata["int_response_code"] = 404; //501; //410; //404; | 150 | responsedata["int_response_code"] = 404; //501; //410; //404; |
157 | responsedata["content_type"] = "text/plain"; | 151 | responsedata["content_type"] = "text/plain"; |
158 | responsedata["keepalive"] = false; | ||
159 | responsedata["str_response_string"] = "This range doesnt exist."; | 152 | responsedata["str_response_string"] = "This range doesnt exist."; |
160 | responsedata["reusecontext"] = false; | ||
161 | responsedata["int_lod"] = 3; | ||
162 | return responsedata; | 153 | return responsedata; |
163 | } | 154 | } |
164 | else | 155 | else |
@@ -169,28 +160,11 @@ namespace OpenSim.Capabilities.Handlers | |||
169 | 160 | ||
170 | //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); | 161 | //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); |
171 | 162 | ||
172 | if (start > 20000) | ||
173 | { | ||
174 | responsedata["int_lod"] = 3; | ||
175 | } | ||
176 | else if (start < 4097) | ||
177 | { | ||
178 | responsedata["int_lod"] = 1; | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | responsedata["int_lod"] = 2; | ||
183 | } | ||
184 | |||
185 | |||
186 | if (start == 0 && len == mesh.Data.Length) // well redudante maybe | 163 | if (start == 0 && len == mesh.Data.Length) // well redudante maybe |
187 | { | 164 | { |
188 | responsedata["int_response_code"] = (int)System.Net.HttpStatusCode.OK; | 165 | responsedata["int_response_code"] = (int)System.Net.HttpStatusCode.OK; |
189 | responsedata["bin_response_data"] = mesh.Data; | 166 | responsedata["bin_response_data"] = mesh.Data; |
190 | responsedata["int_bytes"] = mesh.Data.Length; | 167 | responsedata["int_bytes"] = mesh.Data.Length; |
191 | responsedata["reusecontext"] = false; | ||
192 | responsedata["int_lod"] = 3; | ||
193 | |||
194 | } | 168 | } |
195 | else | 169 | else |
196 | { | 170 | { |
@@ -203,7 +177,6 @@ namespace OpenSim.Capabilities.Handlers | |||
203 | Array.Copy(mesh.Data, start, d, 0, len); | 177 | Array.Copy(mesh.Data, start, d, 0, len); |
204 | responsedata["bin_response_data"] = d; | 178 | responsedata["bin_response_data"] = d; |
205 | responsedata["int_bytes"] = len; | 179 | responsedata["int_bytes"] = len; |
206 | responsedata["reusecontext"] = false; | ||
207 | } | 180 | } |
208 | } | 181 | } |
209 | } | 182 | } |
@@ -213,8 +186,6 @@ namespace OpenSim.Capabilities.Handlers | |||
213 | responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); | 186 | responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); |
214 | responsedata["content_type"] = "application/vnd.ll.mesh"; | 187 | responsedata["content_type"] = "application/vnd.ll.mesh"; |
215 | responsedata["int_response_code"] = 200; | 188 | responsedata["int_response_code"] = 200; |
216 | responsedata["reusecontext"] = false; | ||
217 | responsedata["int_lod"] = 3; | ||
218 | } | 189 | } |
219 | } | 190 | } |
220 | else | 191 | else |
@@ -222,8 +193,6 @@ namespace OpenSim.Capabilities.Handlers | |||
222 | responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); | 193 | responsedata["str_response_string"] = Convert.ToBase64String(mesh.Data); |
223 | responsedata["content_type"] = "application/vnd.ll.mesh"; | 194 | responsedata["content_type"] = "application/vnd.ll.mesh"; |
224 | responsedata["int_response_code"] = 200; | 195 | responsedata["int_response_code"] = 200; |
225 | responsedata["reusecontext"] = false; | ||
226 | responsedata["int_lod"] = 3; | ||
227 | } | 196 | } |
228 | } | 197 | } |
229 | // Optionally add additional mesh types here | 198 | // Optionally add additional mesh types here |
@@ -231,10 +200,7 @@ namespace OpenSim.Capabilities.Handlers | |||
231 | { | 200 | { |
232 | responsedata["int_response_code"] = 404; //501; //410; //404; | 201 | responsedata["int_response_code"] = 404; //501; //410; //404; |
233 | responsedata["content_type"] = "text/plain"; | 202 | responsedata["content_type"] = "text/plain"; |
234 | responsedata["keepalive"] = false; | ||
235 | responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; | 203 | responsedata["str_response_string"] = "Unfortunately, this asset isn't a mesh."; |
236 | responsedata["reusecontext"] = false; | ||
237 | responsedata["int_lod"] = 1; | ||
238 | return responsedata; | 204 | return responsedata; |
239 | } | 205 | } |
240 | } | 206 | } |
@@ -242,10 +208,7 @@ namespace OpenSim.Capabilities.Handlers | |||
242 | { | 208 | { |
243 | responsedata["int_response_code"] = 404; //501; //410; //404; | 209 | responsedata["int_response_code"] = 404; //501; //410; //404; |
244 | responsedata["content_type"] = "text/plain"; | 210 | responsedata["content_type"] = "text/plain"; |
245 | responsedata["keepalive"] = false; | ||
246 | responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; | 211 | responsedata["str_response_string"] = "Your Mesh wasn't found. Sorry!"; |
247 | responsedata["reusecontext"] = false; | ||
248 | responsedata["int_lod"] = 0; | ||
249 | return responsedata; | 212 | return responsedata; |
250 | } | 213 | } |
251 | } | 214 | } |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index f59c902..ddd9578 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -403,7 +403,7 @@ namespace OpenSim.Framework.Console | |||
403 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 403 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
404 | 404 | ||
405 | m_Server.AddPollServiceHTTPHandler( | 405 | m_Server.AddPollServiceHTTPHandler( |
406 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout | 406 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, null, sessionID,25000)); // 25 secs timeout |
407 | 407 | ||
408 | // Our reply is an XML document. | 408 | // Our reply is an XML document. |
409 | // TODO: Change this to Linq.Xml | 409 | // TODO: Change this to Linq.Xml |
diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs index dfe9695..d79eb0d 100644 --- a/OpenSim/Framework/NetworkServersInfo.cs +++ b/OpenSim/Framework/NetworkServersInfo.cs | |||
@@ -37,6 +37,8 @@ namespace OpenSim.Framework | |||
37 | public bool isSandbox; | 37 | public bool isSandbox; |
38 | public bool HttpUsesSSL = false; | 38 | public bool HttpUsesSSL = false; |
39 | public string HttpSSLCN = ""; | 39 | public string HttpSSLCN = ""; |
40 | public string HttpSSLCertPath = ""; | ||
41 | public string HttpSSLCNCertPass = ""; | ||
40 | public uint httpSSLPort = 9001; | 42 | public uint httpSSLPort = 9001; |
41 | 43 | ||
42 | // "Out of band" managemnt https | 44 | // "Out of band" managemnt https |
@@ -62,6 +64,8 @@ namespace OpenSim.Framework | |||
62 | (uint)config.Configs["Network"].GetInt("http_listener_sslport", ((int)ConfigSettings.DefaultRegionHttpPort+1)); | 64 | (uint)config.Configs["Network"].GetInt("http_listener_sslport", ((int)ConfigSettings.DefaultRegionHttpPort+1)); |
63 | HttpUsesSSL = config.Configs["Network"].GetBoolean("http_listener_ssl", false); | 65 | HttpUsesSSL = config.Configs["Network"].GetBoolean("http_listener_ssl", false); |
64 | HttpSSLCN = config.Configs["Network"].GetString("http_listener_cn", "localhost"); | 66 | HttpSSLCN = config.Configs["Network"].GetString("http_listener_cn", "localhost"); |
67 | HttpSSLCertPath = config.Configs["Network"].GetString("http_listener_cert_path", HttpSSLCertPath); | ||
68 | HttpSSLCNCertPass = config.Configs["Network"].GetString("http_listener_cert_pass", HttpSSLCNCertPass); | ||
65 | 69 | ||
66 | // "Out of band management https" | 70 | // "Out of band management https" |
67 | ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false); | 71 | ssl_listener = config.Configs["Network"].GetBoolean("https_listener",false); |
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 81dd357..f832f81 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -33,6 +33,9 @@ using System.Text; | |||
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using System.Timers; | 35 | using System.Timers; |
36 | using System.Net; | ||
37 | using System.Net.Security; | ||
38 | using System.Security.Cryptography.X509Certificates; | ||
36 | using log4net; | 39 | using log4net; |
37 | using log4net.Appender; | 40 | using log4net.Appender; |
38 | using log4net.Core; | 41 | using log4net.Core; |
@@ -86,6 +89,26 @@ namespace OpenSim.Framework.Servers | |||
86 | m_osSecret = UUID.Random().ToString(); | 89 | m_osSecret = UUID.Random().ToString(); |
87 | } | 90 | } |
88 | 91 | ||
92 | private static bool m_NoVerifyCertChain = false; | ||
93 | private static bool m_NoVerifyCertHostname = false; | ||
94 | |||
95 | public static bool ValidateServerCertificate( | ||
96 | object sender, | ||
97 | X509Certificate certificate, | ||
98 | X509Chain chain, | ||
99 | SslPolicyErrors sslPolicyErrors) | ||
100 | { | ||
101 | if (m_NoVerifyCertChain) | ||
102 | sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateChainErrors; | ||
103 | |||
104 | if (m_NoVerifyCertHostname) | ||
105 | sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateNameMismatch; | ||
106 | |||
107 | if (sslPolicyErrors == SslPolicyErrors.None) | ||
108 | return true; | ||
109 | |||
110 | return false; | ||
111 | } | ||
89 | /// <summary> | 112 | /// <summary> |
90 | /// Must be overriden by child classes for their own server specific startup behaviour. | 113 | /// Must be overriden by child classes for their own server specific startup behaviour. |
91 | /// </summary> | 114 | /// </summary> |
@@ -96,6 +119,11 @@ namespace OpenSim.Framework.Servers | |||
96 | RegisterCommonComponents(Config); | 119 | RegisterCommonComponents(Config); |
97 | 120 | ||
98 | IConfig startupConfig = Config.Configs["Startup"]; | 121 | IConfig startupConfig = Config.Configs["Startup"]; |
122 | |||
123 | m_NoVerifyCertChain = startupConfig.GetBoolean("NoVerifyCertChain", m_NoVerifyCertChain); | ||
124 | m_NoVerifyCertHostname = startupConfig.GetBoolean("NoVerifyCertHostname", m_NoVerifyCertHostname); | ||
125 | ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; | ||
126 | |||
99 | int logShowStatsSeconds = startupConfig.GetInt("LogShowStatsSeconds", m_periodDiagnosticTimerMS / 1000); | 127 | int logShowStatsSeconds = startupConfig.GetInt("LogShowStatsSeconds", m_periodDiagnosticTimerMS / 1000); |
100 | m_periodDiagnosticTimerMS = logShowStatsSeconds * 1000; | 128 | m_periodDiagnosticTimerMS = logShowStatsSeconds * 1000; |
101 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); | 129 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 92be3a3..da2b860 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -32,6 +32,7 @@ using System.Collections.Specialized; | |||
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Net; | 33 | using System.Net; |
34 | using System.Net.Sockets; | 34 | using System.Net.Sockets; |
35 | using System.Net.Security; | ||
35 | using System.Security.Cryptography.X509Certificates; | 36 | using System.Security.Cryptography.X509Certificates; |
36 | using System.Reflection; | 37 | using System.Reflection; |
37 | using System.Globalization; | 38 | using System.Globalization; |
@@ -43,10 +44,11 @@ using log4net; | |||
43 | using Nwc.XmlRpc; | 44 | using Nwc.XmlRpc; |
44 | using OpenMetaverse.StructuredData; | 45 | using OpenMetaverse.StructuredData; |
45 | using CoolHTTPListener = HttpServer.HttpListener; | 46 | using CoolHTTPListener = HttpServer.HttpListener; |
46 | using HttpListener=System.Net.HttpListener; | 47 | using HttpListener = System.Net.HttpListener; |
47 | using LogPrio=HttpServer.LogPrio; | 48 | using LogPrio = HttpServer.LogPrio; |
48 | using OpenSim.Framework.Monitoring; | 49 | using OpenSim.Framework.Monitoring; |
49 | using System.IO.Compression; | 50 | using System.IO.Compression; |
51 | using System.Security.Cryptography; | ||
50 | 52 | ||
51 | namespace OpenSim.Framework.Servers.HttpServer | 53 | namespace OpenSim.Framework.Servers.HttpServer |
52 | { | 54 | { |
@@ -107,19 +109,26 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
107 | new Dictionary<string, WebSocketRequestDelegate>(); | 109 | new Dictionary<string, WebSocketRequestDelegate>(); |
108 | 110 | ||
109 | protected uint m_port; | 111 | protected uint m_port; |
110 | protected uint m_sslport; | ||
111 | protected bool m_ssl; | 112 | protected bool m_ssl; |
112 | private X509Certificate2 m_cert; | 113 | private X509Certificate2 m_cert; |
113 | protected bool m_firstcaps = true; | ||
114 | protected string m_SSLCommonName = ""; | 114 | protected string m_SSLCommonName = ""; |
115 | protected List<string> m_certNames = new List<string>(); | ||
116 | protected List<string> m_certIPs = new List<string>(); | ||
117 | protected string m_certCN= ""; | ||
118 | protected RemoteCertificateValidationCallback m_certificateValidationCallback = null; | ||
115 | 119 | ||
116 | protected IPAddress m_listenIPAddress = IPAddress.Any; | 120 | protected IPAddress m_listenIPAddress = IPAddress.Any; |
117 | 121 | ||
118 | public PollServiceRequestManager PollServiceRequestManager { get; private set; } | 122 | public PollServiceRequestManager PollServiceRequestManager { get; private set; } |
119 | 123 | ||
124 | public string Protocol | ||
125 | { | ||
126 | get { return m_ssl ? "https://" : "http://"; } | ||
127 | } | ||
128 | |||
120 | public uint SSLPort | 129 | public uint SSLPort |
121 | { | 130 | { |
122 | get { return m_sslport; } | 131 | get { return m_port; } |
123 | } | 132 | } |
124 | 133 | ||
125 | public string SSLCommonName | 134 | public string SSLCommonName |
@@ -148,27 +157,151 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
148 | m_port = port; | 157 | m_port = port; |
149 | } | 158 | } |
150 | 159 | ||
151 | public BaseHttpServer(uint port, bool ssl) : this (port) | 160 | private void load_cert(string CPath, string CPass) |
152 | { | 161 | { |
153 | m_ssl = ssl; | 162 | try |
163 | { | ||
164 | m_cert = new X509Certificate2(CPath, CPass); | ||
165 | X509Extension ext = m_cert.Extensions["2.5.29.17"]; | ||
166 | if(ext != null) | ||
167 | { | ||
168 | AsnEncodedData asndata = new AsnEncodedData(ext.Oid, ext.RawData); | ||
169 | string datastr = asndata.Format(true); | ||
170 | string[] lines = datastr.Split(new char[] {'\n','\r'}); | ||
171 | foreach(string s in lines) | ||
172 | { | ||
173 | if(String.IsNullOrEmpty(s)) | ||
174 | continue; | ||
175 | string[] parts = s.Split(new char[] {'='}); | ||
176 | if(String.IsNullOrEmpty(parts[0])) | ||
177 | continue; | ||
178 | string entryName = parts[0].Replace(" ",""); | ||
179 | if(entryName == "DNSName") | ||
180 | m_certNames.Add(parts[1]); | ||
181 | else if(entryName == "IPAddress") | ||
182 | m_certIPs.Add(parts[1]); | ||
183 | } | ||
184 | } | ||
185 | m_certCN = m_cert.GetNameInfo(X509NameType.SimpleName, false); | ||
186 | } | ||
187 | catch | ||
188 | { | ||
189 | throw new Exception("SSL cert load error"); | ||
190 | } | ||
154 | } | 191 | } |
155 | 192 | ||
156 | public BaseHttpServer(uint port, bool ssl, uint sslport, string CN) : this (port, ssl) | 193 | public BaseHttpServer(uint port, bool ssl, string CN, string CPath, string CPass) |
157 | { | 194 | { |
158 | if (m_ssl) | 195 | m_port = port; |
196 | if (ssl) | ||
159 | { | 197 | { |
160 | m_sslport = sslport; | 198 | if(string.IsNullOrEmpty(CPath)) |
199 | throw new Exception("invalid main http server cert path"); | ||
200 | |||
201 | if(Uri.CheckHostName(CN) == UriHostNameType.Unknown) | ||
202 | throw new Exception("invalid main http server CN (ExternalHostName)"); | ||
203 | |||
204 | m_certNames.Clear(); | ||
205 | m_certIPs.Clear(); | ||
206 | m_certCN= ""; | ||
207 | |||
208 | m_ssl = true; | ||
209 | load_cert(CPath, CPass); | ||
210 | |||
211 | if(!CheckSSLCertHost(CN)) | ||
212 | throw new Exception("invalid main http server CN (ExternalHostName)"); | ||
213 | |||
214 | m_SSLCommonName = CN; | ||
215 | |||
216 | if(m_cert.Issuer == m_cert.Subject ) | ||
217 | m_log.Warn("Self signed certificate. Clients need to allow this (some viewers debug option NoVerifySSLcert must be set to true"); | ||
161 | } | 218 | } |
219 | else | ||
220 | m_ssl = false; | ||
162 | } | 221 | } |
163 | 222 | ||
164 | public BaseHttpServer(uint port, bool ssl, string CPath, string CPass) : this (port, ssl) | 223 | public BaseHttpServer(uint port, bool ssl, string CPath, string CPass) |
165 | { | 224 | { |
166 | if (m_ssl) | 225 | m_port = port; |
226 | if (ssl) | ||
167 | { | 227 | { |
168 | m_cert = new X509Certificate2(CPath, CPass); | 228 | load_cert(CPath, CPass); |
229 | if(m_cert.Issuer == m_cert.Subject ) | ||
230 | m_log.Warn("Self signed certificate. Http clients need to allow this"); | ||
231 | m_ssl = true; | ||
232 | } | ||
233 | else | ||
234 | m_ssl = false; | ||
235 | } | ||
236 | |||
237 | static bool MatchDNS (string hostname, string dns) | ||
238 | { | ||
239 | int indx = dns.IndexOf ('*'); | ||
240 | if (indx == -1) | ||
241 | return (String.Compare(hostname, dns, true, CultureInfo.InvariantCulture) == 0); | ||
242 | |||
243 | int dnslen = dns.Length; | ||
244 | dnslen--; | ||
245 | if(indx == dnslen) | ||
246 | return true; // just * ? | ||
247 | |||
248 | if(indx > dnslen - 2) | ||
249 | return false; // 2 short ? | ||
250 | |||
251 | if (dns[indx + 1] != '.') | ||
252 | return false; | ||
253 | |||
254 | int indx2 = dns.IndexOf ('*', indx + 1); | ||
255 | if (indx2 != -1) | ||
256 | return false; // there can only be one; | ||
257 | |||
258 | string end = dns.Substring(indx + 1); | ||
259 | int hostlen = hostname.Length; | ||
260 | int endlen = end.Length; | ||
261 | int length = hostlen - endlen; | ||
262 | if (length <= 0) | ||
263 | return false; | ||
264 | |||
265 | if (String.Compare(hostname, length, end, 0, endlen, true, CultureInfo.InvariantCulture) != 0) | ||
266 | return false; | ||
267 | |||
268 | if (indx == 0) | ||
269 | { | ||
270 | indx2 = hostname.IndexOf ('.'); | ||
271 | return ((indx2 == -1) || (indx2 >= length)); | ||
272 | } | ||
273 | |||
274 | string start = dns.Substring (0, indx); | ||
275 | return (String.Compare (hostname, 0, start, 0, start.Length, true, CultureInfo.InvariantCulture) == 0); | ||
276 | } | ||
277 | |||
278 | public bool CheckSSLCertHost(string hostname) | ||
279 | { | ||
280 | UriHostNameType htype = Uri.CheckHostName(hostname); | ||
281 | |||
282 | if(htype == UriHostNameType.Unknown || htype == UriHostNameType.Basic) | ||
283 | return false; | ||
284 | if(htype == UriHostNameType.Dns) | ||
285 | { | ||
286 | foreach(string name in m_certNames) | ||
287 | { | ||
288 | if(MatchDNS(hostname, name)) | ||
289 | return true; | ||
290 | } | ||
291 | if(MatchDNS(hostname, m_certCN)) | ||
292 | return true; | ||
293 | } | ||
294 | else | ||
295 | { | ||
296 | foreach(string ip in m_certIPs) | ||
297 | { | ||
298 | if (String.Compare(hostname, ip, true, CultureInfo.InvariantCulture) != 0) | ||
299 | return true; | ||
300 | } | ||
169 | } | 301 | } |
170 | } | ||
171 | 302 | ||
303 | return false; | ||
304 | } | ||
172 | /// <summary> | 305 | /// <summary> |
173 | /// Add a stream handler to the http server. If the handler already exists, then nothing happens. | 306 | /// Add a stream handler to the http server. If the handler already exists, then nothing happens. |
174 | /// </summary> | 307 | /// </summary> |
@@ -396,12 +529,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
396 | if (psEvArgs.Request != null) | 529 | if (psEvArgs.Request != null) |
397 | { | 530 | { |
398 | OSHttpRequest req = new OSHttpRequest(context, request); | 531 | OSHttpRequest req = new OSHttpRequest(context, request); |
399 | |||
400 | Stream requestStream = req.InputStream; | ||
401 | |||
402 | string requestBody; | 532 | string requestBody; |
403 | Encoding encoding = Encoding.UTF8; | 533 | Encoding encoding = Encoding.UTF8; |
404 | using(StreamReader reader = new StreamReader(requestStream, encoding)) | 534 | using(StreamReader reader = new StreamReader(req.InputStream, encoding)) |
405 | requestBody = reader.ReadToEnd(); | 535 | requestBody = reader.ReadToEnd(); |
406 | 536 | ||
407 | Hashtable keysvals = new Hashtable(); | 537 | Hashtable keysvals = new Hashtable(); |
@@ -460,7 +590,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
460 | } | 590 | } |
461 | 591 | ||
462 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); | 592 | OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); |
463 | resp.ReuseContext = true; | 593 | // resp.ReuseContext = true; |
464 | // resp.ReuseContext = false; | 594 | // resp.ReuseContext = false; |
465 | HandleRequest(req, resp); | 595 | HandleRequest(req, resp); |
466 | 596 | ||
@@ -496,6 +626,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
496 | byte[] buffer500 = SendHTML500(response); | 626 | byte[] buffer500 = SendHTML500(response); |
497 | response.OutputStream.Write(buffer500, 0, buffer500.Length); | 627 | response.OutputStream.Write(buffer500, 0, buffer500.Length); |
498 | response.Send(); | 628 | response.Send(); |
629 | if(request.InputStream.CanRead) | ||
630 | request.InputStream.Close(); | ||
499 | } | 631 | } |
500 | catch | 632 | catch |
501 | { | 633 | { |
@@ -540,7 +672,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
540 | // } | 672 | // } |
541 | // } | 673 | // } |
542 | 674 | ||
543 | //response.KeepAlive = true; | ||
544 | response.SendChunked = false; | 675 | response.SendChunked = false; |
545 | 676 | ||
546 | string path = request.RawUrl; | 677 | string path = request.RawUrl; |
@@ -564,11 +695,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
564 | { | 695 | { |
565 | //m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler"); | 696 | //m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler"); |
566 | IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler; | 697 | IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler; |
567 | Stream requestStream = request.InputStream; | ||
568 | 698 | ||
569 | string requestBody; | 699 | string requestBody; |
570 | Encoding encoding = Encoding.UTF8; | 700 | Encoding encoding = Encoding.UTF8; |
571 | using(StreamReader reader = new StreamReader(requestStream, encoding)) | 701 | using(StreamReader reader = new StreamReader(request.InputStream, encoding)) |
572 | requestBody = reader.ReadToEnd(); | 702 | requestBody = reader.ReadToEnd(); |
573 | 703 | ||
574 | Hashtable keysvals = new Hashtable(); | 704 | Hashtable keysvals = new Hashtable(); |
@@ -609,7 +739,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
609 | else | 739 | else |
610 | { | 740 | { |
611 | IStreamHandler streamHandler = (IStreamHandler)requestHandler; | 741 | IStreamHandler streamHandler = (IStreamHandler)requestHandler; |
612 | |||
613 | using (MemoryStream memoryStream = new MemoryStream()) | 742 | using (MemoryStream memoryStream = new MemoryStream()) |
614 | { | 743 | { |
615 | streamHandler.Handle(path, request.InputStream, memoryStream, request, response); | 744 | streamHandler.Handle(path, request.InputStream, memoryStream, request, response); |
@@ -720,10 +849,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
720 | requestEndTick = Environment.TickCount; | 849 | requestEndTick = Environment.TickCount; |
721 | 850 | ||
722 | response.Send(); | 851 | response.Send(); |
723 | |||
724 | //response.OutputStream.Close(); | ||
725 | |||
726 | //response.FreeContext(); | ||
727 | } | 852 | } |
728 | catch (SocketException e) | 853 | catch (SocketException e) |
729 | { | 854 | { |
@@ -755,6 +880,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
755 | } | 880 | } |
756 | finally | 881 | finally |
757 | { | 882 | { |
883 | if(request.InputStream.CanRead) | ||
884 | request.InputStream.Close(); | ||
885 | |||
758 | // Every month or so this will wrap and give bad numbers, not really a problem | 886 | // Every month or so this will wrap and give bad numbers, not really a problem |
759 | // since its just for reporting | 887 | // since its just for reporting |
760 | int tickdiff = requestEndTick - requestStartTick; | 888 | int tickdiff = requestEndTick - requestStartTick; |
@@ -1008,12 +1136,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1008 | using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) | 1136 | using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) |
1009 | requestBody = reader.ReadToEnd(); | 1137 | requestBody = reader.ReadToEnd(); |
1010 | 1138 | ||
1011 | } | 1139 | } |
1012 | finally | 1140 | finally |
1013 | { | 1141 | { |
1014 | if (innerStream != null) | 1142 | if (innerStream != null && innerStream.CanRead) |
1015 | innerStream.Dispose(); | 1143 | innerStream.Dispose(); |
1016 | requestStream.Dispose(); | 1144 | if (requestStream.CanRead) |
1145 | requestStream.Dispose(); | ||
1017 | } | 1146 | } |
1018 | 1147 | ||
1019 | //m_log.Debug(requestBody); | 1148 | //m_log.Debug(requestBody); |
@@ -1094,6 +1223,17 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1094 | 1223 | ||
1095 | if (gridproxy) | 1224 | if (gridproxy) |
1096 | xmlRprcRequest.Params.Add("gridproxy"); // Param[4] | 1225 | xmlRprcRequest.Params.Add("gridproxy"); // Param[4] |
1226 | |||
1227 | // reserve this for | ||
1228 | // ... by Fumi.Iseki for DTLNSLMoneyServer | ||
1229 | // BUT make its presence possible to detect/parse | ||
1230 | string rcn = request.IHttpClientContext.SSLCommonName; | ||
1231 | if(!string.IsNullOrWhiteSpace(rcn)) | ||
1232 | { | ||
1233 | rcn = "SSLCN:" + rcn; | ||
1234 | xmlRprcRequest.Params.Add(rcn); // Param[4] or Param[5] | ||
1235 | } | ||
1236 | |||
1097 | try | 1237 | try |
1098 | { | 1238 | { |
1099 | xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); | 1239 | xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); |
@@ -1265,7 +1405,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1265 | requestBody= reader.ReadToEnd(); | 1405 | requestBody= reader.ReadToEnd(); |
1266 | 1406 | ||
1267 | //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); | 1407 | //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); |
1268 | response.KeepAlive = true; | ||
1269 | 1408 | ||
1270 | OSD llsdRequest = null; | 1409 | OSD llsdRequest = null; |
1271 | OSD llsdResponse = null; | 1410 | OSD llsdResponse = null; |
@@ -1793,7 +1932,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1793 | */ | 1932 | */ |
1794 | // disable this things | 1933 | // disable this things |
1795 | response.KeepAlive = false; | 1934 | response.KeepAlive = false; |
1796 | response.ReuseContext = false; | 1935 | // response.ReuseContext = false; |
1797 | 1936 | ||
1798 | // Cross-Origin Resource Sharing with simple requests | 1937 | // Cross-Origin Resource Sharing with simple requests |
1799 | if (responsedata.ContainsKey("access_control_allow_origin")) | 1938 | if (responsedata.ContainsKey("access_control_allow_origin")) |
@@ -1895,7 +2034,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1895 | 2034 | ||
1896 | public void Start() | 2035 | public void Start() |
1897 | { | 2036 | { |
1898 | Start(true); | 2037 | Start(true,true); |
1899 | } | 2038 | } |
1900 | 2039 | ||
1901 | /// <summary> | 2040 | /// <summary> |
@@ -1905,7 +2044,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1905 | /// If true then poll responses are performed asynchronsly. | 2044 | /// If true then poll responses are performed asynchronsly. |
1906 | /// Option exists to allow regression tests to perform processing synchronously. | 2045 | /// Option exists to allow regression tests to perform processing synchronously. |
1907 | /// </param> | 2046 | /// </param> |
1908 | public void Start(bool performPollResponsesAsync) | 2047 | public void Start(bool performPollResponsesAsync, bool runPool) |
1909 | { | 2048 | { |
1910 | m_log.InfoFormat( | 2049 | m_log.InfoFormat( |
1911 | "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port); | 2050 | "[BASE HTTP SERVER]: Starting {0} server on port {1}", UseSSL ? "HTTPS" : "HTTP", Port); |
@@ -1934,6 +2073,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1934 | //m_httpListener.Prefixes.Add("https://+:" + (m_sslport) + "/"); | 2073 | //m_httpListener.Prefixes.Add("https://+:" + (m_sslport) + "/"); |
1935 | //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); | 2074 | //m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); |
1936 | m_httpListener2 = CoolHTTPListener.Create(IPAddress.Any, (int)m_port, m_cert); | 2075 | m_httpListener2 = CoolHTTPListener.Create(IPAddress.Any, (int)m_port, m_cert); |
2076 | if(m_certificateValidationCallback != null) | ||
2077 | m_httpListener2.CertificateValidationCallback = m_certificateValidationCallback; | ||
1937 | m_httpListener2.ExceptionThrown += httpServerException; | 2078 | m_httpListener2.ExceptionThrown += httpServerException; |
1938 | m_httpListener2.LogWriter = httpserverlog; | 2079 | m_httpListener2.LogWriter = httpserverlog; |
1939 | } | 2080 | } |
@@ -1943,9 +2084,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1943 | m_httpListener2.Start(64); | 2084 | m_httpListener2.Start(64); |
1944 | 2085 | ||
1945 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events | 2086 | // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events |
1946 | 2087 | if(runPool) | |
1947 | PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000); | 2088 | { |
1948 | PollServiceRequestManager.Start(); | 2089 | PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000); |
2090 | PollServiceRequestManager.Start(); | ||
2091 | } | ||
1949 | 2092 | ||
1950 | HTTPDRunning = true; | 2093 | HTTPDRunning = true; |
1951 | 2094 | ||
@@ -1959,7 +2102,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1959 | catch (Exception e) | 2102 | catch (Exception e) |
1960 | { | 2103 | { |
1961 | m_log.Error("[BASE HTTP SERVER]: Error - " + e.Message); | 2104 | m_log.Error("[BASE HTTP SERVER]: Error - " + e.Message); |
1962 | m_log.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + ", " + m_sslport + "?"); | 2105 | m_log.Error("[BASE HTTP SERVER]: Tip: Do you have permission to listen on port " + m_port + "?"); |
1963 | 2106 | ||
1964 | // We want this exception to halt the entire server since in current configurations we aren't too | 2107 | // We want this exception to halt the entire server since in current configurations we aren't too |
1965 | // useful without inbound HTTP. | 2108 | // useful without inbound HTTP. |
@@ -2124,10 +2267,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
2124 | string file = Path.Combine(".", "http_500.html"); | 2267 | string file = Path.Combine(".", "http_500.html"); |
2125 | if (!File.Exists(file)) | 2268 | if (!File.Exists(file)) |
2126 | return getDefaultHTTP500(); | 2269 | return getDefaultHTTP500(); |
2127 | 2270 | string result; | |
2128 | StreamReader sr = File.OpenText(file); | 2271 | using(StreamReader sr = File.OpenText(file)) |
2129 | string result = sr.ReadToEnd(); | 2272 | result = sr.ReadToEnd(); |
2130 | sr.Close(); | ||
2131 | return result; | 2273 | return result; |
2132 | } | 2274 | } |
2133 | 2275 | ||
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs index f61b090..d26b68a 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs | |||
@@ -118,7 +118,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
118 | /// </summary> | 118 | /// </summary> |
119 | string StatusDescription { get; set; } | 119 | string StatusDescription { get; set; } |
120 | 120 | ||
121 | bool ReuseContext { get; set; } | 121 | // bool ReuseContext { get; set; } |
122 | 122 | ||
123 | /// <summary> | 123 | /// <summary> |
124 | /// Add a header field and content to the response. | 124 | /// Add a header field and content to the response. |
diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs index d7744fc..8e1b545 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs | |||
@@ -256,7 +256,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
256 | _httpResponse.Reason = value; | 256 | _httpResponse.Reason = value; |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | /* | |
260 | public bool ReuseContext | 260 | public bool ReuseContext |
261 | { | 261 | { |
262 | get | 262 | get |
@@ -275,7 +275,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
275 | } | 275 | } |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | */ | |
279 | protected IHttpResponse _httpResponse; | 279 | protected IHttpResponse _httpResponse; |
280 | private IHttpClientContext _httpClientContext; | 280 | private IHttpClientContext _httpClientContext; |
281 | 281 | ||
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 7150aad..7c7d08d 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | |||
@@ -37,6 +37,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
37 | public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId); | 37 | public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId); |
38 | 38 | ||
39 | public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId); | 39 | public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId); |
40 | public delegate void DropMethod(UUID requestID, UUID pId); | ||
40 | 41 | ||
41 | public class PollServiceEventArgs : EventArgs | 42 | public class PollServiceEventArgs : EventArgs |
42 | { | 43 | { |
@@ -44,6 +45,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
44 | public GetEventsMethod GetEvents; | 45 | public GetEventsMethod GetEvents; |
45 | public NoEventsMethod NoEvents; | 46 | public NoEventsMethod NoEvents; |
46 | public RequestMethod Request; | 47 | public RequestMethod Request; |
48 | public DropMethod Drop; | ||
47 | public UUID Id; | 49 | public UUID Id; |
48 | public int TimeOutms; | 50 | public int TimeOutms; |
49 | public EventType Type; | 51 | public EventType Type; |
@@ -73,13 +75,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
73 | RequestMethod pRequest, | 75 | RequestMethod pRequest, |
74 | string pUrl, | 76 | string pUrl, |
75 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, | 77 | HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, |
76 | UUID pId, int pTimeOutms) | 78 | DropMethod pDrop, UUID pId, int pTimeOutms) |
77 | { | 79 | { |
78 | Request = pRequest; | 80 | Request = pRequest; |
79 | Url = pUrl; | 81 | Url = pUrl; |
80 | HasEvents = pHasEvents; | 82 | HasEvents = pHasEvents; |
81 | GetEvents = pGetEvents; | 83 | GetEvents = pGetEvents; |
82 | NoEvents = pNoEvents; | 84 | NoEvents = pNoEvents; |
85 | Drop = pDrop; | ||
83 | Id = pId; | 86 | Id = pId; |
84 | TimeOutms = pTimeOutms; | 87 | TimeOutms = pTimeOutms; |
85 | Type = EventType.Poll; | 88 | Type = EventType.Poll; |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index fefcb20..eb8ca0d 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | |||
@@ -47,8 +47,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
47 | public readonly UUID RequestID; | 47 | public readonly UUID RequestID; |
48 | public int contextHash; | 48 | public int contextHash; |
49 | 49 | ||
50 | /* | ||
50 | private void GenContextHash() | 51 | private void GenContextHash() |
51 | { | 52 | { |
53 | |||
52 | Random rnd = new Random(); | 54 | Random rnd = new Random(); |
53 | contextHash = 0; | 55 | contextHash = 0; |
54 | if (Request.Headers["remote_addr"] != null) | 56 | if (Request.Headers["remote_addr"] != null) |
@@ -62,8 +64,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
62 | } | 64 | } |
63 | else | 65 | else |
64 | contextHash += rnd.Next() & 0xffff; | 66 | contextHash += rnd.Next() & 0xffff; |
65 | } | ||
66 | 67 | ||
68 | } | ||
69 | */ | ||
67 | public PollServiceHttpRequest( | 70 | public PollServiceHttpRequest( |
68 | PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) | 71 | PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) |
69 | { | 72 | { |
@@ -72,7 +75,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
72 | Request = pRequest; | 75 | Request = pRequest; |
73 | RequestTime = System.Environment.TickCount; | 76 | RequestTime = System.Environment.TickCount; |
74 | RequestID = UUID.Random(); | 77 | RequestID = UUID.Random(); |
75 | GenContextHash(); | 78 | // GenContextHash(); |
79 | contextHash = HttpContext.contextID; | ||
76 | } | 80 | } |
77 | 81 | ||
78 | internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) | 82 | internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata) |
@@ -88,7 +92,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
88 | response.SendChunked = false; | 92 | response.SendChunked = false; |
89 | response.ContentLength64 = buffer.Length; | 93 | response.ContentLength64 = buffer.Length; |
90 | response.ContentEncoding = Encoding.UTF8; | 94 | response.ContentEncoding = Encoding.UTF8; |
91 | response.ReuseContext = false; | 95 | // response.ReuseContext = false; |
92 | 96 | ||
93 | try | 97 | try |
94 | { | 98 | { |
@@ -116,7 +120,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
116 | response.SendChunked = false; | 120 | response.SendChunked = false; |
117 | response.ContentLength64 = 0; | 121 | response.ContentLength64 = 0; |
118 | response.ContentEncoding = Encoding.UTF8; | 122 | response.ContentEncoding = Encoding.UTF8; |
119 | response.ReuseContext = false; | 123 | // response.ReuseContext = false; |
120 | response.KeepAlive = false; | 124 | response.KeepAlive = false; |
121 | response.SendChunked = false; | 125 | response.SendChunked = false; |
122 | response.StatusCode = 503; | 126 | response.StatusCode = 503; |
@@ -138,8 +142,9 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
138 | { | 142 | { |
139 | if (b1.contextHash != b2.contextHash) | 143 | if (b1.contextHash != b2.contextHash) |
140 | return false; | 144 | return false; |
141 | bool b = Object.ReferenceEquals(b1.HttpContext, b2.HttpContext); | 145 | // bool b = Object.ReferenceEquals(b1.HttpContext, b2.HttpContext); |
142 | return b; | 146 | // return b; |
147 | return true; | ||
143 | } | 148 | } |
144 | 149 | ||
145 | public int GetHashCode(PollServiceHttpRequest b2) | 150 | public int GetHashCode(PollServiceHttpRequest b2) |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index bd1c040..ffc6ad3 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -156,6 +156,19 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | public void DropByContext(PollServiceHttpRequest req) | ||
160 | { | ||
161 | Queue<PollServiceHttpRequest> ctxQeueue; | ||
162 | lock (m_bycontext) | ||
163 | { | ||
164 | if (m_bycontext.TryGetValue(req, out ctxQeueue)) | ||
165 | { | ||
166 | ctxQeueue.Clear(); | ||
167 | m_bycontext.Remove(req); | ||
168 | } | ||
169 | } | ||
170 | } | ||
171 | |||
159 | public void EnqueueInt(PollServiceHttpRequest req) | 172 | public void EnqueueInt(PollServiceHttpRequest req) |
160 | { | 173 | { |
161 | if (m_running) | 174 | if (m_running) |
@@ -234,23 +247,64 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
234 | { | 247 | { |
235 | PollServiceHttpRequest req = m_requests.Dequeue(5000); | 248 | PollServiceHttpRequest req = m_requests.Dequeue(5000); |
236 | Watchdog.UpdateThread(); | 249 | Watchdog.UpdateThread(); |
237 | if (req != null) | 250 | if(req == null) |
251 | continue; | ||
252 | |||
253 | try | ||
238 | { | 254 | { |
239 | try | 255 | if(!req.HttpContext.CanSend()) |
256 | { | ||
257 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); | ||
258 | byContextDequeue(req); | ||
259 | continue; | ||
260 | } | ||
261 | |||
262 | if(req.HttpContext.IsSending()) | ||
240 | { | 263 | { |
241 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | 264 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) |
242 | { | 265 | { |
243 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | 266 | req.PollServiceArgs.Drop(req.RequestID, req.PollServiceArgs.Id); |
267 | byContextDequeue(req); | ||
268 | } | ||
269 | else | ||
270 | ReQueueEvent(req); | ||
271 | continue; | ||
272 | } | ||
273 | |||
274 | if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) | ||
275 | { | ||
276 | Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); | ||
244 | 277 | ||
278 | m_threadPool.QueueWorkItem(x => | ||
279 | { | ||
280 | try | ||
281 | { | ||
282 | req.DoHTTPGruntWork(m_server, responsedata); | ||
283 | } | ||
284 | catch (ObjectDisposedException) { } | ||
285 | finally | ||
286 | { | ||
287 | if(req.HttpContext.CanSend() && req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Poll | ||
288 | && (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
289 | ReQueueEvent(req); | ||
290 | else | ||
291 | byContextDequeue(req); | ||
292 | } | ||
293 | return null; | ||
294 | }, null); | ||
295 | } | ||
296 | else | ||
297 | { | ||
298 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | ||
299 | { | ||
245 | m_threadPool.QueueWorkItem(x => | 300 | m_threadPool.QueueWorkItem(x => |
246 | { | 301 | { |
247 | try | 302 | try |
248 | { | 303 | { |
249 | req.DoHTTPGruntWork(m_server, responsedata); | 304 | req.DoHTTPGruntWork(m_server, |
250 | } | 305 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); |
251 | catch (ObjectDisposedException) | ||
252 | { | ||
253 | } | 306 | } |
307 | catch (ObjectDisposedException) {} | ||
254 | finally | 308 | finally |
255 | { | 309 | { |
256 | byContextDequeue(req); | 310 | byContextDequeue(req); |
@@ -260,39 +314,15 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
260 | } | 314 | } |
261 | else | 315 | else |
262 | { | 316 | { |
263 | if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) | 317 | ReQueueEvent(req); |
264 | { | ||
265 | m_threadPool.QueueWorkItem(x => | ||
266 | { | ||
267 | try | ||
268 | { | ||
269 | req.DoHTTPGruntWork(m_server, | ||
270 | req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); | ||
271 | } | ||
272 | catch (ObjectDisposedException) | ||
273 | { | ||
274 | // Ignore it, no need to reply | ||
275 | } | ||
276 | finally | ||
277 | { | ||
278 | byContextDequeue(req); | ||
279 | } | ||
280 | return null; | ||
281 | }, null); | ||
282 | } | ||
283 | else | ||
284 | { | ||
285 | ReQueueEvent(req); | ||
286 | } | ||
287 | } | 318 | } |
288 | } | 319 | } |
289 | catch (Exception e) | 320 | } |
290 | { | 321 | catch (Exception e) |
291 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); | 322 | { |
292 | } | 323 | m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); |
293 | } | 324 | } |
294 | } | 325 | } |
295 | } | 326 | } |
296 | |||
297 | } | 327 | } |
298 | } | 328 | } |
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 9b1d906..7ecd383 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs | |||
@@ -42,6 +42,7 @@ namespace OpenSim.Framework.Servers | |||
42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | private static BaseHttpServer instance = null; | 44 | private static BaseHttpServer instance = null; |
45 | private static BaseHttpServer unsecureinstance = null; | ||
45 | private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); | 46 | private static Dictionary<uint, BaseHttpServer> m_Servers = new Dictionary<uint, BaseHttpServer>(); |
46 | 47 | ||
47 | /// <summary> | 48 | /// <summary> |
@@ -93,6 +94,21 @@ namespace OpenSim.Framework.Servers | |||
93 | } | 94 | } |
94 | } | 95 | } |
95 | 96 | ||
97 | |||
98 | public static BaseHttpServer ÚnSecureInstance | ||
99 | { | ||
100 | get { return unsecureinstance; } | ||
101 | |||
102 | set | ||
103 | { | ||
104 | lock (m_Servers) | ||
105 | if (!m_Servers.ContainsValue(value)) | ||
106 | throw new Exception("HTTP server must already have been registered to be set as the main instance"); | ||
107 | |||
108 | unsecureinstance = value; | ||
109 | } | ||
110 | } | ||
111 | |||
96 | /// <summary> | 112 | /// <summary> |
97 | /// Get all the registered servers. | 113 | /// Get all the registered servers. |
98 | /// </summary> | 114 | /// </summary> |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 0862fcf..757e255 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -353,7 +353,18 @@ namespace OpenSim | |||
353 | if (startupConfig == null || startupConfig.GetBoolean("JobEngineEnabled", true)) | 353 | if (startupConfig == null || startupConfig.GetBoolean("JobEngineEnabled", true)) |
354 | WorkManager.JobEngine.Start(); | 354 | WorkManager.JobEngine.Start(); |
355 | 355 | ||
356 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; | 356 | |
357 | if(m_networkServersInfo.HttpUsesSSL) | ||
358 | { | ||
359 | m_httpServerSSL = true; | ||
360 | m_httpServerPort = m_networkServersInfo.httpSSLPort; | ||
361 | } | ||
362 | else | ||
363 | { | ||
364 | m_httpServerSSL = false; | ||
365 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; | ||
366 | } | ||
367 | |||
357 | SceneManager.OnRestartSim += HandleRestartRegion; | 368 | SceneManager.OnRestartSim += HandleRestartRegion; |
358 | 369 | ||
359 | // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is | 370 | // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is |
@@ -406,7 +417,18 @@ namespace OpenSim | |||
406 | 417 | ||
407 | // set initial ServerURI | 418 | // set initial ServerURI |
408 | regionInfo.HttpPort = m_httpServerPort; | 419 | regionInfo.HttpPort = m_httpServerPort; |
409 | regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort.ToString() + "/"; | 420 | if(m_httpServerSSL) |
421 | { | ||
422 | if(!m_httpServer.CheckSSLCertHost(regionInfo.ExternalHostName)) | ||
423 | throw new Exception("main http cert CN doesn't match region External IP"); | ||
424 | |||
425 | regionInfo.ServerURI = "https://" + regionInfo.ExternalHostName + | ||
426 | ":" + regionInfo.HttpPort.ToString() + "/"; | ||
427 | } | ||
428 | else | ||
429 | regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + | ||
430 | ":" + regionInfo.HttpPort.ToString() + "/"; | ||
431 | |||
410 | 432 | ||
411 | regionInfo.osSecret = m_osSecret; | 433 | regionInfo.osSecret = m_osSecret; |
412 | 434 | ||
@@ -1104,10 +1126,10 @@ namespace OpenSim | |||
1104 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); | 1126 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); |
1105 | } | 1127 | } |
1106 | } | 1128 | } |
1107 | } | 1129 | } |
1108 | 1130 | ||
1109 | return true; // need to update the database | 1131 | return true; // need to update the database |
1110 | } | 1132 | } |
1111 | } | 1133 | } |
1112 | 1134 | ||
1113 | public class OpenSimConfigSource | 1135 | public class OpenSimConfigSource |
diff --git a/OpenSim/Region/Application/RegionApplicationBase.cs b/OpenSim/Region/Application/RegionApplicationBase.cs index 83a9fff..7e8308e 100644 --- a/OpenSim/Region/Application/RegionApplicationBase.cs +++ b/OpenSim/Region/Application/RegionApplicationBase.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim | |||
50 | protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>(); | 50 | protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>(); |
51 | protected NetworkServersInfo m_networkServersInfo; | 51 | protected NetworkServersInfo m_networkServersInfo; |
52 | protected uint m_httpServerPort; | 52 | protected uint m_httpServerPort; |
53 | protected bool m_httpServerSSL; | ||
53 | protected ISimulationDataService m_simulationDataService; | 54 | protected ISimulationDataService m_simulationDataService; |
54 | protected IEstateDataService m_estateDataService; | 55 | protected IEstateDataService m_estateDataService; |
55 | 56 | ||
@@ -68,20 +69,37 @@ namespace OpenSim | |||
68 | 69 | ||
69 | Initialize(); | 70 | Initialize(); |
70 | 71 | ||
71 | m_httpServer | 72 | uint mainport = m_networkServersInfo.HttpListenerPort; |
72 | = new BaseHttpServer( | 73 | uint mainSSLport = m_networkServersInfo.httpSSLPort; |
73 | m_httpServerPort, m_networkServersInfo.HttpUsesSSL, m_networkServersInfo.httpSSLPort, | ||
74 | m_networkServersInfo.HttpSSLCN); | ||
75 | 74 | ||
76 | if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort)) | 75 | if (m_networkServersInfo.HttpUsesSSL && (mainport == mainSSLport)) |
77 | { | 76 | { |
78 | m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports"); | 77 | m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports"); |
79 | } | 78 | } |
80 | 79 | ||
81 | m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort); | 80 | if(m_networkServersInfo.HttpUsesSSL) |
82 | m_httpServer.Start(); | 81 | { |
82 | m_httpServer = new BaseHttpServer( | ||
83 | mainSSLport, m_networkServersInfo.HttpUsesSSL, | ||
84 | m_networkServersInfo.HttpSSLCN, | ||
85 | m_networkServersInfo.HttpSSLCertPath, m_networkServersInfo.HttpSSLCNCertPass); | ||
86 | m_httpServer.Start(true,true); | ||
87 | MainServer.AddHttpServer(m_httpServer); | ||
88 | } | ||
89 | |||
90 | // unsecure main server | ||
91 | BaseHttpServer server = new BaseHttpServer(mainport); | ||
92 | if(!m_networkServersInfo.HttpUsesSSL) | ||
93 | { | ||
94 | m_httpServer = server; | ||
95 | server.Start(true, true); | ||
96 | } | ||
97 | else | ||
98 | server.Start(false, false); | ||
99 | |||
100 | MainServer.AddHttpServer(server); | ||
101 | MainServer.ÚnSecureInstance = server; | ||
83 | 102 | ||
84 | MainServer.AddHttpServer(m_httpServer); | ||
85 | MainServer.Instance = m_httpServer; | 103 | MainServer.Instance = m_httpServer; |
86 | 104 | ||
87 | // "OOB" Server | 105 | // "OOB" Server |
@@ -89,22 +107,22 @@ namespace OpenSim | |||
89 | { | 107 | { |
90 | if (!m_networkServersInfo.ssl_external) | 108 | if (!m_networkServersInfo.ssl_external) |
91 | { | 109 | { |
92 | BaseHttpServer server = new BaseHttpServer( | 110 | server = new BaseHttpServer( |
93 | m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path, | 111 | m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, |
112 | m_networkServersInfo.cert_path, | ||
94 | m_networkServersInfo.cert_pass); | 113 | m_networkServersInfo.cert_pass); |
95 | 114 | ||
96 | m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port); | 115 | m_log.InfoFormat("[REGION SERVER]: Starting OOB HTTPS server on port {0}", server.SSLPort); |
116 | server.Start(false, false); | ||
97 | MainServer.AddHttpServer(server); | 117 | MainServer.AddHttpServer(server); |
98 | server.Start(); | ||
99 | } | 118 | } |
100 | else | 119 | else |
101 | { | 120 | { |
102 | BaseHttpServer server = new BaseHttpServer( | 121 | server = new BaseHttpServer(m_networkServersInfo.https_port); |
103 | m_networkServersInfo.https_port); | ||
104 | 122 | ||
105 | m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0} for external HTTPS", server.Port); | 123 | m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0} for external HTTPS", server.Port); |
124 | server.Start(false, false); | ||
106 | MainServer.AddHttpServer(server); | 125 | MainServer.AddHttpServer(server); |
107 | server.Start(); | ||
108 | } | 126 | } |
109 | } | 127 | } |
110 | 128 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 1feece1..aced734 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -372,7 +372,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
372 | 372 | ||
373 | caps.RegisterPollHandler( | 373 | caps.RegisterPollHandler( |
374 | "EventQueueGet", | 374 | "EventQueueGet", |
375 | new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); | 375 | new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, Drop, agentID, SERVER_EQ_TIME_NO_EVENTS)); |
376 | } | 376 | } |
377 | 377 | ||
378 | public bool HasEvents(UUID requestID, UUID agentID) | 378 | public bool HasEvents(UUID requestID, UUID agentID) |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index ee3f4f1..b23bffc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | |||
@@ -59,13 +59,12 @@ namespace OpenSim.Region.ClientStack.Linden.Tests | |||
59 | base.SetUp(); | 59 | base.SetUp(); |
60 | 60 | ||
61 | uint port = 9999; | 61 | uint port = 9999; |
62 | uint sslPort = 9998; | ||
63 | 62 | ||
64 | // This is an unfortunate bit of clean up we have to do because MainServer manages things through static | 63 | // This is an unfortunate bit of clean up we have to do because MainServer manages things through static |
65 | // variables and the VM is not restarted between tests. | 64 | // variables and the VM is not restarted between tests. |
66 | MainServer.RemoveHttpServer(port); | 65 | MainServer.RemoveHttpServer(port); |
67 | 66 | ||
68 | BaseHttpServer server = new BaseHttpServer(port, false, sslPort, ""); | 67 | BaseHttpServer server = new BaseHttpServer(port, false, "","",""); |
69 | MainServer.AddHttpServer(server); | 68 | MainServer.AddHttpServer(server); |
70 | MainServer.Instance = server; | 69 | MainServer.Instance = server; |
71 | 70 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 03f0a04..27db72c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |||
@@ -76,7 +76,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
76 | { | 76 | { |
77 | public Hashtable response; | 77 | public Hashtable response; |
78 | public int bytes; | 78 | public int bytes; |
79 | public int lod; | ||
80 | } | 79 | } |
81 | 80 | ||
82 | 81 | ||
@@ -231,11 +230,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
231 | new List<Hashtable>(); | 230 | new List<Hashtable>(); |
232 | private Dictionary<UUID, aPollResponse> responses = | 231 | private Dictionary<UUID, aPollResponse> responses = |
233 | new Dictionary<UUID, aPollResponse>(); | 232 | new Dictionary<UUID, aPollResponse>(); |
233 | private HashSet<UUID> dropedResponses = new HashSet<UUID>(); | ||
234 | 234 | ||
235 | private Scene m_scene; | 235 | private Scene m_scene; |
236 | private MeshCapsDataThrottler m_throttler; | 236 | private MeshCapsDataThrottler m_throttler; |
237 | public PollServiceMeshEventArgs(string uri, UUID pId, Scene scene) : | 237 | public PollServiceMeshEventArgs(string uri, UUID pId, Scene scene) : |
238 | base(null, uri, null, null, null, pId, int.MaxValue) | 238 | base(null, uri, null, null, null, null, pId, int.MaxValue) |
239 | { | 239 | { |
240 | m_scene = scene; | 240 | m_scene = scene; |
241 | m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId); | 241 | m_throttler = new MeshCapsDataThrottler(100000, 1400000, 10000, scene, pId); |
@@ -250,6 +250,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
250 | 250 | ||
251 | } | 251 | } |
252 | }; | 252 | }; |
253 | |||
254 | Drop = (x, y) => | ||
255 | { | ||
256 | lock (responses) | ||
257 | { | ||
258 | responses.Remove(x); | ||
259 | lock(dropedResponses) | ||
260 | dropedResponses.Add(x); | ||
261 | } | ||
262 | }; | ||
263 | |||
253 | GetEvents = (x, y) => | 264 | GetEvents = (x, y) => |
254 | { | 265 | { |
255 | lock (responses) | 266 | lock (responses) |
@@ -307,30 +318,48 @@ namespace OpenSim.Region.ClientStack.Linden | |||
307 | if(m_scene.ShuttingDown) | 318 | if(m_scene.ShuttingDown) |
308 | return; | 319 | return; |
309 | 320 | ||
310 | // If the avatar is gone, don't bother to get the texture | 321 | lock(responses) |
311 | if (m_scene.GetScenePresence(Id) == null) | ||
312 | { | 322 | { |
313 | response = new Hashtable(); | 323 | lock(dropedResponses) |
314 | 324 | { | |
315 | response["int_response_code"] = 500; | 325 | if(dropedResponses.Contains(requestID)) |
316 | response["str_response_string"] = "Script timeout"; | 326 | { |
317 | response["content_type"] = "text/plain"; | 327 | dropedResponses.Remove(requestID); |
318 | response["keepalive"] = false; | 328 | return; |
319 | response["reusecontext"] = false; | 329 | } |
330 | } | ||
331 | |||
332 | // If the avatar is gone, don't bother to get the texture | ||
333 | if (m_scene.GetScenePresence(Id) == null) | ||
334 | { | ||
335 | response = new Hashtable(); | ||
320 | 336 | ||
321 | lock (responses) | 337 | response["int_response_code"] = 500; |
322 | responses[requestID] = new aPollResponse() { bytes = 0, response = response, lod = 0 }; | 338 | response["str_response_string"] = "Script timeout"; |
339 | response["content_type"] = "text/plain"; | ||
340 | response["keepalive"] = false; | ||
341 | responses[requestID] = new aPollResponse() { bytes = 0, response = response}; | ||
323 | 342 | ||
324 | return; | 343 | return; |
344 | } | ||
325 | } | 345 | } |
326 | 346 | ||
327 | response = m_getMeshHandler.Handle(requestinfo.request); | 347 | response = m_getMeshHandler.Handle(requestinfo.request); |
348 | |||
328 | lock (responses) | 349 | lock (responses) |
329 | { | 350 | { |
351 | lock(dropedResponses) | ||
352 | { | ||
353 | if(dropedResponses.Contains(requestID)) | ||
354 | { | ||
355 | dropedResponses.Remove(requestID); | ||
356 | return; | ||
357 | } | ||
358 | } | ||
359 | |||
330 | responses[requestID] = new aPollResponse() | 360 | responses[requestID] = new aPollResponse() |
331 | { | 361 | { |
332 | bytes = (int)response["int_bytes"], | 362 | bytes = (int)response["int_bytes"], |
333 | lod = (int)response["int_lod"], | ||
334 | response = response | 363 | response = response |
335 | }; | 364 | }; |
336 | 365 | ||
@@ -399,7 +428,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
399 | private volatile int lastTimeElapsed = 0; | 428 | private volatile int lastTimeElapsed = 0; |
400 | private volatile int BytesSent = 0; | 429 | private volatile int BytesSent = 0; |
401 | private int CapSetThrottle = 0; | 430 | private int CapSetThrottle = 0; |
402 | private float CapThrottleDistributon = 0.30f; | ||
403 | private readonly Scene m_scene; | 431 | private readonly Scene m_scene; |
404 | private ThrottleOutPacketType Throttle; | 432 | private ThrottleOutPacketType Throttle; |
405 | private readonly UUID User; | 433 | private readonly UUID User; |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 8ef943c..d6b4873 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -218,11 +218,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
218 | new List<Hashtable>(); | 218 | new List<Hashtable>(); |
219 | private Dictionary<UUID, aPollResponse> responses = | 219 | private Dictionary<UUID, aPollResponse> responses = |
220 | new Dictionary<UUID, aPollResponse>(); | 220 | new Dictionary<UUID, aPollResponse>(); |
221 | private HashSet<UUID> dropedResponses = new HashSet<UUID>(); | ||
221 | 222 | ||
222 | private Scene m_scene; | 223 | private Scene m_scene; |
223 | private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000); | 224 | private CapsDataThrottler m_throttler = new CapsDataThrottler(100000, 1400000,10000); |
224 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : | 225 | public PollServiceTextureEventArgs(UUID pId, Scene scene) : |
225 | base(null, "", null, null, null, pId, int.MaxValue) | 226 | base(null, "", null, null, null, null, pId, int.MaxValue) |
226 | { | 227 | { |
227 | m_scene = scene; | 228 | m_scene = scene; |
228 | // x is request id, y is userid | 229 | // x is request id, y is userid |
@@ -236,6 +237,16 @@ namespace OpenSim.Region.ClientStack.Linden | |||
236 | 237 | ||
237 | } | 238 | } |
238 | }; | 239 | }; |
240 | |||
241 | Drop = (x, y) => | ||
242 | { | ||
243 | lock (responses) | ||
244 | { | ||
245 | responses.Remove(x); | ||
246 | dropedResponses.Add(x); | ||
247 | } | ||
248 | }; | ||
249 | |||
239 | GetEvents = (x, y) => | 250 | GetEvents = (x, y) => |
240 | { | 251 | { |
241 | lock (responses) | 252 | lock (responses) |
@@ -304,53 +315,72 @@ namespace OpenSim.Region.ClientStack.Linden | |||
304 | if(m_scene.ShuttingDown) | 315 | if(m_scene.ShuttingDown) |
305 | return; | 316 | return; |
306 | 317 | ||
307 | if (requestinfo.send503) | 318 | lock (responses) |
308 | { | 319 | { |
309 | response = new Hashtable(); | 320 | lock(dropedResponses) |
321 | { | ||
322 | if(dropedResponses.Contains(requestID)) | ||
323 | { | ||
324 | dropedResponses.Remove(requestID); | ||
325 | return; | ||
326 | } | ||
327 | } | ||
310 | 328 | ||
311 | response["int_response_code"] = 503; | 329 | if (requestinfo.send503) |
312 | response["str_response_string"] = "Throttled"; | 330 | { |
313 | response["content_type"] = "text/plain"; | 331 | response = new Hashtable(); |
314 | response["keepalive"] = false; | ||
315 | response["reusecontext"] = false; | ||
316 | 332 | ||
317 | Hashtable headers = new Hashtable(); | 333 | response["int_response_code"] = 503; |
318 | headers["Retry-After"] = 30; | 334 | response["str_response_string"] = "Throttled"; |
319 | response["headers"] = headers; | 335 | response["content_type"] = "text/plain"; |
336 | response["keepalive"] = false; | ||
337 | response["reusecontext"] = false; | ||
338 | |||
339 | Hashtable headers = new Hashtable(); | ||
340 | headers["Retry-After"] = 30; | ||
341 | response["headers"] = headers; | ||
320 | 342 | ||
321 | lock (responses) | ||
322 | responses[requestID] = new aPollResponse() {bytes = 0, response = response}; | 343 | responses[requestID] = new aPollResponse() {bytes = 0, response = response}; |
323 | 344 | ||
324 | return; | 345 | return; |
325 | } | 346 | } |
326 | 347 | ||
327 | // If the avatar is gone, don't bother to get the texture | 348 | // If the avatar is gone, don't bother to get the texture |
328 | if (m_scene.GetScenePresence(Id) == null) | 349 | if (m_scene.GetScenePresence(Id) == null) |
329 | { | 350 | { |
330 | response = new Hashtable(); | 351 | response = new Hashtable(); |
331 | 352 | ||
332 | response["int_response_code"] = 500; | 353 | response["int_response_code"] = 500; |
333 | response["str_response_string"] = "Script timeout"; | 354 | response["str_response_string"] = "Script timeout"; |
334 | response["content_type"] = "text/plain"; | 355 | response["content_type"] = "text/plain"; |
335 | response["keepalive"] = false; | 356 | response["keepalive"] = false; |
336 | response["reusecontext"] = false; | 357 | response["reusecontext"] = false; |
337 | 358 | ||
338 | lock (responses) | ||
339 | responses[requestID] = new aPollResponse() {bytes = 0, response = response}; | 359 | responses[requestID] = new aPollResponse() {bytes = 0, response = response}; |
340 | 360 | ||
341 | return; | 361 | return; |
362 | } | ||
342 | } | 363 | } |
343 | 364 | ||
344 | response = m_getTextureHandler.Handle(requestinfo.request); | 365 | response = m_getTextureHandler.Handle(requestinfo.request); |
366 | |||
345 | lock (responses) | 367 | lock (responses) |
346 | { | 368 | { |
369 | lock(dropedResponses) | ||
370 | { | ||
371 | if(dropedResponses.Contains(requestID)) | ||
372 | { | ||
373 | dropedResponses.Remove(requestID); | ||
374 | m_throttler.ProcessTime(); | ||
375 | return; | ||
376 | } | ||
377 | } | ||
347 | responses[requestID] = new aPollResponse() | 378 | responses[requestID] = new aPollResponse() |
348 | { | 379 | { |
349 | bytes = (int) response["int_bytes"], | 380 | bytes = (int) response["int_bytes"], |
350 | response = response | 381 | response = response |
351 | }; | 382 | }; |
352 | 383 | } | |
353 | } | ||
354 | m_throttler.ProcessTime(); | 384 | m_throttler.ProcessTime(); |
355 | } | 385 | } |
356 | 386 | ||
@@ -426,7 +456,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
426 | 456 | ||
427 | internal sealed class CapsDataThrottler | 457 | internal sealed class CapsDataThrottler |
428 | { | 458 | { |
429 | |||
430 | private volatile int currenttime = 0; | 459 | private volatile int currenttime = 0; |
431 | private volatile int lastTimeElapsed = 0; | 460 | private volatile int lastTimeElapsed = 0; |
432 | private volatile int BytesSent = 0; | 461 | private volatile int BytesSent = 0; |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 23ec141..422c354 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |||
@@ -61,7 +61,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
61 | public UUID reqID; | 61 | public UUID reqID; |
62 | public Hashtable request; | 62 | public Hashtable request; |
63 | public ScenePresence presence; | 63 | public ScenePresence presence; |
64 | public List<UUID> folders; | ||
65 | } | 64 | } |
66 | 65 | ||
67 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 66 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -250,17 +249,28 @@ namespace OpenSim.Region.ClientStack.Linden | |||
250 | { | 249 | { |
251 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 250 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
252 | 251 | ||
253 | private Dictionary<UUID, Hashtable> responses = | 252 | private Dictionary<UUID, Hashtable> responses = new Dictionary<UUID, Hashtable>(); |
254 | new Dictionary<UUID, Hashtable>(); | 253 | private HashSet<UUID> dropedResponses = new HashSet<UUID>(); |
255 | 254 | ||
256 | private WebFetchInvDescModule m_module; | 255 | private WebFetchInvDescModule m_module; |
257 | 256 | ||
258 | public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) : | 257 | public PollServiceInventoryEventArgs(WebFetchInvDescModule module, string url, UUID pId) : |
259 | base(null, url, null, null, null, pId, int.MaxValue) | 258 | base(null, url, null, null, null, null, pId, int.MaxValue) |
260 | { | 259 | { |
261 | m_module = module; | 260 | m_module = module; |
262 | 261 | ||
263 | HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; | 262 | HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; |
263 | |||
264 | Drop = (x, y) => | ||
265 | { | ||
266 | lock (responses) | ||
267 | { | ||
268 | responses.Remove(x); | ||
269 | lock(dropedResponses) | ||
270 | dropedResponses.Add(x); | ||
271 | } | ||
272 | }; | ||
273 | |||
264 | GetEvents = (x, y) => | 274 | GetEvents = (x, y) => |
265 | { | 275 | { |
266 | lock (responses) | 276 | lock (responses) |
@@ -285,8 +295,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
285 | reqinfo.reqID = x; | 295 | reqinfo.reqID = x; |
286 | reqinfo.request = y; | 296 | reqinfo.request = y; |
287 | reqinfo.presence = sp; | 297 | reqinfo.presence = sp; |
288 | reqinfo.folders = new List<UUID>(); | ||
289 | 298 | ||
299 | /* why where we doing this? just to get cof ? | ||
300 | List<UUID> folders = new List<UUID>(); | ||
301 | |||
290 | // Decode the request here | 302 | // Decode the request here |
291 | string request = y["body"].ToString(); | 303 | string request = y["body"].ToString(); |
292 | 304 | ||
@@ -322,11 +334,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
322 | UUID folderID; | 334 | UUID folderID; |
323 | if (UUID.TryParse(folder, out folderID)) | 335 | if (UUID.TryParse(folder, out folderID)) |
324 | { | 336 | { |
325 | if (!reqinfo.folders.Contains(folderID)) | 337 | if (!folders.Contains(folderID)) |
326 | { | 338 | { |
327 | if (sp.COF != UUID.Zero && sp.COF == folderID) | 339 | if (sp.COF != UUID.Zero && sp.COF == folderID) |
328 | highPriority = true; | 340 | highPriority = true; |
329 | reqinfo.folders.Add(folderID); | 341 | folders.Add(folderID); |
330 | } | 342 | } |
331 | } | 343 | } |
332 | } | 344 | } |
@@ -334,6 +346,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
334 | if (highPriority) | 346 | if (highPriority) |
335 | m_queue.PriorityEnqueue(reqinfo); | 347 | m_queue.PriorityEnqueue(reqinfo); |
336 | else | 348 | else |
349 | */ | ||
337 | m_queue.Enqueue(reqinfo); | 350 | m_queue.Enqueue(reqinfo); |
338 | }; | 351 | }; |
339 | 352 | ||
@@ -365,6 +378,19 @@ namespace OpenSim.Region.ClientStack.Linden | |||
365 | 378 | ||
366 | UUID requestID = requestinfo.reqID; | 379 | UUID requestID = requestinfo.reqID; |
367 | 380 | ||
381 | |||
382 | lock(responses) | ||
383 | { | ||
384 | lock(dropedResponses) | ||
385 | { | ||
386 | if(dropedResponses.Contains(requestID)) | ||
387 | { | ||
388 | dropedResponses.Remove(requestID); | ||
389 | return; | ||
390 | } | ||
391 | } | ||
392 | } | ||
393 | |||
368 | Hashtable response = new Hashtable(); | 394 | Hashtable response = new Hashtable(); |
369 | 395 | ||
370 | response["int_response_code"] = 200; | 396 | response["int_response_code"] = 200; |
@@ -377,11 +403,21 @@ namespace OpenSim.Region.ClientStack.Linden | |||
377 | 403 | ||
378 | lock (responses) | 404 | lock (responses) |
379 | { | 405 | { |
406 | lock(dropedResponses) | ||
407 | { | ||
408 | if(dropedResponses.Contains(requestID)) | ||
409 | { | ||
410 | dropedResponses.Remove(requestID); | ||
411 | requestinfo.request.Clear(); | ||
412 | WebFetchInvDescModule.ProcessedRequestsCount++; | ||
413 | return; | ||
414 | } | ||
415 | } | ||
416 | |||
380 | if (responses.ContainsKey(requestID)) | 417 | if (responses.ContainsKey(requestID)) |
381 | m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); | 418 | m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054"); |
382 | responses[requestID] = response; | 419 | responses[requestID] = response; |
383 | } | 420 | } |
384 | requestinfo.folders.Clear(); | ||
385 | requestinfo.request.Clear(); | 421 | requestinfo.request.Clear(); |
386 | WebFetchInvDescModule.ProcessedRequestsCount++; | 422 | WebFetchInvDescModule.ProcessedRequestsCount++; |
387 | } | 423 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 895020c..66ebdbe 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -273,7 +273,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
273 | string uri = "/lslhttp/" + urlcode.ToString() + "/"; | 273 | string uri = "/lslhttp/" + urlcode.ToString() + "/"; |
274 | 274 | ||
275 | PollServiceEventArgs args | 275 | PollServiceEventArgs args |
276 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); | 276 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, Drop, urlcode, 25000); |
277 | args.Type = PollServiceEventArgs.EventType.LslHttp; | 277 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
278 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); | 278 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); |
279 | 279 | ||
@@ -331,7 +331,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
331 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; | 331 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; |
332 | 332 | ||
333 | PollServiceEventArgs args | 333 | PollServiceEventArgs args |
334 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); | 334 | = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, Drop, urlcode, 25000); |
335 | args.Type = PollServiceEventArgs.EventType.LslHttp; | 335 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
336 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); | 336 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); |
337 | 337 | ||
@@ -585,6 +585,28 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
585 | } | 585 | } |
586 | } | 586 | } |
587 | } | 587 | } |
588 | |||
589 | protected void Drop(UUID requestID, UUID sessionID) | ||
590 | { | ||
591 | UrlData url = null; | ||
592 | lock (m_RequestMap) | ||
593 | { | ||
594 | if (m_RequestMap.ContainsKey(requestID)) | ||
595 | { | ||
596 | url = m_RequestMap[requestID]; | ||
597 | m_RequestMap.Remove(requestID); | ||
598 | if(url != null) | ||
599 | { | ||
600 | lock (url.requests) | ||
601 | { | ||
602 | if(url.requests.ContainsKey(requestID)) | ||
603 | url.requests.Remove(requestID); | ||
604 | } | ||
605 | } | ||
606 | } | ||
607 | } | ||
608 | } | ||
609 | |||
588 | protected Hashtable GetEvents(UUID requestID, UUID sessionID) | 610 | protected Hashtable GetEvents(UUID requestID, UUID sessionID) |
589 | { | 611 | { |
590 | UrlData url = null; | 612 | UrlData url = null; |
@@ -744,9 +766,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
744 | else | 766 | else |
745 | { | 767 | { |
746 | queryString = queryString + val + "&"; | 768 | queryString = queryString + val + "&"; |
747 | } | ||
748 | } | 769 | } |
749 | } | 770 | } |
771 | } | ||
750 | if (queryString.Length > 1) | 772 | if (queryString.Length > 1) |
751 | queryString = queryString.Substring(0, queryString.Length - 1); | 773 | queryString = queryString.Substring(0, queryString.Length - 1); |
752 | 774 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 23da90a..60efc04 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -236,8 +236,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
236 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 236 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
237 | foreach (TaskInventoryItem item in items) | 237 | foreach (TaskInventoryItem item in items) |
238 | { | 238 | { |
239 | item.GroupID = groupID; | 239 | item.GroupID = groupID; |
240 | } | 240 | } |
241 | m_items.LockItemsForWrite(false); | 241 | m_items.LockItemsForWrite(false); |
242 | } | 242 | } |
243 | 243 | ||
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs index 50276ae..9273b20 100644 --- a/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs +++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataRequestHandler.cs | |||
@@ -52,12 +52,12 @@ namespace OpenSim.Region.DataSnapshot | |||
52 | m_externalData = externalData; | 52 | m_externalData = externalData; |
53 | 53 | ||
54 | //Register HTTP handler | 54 | //Register HTTP handler |
55 | if (MainServer.Instance.AddHTTPHandler("collector", OnGetSnapshot)) | 55 | if (MainServer.ÚnSecureInstance.AddHTTPHandler("collector", OnGetSnapshot)) |
56 | { | 56 | { |
57 | m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); | 57 | m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); |
58 | } | 58 | } |
59 | // Register validation callback handler | 59 | // Register validation callback handler |
60 | MainServer.Instance.AddHTTPHandler("validate", OnValidate); | 60 | MainServer.ÚnSecureInstance.AddHTTPHandler("validate", OnValidate); |
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs index 241a24d..bafc0b3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiHttpTests.cs | |||
@@ -95,7 +95,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
95 | config.Configs["Network"].Set("ExternalHostNameForLSL", "127.0.0.1"); | 95 | config.Configs["Network"].Set("ExternalHostNameForLSL", "127.0.0.1"); |
96 | m_scene = new SceneHelpers().SetupScene(); | 96 | m_scene = new SceneHelpers().SetupScene(); |
97 | 97 | ||
98 | BaseHttpServer server = new BaseHttpServer(port, false, 0, ""); | 98 | BaseHttpServer server = new BaseHttpServer(port); |
99 | MainServer.AddHttpServer(server); | 99 | MainServer.AddHttpServer(server); |
100 | MainServer.Instance = server; | 100 | MainServer.Instance = server; |
101 | 101 | ||
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs index accf938..5c99ab7 100644 --- a/OpenSim/Server/ServerMain.cs +++ b/OpenSim/Server/ServerMain.cs | |||
@@ -30,6 +30,8 @@ using log4net; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System; | 31 | using System; |
32 | using System.Net; | 32 | using System.Net; |
33 | using System.Net.Security; | ||
34 | using System.Security.Cryptography.X509Certificates; | ||
33 | using System.Collections.Generic; | 35 | using System.Collections.Generic; |
34 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
@@ -52,12 +54,33 @@ namespace OpenSim.Server | |||
52 | new List<IServiceConnector>(); | 54 | new List<IServiceConnector>(); |
53 | 55 | ||
54 | protected static PluginLoader loader; | 56 | protected static PluginLoader loader; |
57 | private static bool m_NoVerifyCertChain = false; | ||
58 | private static bool m_NoVerifyCertHostname = false; | ||
59 | |||
60 | public static bool ValidateServerCertificate( | ||
61 | object sender, | ||
62 | X509Certificate certificate, | ||
63 | X509Chain chain, | ||
64 | SslPolicyErrors sslPolicyErrors) | ||
65 | { | ||
66 | if (m_NoVerifyCertChain) | ||
67 | sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateChainErrors; | ||
68 | |||
69 | if (m_NoVerifyCertHostname) | ||
70 | sslPolicyErrors &= ~SslPolicyErrors.RemoteCertificateNameMismatch; | ||
71 | |||
72 | if (sslPolicyErrors == SslPolicyErrors.None) | ||
73 | return true; | ||
74 | |||
75 | return false; | ||
76 | } | ||
55 | 77 | ||
56 | public static int Main(string[] args) | 78 | public static int Main(string[] args) |
57 | { | 79 | { |
58 | ServicePointManager.DefaultConnectionLimit = 64; | 80 | ServicePointManager.DefaultConnectionLimit = 64; |
59 | ServicePointManager.Expect100Continue = false; | 81 | ServicePointManager.Expect100Continue = false; |
60 | ServicePointManager.UseNagleAlgorithm = false; | 82 | ServicePointManager.UseNagleAlgorithm = false; |
83 | ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; | ||
61 | 84 | ||
62 | try { ServicePointManager.DnsRefreshTimeout = 120000; } // just is case some mono decides to have it infinity | 85 | try { ServicePointManager.DnsRefreshTimeout = 120000; } // just is case some mono decides to have it infinity |
63 | catch { } | 86 | catch { } |
@@ -73,6 +96,10 @@ namespace OpenSim.Server | |||
73 | throw new Exception("Configuration error"); | 96 | throw new Exception("Configuration error"); |
74 | } | 97 | } |
75 | 98 | ||
99 | m_NoVerifyCertChain = serverConfig.GetBoolean("NoVerifyCertChain", m_NoVerifyCertChain); | ||
100 | m_NoVerifyCertHostname = serverConfig.GetBoolean("NoVerifyCertHostname", m_NoVerifyCertHostname); | ||
101 | |||
102 | |||
76 | string connList = serverConfig.GetString("ServiceConnectors", String.Empty); | 103 | string connList = serverConfig.GetString("ServiceConnectors", String.Empty); |
77 | 104 | ||
78 | registryLocation = serverConfig.GetString("RegistryLocation","."); | 105 | registryLocation = serverConfig.GetString("RegistryLocation","."); |