コード例 #1
0
        /// <summary>
        /// Someone wants to link to us
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];
            //string host = (string)requestData["host"];
            //string portstr = (string)requestData["port"];
            string name = (string)requestData["region_name"];
            if (name == null)
                name = string.Empty;

            UUID regionID = UUID.Zero;
            string externalName = string.Empty;
            string imageURL = string.Empty;
            ulong regionHandle = 0;
            string reason = string.Empty;

            bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out externalName, out imageURL, out reason);

            Hashtable hash = new Hashtable();
            hash["result"] = success.ToString();
            hash["uuid"] = regionID.ToString();
            hash["handle"] = regionHandle.ToString();
            hash["region_image"] = imageURL;
            hash["external_name"] = externalName;

            XmlRpcResponse response = new XmlRpcResponse();
            response.Value = hash;
            return response;
        }
コード例 #2
0
    /// <summary>Handle an HTTP request containing an XML-RPC request.</summary>
    /// <remarks>This method deserializes the XML-RPC request, invokes the 
    /// described method, serializes the response (or fault) and sends the XML-RPC response
    /// back as a valid HTTP page.
    /// </remarks>
    /// <param name="httpReq"><c>SimpleHttpRequest</c> containing the request.</param>
    public void Respond(SimpleHttpRequest httpReq)
      {
	XmlRpcRequest xmlRpcReq = (XmlRpcRequest)_deserializer.Deserialize(httpReq.Input);
	XmlRpcResponse xmlRpcResp = new XmlRpcResponse();

	try
	  {
	    xmlRpcResp.Value = _server.Invoke(xmlRpcReq);
	  }
	catch (XmlRpcException e)
	  {
	    xmlRpcResp.SetFault(e.FaultCode, e.FaultString);
	  }
	catch (Exception e2)
	  {
	    xmlRpcResp.SetFault(XmlRpcErrorCodes.APPLICATION_ERROR, 
			  XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": " + e2.Message);
	  }

	if (Logger.Delegate != null)
	  Logger.WriteEntry(xmlRpcResp.ToString(), LogLevel.Information);

	XmlRpcServer.HttpHeader(httpReq.Protocol, "text/xml", 0, " 200 OK", httpReq.Output);
	httpReq.Output.Flush();
	XmlTextWriter xml = new XmlTextWriter(httpReq.Output);
	_serializer.Serialize(xml, xmlRpcResp);
	xml.Flush();
	httpReq.Output.Flush();
      }
コード例 #3
0
        public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable requestData = (Hashtable)request.Params[0];
            AvatarAppearance appearance;
            Hashtable responseData;
            if (requestData.Contains("owner"))
            {
                appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"]));
                if (appearance == null)
                {
                    responseData = new Hashtable();
                    responseData["error_type"] = "no appearance";
                    responseData["error_desc"] = "There was no appearance found for this avatar";
                }
                else
                {
                    responseData = appearance.ToHashTable();
                }
            }
            else
            {
                responseData = new Hashtable();
                responseData["error_type"] = "unknown_avatar";
                responseData["error_desc"] = "The avatar appearance requested is not in the database";
            }

            response.Value = responseData;
            return response;
        }
コード例 #4
0
    public static XmlRpcResponse Parse(StreamReader xmlData)
      {
	XmlTextReader reader = new XmlTextReader(xmlData);
	XmlRpcResponse response = new XmlRpcResponse();
	bool done = false;

	while (!done && reader.Read())
	  {
	    Singleton.ParseNode(reader); // Parent parse...
            switch (reader.NodeType)
	      {
	      case XmlNodeType.EndElement:
		switch (reader.Name)
		  {
		  case FAULT:
		    response.Value = Singleton._value;
		    response.IsFault = true;
		    break;
		  case PARAM:
		    response.Value = Singleton._value;
		    Singleton._value = null;
		    Singleton._text = null;
		    break;
		  }
		break;
	      default:
		break;
	      }	
	  }
	return response;
      }
コード例 #5
0
        public XmlRpcResponse GenerateKeyMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse response = new XmlRpcResponse();

            if (request.Params.Count < 2)
            {
                response.IsFault = true;
                response.SetFault(-1, "Invalid parameters");
                return response;
            }

            // Verify the key of who's calling
            UUID userID = UUID.Zero;
            string authKey = string.Empty;
            UUID.TryParse((string)request.Params[0], out userID);
            authKey = (string)request.Params[1];

            m_log.InfoFormat("[AUTH HANDLER] GenerateKey called with authToken {0}", authKey);
            string newKey = string.Empty;

            newKey = m_LocalService.GetKey(userID, authKey.ToString());
 
            response.Value = (string)newKey;
            return response;
        }
コード例 #6
0
      public void Response()
      {
	XmlRpcResponse respIn = new XmlRpcResponse(22,"Help Me");
	String str = (new XmlRpcResponseSerializer()).Serialize(respIn);
	XmlRpcResponse respOut = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(str);

	Assertion.AssertEquals("faultcode", respIn.FaultCode, respOut.FaultCode);
	Assertion.AssertEquals("faultstring", respIn.FaultString, respOut.FaultString);
      }
コード例 #7
0
ファイル: ChatConsole.cs プロジェクト: RavenB/gridsearch
	private static void Login(XmlRpcResponse response) {
		Hashtable values = (Hashtable)response.Value;
		if (values.Contains("agent_id") && values.Contains("session_id")) {
			// remember our agentID and sessionID
			agentID = new LLUUID((string)values["agent_id"]);
			sessionID = new LLUUID((string)values["session_id"]);

			// start a new thread that reads lines from the console
			(new Thread(new ThreadStart(ReadFromConsole))).Start();
		}
	}
