NetworkServersInfo.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. */
  28. using System;
  29. using OpenSim.Framework.Console;
  30. using OpenSim.Framework.Interfaces;
  31. namespace OpenSim.Framework.Types
  32. {
  33. public class NetworkServersInfo
  34. {
  35. public string AssetURL = "http://127.0.0.1:8003/";
  36. public string AssetSendKey = "";
  37. public string GridURL = "";
  38. public string GridSendKey = "";
  39. public string GridRecvKey = "";
  40. public string UserURL = "";
  41. public string UserSendKey = "";
  42. public string UserRecvKey = "";
  43. public bool isSandbox;
  44. public uint DefaultHomeLocX = 1000;
  45. public uint DefaultHomeLocY = 1000;
  46. public int HttpListenerPort = 9000;
  47. public int RemotingListenerPort = 8895;
  48. public void InitConfig(bool sandboxMode, IGenericConfig configData)
  49. {
  50. this.isSandbox = sandboxMode;
  51. try
  52. {
  53. string attri = "";
  54. attri = "";
  55. attri = configData.GetAttribute("HttpListenerPort");
  56. if (attri == "")
  57. {
  58. string location = MainLog.Instance.CmdPrompt("Http Listener Port", "9000");
  59. configData.SetAttribute("HttpListenerPort", location);
  60. this.HttpListenerPort = Convert.ToInt32(location);
  61. }
  62. else
  63. {
  64. this.HttpListenerPort = Convert.ToInt32(attri);
  65. }
  66. attri = "";
  67. attri = configData.GetAttribute("RemotingListenerPort");
  68. if (attri == "")
  69. {
  70. string location = MainLog.Instance.CmdPrompt("Remoting Listener Port", "8895");
  71. configData.SetAttribute("RemotingListenerPort", location);
  72. this.RemotingListenerPort = Convert.ToInt32(location);
  73. }
  74. else
  75. {
  76. this.RemotingListenerPort = Convert.ToInt32(attri);
  77. }
  78. if (sandboxMode)
  79. {
  80. // default home location X
  81. attri = "";
  82. attri = configData.GetAttribute("DefaultLocationX");
  83. if (attri == "")
  84. {
  85. string location = MainLog.Instance.CmdPrompt("Default Home Location X", "1000");
  86. configData.SetAttribute("DefaultLocationX", location);
  87. this.DefaultHomeLocX = (uint)Convert.ToUInt32(location);
  88. }
  89. else
  90. {
  91. this.DefaultHomeLocX = (uint)Convert.ToUInt32(attri);
  92. }
  93. // default home location Y
  94. attri = "";
  95. attri = configData.GetAttribute("DefaultLocationY");
  96. if (attri == "")
  97. {
  98. string location = MainLog.Instance.CmdPrompt("Default Home Location Y", "1000");
  99. configData.SetAttribute("DefaultLocationY", location);
  100. this.DefaultHomeLocY = (uint)Convert.ToUInt32(location);
  101. }
  102. else
  103. {
  104. this.DefaultHomeLocY = (uint)Convert.ToUInt32(attri);
  105. }
  106. }
  107. if (!isSandbox)
  108. {
  109. //Grid Server
  110. attri = "";
  111. attri = configData.GetAttribute("GridServerURL");
  112. if (attri == "")
  113. {
  114. this.GridURL = MainLog.Instance.CmdPrompt("Grid server URL", "http://127.0.0.1:8001/");
  115. configData.SetAttribute("GridServerURL", this.GridURL);
  116. }
  117. else
  118. {
  119. this.GridURL = attri;
  120. }
  121. //Grid Send Key
  122. attri = "";
  123. attri = configData.GetAttribute("GridSendKey");
  124. if (attri == "")
  125. {
  126. this.GridSendKey = MainLog.Instance.CmdPrompt("Key to send to grid server", "null");
  127. configData.SetAttribute("GridSendKey", this.GridSendKey);
  128. }
  129. else
  130. {
  131. this.GridSendKey = attri;
  132. }
  133. //Grid Receive Key
  134. attri = "";
  135. attri = configData.GetAttribute("GridRecvKey");
  136. if (attri == "")
  137. {
  138. this.GridRecvKey = MainLog.Instance.CmdPrompt("Key to expect from grid server", "null");
  139. configData.SetAttribute("GridRecvKey", this.GridRecvKey);
  140. }
  141. else
  142. {
  143. this.GridRecvKey = attri;
  144. }
  145. //Grid Server
  146. attri = "";
  147. attri = configData.GetAttribute("UserServerURL");
  148. if (attri == "")
  149. {
  150. this.UserURL= MainLog.Instance.CmdPrompt("User server URL", "http://127.0.0.1:8002/");
  151. configData.SetAttribute("UserServerURL", this.UserURL);
  152. }
  153. else
  154. {
  155. this.UserURL = attri;
  156. }
  157. //Grid Send Key
  158. attri = "";
  159. attri = configData.GetAttribute("UserSendKey");
  160. if (attri == "")
  161. {
  162. this.UserSendKey = MainLog.Instance.CmdPrompt("Key to send to user server", "null");
  163. configData.SetAttribute("UserSendKey", this.UserSendKey);
  164. }
  165. else
  166. {
  167. this.UserSendKey = attri;
  168. }
  169. //Grid Receive Key
  170. attri = "";
  171. attri = configData.GetAttribute("UserRecvKey");
  172. if (attri == "")
  173. {
  174. this.UserRecvKey = MainLog.Instance.CmdPrompt("Key to expect from user server", "null");
  175. configData.SetAttribute("UserRecvKey", this.UserRecvKey);
  176. }
  177. else
  178. {
  179. this.UserRecvKey = attri;
  180. }
  181. attri = "";
  182. attri = configData.GetAttribute("AssetServerURL");
  183. if (attri == "")
  184. {
  185. this.AssetURL = MainLog.Instance.CmdPrompt("Asset server URL", "http://127.0.0.1:8003/");
  186. configData.SetAttribute("AssetServerURL", this.GridURL);
  187. }
  188. else
  189. {
  190. this.AssetURL = attri;
  191. }
  192. }
  193. configData.Commit();
  194. }
  195. catch (Exception e)
  196. {
  197. MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured");
  198. MainLog.Instance.Warn(e.ToString());
  199. }
  200. }
  201. }
  202. }