aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/RegionLoader
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs4
-rw-r--r--OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs68
2 files changed, 51 insertions, 21 deletions
diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs
index 0aae4ff..8332c14 100644
--- a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs
+++ b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs
@@ -48,11 +48,13 @@ namespace OpenSim.Framework.RegionLoader.Filesystem
48 public RegionInfo[] LoadRegions() 48 public RegionInfo[] LoadRegions()
49 { 49 {
50 string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); 50 string regionConfigPath = Path.Combine(Util.configDir(), "Regions");
51 bool allowRegionless = false;
51 52
52 try 53 try
53 { 54 {
54 IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"]; 55 IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"];
55 regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim(); 56 regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim();
57 allowRegionless = startupConfig.GetBoolean("allow_regionless", false);
56 } 58 }
57 catch (Exception) 59 catch (Exception)
58 { 60 {
@@ -68,7 +70,7 @@ namespace OpenSim.Framework.RegionLoader.Filesystem
68 string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); 70 string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
69 71
70 // Create an empty Regions.ini if there are no existing config files. 72 // Create an empty Regions.ini if there are no existing config files.
71 if (configFiles.Length == 0 && iniFiles.Length == 0) 73 if (!allowRegionless && configFiles.Length == 0 && iniFiles.Length == 0)
72 { 74 {
73 new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource); 75 new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource);
74 iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); 76 iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
index de4898a..a2f5d9c 100644
--- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
+++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
@@ -57,6 +57,8 @@ namespace OpenSim.Framework.RegionLoader.Web
57 { 57 {
58 IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"]; 58 IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"];
59 string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim(); 59 string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim();
60 bool allowRegionless = startupConfig.GetBoolean("allow_regionless", false);
61
60 if (url == String.Empty) 62 if (url == String.Empty)
61 { 63 {
62 m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty."); 64 m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty.");
@@ -64,37 +66,63 @@ namespace OpenSim.Framework.RegionLoader.Web
64 } 66 }
65 else 67 else
66 { 68 {
69 RegionInfo[] regionInfos = new RegionInfo[] {};
70 int regionCount = 0;
67 HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); 71 HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url);
68 webRequest.Timeout = 30000; //30 Second Timeout 72 webRequest.Timeout = 30000; //30 Second Timeout
69 m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url); 73 m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url);
70 HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); 74
71 m_log.Debug("[WEBLOADER]: Downloading region information..."); 75 try
72 StreamReader reader = new StreamReader(webResponse.GetResponseStream());
73 string xmlSource = String.Empty;
74 string tempStr = reader.ReadLine();
75 while (tempStr != null)
76 { 76 {
77 xmlSource = xmlSource + tempStr; 77 HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
78 tempStr = reader.ReadLine(); 78 m_log.Debug("[WEBLOADER]: Downloading region information...");
79 StreamReader reader = new StreamReader(webResponse.GetResponseStream());
80 string xmlSource = String.Empty;
81 string tempStr = reader.ReadLine();
82 while (tempStr != null)
83 {
84 xmlSource = xmlSource + tempStr;
85 tempStr = reader.ReadLine();
86 }
87 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
88 xmlSource.Length);
89 XmlDocument xmlDoc = new XmlDocument();
90 xmlDoc.LoadXml(xmlSource);
91 if (xmlDoc.FirstChild.Name == "Regions")
92 {
93 regionCount = xmlDoc.FirstChild.ChildNodes.Count;
94
95 if (regionCount > 0)
96 {
97 regionInfos = new RegionInfo[regionCount];
98 int i;
99 for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
100 {
101 m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml);
102 regionInfos[i] =
103 new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource);
104 }
105 }
106 }
79 } 107 }
80 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + 108 catch (WebException ex)
81 xmlSource.Length);
82 XmlDocument xmlDoc = new XmlDocument();
83 xmlDoc.LoadXml(xmlSource);
84 if (xmlDoc.FirstChild.Name == "Regions")
85 { 109 {
86 RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count]; 110 if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound)
87 int i;
88 for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
89 { 111 {
90 m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); 112 if (!allowRegionless)
91 regionInfos[i] = 113 throw ex;
92 new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource);
93 } 114 }
115 else
116 throw ex;
117 }
94 118
119 if (regionCount > 0 | allowRegionless)
95 return regionInfos; 120 return regionInfos;
121 else
122 {
123 m_log.Error("[WEBLOADER]: No region configs were available.");
124 return null;
96 } 125 }
97 return null;
98 } 126 }
99 } 127 }
100 } 128 }