コード例 #8
0
ファイル: LindenLogin.cs プロジェクト: osgrid/openmetaverse
        public XmlRpcResponse CreateFailureResponse(string reason, string message, bool loginSuccess)
        {
            Hashtable responseData = new Hashtable(3);
            responseData["reason"] = reason;
            responseData["message"] = message;
            responseData["login"] = loginSuccess.ToString().ToLower();

            XmlRpcResponse response = new XmlRpcResponse();
            response.Value = responseData;
            return response;
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: SangoFighting/dd
		public string execute(string s){
			string[] ss = s.Split ('-');
			client.MethodName = ss[0];
			client.Params.Clear();
			client.Params.Add(ss[1]);
			if (ss[0].Equals("Handler.raa_request") || ss[0].Equals("Handler.raa_release")
				|| ss[0].Equals("Handler.masterElection"))
				client.Params.Add(ss[2]);
			response = client.Send (server_url);
			return response.Value.ToString();
		}
コード例 #10
0
        public XmlRpcResponse AgentIsComingHome(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];
            //string host = (string)requestData["host"];
            //string portstr = (string)requestData["port"];
            string sessionID_str = (string)requestData["sessionID"];
            UUID sessionID = UUID.Zero;
            UUID.TryParse (sessionID_str, out sessionID);
            string gridName = (string)requestData["externalName"];

            bool success = m_HomeUsersService.AgentIsComingHome (sessionID, gridName);

            Hashtable hash = new Hashtable ();
            hash["result"] = success.ToString ();
            XmlRpcResponse response = new XmlRpcResponse {Value = hash};
            return response;
        }
コード例 #11
0
        public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers)
        {
            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();
            // Query Result Information

            responseData["avcount"] = returnUsers.Count.ToString();

            for (int i = 0; i < returnUsers.Count; i++)
            {
                responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString();
                responseData["friendID" + i] = returnUsers[i].Friend.ToString();
                responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString();
                responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString();
            }
            response.Value = responseData;

            return response;
        }
コード例 #12
0
 public XmlRpcResponse BuyFunc(XmlRpcRequest request, IPEndPoint ep)
 {
     Hashtable requestData = (Hashtable)request.Params[0];
     bool success = false;
     if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy") &&
         m_connector.GetConfig().CanBuyCurrencyInworld)
     {
         UUID agentId;
         if (UUID.TryParse((string)requestData["agentId"], out agentId))
         {
             uint amountBuying = uint.Parse(requestData["currencyBuy"].ToString());
             success = m_connector.InworldCurrencyBuyTransaction(agentId, amountBuying, ep);
         }
     }
     XmlRpcResponse returnval = new XmlRpcResponse();
     Hashtable returnresp = new Hashtable { { "success", success } };
     returnval.Value = returnresp;
     return returnval;
 }
コード例 #13
0
ファイル: LoginSwitch.cs プロジェクト: AlphaStaxLLC/taiga
 public XmlRpcResponse XmlRPCCheckAuthSessionSwitch(XmlRpcRequest request, IPEndPoint remoteClient)
 {
     Hashtable requestData = (Hashtable)request.Params[0];
     XmlRpcResponse response = new XmlRpcResponse();
     Hashtable responseData = new Hashtable();
     if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id"))
     {
         UUID avatar;
         UUID sessionID;
         if (UUID.TryParse((string)requestData["avatar_uuid"], out avatar) &&
             UUID.TryParse((string)requestData["session_id"], out sessionID)) 
         {
             if (m_LoggingInClients.ContainsKey(avatar))
             {
                 if (m_LoggingInClients[avatar] == sessionID)
                 {
                     responseData["auth_session"] = "TRUE";
                 }
                 else
                 {
                     responseData["auth_session"] = "FALSE";
                 }
                 m_LoggingInClients.Remove(avatar);
                 response.Value = responseData;
                 return response;
             }
             else 
             {
                 // try normal OpenSim authentication 
                 return m_UserLoginService.XmlRPCCheckAuthSession(request, remoteClient);
             }
         }
     }
     responseData["auth_session"] = "FALSE";
     response.Value = responseData;
     return response;
 }
コード例 #14
0
    /// <summary>Static method that parses XML data into a response using the Singleton.</summary>
    /// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC response.</param>
    /// <returns><c>XmlRpcResponse</c> object resulting from the parse.</returns>
    override public Object Deserialize(TextReader xmlData)
      {
	XmlTextReader reader = new XmlTextReader(xmlData);
	XmlRpcResponse response = new XmlRpcResponse();
	bool done = false;
	
	lock(this)
	  {
	    Reset();
	    
	    while (!done && reader.Read())
	      {
		DeserializeNode(reader); // Parent parse...
		switch (reader.NodeType)
		  {
		  case XmlNodeType.EndElement:
		    switch (reader.Name)
		      {
		      case FAULT:
			response.Value = _value;
			response.IsFault = true;
			break;
		      case PARAM:
			response.Value = _value;
			_value = null;
			_text = null;
			break;
		      }
		    break;
		  default:
		    break;
		  }	
	      }
	  }
	return response;
      }
コード例 #15
0
ファイル: SceneUploadReceiver.cs プロジェクト: b2rex/b2rex
 public XmlRpcResponse ClearXmlRpcHandler(XmlRpcRequest request, IPEndPoint client)
 {
     // AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID);
     XmlRpcResponse response = new XmlRpcResponse();
     Hashtable requestData = (Hashtable)request.Params[0];
     Hashtable resp = new Hashtable();
     if (requestData.ContainsKey("RegionID"))
     {
     UUID regionID = UUID.Parse((string)requestData["RegionID"]);
     m_scene = SelectRegion(regionID);
     m_scene.DeleteAllSceneObjects();
     }
     else
     {
     resp["success"] = false;
     resp["error"] = "no RegionID provided";
     response.Value = resp;
             return response;
     }
     // return ok;
     resp["success"] = true;
     response.Value = resp;
     return response;
 }
