diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim.Framework/UserProfileManager.cs | 469 | ||||
-rw-r--r-- | OpenSim.RegionServer/CAPS/IXmlRPCHandler.cs | 11 | ||||
-rw-r--r-- | OpenSim.RegionServer/CAPS/SimHttp.cs | 241 | ||||
-rw-r--r-- | OpenSim.RegionServer/OpenSim.RegionServer.csproj | 7 | ||||
-rw-r--r-- | OpenSim.RegionServer/OpenSim.RegionServer.dll.build | 3 | ||||
-rw-r--r-- | OpenSim.RegionServer/OpenSimMain.cs | 86 | ||||
-rw-r--r-- | OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs | 2 | ||||
-rw-r--r-- | OpenSim.RegionServer/UserServer/LoginServer.cs | 303 | ||||
-rw-r--r-- | Servers/BaseHttpServer.cs | 201 | ||||
-rw-r--r-- | Servers/IRestHandler.cs (renamed from OpenSim.RegionServer/CAPS/IRestHandler.cs) | 0 | ||||
-rw-r--r-- | Servers/OpenSim.Servers.csproj | 2 | ||||
-rw-r--r-- | Servers/OpenSim.Servers.dll.build | 2 | ||||
-rw-r--r-- | Servers/XmlRpcMethod.cs | 7 |
13 files changed, 766 insertions, 568 deletions
diff --git a/OpenSim.Framework/UserProfileManager.cs b/OpenSim.Framework/UserProfileManager.cs index 22375bc..ef5ab71 100644 --- a/OpenSim.Framework/UserProfileManager.cs +++ b/OpenSim.Framework/UserProfileManager.cs | |||
@@ -32,164 +32,353 @@ namespace OpenSim.Framework.User | |||
32 | DefaultStartupMsg = message; | 32 | DefaultStartupMsg = message; |
33 | } | 33 | } |
34 | 34 | ||
35 | /* public virtual string ParseXMLRPC(string requestBody) | ||
36 | { | ||
37 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); | ||
38 | |||
39 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
40 | switch (request.MethodName) | ||
41 | { | ||
42 | case "login_to_simulator":*/ | ||
43 | |||
35 | public virtual string ParseXMLRPC(string requestBody) | 44 | public virtual string ParseXMLRPC(string requestBody) |
36 | { | 45 | { |
46 | |||
37 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); | 47 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); |
38 | 48 | ||
39 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
40 | switch (request.MethodName) | 49 | switch (request.MethodName) |
41 | { | 50 | { |
42 | case "login_to_simulator": | 51 | case "login_to_simulator": |
43 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); | 52 | XmlRpcResponse response = XmlRpcLoginMethod(request); |
44 | bool GoodLogin = false; | ||
45 | string firstname = ""; | ||
46 | string lastname = ""; | ||
47 | string passwd = ""; | ||
48 | 53 | ||
49 | if (GoodXML) | 54 | return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(response), "utf-16", "utf-8")); |
50 | { | 55 | } |
51 | firstname = (string)requestData["first"]; | 56 | |
52 | lastname = (string)requestData["last"]; | 57 | return ""; |
53 | passwd = (string)requestData["passwd"]; | 58 | } |
54 | GoodLogin = AuthenticateUser(firstname, lastname, passwd); | ||
55 | } | ||
56 | 59 | ||
60 | /* public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
61 | { | ||
62 | XmlRpcResponse response = new XmlRpcResponse(); | ||
63 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
57 | 64 | ||
58 | if (!(GoodXML && GoodLogin)) | 65 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); |
59 | { | 66 | bool GoodLogin = false; |
60 | XmlRpcResponse LoginErrorResp = new XmlRpcResponse(); | 67 | string firstname = ""; |
61 | Hashtable ErrorRespData = new Hashtable(); | 68 | string lastname = ""; |
62 | ErrorRespData["reason"] = "key"; | 69 | string passwd = ""; |
63 | ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct"; | ||
64 | ErrorRespData["login"] = "false"; | ||
65 | LoginErrorResp.Value = ErrorRespData; | ||
66 | return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginErrorResp), " encoding=\"utf-16\"", "")); | ||
67 | } | ||
68 | 70 | ||
69 | UserProfile TheUser = GetProfileByName(firstname, lastname); | 71 | if (GoodXML) |
72 | { | ||
73 | firstname = (string)requestData["first"]; | ||
74 | lastname = (string)requestData["last"]; | ||
75 | passwd = (string)requestData["passwd"]; | ||
76 | GoodLogin = AuthenticateUser(firstname, lastname, passwd); | ||
77 | } | ||
70 | 78 | ||
71 | /* | ||
72 | if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null))) | ||
73 | { | ||
74 | XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); | ||
75 | Hashtable PresenceErrorRespData = new Hashtable(); | ||
76 | PresenceErrorRespData["reason"] = "presence"; | ||
77 | PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner"; | ||
78 | PresenceErrorRespData["login"] = "false"; | ||
79 | PresenceErrorResp.Value = PresenceErrorRespData; | ||
80 | return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", "")); | ||
81 | 79 | ||
82 | }*/ | 80 | if (!(GoodXML && GoodLogin)) |
81 | { | ||
82 | XmlRpcResponse LoginErrorResp = new XmlRpcResponse(); | ||
83 | Hashtable ErrorRespData = new Hashtable(); | ||
84 | ErrorRespData["reason"] = "key"; | ||
85 | ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct"; | ||
86 | ErrorRespData["login"] = "false"; | ||
87 | LoginErrorResp.Value = ErrorRespData; | ||
88 | return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginErrorResp), " encoding=\"utf-16\"", "")); | ||
89 | } | ||
83 | 90 | ||
84 | try | 91 | UserProfile TheUser = GetProfileByName(firstname, lastname); |
85 | { | ||
86 | LLUUID AgentID = TheUser.UUID; | ||
87 | TheUser.InitSessionData(); | ||
88 | // SimProfile SimInfo = new SimProfile(); | ||
89 | // SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); | ||
90 | |||
91 | XmlRpcResponse LoginGoodResp = new XmlRpcResponse(); | ||
92 | Hashtable LoginGoodData = new Hashtable(); | ||
93 | |||
94 | Hashtable GlobalT = new Hashtable(); | ||
95 | GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
96 | GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
97 | GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
98 | ArrayList GlobalTextures = new ArrayList(); | ||
99 | GlobalTextures.Add(GlobalT); | ||
100 | |||
101 | Hashtable LoginFlagsHash = new Hashtable(); | ||
102 | LoginFlagsHash["daylight_savings"] = "N"; | ||
103 | LoginFlagsHash["stipend_since_login"] = "N"; | ||
104 | LoginFlagsHash["gendered"] = "Y"; | ||
105 | LoginFlagsHash["ever_logged_in"] = "Y"; | ||
106 | ArrayList LoginFlags = new ArrayList(); | ||
107 | LoginFlags.Add(LoginFlagsHash); | ||
108 | |||
109 | Hashtable uiconfig = new Hashtable(); | ||
110 | uiconfig["allow_first_life"] = "Y"; | ||
111 | ArrayList ui_config = new ArrayList(); | ||
112 | ui_config.Add(uiconfig); | ||
113 | |||
114 | Hashtable ClassifiedCategoriesHash = new Hashtable(); | ||
115 | ClassifiedCategoriesHash["category_name"] = "bla bla"; | ||
116 | ClassifiedCategoriesHash["category_id"] = (Int32)1; | ||
117 | ArrayList ClassifiedCategories = new ArrayList(); | ||
118 | ClassifiedCategories.Add(ClassifiedCategoriesHash); | ||
119 | |||
120 | Console.WriteLine("copying inventory data to response"); | ||
121 | ArrayList AgentInventory = new ArrayList(); | ||
122 | foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values) | ||
123 | { | ||
124 | Hashtable TempHash = new Hashtable(); | ||
125 | TempHash["name"] = InvFolder.FolderName; | ||
126 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | ||
127 | TempHash["version"] = (Int32)InvFolder.Version; | ||
128 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | ||
129 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | ||
130 | AgentInventory.Add(TempHash); | ||
131 | } | ||
132 | |||
133 | Hashtable InventoryRootHash = new Hashtable(); | ||
134 | InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated(); | ||
135 | ArrayList InventoryRoot = new ArrayList(); | ||
136 | InventoryRoot.Add(InventoryRootHash); | ||
137 | |||
138 | Hashtable InitialOutfitHash = new Hashtable(); | ||
139 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
140 | InitialOutfitHash["gender"] = "female"; | ||
141 | ArrayList InitialOutfit = new ArrayList(); | ||
142 | InitialOutfit.Add(InitialOutfitHash); | ||
143 | |||
144 | uint circode = (uint)(Util.RandomClass.Next()); | ||
145 | //TheUser.AddSimCircuit(circode, SimInfo.UUID); | ||
146 | |||
147 | LoginGoodData["last_name"] = TheUser.lastname ; | ||
148 | LoginGoodData["ui-config"] = ui_config; | ||
149 | LoginGoodData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); | ||
150 | LoginGoodData["login-flags"] = LoginFlags; | ||
151 | LoginGoodData["global-textures"] = GlobalTextures; | ||
152 | LoginGoodData["classified_categories"] = ClassifiedCategories; | ||
153 | LoginGoodData["event_categories"] = new ArrayList(); | ||
154 | LoginGoodData["inventory-skeleton"] = AgentInventory; | ||
155 | LoginGoodData["inventory-skel-lib"] = new ArrayList(); | ||
156 | LoginGoodData["inventory-root"] = InventoryRoot; | ||
157 | LoginGoodData["event_notifications"] = new ArrayList(); | ||
158 | LoginGoodData["gestures"] = new ArrayList(); | ||
159 | LoginGoodData["inventory-lib-owner"] = new ArrayList(); | ||
160 | LoginGoodData["initial-outfit"] = InitialOutfit; | ||
161 | LoginGoodData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
162 | LoginGoodData["start_location"] = "last"; | ||
163 | LoginGoodData["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}"; | ||
164 | LoginGoodData["message"] = DefaultStartupMsg; | ||
165 | LoginGoodData["first_name"] = TheUser.firstname ; | ||
166 | LoginGoodData["circuit_code"] = (Int32)circode; | ||
167 | LoginGoodData["sim_port"] = 9000; //(Int32)SimInfo.sim_port; | ||
168 | LoginGoodData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated(); | ||
169 | LoginGoodData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n"; | ||
170 | LoginGoodData["agent_id"] = AgentID.ToStringHyphenated(); | ||
171 | LoginGoodData["region_y"] = (Int32) 996 * 256; // (Int32)SimInfo.RegionLocY * 256; | ||
172 | LoginGoodData["region_x"] = (Int32) 997 * 256; //SimInfo.RegionLocX * 256; | ||
173 | LoginGoodData["seed_capability"] = null; | ||
174 | LoginGoodData["agent_access"] = "M"; | ||
175 | LoginGoodData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated(); | ||
176 | LoginGoodData["login"] = "true"; | ||
177 | |||
178 | this.CustomiseResponse(ref LoginGoodData, TheUser); | ||
179 | LoginGoodResp.Value = LoginGoodData; | ||
180 | //TheUser.SendDataToSim(SimInfo); | ||
181 | return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginGoodResp), "utf-16", "utf-8")); | ||
182 | 92 | ||
183 | } | 93 | |
184 | catch (Exception E) | 94 | if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null))) |
95 | { | ||
96 | XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); | ||
97 | Hashtable PresenceErrorRespData = new Hashtable(); | ||
98 | PresenceErrorRespData["reason"] = "presence"; | ||
99 | PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner"; | ||
100 | PresenceErrorRespData["login"] = "false"; | ||
101 | PresenceErrorResp.Value = PresenceErrorRespData; | ||
102 | return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", "")); | ||
103 | |||
104 | } | ||
105 | |||
106 | try | ||
107 | { | ||
108 | LLUUID AgentID = TheUser.UUID; | ||
109 | TheUser.InitSessionData(); | ||
110 | // SimProfile SimInfo = new SimProfile(); | ||
111 | // SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); | ||
112 | |||
113 | XmlRpcResponse LoginGoodResp = new XmlRpcResponse(); | ||
114 | Hashtable LoginGoodData = new Hashtable(); | ||
115 | |||
116 | Hashtable GlobalT = new Hashtable(); | ||
117 | GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
118 | GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
119 | GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
120 | ArrayList GlobalTextures = new ArrayList(); | ||
121 | GlobalTextures.Add(GlobalT); | ||
122 | |||
123 | Hashtable LoginFlagsHash = new Hashtable(); | ||
124 | LoginFlagsHash["daylight_savings"] = "N"; | ||
125 | LoginFlagsHash["stipend_since_login"] = "N"; | ||
126 | LoginFlagsHash["gendered"] = "Y"; | ||
127 | LoginFlagsHash["ever_logged_in"] = "Y"; | ||
128 | ArrayList LoginFlags = new ArrayList(); | ||
129 | LoginFlags.Add(LoginFlagsHash); | ||
130 | |||
131 | Hashtable uiconfig = new Hashtable(); | ||
132 | uiconfig["allow_first_life"] = "Y"; | ||
133 | ArrayList ui_config = new ArrayList(); | ||
134 | ui_config.Add(uiconfig); | ||
135 | |||
136 | Hashtable ClassifiedCategoriesHash = new Hashtable(); | ||
137 | ClassifiedCategoriesHash["category_name"] = "bla bla"; | ||
138 | ClassifiedCategoriesHash["category_id"] = (Int32)1; | ||
139 | ArrayList ClassifiedCategories = new ArrayList(); | ||
140 | ClassifiedCategories.Add(ClassifiedCategoriesHash); | ||
141 | |||
142 | Console.WriteLine("copying inventory data to response"); | ||
143 | ArrayList AgentInventory = new ArrayList(); | ||
144 | foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values) | ||
145 | { | ||
146 | Hashtable TempHash = new Hashtable(); | ||
147 | TempHash["name"] = InvFolder.FolderName; | ||
148 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | ||
149 | TempHash["version"] = (Int32)InvFolder.Version; | ||
150 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | ||
151 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | ||
152 | AgentInventory.Add(TempHash); | ||
153 | } | ||
154 | |||
155 | Hashtable InventoryRootHash = new Hashtable(); | ||
156 | InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated(); | ||
157 | ArrayList InventoryRoot = new ArrayList(); | ||
158 | InventoryRoot.Add(InventoryRootHash); | ||
159 | |||
160 | Hashtable InitialOutfitHash = new Hashtable(); | ||
161 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
162 | InitialOutfitHash["gender"] = "female"; | ||
163 | ArrayList InitialOutfit = new ArrayList(); | ||
164 | InitialOutfit.Add(InitialOutfitHash); | ||
165 | |||
166 | uint circode = (uint)(Util.RandomClass.Next()); | ||
167 | //TheUser.AddSimCircuit(circode, SimInfo.UUID); | ||
168 | |||
169 | LoginGoodData["last_name"] = TheUser.lastname ; | ||
170 | LoginGoodData["ui-config"] = ui_config; | ||
171 | LoginGoodData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); | ||
172 | LoginGoodData["login-flags"] = LoginFlags; | ||
173 | LoginGoodData["global-textures"] = GlobalTextures; | ||
174 | LoginGoodData["classified_categories"] = ClassifiedCategories; | ||
175 | LoginGoodData["event_categories"] = new ArrayList(); | ||
176 | LoginGoodData["inventory-skeleton"] = AgentInventory; | ||
177 | LoginGoodData["inventory-skel-lib"] = new ArrayList(); | ||
178 | LoginGoodData["inventory-root"] = InventoryRoot; | ||
179 | LoginGoodData["event_notifications"] = new ArrayList(); | ||
180 | LoginGoodData["gestures"] = new ArrayList(); | ||
181 | LoginGoodData["inventory-lib-owner"] = new ArrayList(); | ||
182 | LoginGoodData["initial-outfit"] = InitialOutfit; | ||
183 | LoginGoodData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
184 | LoginGoodData["start_location"] = "last"; | ||
185 | LoginGoodData["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}"; | ||
186 | LoginGoodData["message"] = DefaultStartupMsg; | ||
187 | LoginGoodData["first_name"] = TheUser.firstname ; | ||
188 | LoginGoodData["circuit_code"] = (Int32)circode; | ||
189 | LoginGoodData["sim_port"] = 9000; //(Int32)SimInfo.sim_port; | ||
190 | LoginGoodData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated(); | ||
191 | LoginGoodData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n"; | ||
192 | LoginGoodData["agent_id"] = AgentID.ToStringHyphenated(); | ||
193 | LoginGoodData["region_y"] = (Int32) 996 * 256; // (Int32)SimInfo.RegionLocY * 256; | ||
194 | LoginGoodData["region_x"] = (Int32) 997 * 256; //SimInfo.RegionLocX * 256; | ||
195 | LoginGoodData["seed_capability"] = null; | ||
196 | LoginGoodData["agent_access"] = "M"; | ||
197 | LoginGoodData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated(); | ||
198 | LoginGoodData["login"] = "true"; | ||
199 | |||
200 | this.CustomiseResponse(ref LoginGoodData, TheUser); | ||
201 | LoginGoodResp.Value = LoginGoodData; | ||
202 | //TheUser.SendDataToSim(SimInfo); | ||
203 | return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(LoginGoodResp), "utf-16", "utf-8")); | ||
204 | |||
205 | } | ||
206 | catch (Exception E) | ||
207 | { | ||
208 | Console.WriteLine(E.ToString()); | ||
209 | } | ||
210 | |||
211 | break; | ||
212 | } | ||
213 | |||
214 | return ""; | ||
215 | }*/ | ||
216 | |||
217 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
218 | { | ||
219 | XmlRpcResponse response = new XmlRpcResponse(); | ||
220 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
221 | |||
222 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); | ||
223 | bool GoodLogin = false; | ||
224 | string firstname = ""; | ||
225 | string lastname = ""; | ||
226 | string passwd = ""; | ||
227 | |||
228 | if (GoodXML) | ||
229 | { | ||
230 | firstname = (string)requestData["first"]; | ||
231 | lastname = (string)requestData["last"]; | ||
232 | passwd = (string)requestData["passwd"]; | ||
233 | GoodLogin = AuthenticateUser(firstname, lastname, passwd); | ||
234 | } | ||
235 | |||
236 | |||
237 | if (!(GoodXML && GoodLogin)) | ||
238 | { | ||
239 | response = CreateErrorConnectingToGridResponse(); | ||
240 | } | ||
241 | else | ||
242 | { | ||
243 | UserProfile TheUser = GetProfileByName(firstname, lastname); | ||
244 | //we need to sort out how sessions are logged out , currently the sim tells the gridserver | ||
245 | //but if as this suggests the userserver handles it then please have the sim telling the userserver instead | ||
246 | //as it really makes things messy for sandbox mode | ||
247 | //if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null))) | ||
248 | // { | ||
249 | // response = CreateAlreadyLoggedInResponse(); | ||
250 | // } | ||
251 | //else | ||
252 | //{ | ||
253 | try | ||
254 | { | ||
255 | Hashtable responseData = new Hashtable(); | ||
256 | |||
257 | LLUUID AgentID = TheUser.UUID; | ||
258 | TheUser.InitSessionData(); | ||
259 | // SimProfile SimInfo = new SimProfile(); | ||
260 | // SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); | ||
261 | |||
262 | |||
263 | Hashtable GlobalT = new Hashtable(); | ||
264 | GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
265 | GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
266 | GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
267 | ArrayList GlobalTextures = new ArrayList(); | ||
268 | GlobalTextures.Add(GlobalT); | ||
269 | |||
270 | Hashtable LoginFlagsHash = new Hashtable(); | ||
271 | LoginFlagsHash["daylight_savings"] = "N"; | ||
272 | LoginFlagsHash["stipend_since_login"] = "N"; | ||
273 | LoginFlagsHash["gendered"] = "Y"; | ||
274 | LoginFlagsHash["ever_logged_in"] = "Y"; | ||
275 | ArrayList LoginFlags = new ArrayList(); | ||
276 | LoginFlags.Add(LoginFlagsHash); | ||
277 | |||
278 | Hashtable uiconfig = new Hashtable(); | ||
279 | uiconfig["allow_first_life"] = "Y"; | ||
280 | ArrayList ui_config = new ArrayList(); | ||
281 | ui_config.Add(uiconfig); | ||
282 | |||
283 | Hashtable ClassifiedCategoriesHash = new Hashtable(); | ||
284 | ClassifiedCategoriesHash["category_name"] = "bla bla"; | ||
285 | ClassifiedCategoriesHash["category_id"] = (Int32)1; | ||
286 | ArrayList ClassifiedCategories = new ArrayList(); | ||
287 | ClassifiedCategories.Add(ClassifiedCategoriesHash); | ||
288 | |||
289 | ArrayList AgentInventory = new ArrayList(); | ||
290 | foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values) | ||
185 | { | 291 | { |
186 | Console.WriteLine(E.ToString()); | 292 | Hashtable TempHash = new Hashtable(); |
293 | TempHash["name"] = InvFolder.FolderName; | ||
294 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | ||
295 | TempHash["version"] = (Int32)InvFolder.Version; | ||
296 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | ||
297 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | ||
298 | AgentInventory.Add(TempHash); | ||
187 | } | 299 | } |
188 | 300 | ||
189 | break; | 301 | Hashtable InventoryRootHash = new Hashtable(); |
302 | InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated(); | ||
303 | ArrayList InventoryRoot = new ArrayList(); | ||
304 | InventoryRoot.Add(InventoryRootHash); | ||
305 | |||
306 | Hashtable InitialOutfitHash = new Hashtable(); | ||
307 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
308 | InitialOutfitHash["gender"] = "female"; | ||
309 | ArrayList InitialOutfit = new ArrayList(); | ||
310 | InitialOutfit.Add(InitialOutfitHash); | ||
311 | |||
312 | uint circode = (uint)(Util.RandomClass.Next()); | ||
313 | //TheUser.AddSimCircuit(circode, SimInfo.UUID); | ||
314 | |||
315 | responseData["last_name"] = TheUser.lastname; | ||
316 | responseData["ui-config"] = ui_config; | ||
317 | responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); | ||
318 | responseData["login-flags"] = LoginFlags; | ||
319 | responseData["global-textures"] = GlobalTextures; | ||
320 | responseData["classified_categories"] = ClassifiedCategories; | ||
321 | responseData["event_categories"] = new ArrayList(); | ||
322 | responseData["inventory-skeleton"] = AgentInventory; | ||
323 | responseData["inventory-skel-lib"] = new ArrayList(); | ||
324 | responseData["inventory-root"] = InventoryRoot; | ||
325 | responseData["event_notifications"] = new ArrayList(); | ||
326 | responseData["gestures"] = new ArrayList(); | ||
327 | responseData["inventory-lib-owner"] = new ArrayList(); | ||
328 | responseData["initial-outfit"] = InitialOutfit; | ||
329 | responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
330 | responseData["start_location"] = "last"; | ||
331 | responseData["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}"; | ||
332 | responseData["message"] = DefaultStartupMsg; | ||
333 | responseData["first_name"] = TheUser.firstname; | ||
334 | responseData["circuit_code"] = (Int32)circode; | ||
335 | responseData["sim_port"] = 9000; //(Int32)SimInfo.sim_port; | ||
336 | responseData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated(); | ||
337 | responseData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n"; | ||
338 | responseData["agent_id"] = AgentID.ToStringHyphenated(); | ||
339 | responseData["region_y"] = (Int32)996 * 256; // (Int32)SimInfo.RegionLocY * 256; | ||
340 | responseData["region_x"] = (Int32)997 * 256; //SimInfo.RegionLocX * 256; | ||
341 | responseData["seed_capability"] = null; | ||
342 | responseData["agent_access"] = "M"; | ||
343 | responseData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated(); | ||
344 | responseData["login"] = "true"; | ||
345 | |||
346 | this.CustomiseResponse(ref responseData, TheUser); | ||
347 | response.Value = responseData; | ||
348 | //TheUser.SendDataToSim(SimInfo); | ||
349 | |||
350 | |||
351 | |||
352 | } | ||
353 | catch (Exception E) | ||
354 | { | ||
355 | Console.WriteLine(E.ToString()); | ||
356 | } | ||
357 | //} | ||
190 | } | 358 | } |
359 | return response; | ||
360 | } | ||
191 | 361 | ||
192 | return ""; | 362 | private static XmlRpcResponse CreateErrorConnectingToGridResponse() |
363 | { | ||
364 | XmlRpcResponse response = new XmlRpcResponse(); | ||
365 | Hashtable ErrorRespData = new Hashtable(); | ||
366 | ErrorRespData["reason"] = "key"; | ||
367 | ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct"; | ||
368 | ErrorRespData["login"] = "false"; | ||
369 | response.Value = ErrorRespData; | ||
370 | return response; | ||
371 | } | ||
372 | |||
373 | private static XmlRpcResponse CreateAlreadyLoggedInResponse() | ||
374 | { | ||
375 | XmlRpcResponse response = new XmlRpcResponse(); | ||
376 | Hashtable PresenceErrorRespData = new Hashtable(); | ||
377 | PresenceErrorRespData["reason"] = "presence"; | ||
378 | PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner"; | ||
379 | PresenceErrorRespData["login"] = "false"; | ||
380 | response.Value = PresenceErrorRespData; | ||
381 | return response; | ||
193 | } | 382 | } |
194 | 383 | ||
195 | public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser) | 384 | public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser) |
@@ -203,8 +392,8 @@ namespace OpenSim.Framework.User | |||
203 | response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}"; | 392 | response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}"; |
204 | response["sim_ip"] = SimInfo.sim_ip.ToString(); | 393 | response["sim_ip"] = SimInfo.sim_ip.ToString(); |
205 | response["sim_port"] = (Int32)SimInfo.sim_port; | 394 | response["sim_port"] = (Int32)SimInfo.sim_port; |
206 | response["region_y"] = (Int32) SimInfo.RegionLocY * 256; | 395 | response["region_y"] = (Int32)SimInfo.RegionLocY * 256; |
207 | response["region_x"] = (Int32) SimInfo.RegionLocX * 256; | 396 | response["region_x"] = (Int32)SimInfo.RegionLocX * 256; |
208 | 397 | ||
209 | //default is ogs user server, so let the sim know about the user via a XmlRpcRequest | 398 | //default is ogs user server, so let the sim know about the user via a XmlRpcRequest |
210 | Console.WriteLine(SimInfo.caps_url); | 399 | Console.WriteLine(SimInfo.caps_url); |
diff --git a/OpenSim.RegionServer/CAPS/IXmlRPCHandler.cs b/OpenSim.RegionServer/CAPS/IXmlRPCHandler.cs deleted file mode 100644 index c3cbbcc..0000000 --- a/OpenSim.RegionServer/CAPS/IXmlRPCHandler.cs +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.CAPS | ||
6 | { | ||
7 | public interface IXmlRPCHandler | ||
8 | { | ||
9 | string HandleRPC(string requestBody); | ||
10 | } | ||
11 | } | ||
diff --git a/OpenSim.RegionServer/CAPS/SimHttp.cs b/OpenSim.RegionServer/CAPS/SimHttp.cs deleted file mode 100644 index bfba635..0000000 --- a/OpenSim.RegionServer/CAPS/SimHttp.cs +++ /dev/null | |||
@@ -1,241 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) OpenSimCAPS project, http://osgrid.org/ | ||
3 | |||
4 | |||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions are met: | ||
9 | * * Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * * Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * * Neither the name of the <organization> nor the | ||
15 | * names of its contributors may be used to endorse or promote products | ||
16 | * derived from this software without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY | ||
19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
21 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Text; | ||
32 | using Nwc.XmlRpc; | ||
33 | using System.Threading; | ||
34 | using System.Text.RegularExpressions; | ||
35 | using System.Net; | ||
36 | using System.IO; | ||
37 | using System.Collections; | ||
38 | using System.Collections.Generic; | ||
39 | using libsecondlife; | ||
40 | using OpenSim.Framework.Console; | ||
41 | using OpenSim.Framework.Interfaces; | ||
42 | using OpenSim.Servers; | ||
43 | |||
44 | namespace OpenSim.CAPS | ||
45 | { | ||
46 | // Dummy HTTP server, does nothing useful for now | ||
47 | |||
48 | public class SimCAPSHTTPServer : BaseHttpServer | ||
49 | { | ||
50 | private Thread m_workerThread; | ||
51 | private HttpListener m_httpListener; | ||
52 | private Dictionary<string, IRestHandler> m_restHandlers = new Dictionary<string, IRestHandler>(); | ||
53 | private Dictionary<string, IXmlRPCHandler> RPCHandlers = new Dictionary<string, IXmlRPCHandler>(); | ||
54 | private IGridServer m_gridServer; | ||
55 | private int m_port; | ||
56 | |||
57 | public SimCAPSHTTPServer(IGridServer gridServer, int port) | ||
58 | { | ||
59 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server"); | ||
60 | m_workerThread = new Thread(new ThreadStart(StartHTTP)); | ||
61 | m_workerThread.Start(); | ||
62 | m_gridServer = gridServer; | ||
63 | m_port = port; | ||
64 | } | ||
65 | |||
66 | public void StartHTTP() | ||
67 | { | ||
68 | try | ||
69 | { | ||
70 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK"); | ||
71 | m_httpListener = new HttpListener(); | ||
72 | |||
73 | m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); | ||
74 | m_httpListener.Start(); | ||
75 | |||
76 | HttpListenerContext context; | ||
77 | while (true) | ||
78 | { | ||
79 | context = m_httpListener.GetContext(); | ||
80 | ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); | ||
81 | } | ||
82 | } | ||
83 | catch (Exception e) | ||
84 | { | ||
85 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.Message); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | public bool AddRestHandler(string path, IRestHandler handler) | ||
90 | { | ||
91 | if (!this.m_restHandlers.ContainsKey(path)) | ||
92 | { | ||
93 | this.m_restHandlers.Add(path, handler); | ||
94 | return true; | ||
95 | } | ||
96 | |||
97 | //must already have a handler for that path so return false | ||
98 | return false; | ||
99 | } | ||
100 | |||
101 | public bool AddXmlRPCHandler(string method, IXmlRPCHandler handler) | ||
102 | { | ||
103 | if (!this.RPCHandlers.ContainsKey(method)) | ||
104 | { | ||
105 | this.RPCHandlers.Add(method, handler); | ||
106 | return true; | ||
107 | } | ||
108 | |||
109 | //must already have a handler for that path so return false | ||
110 | return false; | ||
111 | } | ||
112 | |||
113 | protected virtual string ParseXMLRPC(string requestBody) | ||
114 | { | ||
115 | string responseString = ""; | ||
116 | try | ||
117 | { | ||
118 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); | ||
119 | |||
120 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
121 | switch (request.MethodName) | ||
122 | { | ||
123 | case "expect_user": | ||
124 | AgentCircuitData agent_data = new AgentCircuitData(); | ||
125 | agent_data.SessionID = new LLUUID((string)requestData["session_id"]); | ||
126 | agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); | ||
127 | agent_data.firstname = (string)requestData["firstname"]; | ||
128 | agent_data.lastname = (string)requestData["lastname"]; | ||
129 | agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); | ||
130 | agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | ||
131 | if (m_gridServer.GetName() == "Remote") | ||
132 | { | ||
133 | ((RemoteGridBase) m_gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); | ||
134 | } | ||
135 | responseString = "<?xml version=\"1.0\"?><methodResponse><params /></methodResponse>"; | ||
136 | break; | ||
137 | default: | ||
138 | if (this.RPCHandlers.ContainsKey(request.MethodName)) | ||
139 | { | ||
140 | //responseString = this.RPCHandlers[request.MethodName] | ||
141 | } | ||
142 | break; | ||
143 | } | ||
144 | } | ||
145 | catch (Exception e) | ||
146 | { | ||
147 | Console.WriteLine(e.ToString()); | ||
148 | } | ||
149 | return responseString; | ||
150 | } | ||
151 | |||
152 | protected virtual string ParseREST(string requestBody, string requestURL, string requestMethod) | ||
153 | { | ||
154 | string[] path; | ||
155 | string pathDelimStr = "/"; | ||
156 | char[] pathDelimiter = pathDelimStr.ToCharArray(); | ||
157 | path = requestURL.Split(pathDelimiter); | ||
158 | |||
159 | string responseString = ""; | ||
160 | |||
161 | //path[0] should be empty so we are interested in path[1] | ||
162 | if (path.Length > 1) | ||
163 | { | ||
164 | if ((path[1] != "") && (this.m_restHandlers.ContainsKey(path[1]))) | ||
165 | { | ||
166 | responseString = this.m_restHandlers[path[1]].HandleREST(requestBody, requestURL, requestMethod); | ||
167 | } | ||
168 | } | ||
169 | |||
170 | return responseString; | ||
171 | } | ||
172 | |||
173 | protected virtual string ParseLLSDXML(string requestBody) | ||
174 | { | ||
175 | // dummy function for now - IMPLEMENT ME! | ||
176 | return ""; | ||
177 | } | ||
178 | |||
179 | public virtual void HandleRequest(Object stateinfo) | ||
180 | { | ||
181 | // Console.WriteLine("new http incoming"); | ||
182 | HttpListenerContext context = (HttpListenerContext)stateinfo; | ||
183 | |||
184 | HttpListenerRequest request = context.Request; | ||
185 | HttpListenerResponse response = context.Response; | ||
186 | |||
187 | response.KeepAlive = false; | ||
188 | response.SendChunked = false; | ||
189 | |||
190 | System.IO.Stream body = request.InputStream; | ||
191 | System.Text.Encoding encoding = System.Text.Encoding.UTF8; | ||
192 | System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); | ||
193 | |||
194 | string requestBody = reader.ReadToEnd(); | ||
195 | body.Close(); | ||
196 | reader.Close(); | ||
197 | |||
198 | //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType); | ||
199 | //Console.WriteLine(requestBody); | ||
200 | |||
201 | string responseString = ""; | ||
202 | switch (request.ContentType) | ||
203 | { | ||
204 | case "text/xml": | ||
205 | // must be XML-RPC, so pass to the XML-RPC parser | ||
206 | |||
207 | responseString = ParseXMLRPC(requestBody); | ||
208 | response.AddHeader("Content-type", "text/xml"); | ||
209 | break; | ||
210 | |||
211 | case "application/xml": | ||
212 | // probably LLSD we hope, otherwise it should be ignored by the parser | ||
213 | responseString = ParseLLSDXML(requestBody); | ||
214 | response.AddHeader("Content-type", "application/xml"); | ||
215 | break; | ||
216 | |||
217 | case "application/x-www-form-urlencoded": | ||
218 | // a form data POST so send to the REST parser | ||
219 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
220 | response.AddHeader("Content-type", "text/html"); | ||
221 | break; | ||
222 | |||
223 | case null: | ||
224 | // must be REST or invalid crap, so pass to the REST parser | ||
225 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
226 | response.AddHeader("Content-type", "text/html"); | ||
227 | break; | ||
228 | |||
229 | } | ||
230 | |||
231 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); | ||
232 | System.IO.Stream output = response.OutputStream; | ||
233 | response.SendChunked = false; | ||
234 | response.ContentLength64 = buffer.Length; | ||
235 | output.Write(buffer, 0, buffer.Length); | ||
236 | output.Close(); | ||
237 | } | ||
238 | } | ||
239 | |||
240 | |||
241 | } | ||
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj index d9d5f1a..13b9767 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj | |||
@@ -117,7 +117,6 @@ | |||
117 | <Compile Include="AgentAssetUpload.cs"> | 117 | <Compile Include="AgentAssetUpload.cs"> |
118 | <SubType>Code</SubType> | 118 | <SubType>Code</SubType> |
119 | </Compile> | 119 | </Compile> |
120 | <Compile Include="CAPS\IXmlRPCHandler.cs" /> | ||
121 | <Compile Include="ConsoleCmds.cs"> | 120 | <Compile Include="ConsoleCmds.cs"> |
122 | <SubType>Code</SubType> | 121 | <SubType>Code</SubType> |
123 | </Compile> | 122 | </Compile> |
@@ -151,12 +150,6 @@ | |||
151 | <Compile Include="CAPS\AdminWebFront.cs"> | 150 | <Compile Include="CAPS\AdminWebFront.cs"> |
152 | <SubType>Code</SubType> | 151 | <SubType>Code</SubType> |
153 | </Compile> | 152 | </Compile> |
154 | <Compile Include="CAPS\IRestHandler.cs"> | ||
155 | <SubType>Code</SubType> | ||
156 | </Compile> | ||
157 | <Compile Include="CAPS\SimHttp.cs"> | ||
158 | <SubType>Code</SubType> | ||
159 | </Compile> | ||
160 | <Compile Include="types\Mesh.cs"> | 153 | <Compile Include="types\Mesh.cs"> |
161 | <SubType>Code</SubType> | 154 | <SubType>Code</SubType> |
162 | </Compile> | 155 | </Compile> |
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build index ef7dce9..0cb9bf6 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build +++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build | |||
@@ -23,9 +23,6 @@ | |||
23 | <include name="Assets/AssetCache.cs" /> | 23 | <include name="Assets/AssetCache.cs" /> |
24 | <include name="Assets/InventoryCache.cs" /> | 24 | <include name="Assets/InventoryCache.cs" /> |
25 | <include name="CAPS/AdminWebFront.cs" /> | 25 | <include name="CAPS/AdminWebFront.cs" /> |
26 | <include name="CAPS/IRestHandler.cs" /> | ||
27 | <include name="CAPS/IXmlRPCHandler.cs" /> | ||
28 | <include name="CAPS/SimHttp.cs" /> | ||
29 | <include name="types/Mesh.cs" /> | 26 | <include name="types/Mesh.cs" /> |
30 | <include name="types/Triangle.cs" /> | 27 | <include name="types/Triangle.cs" /> |
31 | <include name="UserServer/LocalUserProfileManager.cs" /> | 28 | <include name="UserServer/LocalUserProfileManager.cs" /> |
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index 07a2d6d..651c0c6 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs | |||
@@ -45,6 +45,8 @@ using OpenSim.Assets; | |||
45 | using OpenSim.CAPS; | 45 | using OpenSim.CAPS; |
46 | using OpenSim.Framework.Console; | 46 | using OpenSim.Framework.Console; |
47 | using OpenSim.Physics.Manager; | 47 | using OpenSim.Physics.Manager; |
48 | using Nwc.XmlRpc; | ||
49 | using OpenSim.Servers; | ||
48 | 50 | ||
49 | namespace OpenSim | 51 | namespace OpenSim |
50 | { | 52 | { |
@@ -54,7 +56,8 @@ namespace OpenSim | |||
54 | private World LocalWorld; | 56 | private World LocalWorld; |
55 | private Grid GridServers; | 57 | private Grid GridServers; |
56 | private SimConfig Cfg; | 58 | private SimConfig Cfg; |
57 | private SimCAPSHTTPServer HttpServer; | 59 | //private SimCAPSHTTPServer HttpServer; |
60 | private BaseHttpServer HttpServer; | ||
58 | private AssetCache AssetCache; | 61 | private AssetCache AssetCache; |
59 | private InventoryCache InventoryCache; | 62 | private InventoryCache InventoryCache; |
60 | //public Dictionary<EndPoint, SimClient> ClientThreads = new Dictionary<EndPoint, SimClient>(); | 63 | //public Dictionary<EndPoint, SimClient> ClientThreads = new Dictionary<EndPoint, SimClient>(); |
@@ -78,13 +81,13 @@ namespace OpenSim | |||
78 | public bool user_accounts = false; | 81 | public bool user_accounts = false; |
79 | 82 | ||
80 | protected ConsoleBase m_console; | 83 | protected ConsoleBase m_console; |
81 | 84 | ||
82 | public OpenSimMain( bool sandBoxMode, bool startLoginServer, string physicsEngine ) | 85 | public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine) |
83 | { | 86 | { |
84 | m_sandbox = sandBoxMode; | 87 | m_sandbox = sandBoxMode; |
85 | m_loginserver = startLoginServer; | 88 | m_loginserver = startLoginServer; |
86 | m_physicsEngine = physicsEngine; | 89 | m_physicsEngine = physicsEngine; |
87 | 90 | ||
88 | m_console = new ConsoleBase("region-console.log", "Region", this); | 91 | m_console = new ConsoleBase("region-console.log", "Region", this); |
89 | OpenSim.Framework.Console.MainConsole.Instance = m_console; | 92 | OpenSim.Framework.Console.MainConsole.Instance = m_console; |
90 | } | 93 | } |
@@ -92,11 +95,11 @@ namespace OpenSim | |||
92 | public virtual void StartUp() | 95 | public virtual void StartUp() |
93 | { | 96 | { |
94 | GridServers = new Grid(); | 97 | GridServers = new Grid(); |
95 | if ( m_sandbox ) | 98 | if (m_sandbox) |
96 | { | 99 | { |
97 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; | 100 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; |
98 | GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; | 101 | GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; |
99 | 102 | ||
100 | m_console.WriteLine("Starting in Sandbox mode"); | 103 | m_console.WriteLine("Starting in Sandbox mode"); |
101 | } | 104 | } |
102 | else | 105 | else |
@@ -108,7 +111,7 @@ namespace OpenSim | |||
108 | } | 111 | } |
109 | 112 | ||
110 | GridServers.Initialise(); | 113 | GridServers.Initialise(); |
111 | 114 | ||
112 | startuptime = DateTime.Now; | 115 | startuptime = DateTime.Now; |
113 | 116 | ||
114 | AssetCache = new AssetCache(GridServers.AssetServer); | 117 | AssetCache = new AssetCache(GridServers.AssetServer); |
@@ -134,36 +137,74 @@ namespace OpenSim | |||
134 | LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap); | 137 | LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap); |
135 | 138 | ||
136 | GridServers.AssetServer.SetServerInfo(Cfg.AssetURL, Cfg.AssetSendKey); | 139 | GridServers.AssetServer.SetServerInfo(Cfg.AssetURL, Cfg.AssetSendKey); |
137 | GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); | 140 | //GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); |
141 | IGridServer gridServer = GridServers.GridServer; | ||
142 | gridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); | ||
138 | 143 | ||
139 | LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. | 144 | LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. |
140 | LocalWorld.LoadPrimsFromStorage(); | 145 | LocalWorld.LoadPrimsFromStorage(); |
141 | 146 | ||
142 | if ( m_sandbox) | 147 | if (m_sandbox) |
143 | { | 148 | { |
144 | AssetCache.LoadDefaultTextureSet(); | 149 | AssetCache.LoadDefaultTextureSet(); |
145 | } | 150 | } |
146 | 151 | ||
147 | m_console.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); | 152 | m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server"); |
148 | HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); | 153 | // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); |
154 | HttpServer = new BaseHttpServer(Cfg.IPListenPort); | ||
155 | |||
156 | if (gridServer.GetName() == "Remote") | ||
157 | { | ||
158 | //we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server | ||
159 | HttpServer.AddXmlRPCHandler("expect_user", | ||
160 | delegate(XmlRpcRequest request) | ||
161 | { | ||
162 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
163 | AgentCircuitData agent_data = new AgentCircuitData(); | ||
164 | agent_data.SessionID = new LLUUID((string)requestData["session_id"]); | ||
165 | agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); | ||
166 | agent_data.firstname = (string)requestData["firstname"]; | ||
167 | agent_data.lastname = (string)requestData["lastname"]; | ||
168 | agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); | ||
169 | agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | ||
170 | |||
171 | ((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); | ||
172 | |||
173 | return new XmlRpcResponse(); | ||
174 | }); | ||
175 | } | ||
176 | |||
149 | 177 | ||
150 | LoginServer loginServer = null; | 178 | LoginServer loginServer = null; |
151 | if (m_loginserver && m_sandbox) | 179 | if (m_loginserver && m_sandbox) |
152 | { | 180 | { |
153 | loginServer = new LoginServer(GridServers.GridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts); | 181 | loginServer = new LoginServer(gridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts); |
154 | loginServer.Startup(); | 182 | loginServer.Startup(); |
155 | 183 | ||
156 | } | 184 | } |
157 | if((m_loginserver) && (m_sandbox) && (user_accounts)) | 185 | |
186 | if ((m_loginserver) && (m_sandbox) && (user_accounts)) | ||
158 | { | 187 | { |
188 | //sandbox mode with loginserver using accounts | ||
159 | this.GridServers.UserServer = loginServer; | 189 | this.GridServers.UserServer = loginServer; |
160 | HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, loginServer)); | 190 | HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, loginServer)); |
191 | HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod); | ||
161 | } | 192 | } |
162 | else | 193 | else if ((m_loginserver) && (m_sandbox)) |
194 | { | ||
195 | //sandbox mode with loginserver not using accounts | ||
196 | HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null)); | ||
197 | HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); | ||
198 | } | ||
199 | else | ||
163 | { | 200 | { |
201 | //not in sandbox mode so no loginserver, so we don't handle login attempts | ||
164 | HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null)); | 202 | HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null)); |
165 | } | 203 | } |
166 | 204 | ||
205 | m_console.WriteLine("Main.cs:Startup() - Starting HTTP server"); | ||
206 | HttpServer.Start(); | ||
207 | |||
167 | MainServerListener(); | 208 | MainServerListener(); |
168 | 209 | ||
169 | timer1.Enabled = true; | 210 | timer1.Enabled = true; |
@@ -207,12 +248,12 @@ namespace OpenSim | |||
207 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | 248 | int numBytes = Server.EndReceiveFrom(result, ref epSender); |
208 | int packetEnd = numBytes - 1; | 249 | int packetEnd = numBytes - 1; |
209 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | 250 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); |
210 | 251 | ||
211 | // This is either a new client or a packet to send to an old one | 252 | // This is either a new client or a packet to send to an old one |
212 | // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender)) | 253 | // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender)) |
213 | 254 | ||
214 | // do we already have a circuit for this endpoint | 255 | // do we already have a circuit for this endpoint |
215 | if(this.clientCircuits.ContainsKey(epSender)) | 256 | if (this.clientCircuits.ContainsKey(epSender)) |
216 | { | 257 | { |
217 | ClientThreads[this.clientCircuits[epSender]].InPacket(packet); | 258 | ClientThreads[this.clientCircuits[epSender]].InPacket(packet); |
218 | } | 259 | } |
@@ -223,7 +264,6 @@ namespace OpenSim | |||
223 | SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox); | 264 | SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox); |
224 | if ((this.GridServers.UserServer != null) && (user_accounts)) | 265 | if ((this.GridServers.UserServer != null) && (user_accounts)) |
225 | { | 266 | { |
226 | Console.WriteLine("setting userserver"); | ||
227 | newuser.UserServer = this.GridServers.UserServer; | 267 | newuser.UserServer = this.GridServers.UserServer; |
228 | } | 268 | } |
229 | //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); | 269 | //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); |
@@ -256,11 +296,11 @@ namespace OpenSim | |||
256 | 296 | ||
257 | } | 297 | } |
258 | 298 | ||
259 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode )//EndPoint packetSender) | 299 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) |
260 | { | 300 | { |
261 | // find the endpoint for this circuit | 301 | // find the endpoint for this circuit |
262 | EndPoint sendto = null; | 302 | EndPoint sendto = null; |
263 | foreach(KeyValuePair<EndPoint, uint> p in this.clientCircuits) | 303 | foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) |
264 | { | 304 | { |
265 | if (p.Value == circuitcode) | 305 | if (p.Value == circuitcode) |
266 | { | 306 | { |
@@ -304,7 +344,7 @@ namespace OpenSim | |||
304 | { | 344 | { |
305 | LocalWorld.Update(); | 345 | LocalWorld.Update(); |
306 | } | 346 | } |
307 | 347 | ||
308 | public void RunCmd(string command, string[] cmdparams) | 348 | public void RunCmd(string command, string[] cmdparams) |
309 | { | 349 | { |
310 | switch (command) | 350 | switch (command) |
@@ -353,5 +393,5 @@ namespace OpenSim | |||
353 | } | 393 | } |
354 | } | 394 | } |
355 | 395 | ||
356 | 396 | ||
357 | } | 397 | } |
diff --git a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs index b31feda..3ae7878 100644 --- a/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs +++ b/OpenSim.RegionServer/UserServer/LocalUserProfileManager.cs | |||
@@ -10,7 +10,7 @@ using libsecondlife; | |||
10 | 10 | ||
11 | namespace OpenSim.UserServer | 11 | namespace OpenSim.UserServer |
12 | { | 12 | { |
13 | class LocalUserProfileManager : UserProfileManager | 13 | public class LocalUserProfileManager : UserProfileManager |
14 | { | 14 | { |
15 | private IGridServer m_gridServer; | 15 | private IGridServer m_gridServer; |
16 | private int m_port; | 16 | private int m_port; |
diff --git a/OpenSim.RegionServer/UserServer/LoginServer.cs b/OpenSim.RegionServer/UserServer/LoginServer.cs index 7b4c1f0..a68e013 100644 --- a/OpenSim.RegionServer/UserServer/LoginServer.cs +++ b/OpenSim.RegionServer/UserServer/LoginServer.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.UserServer | |||
50 | /// <summary> | 50 | /// <summary> |
51 | /// When running in local (default) mode , handles client logins. | 51 | /// When running in local (default) mode , handles client logins. |
52 | /// </summary> | 52 | /// </summary> |
53 | public class LoginServer : LoginService , IUserServer | 53 | public class LoginServer : LoginService, IUserServer |
54 | { | 54 | { |
55 | private IGridServer m_gridServer; | 55 | private IGridServer m_gridServer; |
56 | private ushort _loginPort = 8080; | 56 | private ushort _loginPort = 8080; |
@@ -66,7 +66,15 @@ namespace OpenSim.UserServer | |||
66 | private int m_simPort; | 66 | private int m_simPort; |
67 | private string m_simAddr; | 67 | private string m_simAddr; |
68 | 68 | ||
69 | public LoginServer(IGridServer gridServer, string simAddr, int simPort , bool useAccounts) | 69 | public LocalUserProfileManager LocalUserManager |
70 | { | ||
71 | get | ||
72 | { | ||
73 | return userManager; | ||
74 | } | ||
75 | } | ||
76 | |||
77 | public LoginServer(IGridServer gridServer, string simAddr, int simPort, bool useAccounts) | ||
70 | { | 78 | { |
71 | m_gridServer = gridServer; | 79 | m_gridServer = gridServer; |
72 | m_simPort = simPort; | 80 | m_simPort = simPort; |
@@ -74,6 +82,14 @@ namespace OpenSim.UserServer | |||
74 | this.userAccounts = useAccounts; | 82 | this.userAccounts = useAccounts; |
75 | } | 83 | } |
76 | 84 | ||
85 | public void Startup() | ||
86 | { | ||
87 | this.InitializeLogin(); | ||
88 | //Thread runLoginProxy = new Thread(new ThreadStart(RunLogin)); | ||
89 | //runLoginProxy.IsBackground = true; | ||
90 | //runLoginProxy.Start(); | ||
91 | } | ||
92 | |||
77 | // InitializeLogin: initialize the login | 93 | // InitializeLogin: initialize the login |
78 | private void InitializeLogin() | 94 | private void InitializeLogin() |
79 | { | 95 | { |
@@ -94,129 +110,124 @@ namespace OpenSim.UserServer | |||
94 | SR.Close(); | 110 | SR.Close(); |
95 | this._mpasswd = EncodePassword("testpass"); | 111 | this._mpasswd = EncodePassword("testpass"); |
96 | 112 | ||
97 | userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr ); | 113 | userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr); |
98 | userManager.InitUserProfiles(); | 114 | userManager.InitUserProfiles(); |
99 | userManager.SetKeys("", "", "", "Welcome to OpenSim"); | 115 | userManager.SetKeys("", "", "", "Welcome to OpenSim"); |
100 | 116 | ||
101 | loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | 117 | //loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); |
102 | loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort)); | 118 | // loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort)); |
103 | loginServer.Listen(1); | 119 | //loginServer.Listen(1); |
104 | } | ||
105 | |||
106 | public void Startup() | ||
107 | { | ||
108 | this.InitializeLogin(); | ||
109 | Thread runLoginProxy = new Thread(new ThreadStart(RunLogin)); | ||
110 | runLoginProxy.IsBackground = true; | ||
111 | runLoginProxy.Start(); | ||
112 | } | ||
113 | |||
114 | private void RunLogin() | ||
115 | { | ||
116 | Console.WriteLine("Starting Login Server"); | ||
117 | try | ||
118 | { | ||
119 | for (; ; ) | ||
120 | { | ||
121 | Socket client = loginServer.Accept(); | ||
122 | IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint; | ||
123 | |||
124 | |||
125 | NetworkStream networkStream = new NetworkStream(client); | ||
126 | StreamReader networkReader = new StreamReader(networkStream); | ||
127 | StreamWriter networkWriter = new StreamWriter(networkStream); | ||
128 | |||
129 | try | ||
130 | { | ||
131 | LoginRequest(networkReader, networkWriter); | ||
132 | } | ||
133 | catch (Exception e) | ||
134 | { | ||
135 | Console.WriteLine(e.Message); | ||
136 | } | ||
137 | |||
138 | networkWriter.Close(); | ||
139 | networkReader.Close(); | ||
140 | networkStream.Close(); | ||
141 | |||
142 | client.Close(); | ||
143 | |||
144 | // send any packets queued for injection | ||
145 | |||
146 | } | ||
147 | } | ||
148 | catch (Exception e) | ||
149 | { | ||
150 | Console.WriteLine(e.Message); | ||
151 | Console.WriteLine(e.StackTrace); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | // ProxyLogin: proxy a login request | ||
156 | private void LoginRequest(StreamReader reader, StreamWriter writer) | ||
157 | { | ||
158 | lock (this) | ||
159 | { | ||
160 | string line; | ||
161 | int contentLength = 0; | ||
162 | // read HTTP header | ||
163 | do | ||
164 | { | ||
165 | // read one line of the header | ||
166 | line = reader.ReadLine(); | ||
167 | |||
168 | // check for premature EOF | ||
169 | if (line == null) | ||
170 | throw new Exception("EOF in client HTTP header"); | ||
171 | |||
172 | // look for Content-Length | ||
173 | Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line); | ||
174 | if (match.Success) | ||
175 | contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); | ||
176 | } while (line != ""); | ||
177 | |||
178 | // read the HTTP body into a buffer | ||
179 | char[] content = new char[contentLength]; | ||
180 | reader.Read(content, 0, contentLength); | ||
181 | |||
182 | if (this.userAccounts) | ||
183 | { | ||
184 | //ask the UserProfile Manager to process the request | ||
185 | string reply = this.userManager.ParseXMLRPC(new String(content)); | ||
186 | // forward the XML-RPC response to the client | ||
187 | writer.WriteLine("HTTP/1.0 200 OK"); | ||
188 | writer.WriteLine("Content-type: text/xml"); | ||
189 | writer.WriteLine(); | ||
190 | writer.WriteLine(reply); | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | //handle ourselves | ||
195 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); | ||
196 | if (request.MethodName == "login_to_simulator") | ||
197 | { | ||
198 | this.ProcessXmlRequest(request, writer); | ||
199 | } | ||
200 | else | ||
201 | { | ||
202 | XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); | ||
203 | Hashtable PresenceErrorRespData = new Hashtable(); | ||
204 | PresenceErrorRespData["reason"] = "XmlRequest"; ; | ||
205 | PresenceErrorRespData["message"] = "Unknown Rpc request"; | ||
206 | PresenceErrorRespData["login"] = "false"; | ||
207 | PresenceErrorResp.Value = PresenceErrorRespData; | ||
208 | string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); | ||
209 | writer.WriteLine("HTTP/1.0 200 OK"); | ||
210 | writer.WriteLine("Content-type: text/xml"); | ||
211 | writer.WriteLine(); | ||
212 | writer.WriteLine(reply); | ||
213 | } | ||
214 | } | ||
215 | } | ||
216 | } | 120 | } |
217 | 121 | ||
218 | public bool ProcessXmlRequest(XmlRpcRequest request, StreamWriter writer) | 122 | /* private void RunLogin() |
123 | { | ||
124 | Console.WriteLine("Starting Login Server"); | ||
125 | try | ||
126 | { | ||
127 | for (; ; ) | ||
128 | { | ||
129 | Socket client = loginServer.Accept(); | ||
130 | IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint; | ||
131 | |||
132 | |||
133 | NetworkStream networkStream = new NetworkStream(client); | ||
134 | StreamReader networkReader = new StreamReader(networkStream); | ||
135 | StreamWriter networkWriter = new StreamWriter(networkStream); | ||
136 | |||
137 | try | ||
138 | { | ||
139 | LoginRequest(networkReader, networkWriter); | ||
140 | } | ||
141 | catch (Exception e) | ||
142 | { | ||
143 | Console.WriteLine(e.Message); | ||
144 | } | ||
145 | |||
146 | networkWriter.Close(); | ||
147 | networkReader.Close(); | ||
148 | networkStream.Close(); | ||
149 | |||
150 | client.Close(); | ||
151 | |||
152 | // send any packets queued for injection | ||
153 | |||
154 | } | ||
155 | } | ||
156 | catch (Exception e) | ||
157 | { | ||
158 | Console.WriteLine(e.Message); | ||
159 | Console.WriteLine(e.StackTrace); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | // ProxyLogin: proxy a login request | ||
164 | private void LoginRequest(StreamReader reader, StreamWriter writer) | ||
165 | { | ||
166 | lock (this) | ||
167 | { | ||
168 | string line; | ||
169 | int contentLength = 0; | ||
170 | // read HTTP header | ||
171 | do | ||
172 | { | ||
173 | // read one line of the header | ||
174 | line = reader.ReadLine(); | ||
175 | |||
176 | // check for premature EOF | ||
177 | if (line == null) | ||
178 | throw new Exception("EOF in client HTTP header"); | ||
179 | |||
180 | // look for Content-Length | ||
181 | Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line); | ||
182 | if (match.Success) | ||
183 | contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); | ||
184 | } while (line != ""); | ||
185 | |||
186 | // read the HTTP body into a buffer | ||
187 | char[] content = new char[contentLength]; | ||
188 | reader.Read(content, 0, contentLength); | ||
189 | |||
190 | if (this.userAccounts) | ||
191 | { | ||
192 | //ask the UserProfile Manager to process the request | ||
193 | string reply = this.userManager.ParseXMLRPC(new String(content)); | ||
194 | // forward the XML-RPC response to the client | ||
195 | writer.WriteLine("HTTP/1.0 200 OK"); | ||
196 | writer.WriteLine("Content-type: text/xml"); | ||
197 | writer.WriteLine(); | ||
198 | writer.WriteLine(reply); | ||
199 | } | ||
200 | else | ||
201 | { | ||
202 | //handle ourselves | ||
203 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); | ||
204 | if (request.MethodName == "login_to_simulator") | ||
205 | { | ||
206 | this.ProcessXmlRequest(request, writer); | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); | ||
211 | Hashtable PresenceErrorRespData = new Hashtable(); | ||
212 | PresenceErrorRespData["reason"] = "XmlRequest"; ; | ||
213 | PresenceErrorRespData["message"] = "Unknown Rpc request"; | ||
214 | PresenceErrorRespData["login"] = "false"; | ||
215 | PresenceErrorResp.Value = PresenceErrorRespData; | ||
216 | string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); | ||
217 | writer.WriteLine("HTTP/1.0 200 OK"); | ||
218 | writer.WriteLine("Content-type: text/xml"); | ||
219 | writer.WriteLine(); | ||
220 | writer.WriteLine(reply); | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | */ | ||
226 | //public bool ProcessXmlRequest(XmlRpcRequest request, StreamWriter writer) | ||
227 | |||
228 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
219 | { | 229 | { |
230 | Console.WriteLine("login attempt"); | ||
220 | Hashtable requestData = (Hashtable)request.Params[0]; | 231 | Hashtable requestData = (Hashtable)request.Params[0]; |
221 | string first; | 232 | string first; |
222 | string last; | 233 | string last; |
@@ -224,6 +235,8 @@ namespace OpenSim.UserServer | |||
224 | LLUUID Agent; | 235 | LLUUID Agent; |
225 | LLUUID Session; | 236 | LLUUID Session; |
226 | 237 | ||
238 | XmlRpcResponse response = new XmlRpcResponse(); | ||
239 | |||
227 | //get login name | 240 | //get login name |
228 | if (requestData.Contains("first")) | 241 | if (requestData.Contains("first")) |
229 | { | 242 | { |
@@ -254,18 +267,24 @@ namespace OpenSim.UserServer | |||
254 | 267 | ||
255 | if (!Authenticate(first, last, passwd)) | 268 | if (!Authenticate(first, last, passwd)) |
256 | { | 269 | { |
257 | XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); | 270 | /* XmlRpcResponse PresenceErrorResp = new XmlRpcResponse(); |
258 | Hashtable PresenceErrorRespData = new Hashtable(); | 271 | Hashtable PresenceErrorRespData = new Hashtable(); |
259 | PresenceErrorRespData["reason"] = "key"; ; | 272 | PresenceErrorRespData["reason"] = "key"; ; |
260 | PresenceErrorRespData["message"] = "You have entered an invalid name/password combination. Check Caps/lock."; | 273 | PresenceErrorRespData["message"] = "You have entered an invalid name/password combination. Check Caps/lock."; |
261 | PresenceErrorRespData["login"] = "false"; | 274 | PresenceErrorRespData["login"] = "false"; |
262 | PresenceErrorResp.Value = PresenceErrorRespData; | 275 | PresenceErrorResp.Value = PresenceErrorRespData; |
263 | string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); | 276 | string reply = Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(PresenceErrorResp), " encoding=\"utf-16\"", ""); |
264 | writer.WriteLine("HTTP/1.0 200 OK"); | 277 | writer.WriteLine("HTTP/1.0 200 OK"); |
265 | writer.WriteLine("Content-type: text/xml"); | 278 | writer.WriteLine("Content-type: text/xml"); |
266 | writer.WriteLine(); | 279 | writer.WriteLine(); |
267 | writer.WriteLine(reply); | 280 | writer.WriteLine(reply); |
268 | return false; | 281 | return false;*/ |
282 | |||
283 | Hashtable loginError = new Hashtable(); | ||
284 | loginError["reason"] = "key"; ; | ||
285 | loginError["message"] = "You have entered an invalid name/password combination. Check Caps/lock."; | ||
286 | loginError["login"] = "false"; | ||
287 | response.Value = loginError; | ||
269 | } | 288 | } |
270 | 289 | ||
271 | NumClients++; | 290 | NumClients++; |
@@ -291,15 +310,15 @@ namespace OpenSim.UserServer | |||
291 | ArrayList GlobalTextures = new ArrayList(); | 310 | ArrayList GlobalTextures = new ArrayList(); |
292 | GlobalTextures.Add(GlobalT); | 311 | GlobalTextures.Add(GlobalT); |
293 | 312 | ||
294 | XmlRpcResponse response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse); | 313 | response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse); |
295 | Hashtable responseData = (Hashtable)response.Value; | 314 | Hashtable responseData = (Hashtable)response.Value; |
296 | 315 | ||
297 | responseData["sim_port"] = m_simPort; | 316 | responseData["sim_port"] = m_simPort; |
298 | responseData["sim_ip"] = m_simAddr; | 317 | responseData["sim_ip"] = m_simAddr; |
299 | responseData["agent_id"] = Agent.ToStringHyphenated(); | 318 | responseData["agent_id"] = Agent.ToStringHyphenated(); |
300 | responseData["session_id"] = Session.ToStringHyphenated(); | 319 | responseData["session_id"] = Session.ToStringHyphenated(); |
301 | responseData["secure_session_id"]= secureSess.ToStringHyphenated(); | 320 | responseData["secure_session_id"] = secureSess.ToStringHyphenated(); |
302 | responseData["circuit_code"] = (Int32)(Util.RandomClass.Next()); | 321 | responseData["circuit_code"] = (Int32)(Util.RandomClass.Next()); |
303 | responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | 322 | responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; |
304 | responseData["login-flags"] = LoginFlags; | 323 | responseData["login-flags"] = LoginFlags; |
305 | responseData["global-textures"] = GlobalTextures; | 324 | responseData["global-textures"] = GlobalTextures; |
@@ -337,16 +356,16 @@ namespace OpenSim.UserServer | |||
337 | ((LocalGridBase)m_gridServer).AddNewSession(_login); | 356 | ((LocalGridBase)m_gridServer).AddNewSession(_login); |
338 | } | 357 | } |
339 | 358 | ||
340 | // forward the XML-RPC response to the client | 359 | /* // forward the XML-RPC response to the client |
341 | writer.WriteLine("HTTP/1.0 200 OK"); | 360 | writer.WriteLine("HTTP/1.0 200 OK"); |
342 | writer.WriteLine("Content-type: text/xml"); | 361 | writer.WriteLine("Content-type: text/xml"); |
343 | writer.WriteLine(); | 362 | writer.WriteLine(); |
344 | 363 | ||
345 | XmlTextWriter responseWriter = new XmlTextWriter(writer); | 364 | XmlTextWriter responseWriter = new XmlTextWriter(writer); |
346 | XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); | 365 | XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response); |
347 | responseWriter.Close(); | 366 | responseWriter.Close();*/ |
348 | 367 | ||
349 | return true; | 368 | return response; |
350 | } | 369 | } |
351 | 370 | ||
352 | protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last) | 371 | protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last) |
diff --git a/Servers/BaseHttpServer.cs b/Servers/BaseHttpServer.cs index 28849dc..bac7e86 100644 --- a/Servers/BaseHttpServer.cs +++ b/Servers/BaseHttpServer.cs | |||
@@ -1,10 +1,211 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Net; | ||
3 | using System.Text; | 4 | using System.Text; |
5 | using System.Text.RegularExpressions; | ||
6 | using System.Threading; | ||
7 | using OpenSim.CAPS; | ||
8 | using Nwc.XmlRpc; | ||
9 | using System.Collections; | ||
4 | 10 | ||
5 | namespace OpenSim.Servers | 11 | namespace OpenSim.Servers |
6 | { | 12 | { |
7 | public class BaseHttpServer | 13 | public class BaseHttpServer |
8 | { | 14 | { |
15 | protected Thread m_workerThread; | ||
16 | protected HttpListener m_httpListener; | ||
17 | protected Dictionary<string, IRestHandler> m_restHandlers = new Dictionary<string, IRestHandler>(); | ||
18 | protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); | ||
19 | protected int m_port; | ||
20 | |||
21 | public BaseHttpServer(int port) | ||
22 | { | ||
23 | m_port = port; | ||
24 | } | ||
25 | |||
26 | public bool AddRestHandler(string path, IRestHandler handler) | ||
27 | { | ||
28 | if (!this.m_restHandlers.ContainsKey(path)) | ||
29 | { | ||
30 | this.m_restHandlers.Add(path, handler); | ||
31 | return true; | ||
32 | } | ||
33 | |||
34 | //must already have a handler for that path so return false | ||
35 | return false; | ||
36 | } | ||
37 | |||
38 | public bool AddXmlRPCHandler(string method, XmlRpcMethod handler) | ||
39 | { | ||
40 | if (!this.m_rpcHandlers.ContainsKey(method)) | ||
41 | { | ||
42 | this.m_rpcHandlers.Add(method, handler); | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | //must already have a handler for that path so return false | ||
47 | return false; | ||
48 | } | ||
49 | |||
50 | protected virtual string ProcessXMLRPCMethod(string methodName, XmlRpcRequest request) | ||
51 | { | ||
52 | XmlRpcResponse response; | ||
53 | |||
54 | XmlRpcMethod method; | ||
55 | if( this.m_rpcHandlers.TryGetValue( methodName, out method ) ) | ||
56 | { | ||
57 | response = method(request); | ||
58 | } | ||
59 | else | ||
60 | { | ||
61 | response = new XmlRpcResponse(); | ||
62 | Hashtable unknownMethodError = new Hashtable(); | ||
63 | unknownMethodError["reason"] = "XmlRequest"; ; | ||
64 | unknownMethodError["message"] = "Unknown Rpc request"; | ||
65 | unknownMethodError["login"] = "false"; | ||
66 | response.Value = unknownMethodError; | ||
67 | } | ||
68 | |||
69 | return XmlRpcResponseSerializer.Singleton.Serialize(response); | ||
70 | } | ||
71 | |||
72 | protected virtual string ParseREST(string requestBody, string requestURL, string requestMethod) | ||
73 | { | ||
74 | string[] path; | ||
75 | string pathDelimStr = "/"; | ||
76 | char[] pathDelimiter = pathDelimStr.ToCharArray(); | ||
77 | path = requestURL.Split(pathDelimiter); | ||
78 | |||
79 | string responseString = ""; | ||
80 | |||
81 | //path[0] should be empty so we are interested in path[1] | ||
82 | if (path.Length > 1) | ||
83 | { | ||
84 | if ((path[1] != "") && (this.m_restHandlers.ContainsKey(path[1]))) | ||
85 | { | ||
86 | responseString = this.m_restHandlers[path[1]].HandleREST(requestBody, requestURL, requestMethod); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | return responseString; | ||
91 | } | ||
92 | |||
93 | protected virtual string ParseLLSDXML(string requestBody) | ||
94 | { | ||
95 | // dummy function for now - IMPLEMENT ME! | ||
96 | return ""; | ||
97 | } | ||
98 | |||
99 | protected virtual string ParseXMLRPC(string requestBody) | ||
100 | { | ||
101 | string responseString = String.Empty; | ||
102 | |||
103 | try | ||
104 | { | ||
105 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); | ||
106 | |||
107 | string methodName = request.MethodName; | ||
108 | |||
109 | responseString = ProcessXMLRPCMethod(methodName, request ); | ||
110 | } | ||
111 | catch (Exception e) | ||
112 | { | ||
113 | Console.WriteLine(e.ToString()); | ||
114 | } | ||
115 | return responseString; | ||
116 | } | ||
117 | |||
118 | public virtual void HandleRequest(Object stateinfo) | ||
119 | { | ||
120 | HttpListenerContext context = (HttpListenerContext)stateinfo; | ||
121 | |||
122 | HttpListenerRequest request = context.Request; | ||
123 | HttpListenerResponse response = context.Response; | ||
124 | |||
125 | response.KeepAlive = false; | ||
126 | response.SendChunked = false; | ||
127 | |||
128 | System.IO.Stream body = request.InputStream; | ||
129 | System.Text.Encoding encoding = System.Text.Encoding.UTF8; | ||
130 | System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); | ||
131 | |||
132 | string requestBody = reader.ReadToEnd(); | ||
133 | body.Close(); | ||
134 | reader.Close(); | ||
135 | |||
136 | //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType); | ||
137 | //Console.WriteLine(requestBody); | ||
138 | |||
139 | string responseString = ""; | ||
140 | switch (request.ContentType) | ||
141 | { | ||
142 | case "text/xml": | ||
143 | // must be XML-RPC, so pass to the XML-RPC parser | ||
144 | |||
145 | responseString = ParseXMLRPC(requestBody); | ||
146 | responseString = Regex.Replace(responseString, "utf-16", "utf-8"); | ||
147 | |||
148 | response.AddHeader("Content-type", "text/xml"); | ||
149 | break; | ||
150 | |||
151 | case "application/xml": | ||
152 | // probably LLSD we hope, otherwise it should be ignored by the parser | ||
153 | responseString = ParseLLSDXML(requestBody); | ||
154 | response.AddHeader("Content-type", "application/xml"); | ||
155 | break; | ||
156 | |||
157 | case "application/x-www-form-urlencoded": | ||
158 | // a form data POST so send to the REST parser | ||
159 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
160 | response.AddHeader("Content-type", "text/html"); | ||
161 | break; | ||
162 | |||
163 | case null: | ||
164 | // must be REST or invalid crap, so pass to the REST parser | ||
165 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
166 | response.AddHeader("Content-type", "text/html"); | ||
167 | break; | ||
168 | |||
169 | } | ||
170 | |||
171 | byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); | ||
172 | System.IO.Stream output = response.OutputStream; | ||
173 | response.SendChunked = false; | ||
174 | response.ContentLength64 = buffer.Length; | ||
175 | output.Write(buffer, 0, buffer.Length); | ||
176 | output.Close(); | ||
177 | } | ||
178 | |||
179 | public void Start() | ||
180 | { | ||
181 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("BaseHttpServer.cs: Starting up HTTP Server"); | ||
182 | |||
183 | m_workerThread = new Thread(new ThreadStart(StartHTTP)); | ||
184 | m_workerThread.IsBackground = true; | ||
185 | m_workerThread.Start(); | ||
186 | } | ||
187 | |||
188 | private void StartHTTP() | ||
189 | { | ||
190 | try | ||
191 | { | ||
192 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("BaseHttpServer.cs: StartHTTP() - Spawned main thread OK"); | ||
193 | m_httpListener = new HttpListener(); | ||
194 | |||
195 | m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); | ||
196 | m_httpListener.Start(); | ||
197 | |||
198 | HttpListenerContext context; | ||
199 | while (true) | ||
200 | { | ||
201 | context = m_httpListener.GetContext(); | ||
202 | ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); | ||
203 | } | ||
204 | } | ||
205 | catch (Exception e) | ||
206 | { | ||
207 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.Message); | ||
208 | } | ||
209 | } | ||
9 | } | 210 | } |
10 | } | 211 | } |
diff --git a/OpenSim.RegionServer/CAPS/IRestHandler.cs b/Servers/IRestHandler.cs index f269600..f269600 100644 --- a/OpenSim.RegionServer/CAPS/IRestHandler.cs +++ b/Servers/IRestHandler.cs | |||
diff --git a/Servers/OpenSim.Servers.csproj b/Servers/OpenSim.Servers.csproj index c983fca..9710f47 100644 --- a/Servers/OpenSim.Servers.csproj +++ b/Servers/OpenSim.Servers.csproj | |||
@@ -96,6 +96,8 @@ | |||
96 | <Compile Include="BaseHttpServer.cs"> | 96 | <Compile Include="BaseHttpServer.cs"> |
97 | <SubType>Code</SubType> | 97 | <SubType>Code</SubType> |
98 | </Compile> | 98 | </Compile> |
99 | <Compile Include="IRestHandler.cs" /> | ||
100 | <Compile Include="XmlRpcMethod.cs" /> | ||
99 | </ItemGroup> | 101 | </ItemGroup> |
100 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | 102 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> |
101 | <PropertyGroup> | 103 | <PropertyGroup> |
diff --git a/Servers/OpenSim.Servers.dll.build b/Servers/OpenSim.Servers.dll.build index 8600ab5..48e8dec 100644 --- a/Servers/OpenSim.Servers.dll.build +++ b/Servers/OpenSim.Servers.dll.build | |||
@@ -12,6 +12,8 @@ | |||
12 | </resources> | 12 | </resources> |
13 | <sources failonempty="true"> | 13 | <sources failonempty="true"> |
14 | <include name="BaseHttpServer.cs" /> | 14 | <include name="BaseHttpServer.cs" /> |
15 | <include name="IRestHandler.cs" /> | ||
16 | <include name="XmlRpcMethod.cs" /> | ||
15 | </sources> | 17 | </sources> |
16 | <references basedir="${project::get-base-directory()}"> | 18 | <references basedir="${project::get-base-directory()}"> |
17 | <lib> | 19 | <lib> |
diff --git a/Servers/XmlRpcMethod.cs b/Servers/XmlRpcMethod.cs new file mode 100644 index 0000000..2295405 --- /dev/null +++ b/Servers/XmlRpcMethod.cs | |||
@@ -0,0 +1,7 @@ | |||
1 | using System; | ||
2 | using Nwc.XmlRpc; | ||
3 | |||
4 | namespace OpenSim.Servers | ||
5 | { | ||
6 | public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request ); | ||
7 | } | ||