clockwerk-opensim-stable – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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 OpenSimulator 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.Collections.Generic; |
||
30 | using System.Net; |
||
31 | using System.Net.Sockets; |
||
32 | using System.Reflection; |
||
33 | using System.Xml; |
||
34 | using System.IO; |
||
35 | using log4net; |
||
36 | using Nini.Config; |
||
37 | using OpenMetaverse; |
||
38 | using OpenMetaverse.StructuredData; |
||
39 | //using OpenSim.Framework.Console; |
||
40 | |||
41 | namespace OpenSim.Framework |
||
42 | { |
||
43 | public class RegionLightShareData : ICloneable |
||
44 | { |
||
45 | public bool valid = false; |
||
46 | public UUID regionID = UUID.Zero; |
||
47 | public Vector3 waterColor = new Vector3(4.0f,38.0f,64.0f); |
||
48 | public float waterFogDensityExponent = 4.0f; |
||
49 | public float underwaterFogModifier = 0.25f; |
||
50 | public Vector3 reflectionWaveletScale = new Vector3(2.0f,2.0f,2.0f); |
||
51 | public float fresnelScale = 0.40f; |
||
52 | public float fresnelOffset = 0.50f; |
||
53 | public float refractScaleAbove = 0.03f; |
||
54 | public float refractScaleBelow = 0.20f; |
||
55 | public float blurMultiplier = 0.040f; |
||
56 | public Vector2 bigWaveDirection = new Vector2(1.05f,-0.42f); |
||
57 | public Vector2 littleWaveDirection = new Vector2(1.11f,-1.16f); |
||
58 | public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); |
||
59 | public Vector4 horizon = new Vector4(0.25f, 0.25f, 0.32f, 0.32f); |
||
60 | public float hazeHorizon = 0.19f; |
||
61 | public Vector4 blueDensity = new Vector4(0.12f, 0.22f, 0.38f, 0.38f); |
||
62 | public float hazeDensity = 0.70f; |
||
63 | public float densityMultiplier = 0.18f; |
||
64 | public float distanceMultiplier = 0.8f; |
||
65 | public UInt16 maxAltitude = 1605; |
||
66 | public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f); |
||
67 | public float sunMoonPosition = 0.317f; |
||
68 | public Vector4 ambient = new Vector4(0.35f,0.35f,0.35f,0.35f); |
||
69 | public float eastAngle = 0.0f; |
||
70 | public float sunGlowFocus = 0.10f; |
||
71 | public float sunGlowSize = 1.75f; |
||
72 | public float sceneGamma = 1.0f; |
||
73 | public float starBrightness = 0.0f; |
||
74 | public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f); |
||
75 | public Vector3 cloudXYDensity = new Vector3(1.00f, 0.53f, 1.00f); |
||
76 | public float cloudCoverage = 0.27f; |
||
77 | public float cloudScale = 0.42f; |
||
78 | public Vector3 cloudDetailXYDensity = new Vector3(1.00f, 0.53f, 0.12f); |
||
79 | public float cloudScrollX = 0.20f; |
||
80 | public bool cloudScrollXLock = false; |
||
81 | public float cloudScrollY = 0.01f; |
||
82 | public bool cloudScrollYLock = false; |
||
83 | public bool drawClassicClouds = true; |
||
84 | |||
85 | public delegate void SaveDelegate(RegionLightShareData wl); |
||
86 | public event SaveDelegate OnSave; |
||
87 | public void Save() |
||
88 | { |
||
89 | if (OnSave != null) |
||
90 | OnSave(this); |
||
91 | } |
||
92 | public object Clone() |
||
93 | { |
||
94 | return this.MemberwiseClone(); // call clone method |
||
95 | } |
||
96 | |||
97 | } |
||
98 | |||
99 | public class RegionInfo |
||
100 | { |
||
101 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
||
102 | |||
103 | public bool commFailTF = false; |
||
104 | public ConfigurationMember configMember; |
||
105 | public string RegionFile = String.Empty; |
||
106 | public bool isSandbox = false; |
||
107 | public bool Persistent = true; |
||
108 | |||
109 | private EstateSettings m_estateSettings; |
||
110 | private RegionSettings m_regionSettings; |
||
111 | // private IConfigSource m_configSource = null; |
||
112 | |||
113 | public UUID originRegionID = UUID.Zero; |
||
114 | public string proxyUrl = ""; |
||
115 | public int ProxyOffset = 0; |
||
116 | public string regionSecret = UUID.Random().ToString(); |
||
117 | |||
118 | public string osSecret; |
||
119 | |||
120 | public UUID lastMapUUID = UUID.Zero; |
||
121 | public string lastMapRefresh = "0"; |
||
122 | |||
123 | private float m_nonphysPrimMin = 0; |
||
124 | private int m_nonphysPrimMax = 0; |
||
125 | private float m_physPrimMin = 0; |
||
126 | private int m_physPrimMax = 0; |
||
127 | private bool m_clampPrimSize = false; |
||
128 | private int m_objectCapacity = 0; |
||
129 | private int m_linksetCapacity = 0; |
||
130 | private int m_agentCapacity = 0; |
||
131 | private string m_regionType = String.Empty; |
||
132 | private RegionLightShareData m_windlight = new RegionLightShareData(); |
||
133 | protected uint m_httpPort; |
||
134 | protected string m_serverURI; |
||
135 | protected string m_regionName = String.Empty; |
||
136 | protected bool Allow_Alternate_Ports; |
||
137 | public bool m_allow_alternate_ports; |
||
138 | protected string m_externalHostName; |
||
139 | protected IPEndPoint m_internalEndPoint; |
||
140 | protected uint? m_regionLocX; |
||
141 | protected uint? m_regionLocY; |
||
142 | protected uint m_remotingPort; |
||
143 | public UUID RegionID = UUID.Zero; |
||
144 | public string RemotingAddress; |
||
145 | public UUID ScopeID = UUID.Zero; |
||
146 | private UUID m_maptileStaticUUID = UUID.Zero; |
||
147 | |||
148 | private Dictionary<String, String> m_otherSettings = new Dictionary<string, string>(); |
||
149 | |||
150 | |||
151 | // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. |
||
152 | |||
153 | // MT: Yes. Estates can't span trust boundaries. Therefore, it can be |
||
154 | // assumed that all instances belonging to one estate are able to |
||
155 | // access the same database server. Since estate settings are lodaed |
||
156 | // from there, that should be sufficient for full remote administration |
||
157 | |||
158 | // File based loading |
||
159 | // |
||
160 | public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource) : this(description, filename, skipConsoleConfig, configSource, String.Empty) |
||
161 | { |
||
162 | } |
||
163 | |||
164 | public RegionInfo(string description, string filename, bool skipConsoleConfig, IConfigSource configSource, string configName) |
||
165 | { |
||
166 | // m_configSource = configSource; |
||
167 | |||
168 | if (filename.ToLower().EndsWith(".ini")) |
||
169 | { |
||
170 | if (!File.Exists(filename)) // New region config request |
||
171 | { |
||
172 | IniConfigSource newFile = new IniConfigSource(); |
||
173 | ReadNiniConfig(newFile, configName); |
||
174 | |||
175 | newFile.Save(filename); |
||
176 | |||
177 | RegionFile = filename; |
||
178 | |||
179 | return; |
||
180 | } |
||
181 | |||
182 | IniConfigSource source = new IniConfigSource(filename); |
||
183 | |||
184 | bool saveFile = false; |
||
185 | if (source.Configs[configName] == null) |
||
186 | saveFile = true; |
||
187 | |||
188 | ReadNiniConfig(source, configName); |
||
189 | |||
190 | if (configName != String.Empty && saveFile) |
||
191 | source.Save(filename); |
||
192 | |||
193 | RegionFile = filename; |
||
194 | |||
195 | return; |
||
196 | } |
||
197 | |||
198 | try |
||
199 | { |
||
200 | // This will throw if it's not legal Nini XML format |
||
201 | // and thereby toss it to the legacy loader |
||
202 | // |
||
203 | IConfigSource xmlsource = new XmlConfigSource(filename); |
||
204 | |||
205 | ReadNiniConfig(xmlsource, configName); |
||
206 | |||
207 | RegionFile = filename; |
||
208 | |||
209 | return; |
||
210 | } |
||
211 | catch (Exception) |
||
212 | { |
||
213 | } |
||
214 | |||
215 | configMember = |
||
216 | new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig); |
||
217 | configMember.performConfigurationRetrieve(); |
||
218 | RegionFile = filename; |
||
219 | } |
||
220 | |||
221 | // The web loader uses this |
||
222 | // |
||
223 | public RegionInfo(string description, XmlNode xmlNode, bool skipConsoleConfig, IConfigSource configSource) |
||
224 | { |
||
225 | // m_configSource = configSource; |
||
226 | configMember = |
||
227 | new ConfigurationMember(xmlNode, description, loadConfigurationOptions, handleIncomingConfiguration, !skipConsoleConfig); |
||
228 | configMember.performConfigurationRetrieve(); |
||
229 | m_serverURI = string.Empty; |
||
230 | } |
||
231 | |||
232 | public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) |
||
233 | { |
||
234 | m_regionLocX = regionLocX; |
||
235 | m_regionLocY = regionLocY; |
||
236 | |||
237 | m_internalEndPoint = internalEndPoint; |
||
238 | m_externalHostName = externalUri; |
||
239 | m_serverURI = string.Empty; |
||
240 | } |
||
241 | |||
242 | public RegionInfo() |
||
243 | { |
||
244 | m_serverURI = string.Empty; |
||
245 | } |
||
246 | |||
247 | public EstateSettings EstateSettings |
||
248 | { |
||
249 | get |
||
250 | { |
||
251 | if (m_estateSettings == null) |
||
252 | { |
||
253 | m_estateSettings = new EstateSettings(); |
||
254 | } |
||
255 | |||
256 | return m_estateSettings; |
||
257 | } |
||
258 | |||
259 | set { m_estateSettings = value; } |
||
260 | } |
||
261 | |||
262 | public RegionSettings RegionSettings |
||
263 | { |
||
264 | get |
||
265 | { |
||
266 | if (m_regionSettings == null) |
||
267 | { |
||
268 | m_regionSettings = new RegionSettings(); |
||
269 | } |
||
270 | |||
271 | return m_regionSettings; |
||
272 | } |
||
273 | |||
274 | set { m_regionSettings = value; } |
||
275 | } |
||
276 | |||
277 | public RegionLightShareData WindlightSettings |
||
278 | { |
||
279 | get |
||
280 | { |
||
281 | if (m_windlight == null) |
||
282 | { |
||
283 | m_windlight = new RegionLightShareData(); |
||
284 | } |
||
285 | |||
286 | return m_windlight; |
||
287 | } |
||
288 | |||
289 | set { m_windlight = value; } |
||
290 | } |
||
291 | |||
292 | public float NonphysPrimMin |
||
293 | { |
||
294 | get { return m_nonphysPrimMin; } |
||
295 | } |
||
296 | |||
297 | public int NonphysPrimMax |
||
298 | { |
||
299 | get { return m_nonphysPrimMax; } |
||
300 | } |
||
301 | |||
302 | public float PhysPrimMin |
||
303 | { |
||
304 | get { return m_physPrimMin; } |
||
305 | } |
||
306 | |||
307 | public int PhysPrimMax |
||
308 | { |
||
309 | get { return m_physPrimMax; } |
||
310 | } |
||
311 | |||
312 | public bool ClampPrimSize |
||
313 | { |
||
314 | get { return m_clampPrimSize; } |
||
315 | } |
||
316 | |||
317 | public int ObjectCapacity |
||
318 | { |
||
319 | get { return m_objectCapacity; } |
||
320 | } |
||
321 | |||
322 | public int LinksetCapacity |
||
323 | { |
||
324 | get { return m_linksetCapacity; } |
||
325 | } |
||
326 | |||
327 | public int AgentCapacity |
||
328 | { |
||
329 | get { return m_agentCapacity; } |
||
330 | } |
||
331 | |||
332 | public byte AccessLevel |
||
333 | { |
||
334 | get { return (byte)Util.ConvertMaturityToAccessLevel((uint)RegionSettings.Maturity); } |
||
335 | } |
||
336 | |||
337 | public string RegionType |
||
338 | { |
||
339 | get { return m_regionType; } |
||
340 | } |
||
341 | |||
342 | public UUID MaptileStaticUUID |
||
343 | { |
||
344 | get { return m_maptileStaticUUID; } |
||
345 | } |
||
346 | |||
347 | /// <summary> |
||
348 | /// The port by which http communication occurs with the region (most noticeably, CAPS communication) |
||
349 | /// </summary> |
||
350 | public uint HttpPort |
||
351 | { |
||
352 | get { return m_httpPort; } |
||
353 | set { m_httpPort = value; } |
||
354 | } |
||
355 | |||
356 | /// <summary> |
||
357 | /// A well-formed URI for the host region server (namely "http://" + ExternalHostName) |
||
358 | /// </summary> |
||
359 | |||
360 | public string ServerURI |
||
361 | { |
||
362 | get { |
||
363 | if ( m_serverURI != string.Empty ) { |
||
364 | return m_serverURI; |
||
365 | } else { |
||
366 | return "http://" + m_externalHostName + ":" + m_httpPort + "/"; |
||
367 | } |
||
368 | } |
||
369 | set { |
||
370 | if ( value.EndsWith("/") ) { |
||
371 | m_serverURI = value; |
||
372 | } else { |
||
373 | m_serverURI = value + '/'; |
||
374 | } |
||
375 | } |
||
376 | } |
||
377 | |||
378 | public string RegionName |
||
379 | { |
||
380 | get { return m_regionName; } |
||
381 | set { m_regionName = value; } |
||
382 | } |
||
383 | |||
384 | public uint RemotingPort |
||
385 | { |
||
386 | get { return m_remotingPort; } |
||
387 | set { m_remotingPort = value; } |
||
388 | } |
||
389 | |||
390 | /// <value> |
||
391 | /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw. |
||
392 | /// |
||
393 | /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method? |
||
394 | /// </value> |
||
395 | public IPEndPoint ExternalEndPoint |
||
396 | { |
||
397 | get |
||
398 | { |
||
399 | // Old one defaults to IPv6 |
||
400 | //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port); |
||
401 | |||
402 | IPAddress ia = null; |
||
403 | // If it is already an IP, don't resolve it - just return directly |
||
404 | if (IPAddress.TryParse(m_externalHostName, out ia)) |
||
405 | return new IPEndPoint(ia, m_internalEndPoint.Port); |
||
406 | |||
407 | // Reset for next check |
||
408 | ia = null; |
||
409 | try |
||
410 | { |
||
411 | foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName)) |
||
412 | { |
||
413 | if (ia == null) |
||
414 | ia = Adr; |
||
415 | |||
416 | if (Adr.AddressFamily == AddressFamily.InterNetwork) |
||
417 | { |
||
418 | ia = Adr; |
||
419 | break; |
||
420 | } |
||
421 | } |
||
422 | } |
||
423 | catch (SocketException e) |
||
424 | { |
||
425 | throw new Exception( |
||
426 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + |
||
427 | e + "' attached to this exception", e); |
||
428 | } |
||
429 | |||
430 | return new IPEndPoint(ia, m_internalEndPoint.Port); |
||
431 | } |
||
432 | |||
433 | set { m_externalHostName = value.ToString(); } |
||
434 | } |
||
435 | |||
436 | public string ExternalHostName |
||
437 | { |
||
438 | get { return m_externalHostName; } |
||
439 | set { m_externalHostName = value; } |
||
440 | } |
||
441 | |||
442 | public IPEndPoint InternalEndPoint |
||
443 | { |
||
444 | get { return m_internalEndPoint; } |
||
445 | set { m_internalEndPoint = value; } |
||
446 | } |
||
447 | |||
448 | /// <summary> |
||
449 | /// The x co-ordinate of this region in map tiles (e.g. 1000). |
||
450 | /// </summary> |
||
451 | public uint RegionLocX |
||
452 | { |
||
453 | get { return m_regionLocX.Value; } |
||
454 | set { m_regionLocX = value; } |
||
455 | } |
||
456 | |||
457 | /// <summary> |
||
458 | /// The y co-ordinate of this region in map tiles (e.g. 1000). |
||
459 | /// </summary> |
||
460 | public uint RegionLocY |
||
461 | { |
||
462 | get { return m_regionLocY.Value; } |
||
463 | set { m_regionLocY = value; } |
||
464 | } |
||
465 | |||
466 | public ulong RegionHandle |
||
467 | { |
||
468 | get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } |
||
469 | } |
||
470 | |||
471 | public void SetEndPoint(string ipaddr, int port) |
||
472 | { |
||
473 | IPAddress tmpIP = IPAddress.Parse(ipaddr); |
||
474 | IPEndPoint tmpEPE = new IPEndPoint(tmpIP, port); |
||
475 | m_internalEndPoint = tmpEPE; |
||
476 | } |
||
477 | |||
478 | public string GetOtherSetting(string key) |
||
479 | { |
||
480 | string val; |
||
481 | string keylower = key.ToLower(); |
||
482 | if (m_otherSettings.TryGetValue(keylower, out val)) |
||
483 | return val; |
||
484 | m_log.DebugFormat("[RegionInfo] Could not locate value for parameter {0}", key); |
||
485 | return null; |
||
486 | } |
||
487 | |||
488 | public void SetOtherSetting(string key, string value) |
||
489 | { |
||
490 | string keylower = key.ToLower(); |
||
491 | m_otherSettings[keylower] = value; |
||
492 | } |
||
493 | |||
494 | private void ReadNiniConfig(IConfigSource source, string name) |
||
495 | { |
||
496 | // bool creatingNew = false; |
||
497 | |||
498 | if (source.Configs.Count == 0) |
||
499 | { |
||
500 | MainConsole.Instance.Output("=====================================\n"); |
||
501 | MainConsole.Instance.Output("We are now going to ask a couple of questions about your region.\n"); |
||
502 | MainConsole.Instance.Output("You can press 'enter' without typing anything to use the default\n"); |
||
503 | MainConsole.Instance.Output("the default is displayed between [ ] brackets.\n"); |
||
504 | MainConsole.Instance.Output("=====================================\n"); |
||
505 | |||
506 | if (name == String.Empty) |
||
507 | { |
||
508 | while (name.Trim() == string.Empty) |
||
509 | { |
||
510 | name = MainConsole.Instance.CmdPrompt("New region name", name); |
||
511 | if (name.Trim() == string.Empty) |
||
512 | { |
||
513 | MainConsole.Instance.Output("Cannot interactively create region with no name"); |
||
514 | } |
||
515 | } |
||
516 | } |
||
517 | |||
518 | source.AddConfig(name); |
||
519 | |||
520 | // creatingNew = true; |
||
521 | } |
||
522 | |||
523 | if (name == String.Empty) |
||
524 | name = source.Configs[0].Name; |
||
525 | |||
526 | if (source.Configs[name] == null) |
||
527 | { |
||
528 | source.AddConfig(name); |
||
529 | } |
||
530 | |||
531 | RegionName = name; |
||
532 | IConfig config = source.Configs[name]; |
||
533 | |||
534 | // Track all of the keys in this config and remove as they are processed |
||
535 | // The remaining keys will be added to generic key-value storage for |
||
536 | // whoever might need it |
||
537 | HashSet<String> allKeys = new HashSet<String>(); |
||
538 | foreach (string s in config.GetKeys()) |
||
539 | { |
||
540 | allKeys.Add(s); |
||
541 | } |
||
542 | |||
543 | // RegionUUID |
||
544 | // |
||
545 | allKeys.Remove("RegionUUID"); |
||
546 | string regionUUID = config.GetString("RegionUUID", string.Empty); |
||
547 | if (!UUID.TryParse(regionUUID.Trim(), out RegionID)) |
||
548 | { |
||
549 | UUID newID = UUID.Random(); |
||
550 | while (RegionID == UUID.Zero) |
||
551 | { |
||
552 | regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString()); |
||
553 | if (!UUID.TryParse(regionUUID.Trim(), out RegionID)) |
||
554 | { |
||
555 | MainConsole.Instance.Output("RegionUUID must be a valid UUID"); |
||
556 | } |
||
557 | } |
||
558 | config.Set("RegionUUID", regionUUID); |
||
559 | } |
||
560 | |||
561 | originRegionID = RegionID; // What IS this?! (Needed for RegionCombinerModule?) |
||
562 | |||
563 | // Location |
||
564 | // |
||
565 | allKeys.Remove("Location"); |
||
566 | string location = config.GetString("Location", String.Empty); |
||
567 | if (location == String.Empty) |
||
568 | { |
||
569 | location = MainConsole.Instance.CmdPrompt("Region Location", "1000,1000"); |
||
570 | config.Set("Location", location); |
||
571 | } |
||
572 | |||
573 | string[] locationElements = location.Split(new char[] {','}); |
||
574 | |||
575 | m_regionLocX = Convert.ToUInt32(locationElements[0]); |
||
576 | m_regionLocY = Convert.ToUInt32(locationElements[1]); |
||
577 | |||
578 | // InternalAddress |
||
579 | // |
||
580 | IPAddress address; |
||
581 | allKeys.Remove("InternalAddress"); |
||
582 | if (config.Contains("InternalAddress")) |
||
583 | { |
||
584 | address = IPAddress.Parse(config.GetString("InternalAddress", String.Empty)); |
||
585 | } |
||
586 | else |
||
587 | { |
||
588 | address = IPAddress.Parse(MainConsole.Instance.CmdPrompt("Internal IP address", "0.0.0.0")); |
||
589 | config.Set("InternalAddress", address.ToString()); |
||
590 | } |
||
591 | |||
592 | // InternalPort |
||
593 | // |
||
594 | int port; |
||
595 | allKeys.Remove("InternalPort"); |
||
596 | if (config.Contains("InternalPort")) |
||
597 | { |
||
598 | port = config.GetInt("InternalPort", 9000); |
||
599 | } |
||
600 | else |
||
601 | { |
||
602 | port = Convert.ToInt32(MainConsole.Instance.CmdPrompt("Internal port", "9000")); |
||
603 | config.Set("InternalPort", port); |
||
604 | } |
||
605 | m_internalEndPoint = new IPEndPoint(address, port); |
||
606 | |||
607 | // AllowAlternatePorts |
||
608 | // |
||
609 | allKeys.Remove("AllowAlternatePorts"); |
||
610 | if (config.Contains("AllowAlternatePorts")) |
||
611 | { |
||
612 | m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true); |
||
613 | } |
||
614 | else |
||
615 | { |
||
616 | m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False")); |
||
617 | |||
618 | config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString()); |
||
619 | } |
||
620 | |||
621 | // ExternalHostName |
||
622 | // |
||
623 | allKeys.Remove("ExternalHostName"); |
||
624 | string externalName; |
||
625 | if (config.Contains("ExternalHostName")) |
||
626 | { |
||
627 | externalName = config.GetString("ExternalHostName", "SYSTEMIP"); |
||
628 | } |
||
629 | else |
||
630 | { |
||
631 | externalName = MainConsole.Instance.CmdPrompt("External host name", "SYSTEMIP"); |
||
632 | config.Set("ExternalHostName", externalName); |
||
633 | } |
||
634 | if (externalName == "SYSTEMIP") |
||
635 | { |
||
636 | m_externalHostName = Util.GetLocalHost().ToString(); |
||
637 | m_log.InfoFormat( |
||
638 | "[REGIONINFO]: Resolving SYSTEMIP to {0} for external hostname of region {1}", |
||
639 | m_externalHostName, name); |
||
640 | } |
||
641 | else |
||
642 | { |
||
643 | m_externalHostName = externalName; |
||
644 | } |
||
645 | |||
646 | // RegionType |
||
647 | m_regionType = config.GetString("RegionType", String.Empty); |
||
648 | allKeys.Remove("RegionType"); |
||
649 | |||
650 | #region Prim and map stuff |
||
651 | |||
652 | m_nonphysPrimMin = config.GetFloat("NonPhysicalPrimMin", 0); |
||
653 | allKeys.Remove("NonPhysicalPrimMin"); |
||
654 | |||
655 | m_nonphysPrimMax = config.GetInt("NonPhysicalPrimMax", 0); |
||
656 | allKeys.Remove("NonPhysicalPrimMax"); |
||
657 | |||
658 | m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0); |
||
659 | allKeys.Remove("PhysicalPrimMin"); |
||
660 | |||
661 | m_physPrimMax = config.GetInt("PhysicalPrimMax", 0); |
||
662 | allKeys.Remove("PhysicalPrimMax"); |
||
663 | |||
664 | m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); |
||
665 | allKeys.Remove("ClampPrimSize"); |
||
666 | |||
667 | m_objectCapacity = config.GetInt("MaxPrims", 15000); |
||
668 | allKeys.Remove("MaxPrims"); |
||
669 | |||
670 | m_linksetCapacity = config.GetInt("LinksetPrims", 0); |
||
671 | allKeys.Remove("LinksetPrims"); |
||
672 | |||
673 | allKeys.Remove("MaptileStaticUUID"); |
||
674 | string mapTileStaticUUID = config.GetString("MaptileStaticUUID", UUID.Zero.ToString()); |
||
675 | if (UUID.TryParse(mapTileStaticUUID.Trim(), out m_maptileStaticUUID)) |
||
676 | { |
||
677 | config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); |
||
678 | } |
||
679 | |||
680 | #endregion |
||
681 | |||
682 | m_agentCapacity = config.GetInt("MaxAgents", 100); |
||
683 | allKeys.Remove("MaxAgents"); |
||
684 | |||
685 | // Multi-tenancy |
||
686 | // |
||
687 | ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString())); |
||
688 | allKeys.Remove("ScopeID"); |
||
689 | |||
690 | foreach (String s in allKeys) |
||
691 | { |
||
692 | SetOtherSetting(s, config.GetString(s)); |
||
693 | } |
||
694 | } |
||
695 | |||
696 | private void WriteNiniConfig(IConfigSource source) |
||
697 | { |
||
698 | IConfig config = source.Configs[RegionName]; |
||
699 | |||
700 | if (config != null) |
||
701 | source.Configs.Remove(config); |
||
702 | |||
703 | config = source.AddConfig(RegionName); |
||
704 | |||
705 | config.Set("RegionUUID", RegionID.ToString()); |
||
706 | |||
707 | string location = String.Format("{0},{1}", m_regionLocX, m_regionLocY); |
||
708 | config.Set("Location", location); |
||
709 | |||
710 | config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); |
||
711 | config.Set("InternalPort", m_internalEndPoint.Port); |
||
712 | |||
713 | config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString()); |
||
714 | |||
715 | config.Set("ExternalHostName", m_externalHostName); |
||
716 | |||
717 | if (m_nonphysPrimMin > 0) |
||
718 | config.Set("NonphysicalPrimMax", m_nonphysPrimMin); |
||
719 | |||
720 | if (m_nonphysPrimMax > 0) |
||
721 | config.Set("NonphysicalPrimMax", m_nonphysPrimMax); |
||
722 | |||
723 | if (m_physPrimMin > 0) |
||
724 | config.Set("PhysicalPrimMax", m_physPrimMin); |
||
725 | |||
726 | if (m_physPrimMax > 0) |
||
727 | config.Set("PhysicalPrimMax", m_physPrimMax); |
||
728 | |||
729 | config.Set("ClampPrimSize", m_clampPrimSize.ToString()); |
||
730 | |||
731 | if (m_objectCapacity > 0) |
||
732 | config.Set("MaxPrims", m_objectCapacity); |
||
733 | |||
734 | if (m_linksetCapacity > 0) |
||
735 | config.Set("LinksetPrims", m_linksetCapacity); |
||
736 | |||
737 | if (m_agentCapacity > 0) |
||
738 | config.Set("MaxAgents", m_agentCapacity); |
||
739 | |||
740 | if (ScopeID != UUID.Zero) |
||
741 | config.Set("ScopeID", ScopeID.ToString()); |
||
742 | |||
743 | if (RegionType != String.Empty) |
||
744 | config.Set("RegionType", RegionType); |
||
745 | |||
746 | if (m_maptileStaticUUID != UUID.Zero) |
||
747 | config.Set("MaptileStaticUUID", m_maptileStaticUUID.ToString()); |
||
748 | } |
||
749 | |||
750 | public bool ignoreIncomingConfiguration(string configuration_key, object configuration_result) |
||
751 | { |
||
752 | return true; |
||
753 | } |
||
754 | |||
755 | public void SaveRegionToFile(string description, string filename) |
||
756 | { |
||
757 | if (filename.ToLower().EndsWith(".ini")) |
||
758 | { |
||
759 | IniConfigSource source = new IniConfigSource(); |
||
760 | try |
||
761 | { |
||
762 | source = new IniConfigSource(filename); // Load if it exists |
||
763 | } |
||
764 | catch (Exception) |
||
765 | { |
||
766 | } |
||
767 | |||
768 | WriteNiniConfig(source); |
||
769 | |||
770 | source.Save(filename); |
||
771 | |||
772 | return; |
||
773 | } |
||
774 | else if (filename.ToLower().EndsWith(".xml")) |
||
775 | { |
||
776 | configMember = new ConfigurationMember(filename, description, loadConfigurationOptionsFromMe, |
||
777 | ignoreIncomingConfiguration, false); |
||
778 | configMember.performConfigurationRetrieve(); |
||
779 | RegionFile = filename; |
||
780 | } |
||
781 | else |
||
782 | throw new Exception("Invalid file type for region persistence."); |
||
783 | } |
||
784 | |||
785 | public void loadConfigurationOptionsFromMe() |
||
786 | { |
||
787 | configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID_NULL_FREE, |
||
788 | "UUID of Region (Default is recommended, random UUID)", |
||
789 | RegionID.ToString(), true); |
||
790 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
||
791 | "Region Name", RegionName, true); |
||
792 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
||
793 | "Grid Location (X Axis)", m_regionLocX.ToString(), true); |
||
794 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
||
795 | "Grid Location (Y Axis)", m_regionLocY.ToString(), true); |
||
796 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); |
||
797 | configMember.addConfigurationOption("internal_ip_address", |
||
798 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, |
||
799 | "Internal IP Address for incoming UDP client connections", |
||
800 | m_internalEndPoint.Address.ToString(), |
||
801 | true); |
||
802 | configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
803 | "Internal IP Port for incoming UDP client connections", |
||
804 | m_internalEndPoint.Port.ToString(), true); |
||
805 | configMember.addConfigurationOption("allow_alternate_ports", |
||
806 | ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, |
||
807 | "Allow sim to find alternate UDP ports when ports are in use?", |
||
808 | m_allow_alternate_ports.ToString(), true); |
||
809 | configMember.addConfigurationOption("external_host_name", |
||
810 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
||
811 | "External Host Name", m_externalHostName, true); |
||
812 | configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, |
||
813 | "Last Map UUID", lastMapUUID.ToString(), true); |
||
814 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
||
815 | "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); |
||
816 | |||
817 | configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, |
||
818 | "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true); |
||
819 | |||
820 | configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
821 | "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true); |
||
822 | |||
823 | configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, |
||
824 | "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true); |
||
825 | |||
826 | configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
827 | "Maximum size for physical prims", m_physPrimMax.ToString(), true); |
||
828 | |||
829 | configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, |
||
830 | "Clamp prims to max size", m_clampPrimSize.ToString(), true); |
||
831 | |||
832 | configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
833 | "Max objects this sim will hold", m_objectCapacity.ToString(), true); |
||
834 | |||
835 | configMember.addConfigurationOption("linkset_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
836 | "Max prims an object will hold", m_linksetCapacity.ToString(), true); |
||
837 | |||
838 | configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
839 | "Max avatars this sim will hold", m_agentCapacity.ToString(), true); |
||
840 | |||
841 | configMember.addConfigurationOption("scope_id", ConfigurationOption.ConfigurationTypes.TYPE_UUID, |
||
842 | "Scope ID for this region", ScopeID.ToString(), true); |
||
843 | |||
844 | configMember.addConfigurationOption("region_type", ConfigurationOption.ConfigurationTypes.TYPE_STRING, |
||
845 | "Free form string describing the type of region", String.Empty, true); |
||
846 | |||
847 | configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID, |
||
848 | "UUID of a texture to use as the map for this region", m_maptileStaticUUID.ToString(), true); |
||
849 | } |
||
850 | |||
851 | public void loadConfigurationOptions() |
||
852 | { |
||
853 | configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_UUID, |
||
854 | "UUID of Region (Default is recommended, random UUID)", |
||
855 | UUID.Random().ToString(), true); |
||
856 | configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
||
857 | "Region Name", "OpenSim Test", false); |
||
858 | configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
||
859 | "Grid Location (X Axis)", "1000", false); |
||
860 | configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
||
861 | "Grid Location (Y Axis)", "1000", false); |
||
862 | //m_configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); |
||
863 | configMember.addConfigurationOption("internal_ip_address", |
||
864 | ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, |
||
865 | "Internal IP Address for incoming UDP client connections", "0.0.0.0", |
||
866 | false); |
||
867 | configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
868 | "Internal IP Port for incoming UDP client connections", |
||
869 | ConfigSettings.DefaultRegionHttpPort.ToString(), false); |
||
870 | configMember.addConfigurationOption("allow_alternate_ports", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, |
||
871 | "Allow sim to find alternate UDP ports when ports are in use?", |
||
872 | "false", true); |
||
873 | configMember.addConfigurationOption("external_host_name", |
||
874 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
||
875 | "External Host Name", "127.0.0.1", false); |
||
876 | configMember.addConfigurationOption("lastmap_uuid", ConfigurationOption.ConfigurationTypes.TYPE_UUID, |
||
877 | "Last Map UUID", lastMapUUID.ToString(), true); |
||
878 | |||
879 | configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
||
880 | "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); |
||
881 | |||
882 | configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
883 | "Maximum size for nonphysical prims", "0", true); |
||
884 | |||
885 | configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
886 | "Maximum size for physical prims", "0", true); |
||
887 | |||
888 | configMember.addConfigurationOption("clamp_prim_size", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, |
||
889 | "Clamp prims to max size", "false", true); |
||
890 | |||
891 | configMember.addConfigurationOption("object_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
892 | "Max objects this sim will hold", "15000", true); |
||
893 | |||
894 | configMember.addConfigurationOption("agent_capacity", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
||
895 | "Max avatars this sim will hold", "100", true); |
||
896 | |||
897 | configMember.addConfigurationOption("scope_id", ConfigurationOption.ConfigurationTypes.TYPE_UUID, |
||
898 | "Scope ID for this region", UUID.Zero.ToString(), true); |
||
899 | |||
900 | configMember.addConfigurationOption("region_type", ConfigurationOption.ConfigurationTypes.TYPE_STRING, |
||
901 | "Region Type", String.Empty, true); |
||
902 | |||
903 | configMember.addConfigurationOption("region_static_maptile", ConfigurationOption.ConfigurationTypes.TYPE_UUID, |
||
904 | "UUID of a texture to use as the map for this region", String.Empty, true); |
||
905 | } |
||
906 | |||
907 | public bool handleIncomingConfiguration(string configuration_key, object configuration_result) |
||
908 | { |
||
909 | switch (configuration_key) |
||
910 | { |
||
911 | case "sim_UUID": |
||
912 | RegionID = (UUID) configuration_result; |
||
913 | originRegionID = (UUID) configuration_result; |
||
914 | break; |
||
915 | case "sim_name": |
||
916 | RegionName = (string) configuration_result; |
||
917 | break; |
||
918 | case "sim_location_x": |
||
919 | m_regionLocX = (uint) configuration_result; |
||
920 | break; |
||
921 | case "sim_location_y": |
||
922 | m_regionLocY = (uint) configuration_result; |
||
923 | break; |
||
924 | case "internal_ip_address": |
||
925 | IPAddress address = (IPAddress) configuration_result; |
||
926 | m_internalEndPoint = new IPEndPoint(address, 0); |
||
927 | break; |
||
928 | case "internal_ip_port": |
||
929 | m_internalEndPoint.Port = (int) configuration_result; |
||
930 | break; |
||
931 | case "allow_alternate_ports": |
||
932 | m_allow_alternate_ports = (bool) configuration_result; |
||
933 | break; |
||
934 | case "external_host_name": |
||
935 | if ((string) configuration_result != "SYSTEMIP") |
||
936 | { |
||
937 | m_externalHostName = (string) configuration_result; |
||
938 | } |
||
939 | else |
||
940 | { |
||
941 | m_externalHostName = Util.GetLocalHost().ToString(); |
||
942 | } |
||
943 | break; |
||
944 | case "lastmap_uuid": |
||
945 | lastMapUUID = (UUID)configuration_result; |
||
946 | break; |
||
947 | case "lastmap_refresh": |
||
948 | lastMapRefresh = (string)configuration_result; |
||
949 | break; |
||
950 | case "nonphysical_prim_max": |
||
951 | m_nonphysPrimMax = (int)configuration_result; |
||
952 | break; |
||
953 | case "physical_prim_max": |
||
954 | m_physPrimMax = (int)configuration_result; |
||
955 | break; |
||
956 | case "clamp_prim_size": |
||
957 | m_clampPrimSize = (bool)configuration_result; |
||
958 | break; |
||
959 | case "object_capacity": |
||
960 | m_objectCapacity = (int)configuration_result; |
||
961 | break; |
||
962 | case "linkset_capacity": |
||
963 | m_linksetCapacity = (int)configuration_result; |
||
964 | break; |
||
965 | case "agent_capacity": |
||
966 | m_agentCapacity = (int)configuration_result; |
||
967 | break; |
||
968 | case "scope_id": |
||
969 | ScopeID = (UUID)configuration_result; |
||
970 | break; |
||
971 | case "region_type": |
||
972 | m_regionType = (string)configuration_result; |
||
973 | break; |
||
974 | case "region_static_maptile": |
||
975 | m_maptileStaticUUID = (UUID)configuration_result; |
||
976 | break; |
||
977 | } |
||
978 | |||
979 | return true; |
||
980 | } |
||
981 | |||
982 | public void SaveLastMapUUID(UUID mapUUID) |
||
983 | { |
||
984 | lastMapUUID = mapUUID; |
||
985 | lastMapRefresh = Util.UnixTimeSinceEpoch().ToString(); |
||
986 | |||
987 | if (configMember == null) |
||
988 | return; |
||
989 | |||
990 | configMember.forceSetConfigurationOption("lastmap_uuid", mapUUID.ToString()); |
||
991 | configMember.forceSetConfigurationOption("lastmap_refresh", lastMapRefresh); |
||
992 | } |
||
993 | |||
994 | public OSDMap PackRegionInfoData() |
||
995 | { |
||
996 | OSDMap args = new OSDMap(); |
||
997 | args["region_id"] = OSD.FromUUID(RegionID); |
||
998 | if ((RegionName != null) && !RegionName.Equals("")) |
||
999 | args["region_name"] = OSD.FromString(RegionName); |
||
1000 | args["external_host_name"] = OSD.FromString(ExternalHostName); |
||
1001 | args["http_port"] = OSD.FromString(HttpPort.ToString()); |
||
1002 | args["server_uri"] = OSD.FromString(ServerURI); |
||
1003 | args["region_xloc"] = OSD.FromString(RegionLocX.ToString()); |
||
1004 | args["region_yloc"] = OSD.FromString(RegionLocY.ToString()); |
||
1005 | args["internal_ep_address"] = OSD.FromString(InternalEndPoint.Address.ToString()); |
||
1006 | args["internal_ep_port"] = OSD.FromString(InternalEndPoint.Port.ToString()); |
||
1007 | if ((RemotingAddress != null) && !RemotingAddress.Equals("")) |
||
1008 | args["remoting_address"] = OSD.FromString(RemotingAddress); |
||
1009 | args["remoting_port"] = OSD.FromString(RemotingPort.ToString()); |
||
1010 | args["allow_alt_ports"] = OSD.FromBoolean(m_allow_alternate_ports); |
||
1011 | if ((proxyUrl != null) && !proxyUrl.Equals("")) |
||
1012 | args["proxy_url"] = OSD.FromString(proxyUrl); |
||
1013 | if (RegionType != String.Empty) |
||
1014 | args["region_type"] = OSD.FromString(RegionType); |
||
1015 | |||
1016 | return args; |
||
1017 | } |
||
1018 | |||
1019 | public void UnpackRegionInfoData(OSDMap args) |
||
1020 | { |
||
1021 | if (args["region_id"] != null) |
||
1022 | RegionID = args["region_id"].AsUUID(); |
||
1023 | if (args["region_name"] != null) |
||
1024 | RegionName = args["region_name"].AsString(); |
||
1025 | if (args["external_host_name"] != null) |
||
1026 | ExternalHostName = args["external_host_name"].AsString(); |
||
1027 | if (args["http_port"] != null) |
||
1028 | UInt32.TryParse(args["http_port"].AsString(), out m_httpPort); |
||
1029 | if (args["server_uri"] != null) |
||
1030 | ServerURI = args["server_uri"].AsString(); |
||
1031 | if (args["region_xloc"] != null) |
||
1032 | { |
||
1033 | uint locx; |
||
1034 | UInt32.TryParse(args["region_xloc"].AsString(), out locx); |
||
1035 | RegionLocX = locx; |
||
1036 | } |
||
1037 | if (args["region_yloc"] != null) |
||
1038 | { |
||
1039 | uint locy; |
||
1040 | UInt32.TryParse(args["region_yloc"].AsString(), out locy); |
||
1041 | RegionLocY = locy; |
||
1042 | } |
||
1043 | IPAddress ip_addr = null; |
||
1044 | if (args["internal_ep_address"] != null) |
||
1045 | { |
||
1046 | IPAddress.TryParse(args["internal_ep_address"].AsString(), out ip_addr); |
||
1047 | } |
||
1048 | int port = 0; |
||
1049 | if (args["internal_ep_port"] != null) |
||
1050 | { |
||
1051 | Int32.TryParse(args["internal_ep_port"].AsString(), out port); |
||
1052 | } |
||
1053 | InternalEndPoint = new IPEndPoint(ip_addr, port); |
||
1054 | if (args["remoting_address"] != null) |
||
1055 | RemotingAddress = args["remoting_address"].AsString(); |
||
1056 | if (args["remoting_port"] != null) |
||
1057 | UInt32.TryParse(args["remoting_port"].AsString(), out m_remotingPort); |
||
1058 | if (args["allow_alt_ports"] != null) |
||
1059 | m_allow_alternate_ports = args["allow_alt_ports"].AsBoolean(); |
||
1060 | if (args["proxy_url"] != null) |
||
1061 | proxyUrl = args["proxy_url"].AsString(); |
||
1062 | if (args["region_type"] != null) |
||
1063 | m_regionType = args["region_type"].AsString(); |
||
1064 | } |
||
1065 | |||
1066 | public static RegionInfo Create(UUID regionID, string regionName, uint regX, uint regY, string externalHostName, uint httpPort, uint simPort, uint remotingPort, string serverURI) |
||
1067 | { |
||
1068 | RegionInfo regionInfo; |
||
1069 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(externalHostName), (int)simPort); |
||
1070 | regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, externalHostName); |
||
1071 | regionInfo.RemotingPort = remotingPort; |
||
1072 | regionInfo.RemotingAddress = externalHostName; |
||
1073 | regionInfo.HttpPort = httpPort; |
||
1074 | regionInfo.RegionID = regionID; |
||
1075 | regionInfo.RegionName = regionName; |
||
1076 | regionInfo.ServerURI = serverURI; |
||
1077 | return regionInfo; |
||
1078 | } |
||
1079 | |||
1080 | public Dictionary<string, object> ToKeyValuePairs() |
||
1081 | { |
||
1082 | Dictionary<string, object> kvp = new Dictionary<string, object>(); |
||
1083 | kvp["uuid"] = RegionID.ToString(); |
||
1084 | kvp["locX"] = RegionLocX.ToString(); |
||
1085 | kvp["locY"] = RegionLocY.ToString(); |
||
1086 | kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); |
||
1087 | kvp["external_port"] = ExternalEndPoint.Port.ToString(); |
||
1088 | kvp["external_host_name"] = ExternalHostName; |
||
1089 | kvp["http_port"] = HttpPort.ToString(); |
||
1090 | kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); |
||
1091 | kvp["internal_port"] = InternalEndPoint.Port.ToString(); |
||
1092 | kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); |
||
1093 | kvp["server_uri"] = ServerURI; |
||
1094 | |||
1095 | return kvp; |
||
1096 | } |
||
1097 | } |
||
1098 | } |