コード例 #16
0
    static public void Serialize(XmlTextWriter output, XmlRpcResponse response)
      {
	output.WriteStartDocument();
	output.WriteStartElement(METHOD_RESPONSE);

	if (response.IsFault)
	  output.WriteStartElement(FAULT);
	else
	  {
	    output.WriteStartElement(PARAMS);
	    output.WriteStartElement(PARAM);
	  }

	output.WriteStartElement(VALUE);

	SerializeObject(output,response.Value);

	output.WriteEndElement();

	output.WriteEndElement();
	if (!response.IsFault)
	  output.WriteEndElement();
	output.WriteEndElement();
      }
コード例 #17
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: Received Shutdown Administrator Request");

            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            try
            {
                Hashtable requestData = (Hashtable) request.Params[0];

                if (m_requiredPassword != String.Empty &&
                    (!requestData.Contains("password") || (string) requestData["password"] != m_requiredPassword))
                    throw new Exception("wrong password");

                responseData["accepted"] = true;
                response.Value = responseData;

                int timeout = 2000;
                string message;

                if (requestData.ContainsKey("shutdown")
                    && ((string) requestData["shutdown"] == "delayed")
                    && requestData.ContainsKey("milliseconds"))
                {
                    timeout = Int32.Parse(requestData["milliseconds"].ToString());

                    message
                        = "Region is going down in " + ((int) (timeout/1000)).ToString()
                          + " second(s). Please save what you are doing and log out.";
                }
                else
                {
                    message = "Region is going down now.";
                }

                m_application.SceneManager.ForEachScene(
                    delegate(Scene scene)
                        {
                            IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
                            if (dialogModule != null)
                                dialogModule.SendGeneralAlert(message);
                        });

                // Perform shutdown
                System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing
                shutdownTimer.AutoReset = false;
                shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed);
                lock (shutdownTimer)
                {
                    shutdownTimer.Start();
                }

                responseData["success"] = true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RADMIN]: Shutdown: failed: {0} {1}", e.Message, e.StackTrace);

                responseData["accepted"] = false;
                responseData["error"] = e.Message;

                response.Value = responseData;
            }
            
            m_log.Info("[RADMIN]: Shutdown Administrator Request complete");
            return response;
        }
コード例 #18
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcSaveHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient)

        {
            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            m_log.Info("[RADMIN]: Save height maps request started");

            try
            {
                Hashtable requestData = (Hashtable)request.Params[0];

                m_log.DebugFormat("[RADMIN]: Save Terrain: XmlRpc {0}", request.ToString());

                CheckStringParameters(request, new string[] { "password", "filename", "regionid" });

                if (m_requiredPassword != String.Empty &&
                    (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword))
                    throw new Exception("wrong password");

                string file = (string)requestData["filename"];
                UUID regionID = (UUID)(string)requestData["regionid"];
                m_log.InfoFormat("[RADMIN]: Terrain Saving: {0}", file);

                responseData["accepted"] = true;

                Scene region = null;

                if (!m_application.SceneManager.TryGetScene(regionID, out region))
                    throw new Exception("1: unable to get a scene with that name");

                ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
                if (null == terrainModule) throw new Exception("terrain module not available");

                terrainModule.SaveToFile(file);

                responseData["success"] = false;

                response.Value = responseData;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RADMIN]: Terrain Saving: failed: {0}", e.Message);
                m_log.DebugFormat("[RADMIN]: Terrain Saving: failed: {0}", e.ToString());

                responseData["success"] = false;
                responseData["error"] = e.Message;

            }

            m_log.Info("[RADMIN]: Save height maps request complete");

            return response;
        }
コード例 #19
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcAccessListList(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: Received Access List List Request");

            FailIfRemoteAdminDisabled("Access List List");

            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            try
            {
                responseData["success"] = true;

                Hashtable requestData = (Hashtable) request.Params[0];

                if (!requestData.Contains("password"))
                    throw new Exception(String.Format("missing required parameter"));
                if (!String.IsNullOrEmpty(m_requiredPassword) &&
                    (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");

                if (requestData.Contains("region_uuid"))
                {
                    UUID region_uuid = (UUID) (string) requestData["region_uuid"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
                        throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
                }
                else if (requestData.Contains("region_name"))
                {
                    string region_name = (string) requestData["region_name"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_name))
                        throw new Exception(String.Format("failed to switch to region {0}", region_name));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
                }
                else throw new Exception("neither region_name nor region_uuid given");

                Scene scene = m_application.SceneManager.CurrentScene;
                UUID[] accessControlList = scene.RegionInfo.EstateSettings.EstateAccess;
                Hashtable users = new Hashtable();

                foreach (UUID user in accessControlList)
                {
                    UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
                    UserAccount account = m_application.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, user);
                    if (account != null)
                    {
                        users[user.ToString()] = account.FirstName + " " + account.LastName;
                    }
                }

                responseData["users"] = users;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RADMIN]: Access List List: {0} {1}", e.Message, e.StackTrace);

                responseData["success"] = false;
                responseData["error"] = e.Message;
            }
            finally
            {
                response.Value = responseData;
            }

            m_log.Info("[RADMIN]: Access List List Request complete");
            return response;
        }
