aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/RegionInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.RegionServer/RegionInfo.cs380
1 files changed, 0 insertions, 380 deletions
diff --git a/OpenSim/OpenSim.RegionServer/RegionInfo.cs b/OpenSim/OpenSim.RegionServer/RegionInfo.cs
deleted file mode 100644
index de1750c..0000000
--- a/OpenSim/OpenSim.RegionServer/RegionInfo.cs
+++ /dev/null
@@ -1,380 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using System.Globalization;
32using System.Net;
33using System.Web;
34using System.IO;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Utilities;
37using libsecondlife;
38
39namespace OpenSim.RegionServer
40{
41 public class RegionInfo : RegionInfoBase
42 {
43 //following should be removed and the GenericConfig object passed around,
44 //so each class (AssetServer, GridServer etc) can access what config data they want
45 public string AssetURL = "http://127.0.0.1:8003/";
46 public string AssetSendKey = "";
47
48 public string GridURL = "";
49 public string GridSendKey = "";
50 public string GridRecvKey = "";
51 public string UserURL = "";
52 public string UserSendKey = "";
53 public string UserRecvKey = "";
54 private bool isSandbox;
55
56 public string MasterAvatarFirstName = "";
57 public string MasterAvatarLastName = "";
58 public string MasterAvatarSandboxPassword = "";
59 public LLUUID MasterAvatarAssignedUUID = LLUUID.Zero;
60
61 public string DataStore;
62
63 public RegionInfo()
64 {
65
66 }
67
68 public void SaveToGrid()
69 {
70 //we really want to keep any server connection code out of here and out of the code code
71 // and put it in the server connection classes (those inheriting from IGridServer etc)
72 string reqtext;
73 reqtext = "<Root>";
74 reqtext += "<authkey>" + this.GridSendKey + "</authkey>";
75 reqtext += "<sim>";
76 reqtext += "<uuid>" + this.SimUUID.ToString() + "</uuid>";
77 reqtext += "<regionname>" + this.RegionName + "</regionname>";
78 reqtext += "<sim_ip>" + this.IPListenAddr + "</sim_ip>";
79 reqtext += "<sim_port>" + this.IPListenPort.ToString() + "</sim_port>";
80 reqtext += "<region_locx>" + this.RegionLocX.ToString() + "</region_locx>";
81 reqtext += "<region_locy>" + this.RegionLocY.ToString() + "</region_locy>";
82 reqtext += "<estate_id>1</estate_id>";
83 reqtext += "</sim>";
84 reqtext += "</Root>";
85
86 byte[] reqdata = (new System.Text.ASCIIEncoding()).GetBytes(reqtext);
87 string newpath = "";
88 if (this.GridURL.EndsWith("/"))
89 {
90 newpath = this.GridURL + "sims/";
91 }
92 else
93 {
94 newpath = this.GridURL + "/sims/";
95 }
96
97 WebRequest GridSaveReq = WebRequest.Create(newpath + this.SimUUID.ToString());
98 GridSaveReq.Method = "POST";
99 GridSaveReq.ContentType = "application/x-www-form-urlencoded";
100 GridSaveReq.ContentLength = reqdata.Length;
101
102 Stream stOut = GridSaveReq.GetRequestStream();
103 stOut.Write(reqdata, 0, reqdata.Length);
104 stOut.Close();
105
106 WebResponse gridresp = GridSaveReq.GetResponse();
107 StreamReader stIn = new StreamReader(gridresp.GetResponseStream(), Encoding.ASCII);
108 string GridResponse = stIn.ReadToEnd();
109 stIn.Close();
110 gridresp.Close();
111
112 OpenSim.Framework.Console.MainConsole.Instance.Verbose("RegionInfo.CS:SaveToGrid() - Grid said: " + GridResponse);
113 }
114
115 public void InitConfig(bool sandboxMode, IGenericConfig configData)
116 {
117 this.isSandbox = sandboxMode;
118 try
119 {
120 // Sim UUID
121 string attri = "";
122 attri = configData.GetAttribute("SimUUID");
123 if (attri == "")
124 {
125 this.SimUUID = LLUUID.Random();
126 configData.SetAttribute("SimUUID", this.SimUUID.ToString());
127 }
128 else
129 {
130 this.SimUUID = new LLUUID(attri);
131 }
132
133 // Sim name
134 attri = "";
135 attri = configData.GetAttribute("SimName");
136 if (attri == "")
137 {
138 this.RegionName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: Simulator Name", "OpenSim Island");
139 configData.SetAttribute("SimName", this.RegionName);
140 }
141 else
142 {
143 this.RegionName = attri;
144 }
145 // Sim/Grid location X
146 attri = "";
147 attri = configData.GetAttribute("SimLocationX");
148 if (attri == "")
149 {
150 string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: Grid Location X", "997");
151 configData.SetAttribute("SimLocationX", location);
152 this.RegionLocX = (uint)Convert.ToUInt32(location);
153 }
154 else
155 {
156 this.RegionLocX = (uint)Convert.ToUInt32(attri);
157 }
158 // Sim/Grid location Y
159 attri = "";
160 attri = configData.GetAttribute("SimLocationY");
161 if (attri == "")
162 {
163 string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: Grid Location Y", "996");
164 configData.SetAttribute("SimLocationY", location);
165 this.RegionLocY = (uint)Convert.ToUInt32(location);
166 }
167 else
168 {
169 this.RegionLocY = (uint)Convert.ToUInt32(attri);
170 }
171
172 // Local storage datastore
173 attri = "";
174 attri = configData.GetAttribute("Datastore");
175 if (attri == "")
176 {
177 string datastore = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: Filename for local world storage", "localworld.yap");
178 configData.SetAttribute("Datastore", datastore);
179 this.DataStore = datastore;
180 }
181 else
182 {
183 this.DataStore = attri;
184 }
185
186 //Sim Listen Port
187 attri = "";
188 attri = configData.GetAttribute("SimListenPort");
189 if (attri == "")
190 {
191 string port = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: UDP port for client connections", "9000");
192 configData.SetAttribute("SimListenPort", port);
193 this.IPListenPort = Convert.ToInt32(port);
194 }
195 else
196 {
197 this.IPListenPort = Convert.ToInt32(attri);
198 }
199 //Sim Listen Address
200 attri = "";
201 attri = configData.GetAttribute("SimListenAddress");
202 if (attri == "")
203 {
204 this.IPListenAddr = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: IP Address to listen on for client connections", "127.0.0.1");
205 configData.SetAttribute("SimListenAddress", this.IPListenAddr);
206 }
207 else
208 {
209 // Probably belongs elsewhere, but oh well.
210 if (attri.Trim().StartsWith("SYSTEMIP"))
211 {
212 string localhostname = System.Net.Dns.GetHostName();
213 System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(localhostname);
214 try
215 {
216 this.IPListenAddr = ips[0].ToString();
217 }
218 catch (Exception e)
219 {
220 e.ToString();
221 this.IPListenAddr = "127.0.0.1"; // Use the default if we fail
222 }
223 }
224 else
225 {
226 this.IPListenAddr = attri;
227 }
228 }
229
230 // Terrain Default File
231 attri = "";
232 attri = configData.GetAttribute("TerrainFile");
233 if (attri == "")
234 {
235 this.estateSettings.terrainFile = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: Default Terrain File", "default.r32");
236 configData.SetAttribute("TerrainFile", this.estateSettings.terrainFile);
237 }
238 else
239 {
240 this.estateSettings.terrainFile = attri;
241 }
242
243 attri = "";
244 attri = configData.GetAttribute("TerrainMultiplier");
245 if (attri == "")
246 {
247 string re = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: Terrain Height Multiplier", "60.0");
248 this.estateSettings.terrainMultiplier = Convert.ToDouble(re, CultureInfo.InvariantCulture);
249 configData.SetAttribute("TerrainMultiplier", this.estateSettings.terrainMultiplier.ToString());
250 }
251 else
252 {
253 this.estateSettings.terrainMultiplier = Convert.ToDouble(attri);
254 }
255
256 attri = "";
257 attri = configData.GetAttribute("MasterAvatarFirstName");
258 if (attri == "")
259 {
260 this.MasterAvatarFirstName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: First name of Master Avatar", "Test");
261
262 configData.SetAttribute("MasterAvatarFirstName", this.MasterAvatarFirstName);
263 }
264 else
265 {
266 this.MasterAvatarFirstName = attri;
267 }
268
269 attri = "";
270 attri = configData.GetAttribute("MasterAvatarLastName");
271 if (attri == "")
272 {
273 this.MasterAvatarLastName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GENERAL SETTING: Last name of Master Avatar", "User");
274
275 configData.SetAttribute("MasterAvatarLastName", this.MasterAvatarLastName);
276 }
277 else
278 {
279 this.MasterAvatarLastName = attri;
280 }
281
282 if (isSandbox) //Sandbox Mode Settings
283 {
284 attri = "";
285 attri = configData.GetAttribute("MasterAvatarSandboxPassword");
286 if (attri == "")
287 {
288 this.MasterAvatarSandboxPassword = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("SANDBOX MODE SETTING: Password of Master Avatar", "test");
289
290 configData.SetAttribute("MasterAvatarSandboxPassword", this.MasterAvatarSandboxPassword);
291 }
292 else
293 {
294 this.MasterAvatarSandboxPassword = attri;
295 }
296 }
297 else //Grid Mode Settings
298 {
299 //shouldn't be reading this data in here, it should be up to the classes implementing the server interfaces to read what they need from the config object
300
301 //Grid Server URL
302 attri = "";
303 attri = configData.GetAttribute("GridServerURL");
304 if (attri == "")
305 {
306 this.GridURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GRID MODE SETTING: Grid server URL", "http://127.0.0.1:8001/");
307 configData.SetAttribute("GridServerURL", this.GridURL);
308 }
309 else
310 {
311 this.GridURL = attri;
312 }
313
314 //Grid Send Key
315 attri = "";
316 attri = configData.GetAttribute("GridSendKey");
317 if (attri == "")
318 {
319 this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GRID MODE SETTING: Key to send to grid server", "null");
320 configData.SetAttribute("GridSendKey", this.GridSendKey);
321 }
322 else
323 {
324 this.GridSendKey = attri;
325 }
326
327 //Grid Receive Key
328 attri = "";
329 attri = configData.GetAttribute("GridRecvKey");
330 if (attri == "")
331 {
332 this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GRID MODE SETTING: Key to expect from grid server", "null");
333 configData.SetAttribute("GridRecvKey", this.GridRecvKey);
334 }
335 else
336 {
337 this.GridRecvKey = attri;
338 }
339
340 attri = "";
341 attri = configData.GetAttribute("AssetServerURL");
342 if (attri == "")
343 {
344 this.AssetURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("GRID MODE SETTING: Asset server URL", "http://127.0.0.1:8003/");
345 configData.SetAttribute("AssetServerURL", this.AssetURL);
346 }
347 else
348 {
349 this.AssetURL = attri;
350 }
351
352 }
353
354 this.RegionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
355 if (!this.isSandbox)
356 {
357 this.SaveToGrid();
358 }
359 configData.Commit();
360 }
361 catch (Exception e)
362 {
363 OpenSim.Framework.Console.MainConsole.Instance.Warn("Config.cs:InitConfig() - Exception occured");
364 OpenSim.Framework.Console.MainConsole.Instance.Warn(e.ToString());
365 }
366
367 OpenSim.Framework.Console.MainConsole.Instance.Verbose("Simulator Settings Loaded");
368 /* MainConsole.Instance.Notice("UUID: " + this.SimUUID.ToStringHyphenated());
369 MainConsole.Instance.Notice("Name: " + this.RegionName);
370 MainConsole.Instance.Notice("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
371 MainConsole.Instance.Notice("Region Handle: " + this.RegionHandle.ToString());
372 MainConsole.Instance.Notice("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
373 MainConsole.Instance.Notice("Sandbox Mode? " + isSandbox.ToString());
374 MainConsole.Instance.Notice("Asset URL: " + this.AssetURL);
375 MainConsole.Instance.Notice("Asset key: " + this.AssetSendKey);
376 MainConsole.Instance.Notice("Grid URL: " + this.GridURL);
377 MainConsole.Instance.Notice("Grid key: " + this.GridSendKey); */
378 }
379 }
380}