diff options
Diffstat (limited to '')
-rw-r--r-- | OpenGridServices.UserServer/Main.cs | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/OpenGridServices.UserServer/Main.cs b/OpenGridServices.UserServer/Main.cs index d13fe26..53d3fb1 100644 --- a/OpenGridServices.UserServer/Main.cs +++ b/OpenGridServices.UserServer/Main.cs | |||
@@ -30,12 +30,14 @@ Copyright (c) OpenSim project, http://osgrid.org/ | |||
30 | using System; | 30 | using System; |
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Reflection; | ||
33 | using System.IO; | 34 | using System.IO; |
34 | using System.Text; | 35 | using System.Text; |
35 | using libsecondlife; | 36 | using libsecondlife; |
36 | using OpenSim.Framework.User; | 37 | using OpenSim.Framework.User; |
37 | using OpenSim.Framework.Sims; | 38 | using OpenSim.Framework.Sims; |
38 | using OpenSim.Framework.Inventory; | 39 | using OpenSim.Framework.Inventory; |
40 | using OpenSim.Framework.Interfaces; | ||
39 | using OpenSim.Framework.Console; | 41 | using OpenSim.Framework.Console; |
40 | 42 | ||
41 | namespace OpenGridServices.UserServer | 43 | namespace OpenGridServices.UserServer |
@@ -44,20 +46,17 @@ namespace OpenGridServices.UserServer | |||
44 | /// </summary> | 46 | /// </summary> |
45 | public class OpenUser_Main : conscmd_callback | 47 | public class OpenUser_Main : conscmd_callback |
46 | { | 48 | { |
47 | 49 | private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll"; | |
50 | private UserConfig Cfg; | ||
51 | |||
48 | public static OpenUser_Main userserver; | 52 | public static OpenUser_Main userserver; |
49 | 53 | ||
50 | public UserHTTPServer _httpd; | 54 | public UserHTTPServer _httpd; |
51 | public UserProfileManager _profilemanager; | 55 | public UserProfileManager _profilemanager; |
52 | public UserProfile GridGod; | ||
53 | public string DefaultStartupMsg; | ||
54 | public string GridURL; | ||
55 | public string GridSendKey; | ||
56 | public string GridRecvKey; | ||
57 | 56 | ||
58 | public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>(); | 57 | public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>(); |
59 | 58 | ||
60 | ConsoleBase m_console; | 59 | ConsoleBase m_console; |
61 | 60 | ||
62 | [STAThread] | 61 | [STAThread] |
63 | public static void Main( string[] args ) | 62 | public static void Main( string[] args ) |
@@ -72,9 +71,9 @@ namespace OpenGridServices.UserServer | |||
72 | 71 | ||
73 | private OpenUser_Main() | 72 | private OpenUser_Main() |
74 | { | 73 | { |
75 | m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this); | 74 | m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this); |
76 | MainConsole.Instance = m_console; | 75 | MainConsole.Instance = m_console; |
77 | } | 76 | } |
78 | 77 | ||
79 | private void Work() | 78 | private void Work() |
80 | { | 79 | { |
@@ -87,42 +86,14 @@ namespace OpenGridServices.UserServer | |||
87 | } | 86 | } |
88 | 87 | ||
89 | public void Startup() { | 88 | public void Startup() { |
90 | MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings"); | 89 | MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration"); |
90 | Cfg = this.LoadConfigDll(this.ConfigDll); | ||
91 | Cfg.InitConfig(); | ||
91 | 92 | ||
92 | this.GridURL=MainConsole.Instance.CmdPrompt("Grid URL: "); | ||
93 | this.GridSendKey=MainConsole.Instance.CmdPrompt("Key to send to grid: "); | ||
94 | this.GridRecvKey=MainConsole.Instance.CmdPrompt("Key to expect from grid: "); | ||
95 | |||
96 | this.DefaultStartupMsg=MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!] :","Welcome to OGS!"); | ||
97 | |||
98 | MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager"); | 93 | MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager"); |
99 | _profilemanager = new UserProfileManager(); | 94 | _profilemanager = new UserProfileManager(); |
100 | _profilemanager.InitUserProfiles(); | 95 | _profilemanager.InitUserProfiles(); |
101 | _profilemanager.SetKeys(GridSendKey, GridRecvKey, GridURL, DefaultStartupMsg); | 96 | _profilemanager.SetKeys(Cfg.GridSendKey, Cfg.GridRecvKey, Cfg.GridServerURL, Cfg.DefaultStartupMsg); |
102 | |||
103 | |||
104 | string tempfirstname; | ||
105 | string templastname; | ||
106 | string tempMD5Passwd; | ||
107 | MainConsole.Instance.WriteLine("Main.cs:Startup() - Please configure the grid god user:"); | ||
108 | tempfirstname=MainConsole.Instance.CmdPrompt("First name: "); | ||
109 | templastname=MainConsole.Instance.CmdPrompt("Last name: "); | ||
110 | tempMD5Passwd=MainConsole.Instance.PasswdPrompt("Password: "); | ||
111 | |||
112 | System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); | ||
113 | byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd); | ||
114 | bs = x.ComputeHash(bs); | ||
115 | System.Text.StringBuilder s = new System.Text.StringBuilder(); | ||
116 | foreach (byte b in bs) | ||
117 | { | ||
118 | s.Append(b.ToString("x2").ToLower()); | ||
119 | } | ||
120 | tempMD5Passwd = "$1$" + s.ToString(); | ||
121 | |||
122 | GridGod=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd); | ||
123 | _profilemanager.SetGod(GridGod.UUID); | ||
124 | GridGod.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f); | ||
125 | GridGod.homepos = new LLVector3(128f,128f,23f); | ||
126 | 97 | ||
127 | MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process"); | 98 | MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process"); |
128 | _httpd = new UserHTTPServer(); | 99 | _httpd = new UserHTTPServer(); |
@@ -142,6 +113,34 @@ namespace OpenGridServices.UserServer | |||
142 | break; | 113 | break; |
143 | } | 114 | } |
144 | } | 115 | } |
116 | |||
117 | private UserConfig LoadConfigDll(string dllName) | ||
118 | { | ||
119 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
120 | UserConfig config = null; | ||
121 | |||
122 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
123 | { | ||
124 | if (pluginType.IsPublic) | ||
125 | { | ||
126 | if (!pluginType.IsAbstract) | ||
127 | { | ||
128 | Type typeInterface = pluginType.GetInterface("IUserConfig", true); | ||
129 | |||
130 | if (typeInterface != null) | ||
131 | { | ||
132 | IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
133 | config = plug.GetConfigObject(); | ||
134 | break; | ||
135 | } | ||
136 | |||
137 | typeInterface = null; | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | pluginAssembly = null; | ||
142 | return config; | ||
143 | } | ||
145 | 144 | ||
146 | public void Show(string ShowWhat) | 145 | public void Show(string ShowWhat) |
147 | { | 146 | { |