コード例 #20
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            m_log.Info("[RADMIN]: Load height maps request started");

            try
            {
                Hashtable requestData = (Hashtable) request.Params[0];

                m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request);
                // foreach (string k in requestData.Keys)
                // {
                //     m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}",
                //                       k, (string)requestData[k], ((string)requestData[k]).Length);
                // }

                CheckStringParameters(request, new string[] {"password", "filename", "regionid"});

                if (m_requiredPassword != String.Empty &&
                    (!requestData.Contains("password") || (string) requestData["password"] != m_requiredPassword))
                    throw new Exception("wrong password");

                string file = (string) requestData["filename"];
                UUID regionID = (UUID) (string) requestData["regionid"];
                m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file);

                responseData["accepted"] = true;

                Scene region = null;

                if (!m_application.SceneManager.TryGetScene(regionID, out region))
                    throw new Exception("1: unable to get a scene with that name");

                ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
                if (null == terrainModule) throw new Exception("terrain module not available");
                if (Uri.IsWellFormedUriString(file, UriKind.Absolute))
                {
                    m_log.Info("[RADMIN]: Terrain path is URL");
                    Uri result;
                    if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result))
                    {
                        // the url is valid
                        string fileType = file.Substring(file.LastIndexOf('/') + 1);
                        terrainModule.LoadFromStream(fileType, result);
                    }
                }
                else
                {
                    terrainModule.LoadFromFile(file);
                }
                responseData["success"] = false;

                response.Value = responseData;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RADMIN]: Terrain Loading: failed: {0} {1}", e.Message, e.StackTrace);

                responseData["success"] = false;
                responseData["error"] = e.Message;
            }

            m_log.Info("[RADMIN]: Load height maps request complete");

            return response;
        }
コード例 #21
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcAccessListRemove(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: Received Access List Remove Request");

            FailIfRemoteAdminDisabled("Access List Remove");

            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            try
            {
                responseData["success"] = true;

                Hashtable requestData = (Hashtable) request.Params[0];

                if (!requestData.Contains("password"))
                    throw new Exception(String.Format("missing required parameter"));
                if (!String.IsNullOrEmpty(m_requiredPassword) &&
                    (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");

                if (requestData.Contains("region_uuid"))
                {
                    UUID region_uuid = (UUID) (string) requestData["region_uuid"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
                        throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
                }
                else if (requestData.Contains("region_name"))
                {
                    string region_name = (string) requestData["region_name"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_name))
                        throw new Exception(String.Format("failed to switch to region {0}", region_name));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
                }
                else throw new Exception("neither region_name nor region_uuid given");

                int removedUsers = 0;

                if (requestData.Contains("users"))
                {
                    UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
                    IUserAccountService userService = m_application.SceneManager.CurrentOrFirstScene.UserAccountService;
                    //UserProfileCacheService ups = m_application.CommunicationsManager.UserProfileCacheService;
                    Scene scene = m_application.SceneManager.CurrentScene;
                    Hashtable users = (Hashtable) requestData["users"];
                    List<UUID> uuids = new List<UUID>();
                    foreach (string name in users.Values)
                    {
                        string[] parts = name.Split();
                        UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]);
                        if (account != null)
                        {
                            uuids.Add(account.PrincipalID);
                        }
                    }
                    List<UUID> accessControlList = new List<UUID>(scene.RegionInfo.EstateSettings.EstateAccess);
                    foreach (UUID uuid in uuids)
                    {
                       if (accessControlList.Contains(uuid))
                        {
                            accessControlList.Remove(uuid);
                            removedUsers++;
                        }
                    }
                    scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray();
                    if (scene.RegionInfo.Persistent)
                        scene.RegionInfo.EstateSettings.Save();
                }

                responseData["removed"] = removedUsers;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RADMIN]: Access List Remove Request: {0} {1}", e.Message, e.StackTrace);

                responseData["success"] = false;
                responseData["error"] = e.Message;
            }
            finally
            {
                response.Value = responseData;
            }

            m_log.Info("[RADMIN]: Access List Remove Request complete");
            return response;
        }
コード例 #22
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        /// <summary>
        /// Close a region.
        /// <summary>
        /// <param name="request">incoming XML RPC request</param>
        /// <remarks>
        /// XmlRpcCloseRegionMethod takes the following XMLRPC
        /// parameters
        /// <list type="table">
        /// <listheader><term>parameter name</term><description>description</description></listheader>
        /// <item><term>password</term>
        ///       <description>admin password as set in OpenSim.ini</description></item>
        /// <item><term>region_name</term>
        ///       <description>desired region name</description></item>
        /// <item><term>region_id</term>
        ///       <description>(optional) desired region UUID</description></item>
        /// </list>
        ///
        /// XmlRpcShutdownRegionMethod returns
        /// <list type="table">
        /// <listheader><term>name</term><description>description</description></listheader>
        /// <item><term>success</term>
        ///       <description>true or false</description></item>
        /// <item><term>region_name</term>
        ///       <description>the region name if success is true</description></item>
        /// <item><term>error</term>
        ///       <description>error message if success is false</description></item>
        /// </list>
        /// </remarks>
        public XmlRpcResponse XmlRpcCloseRegionMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: CloseRegion: new request");
            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();
            Scene scene = null;

            lock (m_requestLock)
            {
                try
                {
                    Hashtable requestData = (Hashtable) request.Params[0];
                    CheckStringParameters(request, new string[] {"password"});

                    if (requestData.ContainsKey("region_id") &&
                        !String.IsNullOrEmpty((string) requestData["region_id"]))
                    {
                        // Region specified by UUID
                        UUID regionID = (UUID) (string) requestData["region_id"];
                        if (!m_application.SceneManager.TryGetScene(regionID, out scene))
                            throw new Exception(String.Format("region \"{0}\" does not exist", regionID));

                        m_application.CloseRegion(scene);

                        responseData["success"] = true;
                        responseData["region_id"] = regionID;

                        response.Value = responseData;
                    }
                    else if (requestData.ContainsKey("region_name") &&
                        !String.IsNullOrEmpty((string) requestData["region_name"]))
                    {
                        // Region specified by name

                        string regionName = (string) requestData["region_name"];
                        if (!m_application.SceneManager.TryGetScene(regionName, out scene))
                            throw new Exception(String.Format("region \"{0}\" does not exist", regionName));

                        m_application.CloseRegion(scene);

                        responseData["success"] = true;
                        responseData["region_name"] = regionName;

                        response.Value = responseData;
                    }
                    else
                        throw new Exception("no region specified");
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[RADMIN]: CloseRegion: failed {0} {1}", e.Message, e.StackTrace);

                    responseData["success"] = false;
                    responseData["error"] = e.Message;

                    response.Value = responseData;
                }

                m_log.Info("[RADMIN]: CloseRegion: request complete");
                return response;
            }
        }
