aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/General/RegionInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/General/RegionInfo.cs')
-rw-r--r--OpenSim/Framework/General/RegionInfo.cs328
1 files changed, 0 insertions, 328 deletions
diff --git a/OpenSim/Framework/General/RegionInfo.cs b/OpenSim/Framework/General/RegionInfo.cs
deleted file mode 100644
index 1257849..0000000
--- a/OpenSim/Framework/General/RegionInfo.cs
+++ /dev/null
@@ -1,328 +0,0 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Net;
30using System.Net.Sockets;
31using libsecondlife;
32using Nini.Config;
33
34namespace OpenSim.Framework
35{
36 public class SimpleRegionInfo
37 {
38 public SimpleRegionInfo()
39 {
40 }
41
42 public SimpleRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri)
43 {
44 m_regionLocX = regionLocX;
45 m_regionLocY = regionLocY;
46
47 m_internalEndPoint = internalEndPoint;
48 m_externalHostName = externalUri;
49 }
50
51 public SimpleRegionInfo(uint regionLocX, uint regionLocY, string externalUri, int port)
52 {
53 m_regionLocX = regionLocX;
54 m_regionLocY = regionLocY;
55
56 m_externalHostName = externalUri;
57
58 m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
59 }
60
61 public LLUUID RegionID = new LLUUID();
62
63 private uint m_remotingPort;
64
65 public uint RemotingPort
66 {
67 get { return m_remotingPort; }
68 set { m_remotingPort = value; }
69 }
70
71 public string RemotingAddress;
72
73
74 public IPEndPoint ExternalEndPoint
75 {
76 get
77 {
78 // Old one defaults to IPv6
79 //return new IPEndPoint( Dns.GetHostAddresses( m_externalHostName )[0], m_internalEndPoint.Port );
80
81 IPAddress ia = null;
82 // If it is already an IP, don't resolve it - just return directly
83 if (IPAddress.TryParse(m_externalHostName, out ia))
84 return new IPEndPoint(ia, m_internalEndPoint.Port);
85
86 // Reset for next check
87 ia = null;
88
89
90 // New method favors IPv4
91 foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
92 {
93 if (ia == null)
94 ia = Adr;
95
96 if (Adr.AddressFamily == AddressFamily.InterNetwork)
97 {
98 ia = Adr;
99 break;
100 }
101 }
102
103 return new IPEndPoint(ia, m_internalEndPoint.Port);
104 }
105
106 set { m_externalHostName = value.ToString(); }
107 }
108
109 protected string m_externalHostName;
110
111 public string ExternalHostName
112 {
113 get { return m_externalHostName; }
114 set { m_externalHostName = value; }
115 }
116
117 protected IPEndPoint m_internalEndPoint;
118
119 public IPEndPoint InternalEndPoint
120 {
121 get { return m_internalEndPoint; }
122 set { m_internalEndPoint = value; }
123 }
124
125 protected uint? m_regionLocX;
126
127 public uint RegionLocX
128 {
129 get { return m_regionLocX.Value; }
130 set { m_regionLocX = value; }
131 }
132
133 protected uint? m_regionLocY;
134
135 public uint RegionLocY
136 {
137 get { return m_regionLocY.Value; }
138 set { m_regionLocY = value; }
139 }
140
141 public ulong RegionHandle
142 {
143 get { return Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); }
144 }
145 }
146
147 public class RegionInfo : SimpleRegionInfo
148 {
149 public string RegionName = "";
150
151 public string DataStore = "";
152 public bool isSandbox = false;
153
154 public LLUUID MasterAvatarAssignedUUID = new LLUUID();
155 public string MasterAvatarFirstName = "";
156 public string MasterAvatarLastName = "";
157 public string MasterAvatarSandboxPassword = "";
158
159 // Apparently, we're applying the same estatesettings regardless of whether it's local or remote.
160 private static EstateSettings m_estateSettings;
161
162 public EstateSettings EstateSettings
163 {
164 get
165 {
166 if (m_estateSettings == null)
167 {
168 m_estateSettings = new EstateSettings();
169 }
170
171 return m_estateSettings;
172 }
173 }
174
175 public ConfigurationMember configMember;
176
177 public RegionInfo(string description, string filename)
178 {
179 configMember =
180 new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration);
181 configMember.performConfigurationRetrieve();
182 }
183
184 public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) :
185 base(regionLocX, regionLocY, internalEndPoint, externalUri)
186 {
187 }
188
189 public RegionInfo()
190 {
191 }
192
193 //not in use, should swap to nini though.
194 public void LoadFromNiniSource(IConfigSource source)
195 {
196 LoadFromNiniSource(source, "RegionInfo");
197 }
198
199 //not in use, should swap to nini though.
200 public void LoadFromNiniSource(IConfigSource source, string sectionName)
201 {
202 string errorMessage = "";
203 RegionID =
204 new LLUUID(source.Configs[sectionName].GetString("Region_ID", LLUUID.Random().ToStringHyphenated()));
205 RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test");
206 m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000"));
207 m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000"));
208 DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db");
209
210 string ipAddress = source.Configs[sectionName].GetString("internal_ip_address", "0.0.0.0");
211 IPAddress ipAddressResult;
212 if (IPAddress.TryParse(ipAddress, out ipAddressResult))
213 {
214 m_internalEndPoint = new IPEndPoint(ipAddressResult, 0);
215 }
216 else
217 {
218 errorMessage = "needs an IP Address (IPAddress)";
219 }
220 m_internalEndPoint.Port =
221 source.Configs[sectionName].GetInt("internal_ip_port", NetworkServersInfo.DefaultHttpListenerPort);
222
223 string externalHost = source.Configs[sectionName].GetString("external_host_name", "127.0.0.1");
224 if (externalHost != "SYSTEMIP")
225 {
226 m_externalHostName = externalHost;
227 }
228 else
229 {
230 m_externalHostName = Util.GetLocalHost().ToString();
231 }
232
233 MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test");
234 MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User");
235 MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test");
236
237 if (errorMessage != "")
238 {
239 // a error
240 }
241 }
242
243 public void loadConfigurationOptions()
244 {
245 configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID,
246 "UUID of Region (Default is recommended, random UUID)",
247 LLUUID.Random().ToString(), true);
248 configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
249 "Region Name", "OpenSim Test", false);
250 configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
251 "Grid Location (X Axis)", "1000", false);
252 configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
253 "Grid Location (Y Axis)", "1000", false);
254 configMember.addConfigurationOption("datastore",
255 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
256 "Filename for local storage", "OpenSim.db", false);
257 configMember.addConfigurationOption("internal_ip_address",
258 ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS,
259 "Internal IP Address for incoming UDP client connections", "0.0.0.0",
260 false);
261 configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
262 "Internal IP Port for incoming UDP client connections",
263 NetworkServersInfo.DefaultHttpListenerPort.ToString(), false);
264 configMember.addConfigurationOption("external_host_name",
265 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
266 "External Host Name", "127.0.0.1", false);
267 configMember.addConfigurationOption("master_avatar_first",
268 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
269 "First Name of Master Avatar", "Test", false);
270 configMember.addConfigurationOption("master_avatar_last",
271 ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
272 "Last Name of Master Avatar", "User", false);
273 configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
274 "(Sandbox Mode Only)Password for Master Avatar account", "test", false);
275 }
276
277 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
278 {
279 switch (configuration_key)
280 {
281 case "sim_UUID":
282 RegionID = (LLUUID) configuration_result;
283 break;
284 case "sim_name":
285 RegionName = (string) configuration_result;
286 break;
287 case "sim_location_x":
288 m_regionLocX = (uint) configuration_result;
289 break;
290 case "sim_location_y":
291 m_regionLocY = (uint) configuration_result;
292 break;
293 case "datastore":
294 DataStore = (string) configuration_result;
295 break;
296 case "internal_ip_address":
297 IPAddress address = (IPAddress) configuration_result;
298 m_internalEndPoint = new IPEndPoint(address, 0);
299 break;
300 case "internal_ip_port":
301 m_internalEndPoint.Port = (int) configuration_result;
302 break;
303 case "external_host_name":
304 if ((string) configuration_result != "SYSTEMIP")
305 {
306 m_externalHostName = (string) configuration_result;
307 }
308 else
309 {
310 m_externalHostName = Util.GetLocalHost().ToString();
311 }
312 break;
313 case "master_avatar_first":
314 MasterAvatarFirstName = (string) configuration_result;
315 break;
316 case "master_avatar_last":
317 MasterAvatarLastName = (string) configuration_result;
318 break;
319 case "master_avatar_pass":
320 string tempMD5Passwd = (string) configuration_result;
321 MasterAvatarSandboxPassword = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + "");
322 break;
323 }
324
325 return true;
326 }
327 }
328} \ No newline at end of file