diff options
Diffstat (limited to 'OpenSim/Grid')
-rw-r--r-- | OpenSim/Grid/UserServer/UserLoginService.cs | 239 |
1 files changed, 106 insertions, 133 deletions
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 07b29bd..8ab9af1 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Text.RegularExpressions; | ||
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | using log4net; | 34 | using log4net; |
34 | using Nwc.XmlRpc; | 35 | using Nwc.XmlRpc; |
@@ -127,94 +128,25 @@ namespace OpenSim.Grid.UserServer | |||
127 | /// </summary> | 128 | /// </summary> |
128 | /// <param name="response">The existing response</param> | 129 | /// <param name="response">The existing response</param> |
129 | /// <param name="theUser">The user profile</param> | 130 | /// <param name="theUser">The user profile</param> |
130 | /// <param name="startLocationRequest">Destination of the user</param> | 131 | /// <param name="startLocationRequest">The requested start location</param> |
131 | public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, | 132 | public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) |
132 | string startLocationRequest) | ||
133 | { | 133 | { |
134 | RegionProfileData SimInfo; | 134 | // HomeLocation |
135 | RegionProfileData HomeInfo; | 135 | RegionProfileData homeInfo = null; |
136 | int start_x = -1; | ||
137 | int start_y = -1; | ||
138 | int start_z = -1; | ||
139 | |||
140 | // use the homeRegionID if it is stored already. If not, use the regionHandle as before | 136 | // use the homeRegionID if it is stored already. If not, use the regionHandle as before |
141 | if (theUser.HomeRegionID != UUID.Zero) | 137 | if (theUser.HomeRegionID != UUID.Zero) |
142 | { | 138 | homeInfo = RegionProfileData.RequestSimProfileData(theUser.HomeRegionID, |
143 | HomeInfo = | 139 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); |
144 | RegionProfileData.RequestSimProfileData( | ||
145 | theUser.HomeRegionID, m_config.GridServerURL, | ||
146 | m_config.GridSendKey, m_config.GridRecvKey); | ||
147 | } | ||
148 | else | 140 | else |
149 | { | 141 | homeInfo = RegionProfileData.RequestSimProfileData(theUser.HomeRegion, |
150 | HomeInfo = | 142 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); |
151 | RegionProfileData.RequestSimProfileData( | 143 | if (homeInfo != null) |
152 | theUser.HomeRegion, m_config.GridServerURL, | ||
153 | m_config.GridSendKey, m_config.GridRecvKey); | ||
154 | } | ||
155 | |||
156 | if (startLocationRequest == "last") | ||
157 | { | ||
158 | SimInfo = | ||
159 | RegionProfileData.RequestSimProfileData( | ||
160 | theUser.CurrentAgent.Handle, m_config.GridServerURL, | ||
161 | m_config.GridSendKey, m_config.GridRecvKey); | ||
162 | } | ||
163 | else if (startLocationRequest == "home") | ||
164 | { | ||
165 | SimInfo = HomeInfo; | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | string[] startLocationRequestParsed = Util.ParseStartLocationRequest(startLocationRequest); | ||
170 | m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + | ||
171 | startLocationRequestParsed[1] + ", 3:" + startLocationRequestParsed[2] + ", 4:" + | ||
172 | startLocationRequestParsed[3]); | ||
173 | if (startLocationRequestParsed[0] == "last") | ||
174 | { | ||
175 | SimInfo = | ||
176 | RegionProfileData.RequestSimProfileData( | ||
177 | theUser.CurrentAgent.Handle, m_config.GridServerURL, | ||
178 | m_config.GridSendKey, m_config.GridRecvKey); | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | m_log.Info("[LOGIN]: Looking up Sim: " + startLocationRequestParsed[0]); | ||
183 | SimInfo = | ||
184 | RegionProfileData.RequestSimProfileData( | ||
185 | startLocationRequestParsed[0], m_config.GridServerURL, | ||
186 | m_config.GridSendKey, m_config.GridRecvKey); | ||
187 | |||
188 | if (SimInfo == null) | ||
189 | { | ||
190 | m_log.Info("[LOGIN]: Didn't find region with a close name match sending to home location"); | ||
191 | SimInfo = HomeInfo; | ||
192 | } | ||
193 | else | ||
194 | { | ||
195 | start_x = Convert.ToInt32(startLocationRequestParsed[1]); | ||
196 | start_y = Convert.ToInt32(startLocationRequestParsed[2]); | ||
197 | start_z = Convert.ToInt32(startLocationRequestParsed[3]); | ||
198 | |||
199 | if (start_x >= 0 && start_y >= 0 && start_z >= 0) | ||
200 | { | ||
201 | Vector3 tmp_v = new Vector3(start_x, start_y, start_z); | ||
202 | theUser.CurrentAgent.Position = tmp_v; | ||
203 | } | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
208 | // Customise the response | ||
209 | //CFK: This is redundant and the next message should always appear. | ||
210 | //CFK: m_log.Info("[LOGIN]: Home Location"); | ||
211 | if (HomeInfo != null) | ||
212 | { | 144 | { |
213 | response.Home = | 145 | response.Home = |
214 | string.Format( | 146 | string.Format( |
215 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | 147 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", |
216 | (HomeInfo.regionLocX*Constants.RegionSize), | 148 | (homeInfo.regionLocX*Constants.RegionSize), |
217 | (HomeInfo.regionLocY*Constants.RegionSize), | 149 | (homeInfo.regionLocY*Constants.RegionSize), |
218 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | 150 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, |
219 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | 151 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); |
220 | } | 152 | } |
@@ -236,42 +168,85 @@ namespace OpenSim.Grid.UserServer | |||
236 | regionX, regionY); | 168 | regionX, regionY); |
237 | } | 169 | } |
238 | 170 | ||
239 | if (!PrepareLoginToRegion(SimInfo, theUser, response)) | 171 | // StartLocation |
172 | RegionProfileData regionInfo = null; | ||
173 | if (startLocationRequest == "home") | ||
240 | { | 174 | { |
241 | // Send him to default region instead | 175 | regionInfo = homeInfo; |
242 | // Load information from the gridserver | 176 | theUser.CurrentAgent.Position = theUser.HomeLocation; |
243 | ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) | | 177 | response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; |
244 | ((ulong) m_config.DefaultY * Constants.RegionSize); | 178 | } |
245 | 179 | else if (startLocationRequest == "last") | |
246 | if (defaultHandle == SimInfo.regionHandle) | 180 | { |
181 | regionInfo = RegionProfileData.RequestSimProfileData(theUser.CurrentAgent.Region, | ||
182 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); | ||
183 | response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); | ||
188 | Match uriMatch = reURI.Match(startLocationRequest); | ||
189 | if (uriMatch == null) | ||
247 | { | 190 | { |
248 | m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); | 191 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); |
249 | return false; | ||
250 | } | 192 | } |
193 | else | ||
194 | { | ||
195 | string region = uriMatch.Groups["region"].ToString(); | ||
196 | regionInfo = RegionProfileData.RequestSimProfileData(region, | ||
197 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); | ||
198 | if (regionInfo == null) | ||
199 | { | ||
200 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), | ||
205 | float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["x"].Value)); | ||
206 | } | ||
207 | } | ||
208 | response.LookAt = "[r0,r1,r0]"; | ||
209 | // can be: last, home, safe, url | ||
210 | response.StartLocation = "url"; | ||
211 | } | ||
251 | 212 | ||
252 | m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); | 213 | if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) |
214 | { | ||
215 | return true; | ||
216 | } | ||
253 | 217 | ||
254 | SimInfo = RegionProfileData.RequestSimProfileData(defaultHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); | 218 | // StartLocation not available, send him to a nearby region instead |
219 | //regionInfo = RegionProfileData.RequestSimProfileData("", m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); | ||
220 | //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); | ||
255 | 221 | ||
256 | // Customise the response | 222 | // Send him to default region instead |
257 | response.Home = | 223 | // Load information from the gridserver |
258 | string.Format( | 224 | ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) | |
259 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | 225 | ((ulong) m_config.DefaultY * Constants.RegionSize); |
260 | (SimInfo.regionLocX * Constants.RegionSize), | ||
261 | (SimInfo.regionLocY*Constants.RegionSize), | ||
262 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
263 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
264 | 226 | ||
265 | if (!PrepareLoginToRegion(SimInfo, theUser, response)) | 227 | if ((regionInfo != null) && (defaultHandle == regionInfo.regionHandle)) |
266 | { | 228 | { |
267 | response.CreateDeadRegionResponse(); | 229 | m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); |
268 | return false; | 230 | return false; |
269 | } | ||
270 | } | 231 | } |
271 | 232 | ||
272 | return true; | 233 | m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); |
273 | } | 234 | regionInfo = RegionProfileData.RequestSimProfileData(defaultHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); |
274 | 235 | ||
236 | // Customise the response | ||
237 | //response.Home = | ||
238 | // string.Format( | ||
239 | // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
240 | // (SimInfo.regionLocX * Constants.RegionSize), | ||
241 | // (SimInfo.regionLocY*Constants.RegionSize), | ||
242 | // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
243 | // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
244 | theUser.CurrentAgent.Position = new Vector3(128,128,0); | ||
245 | response.StartLocation = "safe"; | ||
246 | |||
247 | return PrepareLoginToRegion(regionInfo, theUser, response); | ||
248 | } | ||
249 | |||
275 | /// <summary> | 250 | /// <summary> |
276 | /// Prepare a login to the given region. This involves both telling the region to expect a connection | 251 | /// Prepare a login to the given region. This involves both telling the region to expect a connection |
277 | /// and appropriately customising the response to the user. | 252 | /// and appropriately customising the response to the user. |
@@ -280,47 +255,46 @@ namespace OpenSim.Grid.UserServer | |||
280 | /// <param name="user"></param> | 255 | /// <param name="user"></param> |
281 | /// <param name="response"></param> | 256 | /// <param name="response"></param> |
282 | /// <returns>true if the region was successfully contacted, false otherwise</returns> | 257 | /// <returns>true if the region was successfully contacted, false otherwise</returns> |
283 | private bool PrepareLoginToRegion(RegionProfileData sim, UserProfileData user, LoginResponse response) | 258 | private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response) |
284 | { | 259 | { |
285 | try | 260 | try |
286 | { | 261 | { |
287 | response.SimAddress = Util.GetHostFromURL(sim.serverURI).ToString(); | 262 | response.SimAddress = Util.GetHostFromURL(regionInfo.serverURI).ToString(); |
288 | response.SimPort = uint.Parse(sim.serverURI.Split(new char[] {'/', ':'})[4]); | 263 | response.SimPort = uint.Parse(regionInfo.serverURI.Split(new char[] { '/', ':' })[4]); |
289 | response.RegionX = sim.regionLocX; | 264 | response.RegionX = regionInfo.regionLocX; |
290 | response.RegionY = sim.regionLocY; | 265 | response.RegionY = regionInfo.regionLocY; |
291 | 266 | ||
292 | //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI | 267 | //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI |
293 | string capsPath = Util.GetRandomCapsPath(); | 268 | string capsPath = Util.GetRandomCapsPath(); |
294 | response.SeedCapability = sim.httpServerURI + "CAPS/" + capsPath + "0000/"; | 269 | response.SeedCapability = regionInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; |
295 | 270 | ||
296 | // Notify the target of an incoming user | 271 | // Notify the target of an incoming user |
297 | m_log.InfoFormat( | 272 | m_log.InfoFormat( |
298 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", | 273 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", |
299 | sim.regionName, sim.regionLocX, sim.regionLocY, sim.serverURI); | 274 | regionInfo.regionName, response.RegionX, response.RegionY, regionInfo.httpServerURI); |
300 | |||
301 | // Update agent with target sim | 275 | // Update agent with target sim |
302 | user.CurrentAgent.Region = sim.UUID; | 276 | user.CurrentAgent.Region = regionInfo.UUID; |
303 | user.CurrentAgent.Handle = sim.regionHandle; | 277 | user.CurrentAgent.Handle = regionInfo.regionHandle; |
304 | |||
305 | // Prepare notification | 278 | // Prepare notification |
306 | Hashtable SimParams = new Hashtable(); | 279 | Hashtable loginParams = new Hashtable(); |
307 | SimParams["session_id"] = user.CurrentAgent.SessionID.ToString(); | 280 | loginParams["session_id"] = user.CurrentAgent.SessionID.ToString(); |
308 | SimParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString(); | 281 | loginParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString(); |
309 | SimParams["firstname"] = user.FirstName; | 282 | loginParams["firstname"] = user.FirstName; |
310 | SimParams["lastname"] = user.SurName; | 283 | loginParams["lastname"] = user.SurName; |
311 | SimParams["agent_id"] = user.ID.ToString(); | 284 | loginParams["agent_id"] = user.ID.ToString(); |
312 | SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode); | 285 | loginParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode); |
313 | SimParams["startpos_x"] = user.CurrentAgent.Position.X.ToString(); | 286 | loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString(); |
314 | SimParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString(); | 287 | loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString(); |
315 | SimParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString(); | 288 | loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString(); |
316 | SimParams["regionhandle"] = user.CurrentAgent.Handle.ToString(); | 289 | loginParams["regionhandle"] = user.CurrentAgent.Handle.ToString(); |
317 | SimParams["caps_path"] = capsPath; | 290 | loginParams["caps_path"] = capsPath; |
291 | |||
318 | ArrayList SendParams = new ArrayList(); | 292 | ArrayList SendParams = new ArrayList(); |
319 | SendParams.Add(SimParams); | 293 | SendParams.Add(loginParams); |
320 | 294 | ||
321 | // Send | 295 | // Send |
322 | XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); | 296 | XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); |
323 | XmlRpcResponse GridResp = GridReq.Send(sim.httpServerURI, 30000); | 297 | XmlRpcResponse GridResp = GridReq.Send(regionInfo.httpServerURI, 6000); |
324 | 298 | ||
325 | if (!GridResp.IsFault) | 299 | if (!GridResp.IsFault) |
326 | { | 300 | { |
@@ -337,7 +311,6 @@ namespace OpenSim.Grid.UserServer | |||
337 | } | 311 | } |
338 | } | 312 | } |
339 | } | 313 | } |
340 | |||
341 | if (responseSuccess) | 314 | if (responseSuccess) |
342 | { | 315 | { |
343 | handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; | 316 | handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; |