コード例 #23
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcRegionQueryMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: Received Query XML Administrator Request");

            FailIfRemoteAdminDisabled("Query XML");

            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            try
            {
                responseData["success"] = true;

                Hashtable requestData = (Hashtable) request.Params[0];

                // check completeness
                if (!requestData.Contains("password"))
                    throw new Exception(String.Format("missing required parameter"));
                if (!String.IsNullOrEmpty(m_requiredPassword) &&
                    (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");

                if (requestData.Contains("region_uuid"))
                {
                    UUID region_uuid = (UUID) (string) requestData["region_uuid"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
                        throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
                }
                else if (requestData.Contains("region_name"))
                {
                    string region_name = (string) requestData["region_name"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_name))
                        throw new Exception(String.Format("failed to switch to region {0}", region_name));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
                }
                else throw new Exception("neither region_name nor region_uuid given");

                Scene scene = m_application.SceneManager.CurrentScene;
                int health = scene.GetHealth();
                responseData["health"] = health;

                response.Value = responseData;
            }
            catch (Exception e)
            {
                m_log.InfoFormat("[RADMIN]: RegionQuery: {0}", e.Message);

                responseData["success"] = false;
                responseData["error"] = e.Message;

                response.Value = responseData;
            }

            m_log.Info("[RADMIN]: Query XML Administrator Request complete");
            return response;
        }
コード例 #24
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcSaveXMLMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: Received Save XML Administrator Request");

            FailIfRemoteAdminDisabled("Save XML");

            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            try
            {
                Hashtable requestData = (Hashtable) request.Params[0];

                // check completeness
                foreach (string p in new string[] {"password", "filename"})
                {
                    if (!requestData.Contains(p))
                        throw new Exception(String.Format("missing parameter {0}", p));
                    if (String.IsNullOrEmpty((string) requestData[p]))
                        throw new Exception(String.Format("parameter {0} is empty"));
                }

                // check password
                if (!String.IsNullOrEmpty(m_requiredPassword) &&
                    (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");

                string filename = (string) requestData["filename"];
                if (requestData.Contains("region_uuid"))
                {
                    UUID region_uuid = (UUID) (string) requestData["region_uuid"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
                        throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
                }
                else if (requestData.Contains("region_name"))
                {
                    string region_name = (string) requestData["region_name"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_name))
                        throw new Exception(String.Format("failed to switch to region {0}", region_name));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
                }
                else throw new Exception("neither region_name nor region_uuid given");

                responseData["switched"] = true;

                string xml_version = "1";
                if (requestData.Contains("xml_version"))
                {
                    xml_version = (string) requestData["xml_version"];
                }

                switch (xml_version)
                {
                    case "1":
                        m_application.SceneManager.SaveCurrentSceneToXml(filename);
                        break;

                    case "2":
                        m_application.SceneManager.SaveCurrentSceneToXml2(filename);
                        break;

                    default:
                        throw new Exception(String.Format("unknown Xml{0} format", xml_version));
                }

                responseData["saved"] = true;

                response.Value = responseData;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RADMIN]: SaveXml: {0} {1}", e.Message, e.StackTrace);

                responseData["saved"] = false;
                responseData["switched"] = false;
                responseData["error"] = e.Message;

                response.Value = responseData;
            }

            m_log.Info("[RADMIN]: Save XML Administrator Request complete");
            return response;
        }
コード例 #25
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcAlertMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            m_log.Info("[RADMIN]: Alert request started");

            try
            {
                Hashtable requestData = (Hashtable) request.Params[0];

                CheckStringParameters(request, new string[] {"password", "message"});

                if (m_requiredPassword != String.Empty &&
                    (!requestData.Contains("password") || (string) requestData["password"] != m_requiredPassword))
                    throw new Exception("wrong password");

                string message = (string) requestData["message"];
                m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);

                responseData["accepted"] = true;
                responseData["success"] = true;
                response.Value = responseData;

                m_application.SceneManager.ForEachScene(
                    delegate(Scene scene)
                        {
                            IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
                            if (dialogModule != null)
                                dialogModule.SendGeneralAlert(message);
                        });
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message, e.StackTrace);

                responseData["accepted"] = false;
                responseData["success"] = false;
                responseData["error"] = e.Message;
                response.Value = responseData;
            }

            m_log.Info("[RADMIN]: Alert request complete");
            return response;
        }
