29 using System.Collections;
30 using System.Collections.Generic;
32 using System.Reflection;
35 using OpenSim.Framework;
36 using OpenSim.Server.Base;
37 using OpenSim.Services.Interfaces;
38 using OpenSim.Framework.Servers.HttpServer;
39 using OpenSim.Server.Handlers.Base;
46 namespace OpenSim.Server.Handlers.Hypergrid
57 get {
return m_HomeUsersService; }
60 private string[] m_AuthorizedCallers;
62 private bool m_VerifyCallers =
false;
75 base(config, server, String.Empty)
77 IConfig gridConfig = config.Configs[
"UserAgentService"];
78 if (gridConfig != null)
80 string serviceDll = gridConfig.GetString(
"LocalServiceModule", string.Empty);
82 Object[] args =
new Object[] { config, friendsConnector };
85 if (m_HomeUsersService == null)
86 throw new Exception(
"UserAgent server connector cannot proceed because of missing service");
88 string loginServerIP = gridConfig.GetString(
"LoginServerIP",
"127.0.0.1");
89 bool proxy = gridConfig.GetBoolean(
"HasProxy",
false);
91 m_VerifyCallers = gridConfig.GetBoolean(
"VerifyCallers",
false);
92 string csv = gridConfig.GetString(
"AuthorizedCallers",
"127.0.0.1");
93 csv = csv.Replace(
" ",
"");
94 m_AuthorizedCallers = csv.Split(
',');
96 server.AddXmlRPCHandler(
"agent_is_coming_home", AgentIsComingHome,
false);
97 server.AddXmlRPCHandler(
"get_home_region", GetHomeRegion,
false);
98 server.AddXmlRPCHandler(
"verify_agent", VerifyAgent,
false);
99 server.AddXmlRPCHandler(
"verify_client", VerifyClient,
false);
100 server.AddXmlRPCHandler(
"logout_agent", LogoutAgent,
false);
102 #pragma warning disable 0612
103 server.AddXmlRPCHandler(
"status_notification", StatusNotification,
false);
104 server.AddXmlRPCHandler(
"get_online_friends", GetOnlineFriends,
false);
105 #pragma warning restore 0612
106 server.AddXmlRPCHandler(
"get_user_info", GetUserInfo,
false);
107 server.AddXmlRPCHandler(
"get_server_urls", GetServerURLs,
false);
109 server.AddXmlRPCHandler(
"locate_user", LocateUser,
false);
110 server.AddXmlRPCHandler(
"get_uui", GetUUI,
false);
111 server.AddXmlRPCHandler(
"get_uuid", GetUUID,
false);
113 server.AddStreamHandler(
new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy));
116 public XmlRpcResponse
GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
118 Hashtable requestData = (Hashtable)request.Params[0];
121 string userID_str = (
string)requestData[
"userID"];
122 UUID userID = UUID.Zero;
123 UUID.TryParse(userID_str, out userID);
125 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
126 GridRegion regInfo = m_HomeUsersService.GetHomeRegion(userID, out position, out lookAt);
128 Hashtable hash =
new Hashtable();
130 hash[
"result"] =
"false";
133 hash[
"result"] =
"true";
134 hash[
"uuid"] = regInfo.RegionID.ToString();
135 hash[
"x"] = regInfo.RegionLocX.ToString();
136 hash[
"y"] = regInfo.RegionLocY.ToString();
137 hash[
"size_x"] = regInfo.RegionSizeX.ToString();
138 hash[
"size_y"] = regInfo.RegionSizeY.ToString();
139 hash[
"region_name"] = regInfo.RegionName;
140 hash[
"hostname"] = regInfo.ExternalHostName;
141 hash[
"http_port"] = regInfo.HttpPort.ToString();
142 hash[
"internal_port"] = regInfo.InternalEndPoint.Port.ToString();
143 hash[
"position"] = position.ToString();
144 hash[
"lookAt"] = lookAt.ToString();
146 XmlRpcResponse response =
new XmlRpcResponse();
147 response.Value = hash;
154 Hashtable requestData = (Hashtable)request.Params[0];
157 string sessionID_str = (
string)requestData[
"sessionID"];
158 UUID sessionID = UUID.Zero;
159 UUID.TryParse(sessionID_str, out sessionID);
160 string gridName = (string)requestData[
"externalName"];
162 bool success = m_HomeUsersService.IsAgentComingHome(sessionID, gridName);
164 Hashtable hash =
new Hashtable();
165 hash[
"result"] = success.ToString();
166 XmlRpcResponse response =
new XmlRpcResponse();
167 response.Value = hash;
172 public XmlRpcResponse
VerifyAgent(XmlRpcRequest request, IPEndPoint remoteClient)
174 Hashtable requestData = (Hashtable)request.Params[0];
177 string sessionID_str = (
string)requestData[
"sessionID"];
178 UUID sessionID = UUID.Zero;
179 UUID.TryParse(sessionID_str, out sessionID);
180 string token = (string)requestData[
"token"];
182 bool success = m_HomeUsersService.VerifyAgent(sessionID, token);
184 Hashtable hash =
new Hashtable();
185 hash[
"result"] = success.ToString();
186 XmlRpcResponse response =
new XmlRpcResponse();
187 response.Value = hash;
192 public XmlRpcResponse
VerifyClient(XmlRpcRequest request, IPEndPoint remoteClient)
194 Hashtable requestData = (Hashtable)request.Params[0];
197 string sessionID_str = (
string)requestData[
"sessionID"];
198 UUID sessionID = UUID.Zero;
199 UUID.TryParse(sessionID_str, out sessionID);
200 string token = (string)requestData[
"token"];
202 bool success = m_HomeUsersService.VerifyClient(sessionID, token);
204 Hashtable hash =
new Hashtable();
205 hash[
"result"] = success.ToString();
206 XmlRpcResponse response =
new XmlRpcResponse();
207 response.Value = hash;
212 public XmlRpcResponse
LogoutAgent(XmlRpcRequest request, IPEndPoint remoteClient)
214 Hashtable requestData = (Hashtable)request.Params[0];
217 string sessionID_str = (
string)requestData[
"sessionID"];
218 UUID sessionID = UUID.Zero;
219 UUID.TryParse(sessionID_str, out sessionID);
220 string userID_str = (string)requestData[
"userID"];
221 UUID userID = UUID.Zero;
222 UUID.TryParse(userID_str, out userID);
224 m_HomeUsersService.LogoutAgent(userID, sessionID);
226 Hashtable hash =
new Hashtable();
227 hash[
"result"] =
"true";
228 XmlRpcResponse response =
new XmlRpcResponse();
229 response.Value = hash;
237 Hashtable hash =
new Hashtable();
238 hash[
"result"] =
"false";
240 Hashtable requestData = (Hashtable)request.Params[0];
243 if (requestData.ContainsKey(
"userID") && requestData.ContainsKey(
"online"))
245 string userID_str = (string)requestData[
"userID"];
246 UUID userID = UUID.Zero;
247 UUID.TryParse(userID_str, out userID);
248 List<string> ids =
new List<string>();
249 foreach (
object key in requestData.Keys)
251 if (key is
string && ((
string)
key).StartsWith(
"friend_") && requestData[
key] != null)
252 ids.Add(requestData[key].ToString());
255 bool.TryParse(requestData[
"online"].ToString(), out online);
258 List<UUID> friendsOnline = m_HomeUsersService.StatusNotification(ids, userID, online);
259 if (friendsOnline.Count > 0)
262 foreach (UUID
id in friendsOnline)
264 hash[
"friend_" + i.ToString()] =
id.ToString();
269 hash[
"result"] =
"No Friends Online";
273 XmlRpcResponse response =
new XmlRpcResponse();
274 response.Value = hash;
282 Hashtable hash =
new Hashtable();
284 Hashtable requestData = (Hashtable)request.Params[0];
287 if (requestData.ContainsKey(
"userID"))
289 string userID_str = (string)requestData[
"userID"];
290 UUID userID = UUID.Zero;
291 UUID.TryParse(userID_str, out userID);
292 List<string> ids =
new List<string>();
293 foreach (
object key in requestData.Keys)
295 if (key is
string && ((
string)
key).StartsWith(
"friend_") && requestData[
key] != null)
296 ids.Add(requestData[key].ToString());
313 XmlRpcResponse response =
new XmlRpcResponse();
314 response.Value = hash;
319 public XmlRpcResponse
GetUserInfo(XmlRpcRequest request, IPEndPoint remoteClient)
321 Hashtable hash =
new Hashtable();
322 Hashtable requestData = (Hashtable)request.Params[0];
325 if (requestData.ContainsKey(
"userID"))
327 string userID_str = (string)requestData[
"userID"];
328 UUID userID = UUID.Zero;
329 UUID.TryParse(userID_str, out userID);
332 Dictionary<string,object> userInfo = m_HomeUsersService.GetUserInfo(userID);
333 if (userInfo.Count > 0)
335 foreach (KeyValuePair<string, object> kvp
in userInfo)
337 hash[kvp.Key] = kvp.Value;
342 hash[
"result"] =
"failure";
346 XmlRpcResponse response =
new XmlRpcResponse();
347 response.Value = hash;
351 public XmlRpcResponse
GetServerURLs(XmlRpcRequest request, IPEndPoint remoteClient)
353 Hashtable hash =
new Hashtable();
355 Hashtable requestData = (Hashtable)request.Params[0];
358 if (requestData.ContainsKey(
"userID"))
360 string userID_str = (string)requestData[
"userID"];
361 UUID userID = UUID.Zero;
362 UUID.TryParse(userID_str, out userID);
364 Dictionary<string, object> serverURLs = m_HomeUsersService.GetServerURLs(userID);
365 if (serverURLs.Count > 0)
367 foreach (KeyValuePair<string, object> kvp
in serverURLs)
368 hash[
"SRV_" + kvp.Key] = kvp.Value.ToString();
371 hash[
"result"] =
"No Service URLs";
374 XmlRpcResponse response =
new XmlRpcResponse();
375 response.Value = hash;
387 public XmlRpcResponse
LocateUser(XmlRpcRequest request, IPEndPoint remoteClient)
389 Hashtable hash =
new Hashtable();
391 bool authorized =
true;
395 foreach (
string s
in m_AuthorizedCallers)
396 if (s == remoteClient.Address.ToString())
405 Hashtable requestData = (Hashtable)request.Params[0];
408 if (requestData.ContainsKey(
"userID"))
410 string userID_str = (string)requestData[
"userID"];
411 UUID userID = UUID.Zero;
412 UUID.TryParse(userID_str, out userID);
414 string url = m_HomeUsersService.LocateUser(userID);
415 if (url !=
string.Empty)
418 hash[
"result"] =
"Unable to locate user";
422 XmlRpcResponse response =
new XmlRpcResponse();
423 response.Value = hash;
434 public XmlRpcResponse
GetUUI(XmlRpcRequest request, IPEndPoint remoteClient)
436 Hashtable hash =
new Hashtable();
438 Hashtable requestData = (Hashtable)request.Params[0];
441 if (requestData.ContainsKey(
"userID") && requestData.ContainsKey(
"targetUserID"))
443 string userID_str = (string)requestData[
"userID"];
444 UUID userID = UUID.Zero;
445 UUID.TryParse(userID_str, out userID);
447 string tuserID_str = (string)requestData[
"targetUserID"];
448 UUID targetUserID = UUID.Zero;
449 UUID.TryParse(tuserID_str, out targetUserID);
450 string uui = m_HomeUsersService.GetUUI(userID, targetUserID);
451 if (uui !=
string.Empty)
454 hash[
"result"] =
"User unknown";
457 XmlRpcResponse response =
new XmlRpcResponse();
458 response.Value = hash;
468 public XmlRpcResponse
GetUUID(XmlRpcRequest request, IPEndPoint remoteClient)
470 Hashtable hash =
new Hashtable();
472 Hashtable requestData = (Hashtable)request.Params[0];
475 if (requestData.ContainsKey(
"first") && requestData.ContainsKey(
"last"))
477 string first = (string)requestData[
"first"];
478 string last = (string)requestData[
"last"];
479 UUID uuid = m_HomeUsersService.GetUUID(first, last);
480 hash[
"UUID"] = uuid.ToString();
483 XmlRpcResponse response =
new XmlRpcResponse();
484 response.Value = hash;
XmlRpcResponse GetUUID(XmlRpcRequest request, IPEndPoint remoteClient)
Gets the UUID of a user given First name, Last name.
UserAgentServerConnector(IConfigSource config, IHttpServer server, IFriendsSimConnector friendsConnector)
XmlRpcResponse GetOnlineFriends(XmlRpcRequest request, IPEndPoint remoteClient)
XmlRpcResponse VerifyClient(XmlRpcRequest request, IPEndPoint remoteClient)
Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.) for given URLs.
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
UserAgentServerConnector(IConfigSource config, IHttpServer server, string configName)
XmlRpcResponse GetUUI(XmlRpcRequest request, IPEndPoint remoteClient)
Returns the UUI of a user given a UUID.
XmlRpcResponse StatusNotification(XmlRpcRequest request, IPEndPoint remoteClient)
XmlRpcResponse VerifyAgent(XmlRpcRequest request, IPEndPoint remoteClient)
OpenSim.Services.Interfaces.GridRegion GridRegion
UserAgentServerConnector(IConfigSource config, IHttpServer server)
XmlRpcResponse GetUserInfo(XmlRpcRequest request, IPEndPoint remoteClient)
XmlRpcResponse LocateUser(XmlRpcRequest request, IPEndPoint remoteClient)
Locates the user. This is a sensitive operation, only authorized IP addresses can perform it...
XmlRpcResponse LogoutAgent(XmlRpcRequest request, IPEndPoint remoteClient)
XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
XmlRpcResponse AgentIsComingHome(XmlRpcRequest request, IPEndPoint remoteClient)
XmlRpcResponse GetServerURLs(XmlRpcRequest request, IPEndPoint remoteClient)