diff options
Diffstat (limited to 'OpenSim/Framework/General/Types/RegionInfo.cs')
-rw-r--r-- | OpenSim/Framework/General/Types/RegionInfo.cs | 350 |
1 files changed, 0 insertions, 350 deletions
diff --git a/OpenSim/Framework/General/Types/RegionInfo.cs b/OpenSim/Framework/General/Types/RegionInfo.cs deleted file mode 100644 index 49360f8..0000000 --- a/OpenSim/Framework/General/Types/RegionInfo.cs +++ /dev/null | |||
@@ -1,350 +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 | */ | ||
28 | using System; | ||
29 | using System.Globalization; | ||
30 | using System.Net; | ||
31 | using System.Net.Sockets; | ||
32 | using Nini.Config; | ||
33 | using libsecondlife; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Framework.Interfaces; | ||
36 | using OpenSim.Framework.Utilities; | ||
37 | |||
38 | using OpenSim.Framework.Configuration; | ||
39 | |||
40 | |||
41 | namespace OpenSim.Framework.Types | ||
42 | { | ||
43 | public class SimpleRegionInfo | ||
44 | { | ||
45 | public SimpleRegionInfo() | ||
46 | { | ||
47 | } | ||
48 | |||
49 | public SimpleRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) | ||
50 | { | ||
51 | |||
52 | m_regionLocX = regionLocX; | ||
53 | m_regionLocY = regionLocY; | ||
54 | |||
55 | m_internalEndPoint = internalEndPoint; | ||
56 | m_externalHostName = externalUri; | ||
57 | } | ||
58 | |||
59 | public SimpleRegionInfo(uint regionLocX, uint regionLocY, string externalUri, int port) | ||
60 | { | ||
61 | |||
62 | m_regionLocX = regionLocX; | ||
63 | m_regionLocY = regionLocY; | ||
64 | |||
65 | m_externalHostName = externalUri; | ||
66 | |||
67 | m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); | ||
68 | } | ||
69 | |||
70 | public LLUUID RegionID = new LLUUID(); | ||
71 | |||
72 | private uint m_remotingPort; | ||
73 | public uint RemotingPort | ||
74 | { | ||
75 | get | ||
76 | { | ||
77 | return m_remotingPort; | ||
78 | } | ||
79 | set | ||
80 | { | ||
81 | m_remotingPort = value; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | public string RemotingAddress; | ||
86 | |||
87 | |||
88 | public IPEndPoint ExternalEndPoint | ||
89 | { | ||
90 | get | ||
91 | { | ||
92 | // Old one defaults to IPv6 | ||
93 | //return new IPEndPoint( Dns.GetHostAddresses( m_externalHostName )[0], m_internalEndPoint.Port ); | ||
94 | |||
95 | IPAddress ia = null; | ||
96 | // If it is already an IP, don't resolve it - just return directly | ||
97 | if (IPAddress.TryParse(m_externalHostName, out ia)) | ||
98 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
99 | |||
100 | // Reset for next check | ||
101 | ia = null; | ||
102 | |||
103 | |||
104 | // New method favors IPv4 | ||
105 | foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) | ||
106 | { | ||
107 | if (ia == null) | ||
108 | ia = Adr; | ||
109 | |||
110 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
111 | { | ||
112 | ia = Adr; | ||
113 | break; | ||
114 | } | ||
115 | |||
116 | } | ||
117 | |||
118 | return new IPEndPoint(ia, m_internalEndPoint.Port); | ||
119 | } | ||
120 | |||
121 | set | ||
122 | { | ||
123 | m_externalHostName = value.ToString(); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | protected string m_externalHostName; | ||
128 | public string ExternalHostName | ||
129 | { | ||
130 | get | ||
131 | { | ||
132 | return m_externalHostName; | ||
133 | } | ||
134 | set | ||
135 | { | ||
136 | m_externalHostName = value; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | protected IPEndPoint m_internalEndPoint; | ||
141 | public IPEndPoint InternalEndPoint | ||
142 | { | ||
143 | get | ||
144 | { | ||
145 | return m_internalEndPoint; | ||
146 | } | ||
147 | set | ||
148 | { | ||
149 | m_internalEndPoint = value; | ||
150 | } | ||
151 | } | ||
152 | |||
153 | protected uint? m_regionLocX; | ||
154 | public uint RegionLocX | ||
155 | { | ||
156 | get | ||
157 | { | ||
158 | return m_regionLocX.Value; | ||
159 | } | ||
160 | set | ||
161 | { | ||
162 | m_regionLocX = value; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | protected uint? m_regionLocY; | ||
167 | public uint RegionLocY | ||
168 | { | ||
169 | get | ||
170 | { | ||
171 | return m_regionLocY.Value; | ||
172 | } | ||
173 | set | ||
174 | { | ||
175 | m_regionLocY = value; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | public ulong RegionHandle | ||
180 | { | ||
181 | get | ||
182 | { | ||
183 | return Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); | ||
184 | } | ||
185 | } | ||
186 | } | ||
187 | |||
188 | public class RegionInfo : SimpleRegionInfo | ||
189 | { | ||
190 | public string RegionName = ""; | ||
191 | |||
192 | public string DataStore = ""; | ||
193 | public bool isSandbox = false; | ||
194 | |||
195 | public LLUUID MasterAvatarAssignedUUID = new LLUUID(); | ||
196 | public string MasterAvatarFirstName = ""; | ||
197 | public string MasterAvatarLastName = ""; | ||
198 | public string MasterAvatarSandboxPassword = ""; | ||
199 | |||
200 | // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. | ||
201 | private static EstateSettings m_estateSettings; | ||
202 | public EstateSettings EstateSettings | ||
203 | { | ||
204 | get | ||
205 | { | ||
206 | if( m_estateSettings == null ) | ||
207 | { | ||
208 | m_estateSettings = new EstateSettings(); | ||
209 | } | ||
210 | |||
211 | return m_estateSettings; | ||
212 | } | ||
213 | |||
214 | } | ||
215 | |||
216 | public ConfigurationMember configMember; | ||
217 | public RegionInfo(string description, string filename) | ||
218 | { | ||
219 | configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); | ||
220 | configMember.performConfigurationRetrieve(); | ||
221 | } | ||
222 | |||
223 | public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) : | ||
224 | base(regionLocX, regionLocY, internalEndPoint, externalUri) | ||
225 | { | ||
226 | |||
227 | |||
228 | } | ||
229 | |||
230 | public RegionInfo() | ||
231 | { | ||
232 | |||
233 | } | ||
234 | |||
235 | //not in use, should swap to nini though. | ||
236 | public void LoadFromNiniSource(IConfigSource source) | ||
237 | { | ||
238 | this.LoadFromNiniSource(source, "RegionInfo"); | ||
239 | } | ||
240 | |||
241 | //not in use, should swap to nini though. | ||
242 | public void LoadFromNiniSource(IConfigSource source, string sectionName) | ||
243 | { | ||
244 | string errorMessage = ""; | ||
245 | this.RegionID = new LLUUID(source.Configs[sectionName].GetString("Region_ID", LLUUID.Random().ToStringHyphenated())); | ||
246 | this.RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test"); | ||
247 | this.m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000")); | ||
248 | this.m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000")); | ||
249 | this.DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db"); | ||
250 | |||
251 | string ipAddress = source.Configs[sectionName].GetString("internal_ip_address", "0.0.0.0"); | ||
252 | IPAddress ipAddressResult; | ||
253 | if (IPAddress.TryParse(ipAddress, out ipAddressResult)) | ||
254 | { | ||
255 | this.m_internalEndPoint = new IPEndPoint(ipAddressResult, 0); | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | errorMessage = "needs an IP Address (IPAddress)"; | ||
260 | } | ||
261 | this.m_internalEndPoint.Port = source.Configs[sectionName].GetInt("internal_ip_port", NetworkServersInfo.DefaultHttpListenerPort); | ||
262 | |||
263 | string externalHost = source.Configs[sectionName].GetString("external_host_name", "127.0.0.1"); | ||
264 | if (externalHost != "SYSTEMIP") | ||
265 | { | ||
266 | this.m_externalHostName = externalHost; | ||
267 | } | ||
268 | else | ||
269 | { | ||
270 | this.m_externalHostName = Util.GetLocalHost().ToString(); | ||
271 | } | ||
272 | |||
273 | this.MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test"); | ||
274 | this.MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User"); | ||
275 | this.MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test"); | ||
276 | |||
277 | if (errorMessage != "") | ||
278 | { | ||
279 | // a error | ||
280 | } | ||
281 | } | ||
282 | |||
283 | public void loadConfigurationOptions() | ||
284 | { | ||
285 | configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "UUID of Region (Default is recommended, random UUID)", LLUUID.Random().ToString(), true); | ||
286 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Region Name", "OpenSim Test", false); | ||
287 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (X Axis)", "1000", false); | ||
288 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", "1000", false); | ||
289 | configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); | ||
290 | configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, "Internal IP Address for incoming UDP client connections", "0.0.0.0", false); | ||
291 | configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Internal IP Port for incoming UDP client connections", NetworkServersInfo.DefaultHttpListenerPort.ToString(), false); | ||
292 | configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "External Host Name", "127.0.0.1", false); | ||
293 | configMember.addConfigurationOption("master_avatar_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "First Name of Master Avatar", "Test", false); | ||
294 | configMember.addConfigurationOption("master_avatar_last", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Last Name of Master Avatar", "User", false); | ||
295 | configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "(Sandbox Mode Only)Password for Master Avatar account", "test", false); | ||
296 | } | ||
297 | |||
298 | public bool handleIncomingConfiguration(string configuration_key, object configuration_result) | ||
299 | { | ||
300 | switch (configuration_key) | ||
301 | { | ||
302 | case "sim_UUID": | ||
303 | this.RegionID = (LLUUID)configuration_result; | ||
304 | break; | ||
305 | case "sim_name": | ||
306 | this.RegionName = (string)configuration_result; | ||
307 | break; | ||
308 | case "sim_location_x": | ||
309 | this.m_regionLocX = (uint)configuration_result; | ||
310 | break; | ||
311 | case "sim_location_y": | ||
312 | this.m_regionLocY = (uint)configuration_result; | ||
313 | break; | ||
314 | case "datastore": | ||
315 | this.DataStore = (string)configuration_result; | ||
316 | break; | ||
317 | case "internal_ip_address": | ||
318 | IPAddress address = (IPAddress)configuration_result; | ||
319 | this.m_internalEndPoint = new IPEndPoint(address, 0); | ||
320 | break; | ||
321 | case "internal_ip_port": | ||
322 | this.m_internalEndPoint.Port = (int)configuration_result; | ||
323 | break; | ||
324 | case "external_host_name": | ||
325 | if ((string)configuration_result != "SYSTEMIP") | ||
326 | { | ||
327 | this.m_externalHostName = (string)configuration_result; | ||
328 | } | ||
329 | else | ||
330 | { | ||
331 | this.m_externalHostName = Util.GetLocalHost().ToString(); | ||
332 | } | ||
333 | break; | ||
334 | case "master_avatar_first": | ||
335 | this.MasterAvatarFirstName = (string)configuration_result; | ||
336 | break; | ||
337 | case "master_avatar_last": | ||
338 | this.MasterAvatarLastName = (string)configuration_result; | ||
339 | break; | ||
340 | case "master_avatar_pass": | ||
341 | string tempMD5Passwd = (string)configuration_result; | ||
342 | this.MasterAvatarSandboxPassword = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); | ||
343 | break; | ||
344 | } | ||
345 | |||
346 | return true; | ||
347 | } | ||
348 | |||
349 | } | ||
350 | } | ||