コード例 #26
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        /// <summary>
        /// Create a new region.
        /// <summary>
        /// <param name="request">incoming XML RPC request</param>
        /// <remarks>
        /// XmlRpcCreateRegionMethod takes the following XMLRPC
        /// parameters
        /// <list type="table">
        /// <listheader><term>parameter name</term><description>description</description></listheader>
        /// <item><term>password</term>
        ///       <description>admin password as set in OpenSim.ini</description></item>
        /// <item><term>region_name</term>
        ///       <description>desired region name</description></item>
        /// <item><term>region_id</term>
        ///       <description>(optional) desired region UUID</description></item>
        /// <item><term>region_x</term>
        ///       <description>desired region X coordinate (integer)</description></item>
        /// <item><term>region_y</term>
        ///       <description>desired region Y coordinate (integer)</description></item>
        /// <item><term>estate_owner_first</term>
        ///       <description>firstname of estate owner (formerly region master)
        ///       (required if new estate is being created, optional otherwise)</description></item>
        /// <item><term>estate_owner_last</term>
        ///       <description>lastname of estate owner (formerly region master)
        ///       (required if new estate is being created, optional otherwise)</description></item>
        /// <item><term>estate_owner_uuid</term>
        ///       <description>explicit UUID to use for estate owner (optional)</description></item>
        /// <item><term>listen_ip</term>
        ///       <description>internal IP address (dotted quad)</description></item>
        /// <item><term>listen_port</term>
        ///       <description>internal port (integer)</description></item>
        /// <item><term>external_address</term>
        ///       <description>external IP address</description></item>
        /// <item><term>persist</term>
        ///       <description>if true, persist the region info
        ///       ('true' or 'false')</description></item>
        /// <item><term>public</term>
        ///       <description>if true, the region is public
        ///       ('true' or 'false') (optional, default: true)</description></item>
        /// <item><term>enable_voice</term>
        ///       <description>if true, enable voice on all parcels,
        ///       ('true' or 'false') (optional, default: false)</description></item>
        /// <item><term>estate_name</term>
        ///       <description>the name of the estate to join (or to create if it doesn't
        ///       already exist)</description></item>
        /// <item><term>region_file</term>
        ///       <description>The name of the file to persist the region specifications to.
        /// If omitted, the region_file_template setting from OpenSim.ini will be used. (optional)</description></item>
        /// </list>
        ///
        /// XmlRpcCreateRegionMethod returns
        /// <list type="table">
        /// <listheader><term>name</term><description>description</description></listheader>
        /// <item><term>success</term>
        ///       <description>true or false</description></item>
        /// <item><term>error</term>
        ///       <description>error message if success is false</description></item>
        /// <item><term>region_uuid</term>
        ///       <description>UUID of the newly created region</description></item>
        /// <item><term>region_name</term>
        ///       <description>name of the newly created region</description></item>
        /// </list>
        /// </remarks>
        public XmlRpcResponse XmlRpcCreateRegionMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: CreateRegion: new request");

            FailIfRemoteAdminDisabled("CreateRegion");

            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            lock (m_requestLock)
            {
                int  m_regionLimit = m_config.GetInt("region_limit", 0);
                bool m_enableVoiceForNewRegions = m_config.GetBoolean("create_region_enable_voice", false);
                bool m_publicAccess = m_config.GetBoolean("create_region_public", true);

                try
                {
                    Hashtable requestData = (Hashtable) request.Params[0];

                    CheckStringParameters(request, new string[]
                                                       {
                                                           "password",
                                                           "region_name",
                                                           "listen_ip", "external_address",
                                                           "estate_name"
                                                       });
                    CheckIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"});

                    // check password
                    if (!String.IsNullOrEmpty(m_requiredPassword) &&
                        (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");

                    // check whether we still have space left (iff we are using limits)
                    if (m_regionLimit != 0 && m_application.SceneManager.Scenes.Count >= m_regionLimit)
                        throw new Exception(String.Format("cannot instantiate new region, server capacity {0} already reached; delete regions first",
                                                          m_regionLimit));
                    // extract or generate region ID now
                    Scene scene = null;
                    UUID regionID = UUID.Zero;
                    if (requestData.ContainsKey("region_id") &&
                        !String.IsNullOrEmpty((string) requestData["region_id"]))
                    {
                        regionID = (UUID) (string) requestData["region_id"];
                        if (m_application.SceneManager.TryGetScene(regionID, out scene))
                            throw new Exception(
                                String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>",
                                              scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
                                              scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
                    }
                    else
                    {
                        regionID = UUID.Random();
                        m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID);
                    }

                    // create volatile or persistent region info
                    RegionInfo region = new RegionInfo();

                    region.RegionID = regionID;
                    region.originRegionID = regionID;
                    region.RegionName = (string) requestData["region_name"];
                    region.RegionLocX = Convert.ToUInt32(requestData["region_x"]);
                    region.RegionLocY = Convert.ToUInt32(requestData["region_y"]);

                    // check for collisions: region name, region UUID,
                    // region location
                    if (m_application.SceneManager.TryGetScene(region.RegionName, out scene))
                        throw new Exception(
                            String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>",
                                          scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
                                          scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));

                    if (m_application.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene))
                        throw new Exception(
                            String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>",
                                          region.RegionLocX, region.RegionLocY,
                                          scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
                                          scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));

                    region.InternalEndPoint =
                        new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0);

                    region.InternalEndPoint.Port = Convert.ToInt32(requestData["listen_port"]);
                    if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0");
                    if (m_application.SceneManager.TryGetScene(region.InternalEndPoint, out scene))
                        throw new Exception(
                            String.Format(
                                "region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>",
                                region.InternalEndPoint.Address,
                                region.InternalEndPoint.Port,
                                scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
                                scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));

                    region.ExternalHostName = (string) requestData["external_address"];

                    bool persist = Convert.ToBoolean((string) requestData["persist"]);
                    if (persist)
                    {
                        // default place for region configuration files is in the
                        // Regions directory of the config dir (aka /bin)
                        string regionConfigPath = Path.Combine(Util.configDir(), "Regions");
                        try
                        {
                            // OpenSim.ini can specify a different regions dir
                            IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"];
                            regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim();
                        }
                        catch (Exception)
                        {
                            // No INI setting recorded.
                        }
                        
                        string regionIniPath;
                        
                        if (requestData.Contains("region_file"))
                        {
                            // Make sure that the file to be created is in a subdirectory of the region storage directory.
                            string requestedFilePath = Path.Combine(regionConfigPath, (string) requestData["region_file"]);
                            string requestedDirectory = Path.GetDirectoryName(Path.GetFullPath(requestedFilePath));
                            if (requestedDirectory.StartsWith(Path.GetFullPath(regionConfigPath)))
                                regionIniPath = requestedFilePath;
                            else
                                throw new Exception("Invalid location for region file.");
                        }
                        else
                        {
                            regionIniPath = Path.Combine(regionConfigPath,
                                                            String.Format(
                                                                m_config.GetString("region_file_template",
                                                                                   "{0}x{1}-{2}.ini"),
                                                                region.RegionLocX.ToString(),
                                                                region.RegionLocY.ToString(),
                                                                regionID.ToString(),
                                                                region.InternalEndPoint.Port.ToString(),
                                                                region.RegionName.Replace(" ", "_").Replace(":", "_").
                                                                    Replace("/", "_")));
                        }
                        
                        m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}",
                                          region.RegionID, regionIniPath);
                        region.SaveRegionToFile("dynamic region", regionIniPath);
                    }
                    else
                    {
                        region.Persistent = false;
                    }
                        
                    // Set the estate
                    
                    // Check for an existing estate
                    List<int> estateIDs = m_application.EstateDataService.GetEstates((string) requestData["estate_name"]);
                    if (estateIDs.Count < 1)
                    {
                        UUID userID = UUID.Zero;
                        if (requestData.ContainsKey("estate_owner_uuid"))
                        {
                            // ok, client wants us to use an explicit UUID
                            // regardless of what the avatar name provided
                            userID = new UUID((string) requestData["estate_owner_uuid"]);
                            
                            // Check that the specified user exists
                            Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene;
                            IUserAccountService accountService = currentOrFirst.UserAccountService;
                            UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID, userID);
                            
                            if (user == null)
                                throw new Exception("Specified user was not found.");
                        }
                        else if (requestData.ContainsKey("estate_owner_first") & requestData.ContainsKey("estate_owner_last"))
                        {
                            // We need to look up the UUID for the avatar with the provided name.
                            string ownerFirst = (string) requestData["estate_owner_first"];
                            string ownerLast = (string) requestData["estate_owner_last"];
                            
                            Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene;
                            IUserAccountService accountService = currentOrFirst.UserAccountService;
                            UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID,
                                                                               ownerFirst, ownerLast);
                            
                            // Check that the specified user exists
                            if (user == null)
                                throw new Exception("Specified user was not found.");
                            
                            userID = user.PrincipalID;
                        }
                        else
                        {
                            throw new Exception("Estate owner details not provided.");
                        }
                        
                        // Create a new estate with the name provided
                        region.EstateSettings = m_application.EstateDataService.CreateNewEstate();

                        region.EstateSettings.EstateName = (string) requestData["estate_name"];
                        region.EstateSettings.EstateOwner = userID;
                        // Persistence does not seem to effect the need to save a new estate
                        region.EstateSettings.Save();

                        if (!m_application.EstateDataService.LinkRegion(region.RegionID, (int) region.EstateSettings.EstateID))
                            throw new Exception("Failed to join estate.");
                    }
                    else
                    {
                        int estateID = estateIDs[0];

                        region.EstateSettings = m_application.EstateDataService.LoadEstateSettings(region.RegionID, false);

                        if (region.EstateSettings.EstateID != estateID)
                        {
                            // The region is already part of an estate, but not the one we want.
                            region.EstateSettings = m_application.EstateDataService.LoadEstateSettings(estateID);

                            if (!m_application.EstateDataService.LinkRegion(region.RegionID, estateID))
                                throw new Exception("Failed to join estate.");
                        }
                    }
                    
                    // Create the region and perform any initial initialization

                    IScene newScene;
                    m_application.CreateRegion(region, out newScene);

                    // If an access specification was provided, use it.
                    // Otherwise accept the default.
                    newScene.RegionInfo.EstateSettings.PublicAccess = GetBoolean(requestData, "public", m_publicAccess);
                    newScene.RegionInfo.EstateSettings.Save();

                    // enable voice on newly created region if
                    // requested by either the XmlRpc request or the
                    // configuration
                    if (GetBoolean(requestData, "enable_voice", m_enableVoiceForNewRegions))
                    {
                        List<ILandObject> parcels = ((Scene)newScene).LandChannel.AllParcels();

                        foreach (ILandObject parcel in parcels)
                        {
                            parcel.LandData.Flags |= (uint) ParcelFlags.AllowVoiceChat;
                            parcel.LandData.Flags |= (uint) ParcelFlags.UseEstateVoiceChan;
                            ((Scene)newScene).LandChannel.UpdateLandObject(parcel.LandData.LocalID, parcel.LandData);
                        }
                    }

                    responseData["success"] = true;
                    responseData["region_name"] = region.RegionName;
                    responseData["region_uuid"] = region.RegionID.ToString();

                    response.Value = responseData;
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0} {1}", e.Message, e.StackTrace);

                    responseData["success"] = false;
                    responseData["error"] = e.Message;

                    response.Value = responseData;
                }

                m_log.Info("[RADMIN]: CreateRegion: request complete");
                return response;
            }
        }
