public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser) { //default method set up to act as ogs user server SimProfile SimInfo= new SimProfile(); //get siminfo from grid server SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey); Int32 circode = (Int32)Convert.ToUInt32(response["circuit_code"]); theUser.AddSimCircuit((uint)circode, SimInfo.UUID); 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() + "]}"; response["sim_ip"] = SimInfo.sim_ip; response["sim_port"] = (Int32)SimInfo.sim_port; response["region_y"] = (Int32)SimInfo.RegionLocY * 256; response["region_x"] = (Int32)SimInfo.RegionLocX * 256; //default is ogs user server, so let the sim know about the user via a XmlRpcRequest Console.WriteLine(SimInfo.caps_url); Hashtable SimParams = new Hashtable(); SimParams["session_id"] = theUser.CurrentSessionID.ToString(); SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString(); SimParams["firstname"] = theUser.firstname; SimParams["lastname"] = theUser.lastname; SimParams["agent_id"] = theUser.UUID.ToString(); SimParams["circuit_code"] = (Int32)circode; SimParams["startpos_x"] = theUser.homepos.X.ToString(); SimParams["startpos_y"] = theUser.homepos.Y.ToString(); SimParams["startpos_z"] = theUser.homepos.Z.ToString(); ArrayList SendParams = new ArrayList(); SendParams.Add(SimParams); XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000); }
public bool Connect(string GridServerURL, string username, string password) { try { this.ServerURL=GridServerURL; Hashtable LoginParamsHT = new Hashtable(); LoginParamsHT["username"]=username; LoginParamsHT["password"]=password; ArrayList LoginParams = new ArrayList(); LoginParams.Add(LoginParamsHT); XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams); XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000); if (GridResp.IsFault) { connected=false; return false; } else { Hashtable gridrespData = (Hashtable)GridResp.Value; this.SessionID = new LLUUID((string)gridrespData["session_id"]); connected=true; return true; } } catch(Exception e) { Console.WriteLine(e.ToString()); connected=false; return false; } }
/// <summary> /// Request sim data based on arbitrary key/value /// </summary> private RegionProfileData RequestSimData(Uri gridserverUrl, string gridserverSendkey, string keyField, string keyValue) { Hashtable requestData = new Hashtable(); requestData[keyField] = keyValue; requestData["authkey"] = gridserverSendkey; ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); XmlRpcResponse GridResp = GridReq.Send(gridserverUrl.ToString(), 3000); Hashtable responseData = (Hashtable) GridResp.Value; RegionProfileData simData = null; if (!responseData.ContainsKey("error")) { uint locX = Convert.ToUInt32((string)responseData["region_locx"]); uint locY = Convert.ToUInt32((string)responseData["region_locy"]); string externalHostName = (string)responseData["sim_ip"]; uint simPort = Convert.ToUInt32((string)responseData["sim_port"]); uint httpPort = Convert.ToUInt32((string)responseData["http_port"]); uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); string serverUri = (string)responseData["server_uri"]; UUID regionID = new UUID((string)responseData["region_UUID"]); string regionName = (string)responseData["region_name"]; byte access = Convert.ToByte((string)responseData["access"]); simData = RegionProfileData.Create(regionID, regionName, locX, locY, externalHostName, simPort, httpPort, remotingPort, serverUri, access); } return simData; }
public SimProfile LoadFromGrid(LLUUID UUID, string GridURL, string SendKey, string RecvKey) { try { Hashtable GridReqParams = new Hashtable(); GridReqParams["UUID"] = UUID.ToString(); GridReqParams["authkey"] = SendKey; ArrayList SendParams = new ArrayList(); SendParams.Add(GridReqParams); XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000); Hashtable RespData = (Hashtable)GridResp.Value; this.UUID = new LLUUID((string)RespData["UUID"]); this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256)); this.regionname = (string)RespData["regionname"]; this.sim_ip = (string)RespData["sim_ip"]; this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]); this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/"; this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]); this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]); this.sendkey = SendKey; this.recvkey = RecvKey; } catch (Exception e) { Console.WriteLine(e.ToString()); } return this; }
public virtual LandData GetLandData(ulong regionHandle, uint x, uint y) { LandData landData = null; Hashtable hash = new Hashtable(); hash["region_handle"] = regionHandle.ToString(); hash["x"] = x.ToString(); hash["y"] = y.ToString(); IList paramList = new ArrayList(); paramList.Add(hash); try { RegionInfo info = m_MapService.RequestNeighbourInfo(regionHandle); if (info != null) // just to be sure { XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; XmlRpcResponse response = request.Send(uri, 10000); if (response.IsFault) { m_log.ErrorFormat("[LAND CONNECTOR] remote call returned an error: {0}", response.FaultString); } else { hash = (Hashtable)response.Value; try { landData = new LandData(); landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]); landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]); landData.Area = Convert.ToInt32(hash["Area"]); landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]); landData.Description = (string)hash["Description"]; landData.Flags = Convert.ToUInt32(hash["Flags"]); landData.GlobalID = new UUID((string)hash["GlobalID"]); landData.Name = (string)hash["Name"]; landData.OwnerID = new UUID((string)hash["OwnerID"]); landData.SalePrice = Convert.ToInt32(hash["SalePrice"]); landData.SnapshotID = new UUID((string)hash["SnapshotID"]); landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]); m_log.DebugFormat("[OGS1 GRID SERVICES] Got land data for parcel {0}", landData.Name); } catch (Exception e) { m_log.Error("[LAND CONNECTOR] Got exception while parsing land-data:", e); } } } else m_log.WarnFormat("[LAND CONNECTOR] Couldn't find region with handle {0}", regionHandle); } catch (Exception e) { m_log.ErrorFormat("[LAND CONNECTOR] Couldn't contact region {0}: {1}", regionHandle, e); } return landData; }
public static Hashtable SendTransaction(string url, string trans, bool debug) { Hashtable hashtable = new Hashtable(); Hashtable hashtable2 = new Hashtable(); hashtable2["TransID"] = trans; XmlRpcRequest xmlRpcRequest = new XmlRpcRequest("grid_store_transaction_message", new ArrayList { hashtable2 }); try { XmlRpcResponse xmlRpcResponse = xmlRpcRequest.Send(url, 10000); Hashtable hashtable3 = (Hashtable)xmlRpcResponse.Value; if (hashtable3.ContainsKey("success")) { if ((string)hashtable3["success"] == "true") { string value = (string)hashtable3["result"]; hashtable.Add("success", "true"); hashtable.Add("result", value); if (debug) { StoreServiceConnector.m_log.DebugFormat("[Web Store Debug] Success", new object[0]); } } else { string value2 = (string)hashtable3["result"]; hashtable.Add("success", "false"); hashtable.Add("result", value2); if (debug) { StoreServiceConnector.m_log.DebugFormat("[Web Store Debug] Fail", new object[0]); } } } else { hashtable.Add("success", "false"); hashtable.Add("result", "The region server did not respond!"); StoreServiceConnector.m_log.DebugFormat("[Web Store Robust Module]: No response from Region Server! {0}", url); } } catch (WebException ex) { hashtable.Add("success", "false"); StoreServiceConnector.m_log.ErrorFormat("[STORE]: Error sending transaction to {0} the host didn't respond " + ex.ToString(), url); } return hashtable; }
public string RegionManagementBroadcastPostRequest(AuroraWeb.Environment env, string message) { Request request = env.Request; SessionInfo sinfo; if (TryGetSessionInfo(request, out sinfo) && (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)) { env.Session = sinfo; string url = m_WebApp.LoginURL; Hashtable hash = new Hashtable(); if (m_ServerAdminPassword == null) { m_log.Debug("[RegionManagementBroadcastPostRequest] No remote admin password was set in .ini file"); } hash["password"] = m_ServerAdminPassword; hash["message"] = message; IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_broadcast", paramList); XmlRpcResponse response = null; try { response = xmlrpcReq.Send(url, 10000); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementSuccessful; } catch (Exception e) { m_log.Debug("[AuroraWeb]: Exception " + e.Message); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementUnsuccessful; } return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
/// <summary> /// This actually does the XMLRPC Request /// </summary> /// <param name="url">URL we pull the data out of to send the request to</param> /// <param name="im">The Instant Message </param> /// <returns>Bool if the message was successfully delivered at the other side.</returns> public static bool SendInstantMessage(string url, GridInstantMessage im) { Hashtable xmlrpcdata = ConvertGridInstantMessageToXMLRPC(im); xmlrpcdata["region_handle"] = 0; ArrayList SendParams = new ArrayList(); SendParams.Add(xmlrpcdata); XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams); try { XmlRpcResponse GridResp = GridReq.Send(url, 10000); Hashtable responseData = (Hashtable)GridResp.Value; if (responseData.ContainsKey("success")) { if ((string)responseData["success"] == "TRUE") { //m_log.DebugFormat("[XXX] Success"); return true; } else { //m_log.DebugFormat("[XXX] Fail"); return false; } } else { m_log.DebugFormat("[GRID INSTANT MESSAGE]: No response from {0}", url); return false; } } catch (WebException e) { m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} the host didn't respond " + e.ToString(), url); } return false; }
public static string GetNewKey(string authurl, UUID userID, UUID authToken) { //Hashtable keyParams = new Hashtable(); //keyParams["user_id"] = userID; //keyParams["auth_token"] = authKey; List<string> SendParams = new List<string>(); SendParams.Add(userID.ToString()); SendParams.Add(authToken.ToString()); string methodName = "hg_new_auth_key"; XmlRpcRequest request = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse reply; try { reply = request.Send(Util.XmlRpcRequestURI(authurl, methodName), 6000); } catch (Exception e) { System.Console.WriteLine("[HGrid]: Failed to get new key. Reason: " + e.Message); return String.Empty; } if (!reply.IsFault) { string newKey = String.Empty; if (reply.Value != null) newKey = (string)reply.Value; return newKey; } else { System.Console.WriteLine("[HGrid]: XmlRpc request to get auth key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); return String.Empty; } }
/// <summary> /// Request sim data based on arbitrary key/value /// </summary> private RegionProfileData RequestSimData(Uri gridserverUrl, string gridserverSendkey, string keyField, string keyValue) { Hashtable requestData = new Hashtable(); requestData[keyField] = keyValue; requestData["authkey"] = gridserverSendkey; ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); string methodName = "simulator_data_request"; XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(gridserverUrl.ToString(), methodName), 5000); Hashtable responseData = (Hashtable) GridResp.Value; RegionProfileData simData = null; if (!responseData.ContainsKey("error")) { uint locX = Convert.ToUInt32((string)responseData["region_locx"]); uint locY = Convert.ToUInt32((string)responseData["region_locy"]); string externalHostName = (string)responseData["sim_ip"]; uint simPort = Convert.ToUInt32((string)responseData["sim_port"]); uint httpPort = Convert.ToUInt32((string)responseData["http_port"]); uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); UUID regionID = new UUID((string)responseData["region_UUID"]); string regionName = (string)responseData["region_name"]; byte access = Convert.ToByte((string)responseData["access"]); ProductRulesUse product = (ProductRulesUse)Convert.ToInt32(responseData["product"]); string outsideIp = null; if (responseData.ContainsKey("outside_ip")) outsideIp = (string)responseData["outside_ip"]; simData = RegionProfileData.Create(regionID, regionName, locX, locY, externalHostName, simPort, httpPort, remotingPort, access, product, outsideIp); } return simData; }
public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) { Hashtable hash = new Hashtable (); hash["region_uuid"] = regionID.ToString (); IList paramList = new ArrayList (); paramList.Add (hash); XmlRpcRequest request = new XmlRpcRequest ("get_region", paramList); MainConsole.Instance.Debug ("[GATEKEEPER SERVICE CONNECTOR]: contacting " + gatekeeper.ServerURI); XmlRpcResponse response = null; try { response = request.Send (gatekeeper.ServerURI, 10000); } catch (Exception e) { MainConsole.Instance.Debug ("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); return null; } if (response.IsFault) { MainConsole.Instance.ErrorFormat ("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); return null; } hash = (Hashtable)response.Value; //foreach (Object o in hash) // MainConsole.Instance.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { bool success = false; Boolean.TryParse ((string)hash["result"], out success); if (success) { GridRegion region = new GridRegion (); UUID.TryParse ((string)hash["uuid"], out region.RegionID); //MainConsole.Instance.Debug(">> HERE, uuid: " + region.RegionID); int n = 0; if (hash["x"] != null) { Int32.TryParse ((string)hash["x"], out n); region.RegionLocX = n; //MainConsole.Instance.Debug(">> HERE, x: " + region.RegionLocX); } if (hash["y"] != null) { Int32.TryParse ((string)hash["y"], out n); region.RegionLocY = n; //MainConsole.Instance.Debug(">> HERE, y: " + region.RegionLocY); } if (hash["region_name"] != null) { region.RegionName = (string)hash["region_name"]; //MainConsole.Instance.Debug(">> HERE, region_name: " + region.RegionName); } if (hash["hostname"] != null) { region.ExternalHostName = (string)hash["hostname"]; //MainConsole.Instance.Debug(">> HERE, hostname: " + region.ExternalHostName); } if (hash["http_port"] != null) { uint p = 0; UInt32.TryParse ((string)hash["http_port"], out p); region.HttpPort = p; //MainConsole.Instance.Debug(">> HERE, http_port: " + region.HttpPort); } if (hash["internal_port"] != null) { int p = 0; Int32.TryParse ((string)hash["internal_port"], out p); region.InternalEndPoint = new IPEndPoint (IPAddress.Parse ("0.0.0.0"), p); //MainConsole.Instance.Debug(">> HERE, internal_port: " + region.InternalEndPoint); } if (hash["server_uri"] != null) { region.ServerURI = (string)hash["server_uri"]; //MainConsole.Instance.Debug(">> HERE, server_uri: " + region.ServerURI); } // Successful return return region; } } catch (Exception e) { MainConsole.Instance.Error ("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); return null; } return null; }
/// <summary> /// Check that the source of an inventory request for a particular agent is a current session belonging to /// that agent. /// </summary> /// <param name="session_id"></param> /// <param name="avatar_id"></param> /// <returns></returns> public bool CheckAuthSession(string session_id, string avatar_id) { if (m_doLookup) { m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id); if (m_session_cache.getCachedSession(session_id, avatar_id) == null) { // cache miss, ask userserver Hashtable requestData = new Hashtable(); requestData["avatar_uuid"] = avatar_id; requestData["session_id"] = session_id; ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); Hashtable responseData = (Hashtable)UserResp.Value; if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") { m_log.Info("[GRID AGENT INVENTORY]: got authed session from userserver"); // add to cache; the session time will be automatically renewed m_session_cache.Add(session_id, avatar_id); return true; } } else { // cache hits m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache"); return true; } m_log.Warn("[GRID AGENT INVENTORY]: unknown session_id, request rejected"); return false; } else { return true; } }
private void BeginLogin() { LoginParams loginParams = CurrentContext.Value; // Generate a random ID to identify this login attempt loginParams.LoginID = UUID.Random(); CurrentContext = loginParams; #region Sanity Check loginParams if (loginParams.Options == null) loginParams.Options = new List<string>().ToArray(); // Convert the password to MD5 if it isn't already if (loginParams.Password.Length != 35 && !loginParams.Password.StartsWith("$1$")) loginParams.Password = Utils.MD5(loginParams.Password); if (loginParams.ViewerDigest == null) loginParams.ViewerDigest = String.Empty; if (loginParams.Version == null) loginParams.Version = String.Empty; if (loginParams.UserAgent == null) loginParams.UserAgent = String.Empty; if (loginParams.Platform == null) loginParams.Platform = String.Empty; if (loginParams.MAC == null) loginParams.MAC = String.Empty; if (loginParams.Channel == null) loginParams.Channel = String.Empty; if (loginParams.Author == null) loginParams.Author = String.Empty; #endregion // TODO: Allow a user callback to be defined for handling the cert ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); // Even though this will compile on Mono 2.4, it throws a runtime exception //ServicePointManager.ServerCertificateValidationCallback = TrustAllCertificatePolicy.TrustAllCertificateHandler; if (Client.Settings.USE_LLSD_LOGIN) { #region LLSD Based Login // Create the CAPS login structure OSDMap loginLLSD = new OSDMap(); loginLLSD["first"] = OSD.FromString(loginParams.FirstName); loginLLSD["last"] = OSD.FromString(loginParams.LastName); loginLLSD["passwd"] = OSD.FromString(loginParams.Password); loginLLSD["start"] = OSD.FromString(loginParams.Start); loginLLSD["channel"] = OSD.FromString(loginParams.Channel); loginLLSD["version"] = OSD.FromString(loginParams.Version); loginLLSD["platform"] = OSD.FromString(loginParams.Platform); loginLLSD["mac"] = OSD.FromString(loginParams.MAC); loginLLSD["agree_to_tos"] = OSD.FromBoolean(loginParams.AgreeToTos); loginLLSD["read_critical"] = OSD.FromBoolean(loginParams.ReadCritical); loginLLSD["viewer_digest"] = OSD.FromString(loginParams.ViewerDigest); loginLLSD["id0"] = OSD.FromString(loginParams.ID0); // Create the options LLSD array OSDArray optionsOSD = new OSDArray(); for (int i = 0; i < loginParams.Options.Length; i++) optionsOSD.Add(OSD.FromString(loginParams.Options[i])); foreach (string[] callbackOpts in CallbackOptions.Values) { if (callbackOpts != null) { for (int i = 0; i < callbackOpts.Length; i++) { if (!optionsOSD.Contains(callbackOpts[i])) optionsOSD.Add(callbackOpts[i]); } } } loginLLSD["options"] = optionsOSD; // Make the CAPS POST for login Uri loginUri; try { loginUri = new Uri(loginParams.URI); } catch (Exception ex) { Logger.Log(String.Format("Failed to parse login URI {0}, {1}", loginParams.URI, ex.Message), Helpers.LogLevel.Error, Client); return; } CapsClient loginRequest = new CapsClient(loginUri); loginRequest.OnComplete += new CapsClient.CompleteCallback(LoginReplyLLSDHandler); loginRequest.UserData = CurrentContext; UpdateLoginStatus(LoginStatus.ConnectingToLogin, String.Format("Logging in as {0} {1}...", loginParams.FirstName, loginParams.LastName)); loginRequest.BeginGetResponse(loginLLSD, OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT); #endregion } else { #region XML-RPC Based Login Code // Create the Hashtable for XmlRpcCs Hashtable loginXmlRpc = new Hashtable(); loginXmlRpc["first"] = loginParams.FirstName; loginXmlRpc["last"] = loginParams.LastName; loginXmlRpc["passwd"] = loginParams.Password; loginXmlRpc["start"] = loginParams.Start; loginXmlRpc["channel"] = loginParams.Channel; loginXmlRpc["version"] = loginParams.Version; loginXmlRpc["platform"] = loginParams.Platform; loginXmlRpc["mac"] = loginParams.MAC; if (loginParams.AgreeToTos) loginXmlRpc["agree_to_tos"] = "true"; if (loginParams.ReadCritical) loginXmlRpc["read_critical"] = "true"; loginXmlRpc["id0"] = loginParams.ID0; loginXmlRpc["last_exec_event"] = 0; // Create the options array ArrayList options = new ArrayList(); for (int i = 0; i < loginParams.Options.Length; i++) options.Add(loginParams.Options[i]); foreach (string[] callbackOpts in CallbackOptions.Values) { if (callbackOpts != null) { for (int i = 0; i < callbackOpts.Length; i++) { if (!options.Contains(callbackOpts[i])) options.Add(callbackOpts[i]); } } } loginXmlRpc["options"] = options; try { ArrayList loginArray = new ArrayList(1); loginArray.Add(loginXmlRpc); XmlRpcRequest request = new XmlRpcRequest(CurrentContext.Value.MethodName, loginArray); // Start the request Thread requestThread = new Thread( delegate() { try { LoginReplyXmlRpcHandler( request.Send(CurrentContext.Value.URI, CurrentContext.Value.Timeout), loginParams); } catch (WebException e) { UpdateLoginStatus(LoginStatus.Failed, "Error opening the login server connection: " + e.Message); } }); requestThread.Name = "XML-RPC Login"; requestThread.Start(); } catch (Exception e) { UpdateLoginStatus(LoginStatus.Failed, "Error opening the login server connection: " + e); } #endregion } }
public override void LogOffUser(UserProfileData theUser, string message) { RegionProfileData SimInfo; try { SimInfo = m_regionProfileService.RequestSimProfileData( theUser.CurrentAgent.Handle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); if (SimInfo == null) { m_log.Error("[GRID]: Region user was in isn't currently logged in"); return; } } catch (Exception) { m_log.Error("[GRID]: Unable to look up region to log user off"); return; } // Prepare notification Hashtable SimParams = new Hashtable(); SimParams["agent_id"] = theUser.ID.ToString(); SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString(); SimParams["region_secret2"] = SimInfo.regionSecret; //m_log.Info(SimInfo.regionSecret); SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); SimParams["message"] = message; ArrayList SendParams = new ArrayList(); SendParams.Add(SimParams); m_log.InfoFormat( "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, theUser.FirstName + " " + theUser.SurName); try { string methodName = "logoff_user"; XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(SimInfo.httpServerURI, methodName), 6000); if (GridResp.IsFault) { m_log.ErrorFormat( "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); } } catch (Exception) { m_log.Error("[LOGIN]: Error telling region to logout user!"); } // Prepare notification SimParams = new Hashtable(); SimParams["agent_id"] = theUser.ID.ToString(); SimParams["region_secret"] = SimInfo.regionSecret; //m_log.Info(SimInfo.regionSecret); SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); SimParams["message"] = message; SendParams = new ArrayList(); SendParams.Add(SimParams); m_log.InfoFormat( "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, theUser.FirstName + " " + theUser.SurName); try { string methodName = "logoff_user"; XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(SimInfo.httpServerURI, methodName), 6000); if (GridResp.IsFault) { m_log.ErrorFormat( "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); } } catch (Exception) { m_log.Error("[LOGIN]: Error telling region to logout user!"); } //base.LogOffUser(theUser); }
public string GetUUI(UUID userID, UUID targetUserID) { Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); hash["targetUserID"] = targetUserID.ToString(); IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("get_uui", paramList); // string reason = string.Empty; // Send and get reply string uui = string.Empty; XmlRpcResponse response = null; try { response = request.Send(m_ServerURL, 10000); } catch { m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUI", m_ServerURL); // reason = "Exception: " + e.Message; return uui; } if (response.IsFault) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUI returned an error: {1}", m_ServerURL, response.FaultString); // reason = "XMLRPC Fault"; return uui; } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { if (hash == null) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUI Got null response from {0}! THIS IS BAAAAD", m_ServerURL); // reason = "Internal error 1"; return uui; } // Here's the actual response if (hash.ContainsKey("UUI")) uui = hash["UUI"].ToString(); } catch { m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response."); // reason = "Exception: " + e.Message; } return uui; }
public Dictionary<string,object> GetUserInfo (UUID userID) { Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("get_user_info", paramList); Dictionary<string, object> info = new Dictionary<string, object>(); XmlRpcResponse response = null; try { response = request.Send(m_ServerURL, 10000); } catch { m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUserInfo", m_ServerURL); return info; } if (response.IsFault) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString); return info; } hash = (Hashtable)response.Value; try { if (hash == null) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUserInfo Got null response from {0}! THIS IS BAAAAD", m_ServerURL); return info; } // Here is the actual response foreach (object key in hash.Keys) { if (hash[key] != null) { info.Add(key.ToString(), hash[key]); } } } catch { m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); } return info; }
public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) { position = Vector3.UnitY; lookAt = Vector3.UnitY; Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); XmlRpcResponse response = null; try { response = request.Send(m_ServerURL, 10000); } catch (Exception) { return null; } if (response.IsFault) { return null; } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { bool success = false; Boolean.TryParse((string)hash["result"], out success); if (success) { GridRegion region = new GridRegion(); UUID.TryParse((string)hash["uuid"], out region.RegionID); //m_log.Debug(">> HERE, uuid: " + region.RegionID); int n = 0; if (hash["x"] != null) { Int32.TryParse((string)hash["x"], out n); region.RegionLocX = n; //m_log.Debug(">> HERE, x: " + region.RegionLocX); } if (hash["y"] != null) { Int32.TryParse((string)hash["y"], out n); region.RegionLocY = n; //m_log.Debug(">> HERE, y: " + region.RegionLocY); } if (hash["region_name"] != null) { region.RegionName = (string)hash["region_name"]; //m_log.Debug(">> HERE, name: " + region.RegionName); } if (hash["hostname"] != null) region.ExternalHostName = (string)hash["hostname"]; if (hash["http_port"] != null) { uint p = 0; UInt32.TryParse((string)hash["http_port"], out p); region.HttpPort = p; } if (hash.ContainsKey("server_uri") && hash["server_uri"] != null) region.ServerURI = (string)hash["server_uri"]; if (hash["internal_port"] != null) { int p = 0; Int32.TryParse((string)hash["internal_port"], out p); region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); } if (hash["position"] != null) Vector3.TryParse((string)hash["position"], out position); if (hash["lookAt"] != null) Vector3.TryParse((string)hash["lookAt"], out lookAt); // Successful return return region; } } catch (Exception) { return null; } return null; }
public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string externalName, out string imageURL, out string reason) { regionID = UUID.Zero; imageURL = string.Empty; realHandle = 0; externalName = string.Empty; reason = string.Empty; Hashtable hash = new Hashtable (); hash["region_name"] = info.RegionName; IList paramList = new ArrayList (); paramList.Add (hash); XmlRpcRequest request = new XmlRpcRequest ("link_region", paramList); if (info.ServerURI == null) info.ServerURI = "http://" + info.ServerURI + ":" + info.HttpPort; MainConsole.Instance.Debug ("[GATEKEEPER SERVICE CONNECTOR]: Linking to " + info.ServerURI); XmlRpcResponse response = null; try { response = request.Send (info.ServerURI, 10000); } catch (Exception e) { MainConsole.Instance.Debug ("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); reason = "Error contacting remote server"; return false; } if (response.IsFault) { reason = response.FaultString; MainConsole.Instance.ErrorFormat ("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); return false; } hash = (Hashtable)response.Value; //foreach (Object o in hash) // MainConsole.Instance.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { bool success = false; Boolean.TryParse ((string)hash["result"], out success); if (success) { UUID.TryParse ((string)hash["uuid"], out regionID); //MainConsole.Instance.Debug(">> HERE, uuid: " + regionID); if ((string)hash["handle"] != null) { realHandle = Convert.ToUInt64 ((string)hash["handle"]); //MainConsole.Instance.Debug(">> HERE, realHandle: " + realHandle); } if (hash["region_image"] != null) { imageURL = (string)hash["region_image"]; //MainConsole.Instance.Debug(">> HERE, imageURL: " + imageURL); } if (hash["external_name"] != null) { externalName = (string)hash["external_name"]; //MainConsole.Instance.Debug(">> HERE, externalName: " + externalName); } } } catch (Exception e) { reason = "Error parsing return arguments"; MainConsole.Instance.Error ("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); return false; } return true; }
/// <summary> /// This actually does the XMLRPC Request /// </summary> /// <param name="reginfo">RegionInfo we pull the data out of to send the request to</param> /// <param name="xmlrpcdata">The Instant Message data Hashtable</param> /// <returns>Bool if the message was successfully delivered at the other side.</returns> protected virtual bool doIMSending(GridRegion reginfo, Hashtable xmlrpcdata) { ArrayList SendParams = new ArrayList(); SendParams.Add(xmlrpcdata); XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams); try { XmlRpcResponse GridResp = GridReq.Send(reginfo.ServerURI, 3000); Hashtable responseData = (Hashtable)GridResp.Value; if (responseData.ContainsKey("success")) { if ((string)responseData["success"] == "TRUE") { return true; } else { return false; } } else { return false; } } catch (WebException e) { m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} the host didn't respond " + e.ToString(), reginfo.ServerURI.ToString()); } return false; }
public bool SearchRegionByName(string gridServerURL, IList parameters, out Hashtable respData, out string errorMsg) { respData = null; errorMsg = string.Empty; try { XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters); XmlRpcResponse resp = request.Send(gridServerURL, 10000); respData = (Hashtable)resp.Value; if (respData != null && respData.Contains("faultCode")) { errorMsg = (string)respData["faultString"]; return false; } return true; } catch (Exception e) { errorMsg = e.Message; return false; } }
public List<UUID> GetOnlineFriends(UUID userID, List<string> friends) { Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); int i = 0; foreach (string s in friends) { hash["friend_" + i.ToString()] = s; i++; } IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList); // string reason = string.Empty; // Send and get reply List<UUID> online = new List<UUID>(); XmlRpcResponse response = null; try { response = request.Send(m_ServerURL, 10000); } catch { m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURL); // reason = "Exception: " + e.Message; return online; } if (response.IsFault) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURL, response.FaultString); // reason = "XMLRPC Fault"; return online; } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { if (hash == null) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL); // reason = "Internal error 1"; return online; } // Here is the actual response foreach (object key in hash.Keys) { if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null) { UUID uuid; if (UUID.TryParse(hash[key].ToString(), out uuid)) online.Add(uuid); } } } catch { m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); // reason = "Exception: " + e.Message; } return online; }
public bool RegisterRegion( string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines) { m_log.InfoFormat( "[GRID CLIENT]: Registering region {0} with grid at {1}", regionInfo.RegionName, gridServerURL); forcefulBanLines = true; Hashtable GridParams = new Hashtable(); // Login / Authentication GridParams["authkey"] = sendKey; GridParams["recvkey"] = receiveKey; GridParams["UUID"] = regionInfo.RegionID.ToString(); GridParams["sim_ip"] = regionInfo.ExternalHostName; GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); GridParams["sim_name"] = regionInfo.RegionName; GridParams["http_port"] = regionInfo.HttpPort.ToString(); GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString(); GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString(); GridParams["originUUID"] = regionInfo.originRegionID.ToString(); GridParams["server_uri"] = regionInfo.ServerURI; GridParams["region_secret"] = regionInfo.regionSecret; GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString(); if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero) GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString(); else GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString(); // Package into an XMLRPC Request ArrayList SendParams = new ArrayList(); SendParams.Add(GridParams); // Send Request XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); XmlRpcResponse GridResp; try { // The timeout should always be significantly larger than the timeout for the grid server to request // the initial status of the region before confirming registration. GridResp = GridReq.Send(gridServerURL, 90000); } catch (Exception e) { Exception e2 = new Exception( String.Format( "Unable to register region with grid at {0}. Grid service not running?", gridServerURL), e); throw e2; } Hashtable GridRespData = (Hashtable)GridResp.Value; // Hashtable griddatahash = GridRespData; // Process Response if (GridRespData.ContainsKey("error")) { string errorstring = (string)GridRespData["error"]; Exception e = new Exception( String.Format("Unable to connect to grid at {0}: {1}", gridServerURL, errorstring)); throw e; } else { // m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); if (GridRespData.ContainsKey("allow_forceful_banlines")) { if ((string)GridRespData["allow_forceful_banlines"] != "TRUE") { forcefulBanLines = false; } } } return true; }
public Dictionary<string, object> GetServerURLs(UUID userID) { Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("get_server_urls", paramList); // string reason = string.Empty; // Send and get reply Dictionary<string, object> serverURLs = new Dictionary<string,object>(); XmlRpcResponse response = null; try { response = request.Send(m_ServerURL, 10000); } catch { m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs", m_ServerURL); // reason = "Exception: " + e.Message; return serverURLs; } if (response.IsFault) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetServerURLs returned an error: {1}", m_ServerURL, response.FaultString); // reason = "XMLRPC Fault"; return serverURLs; } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { if (hash == null) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL); // reason = "Internal error 1"; return serverURLs; } // Here is the actual response foreach (object key in hash.Keys) { if (key is string && ((string)key).StartsWith("SRV_") && hash[key] != null) { string serverType = key.ToString().Substring(4); // remove "SRV_" serverURLs.Add(serverType, hash[key].ToString()); } } } catch { m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); // reason = "Exception: " + e.Message; } return serverURLs; }
public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer) { string capsPath = agentData.CapsPath; Hashtable loginParams = new Hashtable(); loginParams["session_id"] = agentData.SessionID.ToString(); loginParams["firstname"] = agentData.firstname; loginParams["lastname"] = agentData.lastname; loginParams["agent_id"] = agentData.AgentID.ToString(); loginParams["circuit_code"] = agentData.circuitcode.ToString(); loginParams["startpos_x"] = agentData.startpos.X.ToString(); loginParams["startpos_y"] = agentData.startpos.Y.ToString(); loginParams["startpos_z"] = agentData.startpos.Z.ToString(); loginParams["caps_path"] = capsPath; if (home != null) { loginParams["region_uuid"] = home.RegionID.ToString(); loginParams["regionhandle"] = home.RegionHandle.ToString(); loginParams["home_address"] = home.ExternalHostName; loginParams["home_port"] = home.HttpPort.ToString(); loginParams["internal_port"] = home.InternalEndPoint.Port.ToString(); m_log.Debug(" --------- Home -------"); m_log.Debug(" >> " + loginParams["home_address"] + " <<"); m_log.Debug(" >> " + loginParams["region_uuid"] + " <<"); m_log.Debug(" >> " + loginParams["regionhandle"] + " <<"); m_log.Debug(" >> " + loginParams["home_port"] + " <<"); m_log.Debug(" --------- ------------ -------"); } else m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname); loginParams["userserver_id"] = userServer; loginParams["assetserver_id"] = assetServer; loginParams["inventoryserver_id"] = inventoryServer; ArrayList SendParams = new ArrayList(); SendParams.Add(loginParams); // Send string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/"; //m_log.Debug("XXX uri: " + uri); XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams); XmlRpcResponse reply; try { reply = request.Send(uri, 6000); } catch (Exception e) { m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message); return false; } if (!reply.IsFault) { bool responseSuccess = true; if (reply.Value != null) { Hashtable resp = (Hashtable)reply.Value; if (resp.ContainsKey("success")) { if ((string)resp["success"] == "FALSE") { responseSuccess = false; } } } if (responseSuccess) { m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID); return true; } else { m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients"); return false; } } else { m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode); return false; } }
private bool GetBoolResponse(XmlRpcRequest request, out string reason) { //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); XmlRpcResponse response = null; try { response = request.Send(m_ServerURL, 10000); } catch (Exception e) { m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURL); reason = "Exception: " + e.Message; return false; } if (response.IsFault) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURL, response.FaultString); reason = "XMLRPC Fault"; return false; } Hashtable hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { if (hash == null) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURL); reason = "Internal error 1"; return false; } bool success = false; reason = string.Empty; if (hash.ContainsKey("result")) Boolean.TryParse((string)hash["result"], out success); else { reason = "Internal error 2"; m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURL); } return success; } catch (Exception e) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetBoolResponse response."); if (hash.ContainsKey("result") && hash["result"] != null) m_log.ErrorFormat("Reply was ", (string)hash["result"]); reason = "Exception: " + e.Message; return false; } }
public UUID LinkRegion(GridRegion info, out ulong realHandle) { UUID uuid = UUID.Zero; realHandle = 0; Hashtable hash = new Hashtable(); hash["region_name"] = info.RegionName; IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; m_log.Debug("[HGrid]: Linking to " + uri); XmlRpcResponse response = null; try { response = request.Send(uri, 10000); } catch (Exception e) { m_log.Debug("[HGrid]: Exception " + e.Message); return uuid; } if (response.IsFault) { m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); } else { hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { UUID.TryParse((string)hash["uuid"], out uuid); m_log.Debug(">> HERE, uuid: " + uuid); info.RegionID = uuid; if ((string)hash["handle"] != null) { realHandle = Convert.ToUInt64((string)hash["handle"]); m_log.Debug(">> HERE, realHandle: " + realHandle); } //if (hash["region_image"] != null) //{ // UUID img = UUID.Zero; // UUID.TryParse((string)hash["region_image"], out img); // info.RegionSettings.TerrainImageID = img; //} if (hash["region_name"] != null) { info.RegionName = (string)hash["region_name"]; //m_log.Debug(">> " + info.RegionName); } if (hash["internal_port"] != null) { int port = Convert.ToInt32((string)hash["internal_port"]); info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); //m_log.Debug(">> " + info.InternalEndPoint.ToString()); } } catch (Exception e) { m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); } } return uuid; }
/// <summary> /// Prepare a login to the given region. This involves both telling the region to expect a connection /// and appropriately customising the response to the user. /// </summary> /// <param name="regionInfo"></param> /// <param name="user"></param> /// <param name="response"></param> /// <returns>true if the region was successfully contacted, false otherwise</returns> private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response, string clientVersion) { string regionName = regionInfo.regionName; bool success = false; try { lock (_LastRegionFailure) { if (_LastRegionFailure.ContainsKey(regionName)) { // region failed previously RegionLoginFailure failure = _LastRegionFailure[regionName]; if (failure.IsExpired()) { // failure has expired, retry this region again _LastRegionFailure.Remove(regionName); // m_log.WarnFormat("[LOGIN]: Region '{0}' was previously down, retrying.", regionName); } else { if (failure.IsFailed()) { // m_log.WarnFormat("[LOGIN]: Region '{0}' was recently down, skipping.", regionName); return false; // within 5 minutes, don't repeat attempt } // m_log.WarnFormat("[LOGIN]: Region '{0}' was recently down but under threshold, retrying.", regionName); } } } response.SimAddress = regionInfo.OutsideIpOrResolvedHostname; response.SimPort = regionInfo.serverPort; response.RegionX = regionInfo.regionLocX; response.RegionY = regionInfo.regionLocY; string capsPath = CapsUtil.GetRandomCapsObjectPath(); response.SeedCapability = CapsUtil.GetFullCapsSeedURL(regionInfo.httpServerURI, capsPath); // Notify the target of an incoming user m_log.InfoFormat( "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", regionInfo.regionName, response.RegionX, response.RegionY, response.SeedCapability); // Update agent with target sim user.CurrentAgent.Region = regionInfo.UUID; user.CurrentAgent.Handle = regionInfo.regionHandle; // Prepare notification Hashtable loginParams = new Hashtable(); loginParams["session_id"] = user.CurrentAgent.SessionID.ToString(); loginParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString(); loginParams["firstname"] = user.FirstName; loginParams["lastname"] = user.SurName; loginParams["agent_id"] = user.ID.ToString(); loginParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString(); loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString(); loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString(); loginParams["regionhandle"] = user.CurrentAgent.Handle.ToString(); loginParams["caps_path"] = capsPath; loginParams["client_version"] = clientVersion; // Get appearance AvatarAppearance appearance = m_userManager.GetUserAppearance(user.ID); if (appearance != null) { loginParams["appearance"] = appearance.ToHashTable(); m_log.DebugFormat("[LOGIN]: Found appearance version {0} for {1} {2}", appearance.Serial, user.FirstName, user.SurName); } else { m_log.DebugFormat("[LOGIN]: Appearance not for {0} {1}. Creating default.", user.FirstName, user.SurName); appearance = new AvatarAppearance(user.ID); } // Tell the client the COF version so it can use cached appearance if it matches. response.CofVersion = appearance.Serial.ToString(); loginParams["cof_version"] = response.CofVersion; ArrayList SendParams = new ArrayList(); SendParams.Add(loginParams); SendParams.Add(m_config.GridSendKey); // Send const string METHOD_NAME = "expect_user"; XmlRpcRequest GridReq = new XmlRpcRequest(METHOD_NAME, SendParams); XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(regionInfo.httpServerURI, METHOD_NAME), 6000); if (!GridResp.IsFault) { bool responseSuccess = true; if (GridResp.Value != null) { Hashtable resp = (Hashtable)GridResp.Value; if (resp.ContainsKey("success")) { if ((string)resp["success"] == "FALSE") { responseSuccess = false; } } if (!responseSuccess) { if (resp.ContainsKey("reason")) { response.ErrorMessage = resp["reason"].ToString(); } } } if (responseSuccess) { handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; if (handlerUserLoggedInAtLocation != null) { handlerUserLoggedInAtLocation(user.ID, user.CurrentAgent.SessionID, user.CurrentAgent.Region, user.CurrentAgent.Handle, user.CurrentAgent.Position.X, user.CurrentAgent.Position.Y, user.CurrentAgent.Position.Z, user.FirstName, user.SurName); } success = true; } else { m_log.ErrorFormat("[LOGIN]: Region responded that it is not available to receive clients"); } } else { m_log.ErrorFormat("[LOGIN]: XmlRpc request to region failed with message {0}, code {1} ", GridResp.FaultString, GridResp.FaultCode); } } catch (Exception e) { m_log.ErrorFormat("[LOGIN]: Region not available for login, {0}", e); } lock (_LastRegionFailure) { if (_LastRegionFailure.ContainsKey(regionName)) { RegionLoginFailure failure = _LastRegionFailure[regionName]; if (success) { // Success, so if we've been storing this as a failed region, remove that from the failed list. m_log.WarnFormat("[LOGIN]: Region '{0}' recently down, is available again.", regionName); _LastRegionFailure.Remove(regionName); } else { // Region not available, update cache with incremented count. failure.AddFailure(); // m_log.WarnFormat("[LOGIN]: Region '{0}' is still down ({1}).", regionName, failure.Count); } } else { if (!success) { // Region not available, cache that temporarily. m_log.WarnFormat("[LOGIN]: Region '{0}' is down, marking.", regionName); _LastRegionFailure[regionName] = new RegionLoginFailure(); } } } return success; }
public string RegionManagementRestartPostRequest(Environment env) { Request request = env.TheRequest; SessionInfo sinfo; if (TryGetSessionInfo(request, out sinfo) && (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)) { env.Session = sinfo; string url = m_WebApp.LoginURL; Hashtable hash = new Hashtable(); if (m_ServerAdminPassword == null) { m_log.Debug("[RegionManagementRestartPostRequest] No remote admin password was set in .ini file"); } hash["password"] = m_ServerAdminPassword; IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_shutdown", paramList); XmlRpcResponse response = null; try { //first, shutdown the server response = xmlrpcReq.Send(url, 10000); //then wait until the server is completely shutdown, then re-launch System.Diagnostics.Process[] openSimProcess = System.Diagnostics.Process.GetProcessesByName("OpenSim"); openSimProcess[0].WaitForExit(); System.Diagnostics.Process.Start("OpenSim.exe"); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementSuccessful; } catch (Exception e) { m_log.Debug("[Wifi]: Exception (2) " + e.Message); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementUnsuccessful; } return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }
/* * TODO: More work on the response codes. Right now * returning 200 for success or 499 for exception */ public void SendRequest() { Hashtable param = new Hashtable(); // Check if channel is an UUID // if not, use as method name UUID parseUID; string mName = "llRemoteData"; if (!string.IsNullOrEmpty(Channel)) if (!UUID.TryParse(Channel, out parseUID)) mName = Channel; else param["Channel"] = Channel; param["StringValue"] = Sdata; param["IntValue"] = Convert.ToString(Idata); ArrayList parameters = new ArrayList(); parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest(mName, parameters); try { XmlRpcResponse resp = req.Send(DestURL, 30000); if (resp != null) { Hashtable respParms; if (resp.Value.GetType().Equals(typeof(Hashtable))) { respParms = (Hashtable) resp.Value; } else { ArrayList respData = (ArrayList) resp.Value; respParms = (Hashtable) respData[0]; } if (respParms != null) { if (respParms.Contains("StringValue")) { Sdata = (string) respParms["StringValue"]; } if (respParms.Contains("IntValue")) { Idata = Convert.ToInt32(respParms["IntValue"]); } if (respParms.Contains("faultString")) { Sdata = (string) respParms["faultString"]; } if (respParms.Contains("faultCode")) { Idata = Convert.ToInt32(respParms["faultCode"]); } } } } catch (Exception we) { Sdata = we.Message; m_log.Warn("[SendRemoteDataRequest]: Request failed"); m_log.Warn(we.StackTrace); } _finished = true; }
public string RegionManagementShutdownPostRequest(Environment env) { //m_log.DebugFormat("[Wifi]: RegionManagementShutdownPostRequest"); Request request = env.TheRequest; SessionInfo sinfo; if (TryGetSessionInfo(request, out sinfo) && (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)) { env.Session = sinfo; //FIXME: don't hardcode url, get it from m_GridService //TODO: check if server is actually running first //TODO: add support for shutdown message parameter from html form string url = m_WebApp.LoginURL; Hashtable hash = new Hashtable(); if (m_ServerAdminPassword == null) { m_log.Debug("[RegionManagementShutdownPostRequest] No remote admin password was set in .ini file"); } hash["password"] = m_ServerAdminPassword; IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_shutdown", paramList); XmlRpcResponse response = null; try { response = xmlrpcReq.Send(url, 10000); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementSuccessful; } catch (Exception e) { m_log.Debug("[Wifi]: Exception (1) " + e.Message); env.Flags = Flags.IsAdmin | Flags.IsLoggedIn; env.State = State.RegionManagementUnsuccessful; } return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html")); } return m_WebApp.ReadFile(env, "index.html"); }