Main.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. Copyright (c) OpenSim project, http://osgrid.org/
  3. * All rights reserved.
  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 <organization> 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 <copyright holder> ``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 <copyright holder> 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. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.IO;
  31. using System.Text;
  32. using libsecondlife;
  33. using OpenSim.Framework.User;
  34. using OpenSim.Framework.Sims;
  35. using OpenSim.Framework.Inventory;
  36. using OpenSim.Framework.Console;
  37. namespace OpenGridServices.UserServer
  38. {
  39. /// <summary>
  40. /// </summary>
  41. public class OpenUser_Main : conscmd_callback
  42. {
  43. public static OpenUser_Main userserver;
  44. public UserHTTPServer _httpd;
  45. public UserProfileManager _profilemanager;
  46. public UserProfile GridGod;
  47. public string DefaultStartupMsg;
  48. public string GridURL;
  49. public string GridSendKey;
  50. public string GridRecvKey;
  51. public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
  52. ConsoleBase m_console;
  53. [STAThread]
  54. public static void Main( string[] args )
  55. {
  56. Console.WriteLine("Starting...\n");
  57. userserver = new OpenUser_Main();
  58. userserver.Startup();
  59. userserver.Work();
  60. }
  61. private OpenUser_Main()
  62. {
  63. m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this);
  64. MainConsole.Instance = m_console;
  65. }
  66. private void Work()
  67. {
  68. m_console.WriteLine("\nEnter help for a list of commands\n");
  69. while (true)
  70. {
  71. m_console.MainConsolePrompt();
  72. }
  73. }
  74. public void Startup() {
  75. MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter for default settings");
  76. this.GridURL = MainConsole.Instance.CmdPrompt("Grid URL", "http://localhost:8001/gridserver");
  77. this.GridSendKey=MainConsole.Instance.CmdPrompt("Key to send to grid");
  78. this.GridRecvKey=MainConsole.Instance.CmdPrompt("Key to expect from grid");
  79. this.DefaultStartupMsg=MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!] :","Welcome to OGS!");
  80. MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager");
  81. _profilemanager = new UserProfileManager();
  82. _profilemanager.InitUserProfiles();
  83. _profilemanager.SetKeys(GridSendKey, GridRecvKey, GridURL, DefaultStartupMsg);
  84. string tempfirstname;
  85. string templastname;
  86. string tempMD5Passwd;
  87. MainConsole.Instance.WriteLine("Main.cs:Startup() - Please configure the grid god user:");
  88. tempfirstname=MainConsole.Instance.CmdPrompt("First name", "God");
  89. templastname=MainConsole.Instance.CmdPrompt("Last name", "User");
  90. tempMD5Passwd=MainConsole.Instance.PasswdPrompt("Password");
  91. System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
  92. byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
  93. bs = x.ComputeHash(bs);
  94. System.Text.StringBuilder s = new System.Text.StringBuilder();
  95. foreach (byte b in bs)
  96. {
  97. s.Append(b.ToString("x2").ToLower());
  98. }
  99. tempMD5Passwd = "$1$" + s.ToString();
  100. GridGod=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd);
  101. _profilemanager.SetGod(GridGod.UUID);
  102. GridGod.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
  103. GridGod.homepos = new LLVector3(128f,128f,23f);
  104. MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
  105. _httpd = new UserHTTPServer();
  106. }
  107. public void RunCmd(string cmd, string[] cmdparams)
  108. {
  109. switch (cmd)
  110. {
  111. case "help":
  112. m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)");
  113. break;
  114. case "shutdown":
  115. m_console.Close();
  116. Environment.Exit(0);
  117. break;
  118. }
  119. }
  120. public void Show(string ShowWhat)
  121. {
  122. }
  123. }
  124. }