コード例 #27
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        /// <summary>
        /// Delete a new region.
        /// <summary>
        /// <param name="request">incoming XML RPC request</param>
        /// <remarks>
        /// XmlRpcDeleteRegionMethod takes the following XMLRPC
        /// parameters
        /// <list type="table">
        /// <listheader><term>parameter name</term><description>description</description></listheader>
        /// <item><term>password</term>
        ///       <description>admin password as set in OpenSim.ini</description></item>
        /// <item><term>region_name</term>
        ///       <description>desired region name</description></item>
        /// <item><term>region_id</term>
        ///       <description>(optional) desired region UUID</description></item>
        /// </list>
        ///
        /// XmlRpcDeleteRegionMethod returns
        /// <list type="table">
        /// <listheader><term>name</term><description>description</description></listheader>
        /// <item><term>success</term>
        ///       <description>true or false</description></item>
        /// <item><term>error</term>
        ///       <description>error message if success is false</description></item>
        /// </list>
        /// </remarks>
        public XmlRpcResponse XmlRpcDeleteRegionMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: DeleteRegion: new request");
            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            lock (m_requestLock)
            {
                try
                {
                    Hashtable requestData = (Hashtable) request.Params[0];
                    CheckStringParameters(request, new string[] {"password", "region_name"});

                    Scene scene = null;
                    string regionName = (string) requestData["region_name"];
                    if (!m_application.SceneManager.TryGetScene(regionName, out scene))
                        throw new Exception(String.Format("region \"{0}\" does not exist", regionName));

                    m_application.RemoveRegion(scene, true);

                    responseData["success"] = true;
                    responseData["region_name"] = regionName;

                    response.Value = responseData;
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0} {1}", e.Message, e.StackTrace);

                    responseData["success"] = false;
                    responseData["error"] = e.Message;

                    response.Value = responseData;
                }

                m_log.Info("[RADMIN]: DeleteRegion: request complete");
                return response;
            }
        }
コード例 #28
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcConsoleCommandMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: Received Command XML Administrator Request");

            FailIfRemoteAdminDisabled("Command XML");

            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            try
            {
                responseData["success"] = true;

                Hashtable requestData = (Hashtable) request.Params[0];

                // check completeness
                if (!requestData.Contains("password"))
                    throw new Exception(String.Format("missing required parameter"));
                if (!String.IsNullOrEmpty(m_requiredPassword) &&
                    (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");

                if (!requestData.Contains("command"))
                    throw new Exception(String.Format("missing required parameter"));
                MainConsole.Instance.RunCommand(requestData["command"].ToString());

                response.Value = responseData;
            }
            catch (Exception e)
            {
                m_log.InfoFormat("[RADMIN]: ConsoleCommand: {0}", e.Message);

                responseData["success"] = false;
                responseData["error"] = e.Message;

                response.Value = responseData;
            }

            m_log.Info("[RADMIN]: Command XML Administrator Request complete");
            return response;
        }
コード例 #29
0
        public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse response = new XmlRpcResponse();

            Hashtable requestData = (Hashtable) request.Params[0];
            bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
                            requestData.Contains("StringValue"));

            if (GoodXML)
            {
                UUID channel = new UUID((string) requestData["Channel"]);
                RPCChannelInfo rpcChanInfo;
                if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
                {
                    string intVal = Convert.ToInt32(requestData["IntValue"]).ToString();
                    string strVal = (string) requestData["StringValue"];

                    RPCRequestInfo rpcInfo;

                    lock (XMLRPCListLock)
                    {
                        rpcInfo =
                            new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
                                               intVal);
                        m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
                    }

                    int timeoutCtr = 0;

                    while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
                    {
                        Thread.Sleep(RemoteReplyScriptWait);
                        timeoutCtr += RemoteReplyScriptWait;
                    }
                    if (rpcInfo.IsProcessed())
                    {
                        Hashtable param = new Hashtable();
                        param["StringValue"] = rpcInfo.GetStrRetval();
                        param["IntValue"] = rpcInfo.GetIntRetval();

                        ArrayList parameters = new ArrayList();
                        parameters.Add(param);

                        response.Value = parameters;
                        rpcInfo = null;
                    }
                    else
                    {
                        response.SetFault(-1, "Script timeout");
                        rpcInfo = null;
                    }
                }
                else
                {
                    response.SetFault(-1, "Invalid channel");
                }
            }

            return response;
        }
コード例 #30
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        public XmlRpcResponse XmlRpcAccessListClear(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            m_log.Info("[RADMIN]: Received Access List Clear Request");

            FailIfRemoteAdminDisabled("Access List Clear");

            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable responseData = new Hashtable();

            try
            {
                responseData["success"] = true;

                Hashtable requestData = (Hashtable) request.Params[0];

                if (!requestData.Contains("password"))
                    throw new Exception(String.Format("missing required parameter"));
                if (!String.IsNullOrEmpty(m_requiredPassword) &&
                    (string) requestData["password"] != m_requiredPassword) throw new Exception("wrong password");

                if (requestData.Contains("region_uuid"))
                {
                    UUID region_uuid = (UUID) (string) requestData["region_uuid"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_uuid))
                        throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString()));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_uuid.ToString());
                }
                else if (requestData.Contains("region_name"))
                {
                    string region_name = (string) requestData["region_name"];
                    if (!m_application.SceneManager.TrySetCurrentScene(region_name))
                        throw new Exception(String.Format("failed to switch to region {0}", region_name));
                    m_log.InfoFormat("[RADMIN]: Switched to region {0}", region_name);
                }
                else throw new Exception("neither region_name nor region_uuid given");

                Scene scene = m_application.SceneManager.CurrentScene;
                scene.RegionInfo.EstateSettings.EstateAccess = new UUID[]{};
                if (scene.RegionInfo.Persistent)
                    scene.RegionInfo.EstateSettings.Save();
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RADMIN]: Access List Clear Request: {0} {1}", e.Message, e.StackTrace);

                responseData["success"] = false;
                responseData["error"] = e.Message;
            }
            finally
            {
                response.Value = responseData;
            }

            m_log.Info("[RADMIN]: Access List Clear Request complete");
            return response;
        }