Exemplo n.º 1
0
        /// <summary>
        /// Connect to ICE interface on running Murmur server
        /// </summary>
        /// <param name="address">murmur server address</param>
        /// <param name="port">ice port</param>
        /// <param name="secret">ice password</param>
        /// <param name="timeout"></param>
        /// <returns>object of murmur server</returns>
        public MetaPrx Connect(string address, int port, string secret, string callbackAddress = "127.0.0.1", int callbackPort = 0, int timeout = 1000)
        {
            this.timeout = timeout;

            // initialize
            run(new string[] { });

            ic = Ice.Util.initialize(_data);

            // set ice secret
            if (!string.IsNullOrEmpty(secret))
            {
                ic.getImplicitContext().put("secret", secret);
            }

            try
            {
                var connectionString = string.Format("Meta:tcp -h {0} -p {1} -t {2}", address, port, timeout);

                // Create a proxy
                var obj = ic.stringToProxy(connectionString);

                // Tests whether the target object of this proxy can be reached.
                obj.ice_ping();

                // initialize metadata of murmur server
                _meta = MetaPrxHelper.uncheckedCast(obj);


                var portString         = (callbackPort > 0) ? string.Format("-p {0}", callbackPort) : "";
                var connectionStringCB = string.Format("tcp -h {0} {1} -t {2}", callbackAddress, portString, timeout);

                // Create the callback adapter
                ic.getProperties().setProperty("Ice.PrintAdapterReady", "0");
                _adapter = ic.createObjectAdapterWithEndpoints("Callback.Client", connectionStringCB);
                _adapter.activate();

                _meta.ice_ping();
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.ToString());
                throw new MurmurPlugin.ConnectionRefusedException();
            }

            // FIXME: check for valid ice secret, because getLogLen() is working only if "icesecretwrite" is valid
            //  (there a secure hole - get methods allowed if "icesecretread" is not set)
            //  if secret is invalid it throws UnmarshalOutOfBoundsException();
            try
            {
                // set allowhtml property to the server to check ice writesecret
                _meta.getAllServers()[0].setConf("allowhtml", "true");
            }
            catch
            {
                throw new MurmurPlugin.InvalidSecretException();
            }

            return(_meta);
        }
Exemplo n.º 2
0
 public MurmurSession()
 {
     communicator = Util.initialize();
     proxy        = communicator.stringToProxy("Meta:tcp -h 94.23.170.70 -p 6502");
     meta         = MetaPrxHelper.uncheckedCast(proxy);
     server       = meta.getAllServers().First();
     users        = server.getUsers().Values;
 }
        public void Initialize(IScene scene)
        {
            try
            {
                if (!m_enabled)
                {
                    return;
                }

                IMurmurService service = scene.RequestModuleInterface <IMurmurService>();
                if (service == null)
                {
                    return;
                }

                MurmurConfig config = service.GetConfiguration(scene.RegionInfo.RegionName);
                if (config == null)
                {
                    return;
                }

                bool justStarted = false;
                if (!m_started)
                {
                    justStarted = true;
                    m_started   = true;

                    // retrieve configuration variables
                    m_murmurd_host   = config.MurmurHost;
                    m_server_version = config.ServerVersion;
                    //Fix the callback URL, its our IP, so we deal with it
                    IConfig m_config = m_source.Configs["MurmurService"];
                    if (m_config != null)
                    {
                        config.IceCB = m_config.GetString("murmur_ice_cb", "tcp -h 127.0.0.1");
                    }

                    // Admin interface required values
                    if (String.IsNullOrEmpty(m_murmurd_host))
                    {
                        m_log.Error("[MurmurVoice] plugin disabled: incomplete configuration");
                        return;
                    }

                    Ice.Communicator comm = Ice.Util.initialize();

                    if (config.GlacierEnabled)
                    {
                        router = RouterPrxHelper.uncheckedCast(comm.stringToProxy(config.GlacierIce));
                        comm.setDefaultRouter(router);
                        router.createSession(config.GlacierUser, config.GlacierPass);
                    }

                    MetaPrx meta = MetaPrxHelper.checkedCast(comm.stringToProxy(config.MetaIce));

                    // Create the adapter
                    comm.getProperties().setProperty("Ice.PrintAdapterReady", "0");
                    if (config.GlacierEnabled)
                    {
                        adapter = comm.createObjectAdapterWithRouter("Callback.Client", comm.getDefaultRouter());
                    }
                    else
                    {
                        adapter = comm.createObjectAdapterWithEndpoints("Callback.Client", config.IceCB);
                    }
                    adapter.activate();

                    // Create identity and callback for Metaserver
                    Ice.Identity metaCallbackIdent = new Ice.Identity();
                    metaCallbackIdent.name = "metaCallback";
                    if (router != null)
                    {
                        metaCallbackIdent.category = router.getCategoryForClient();
                    }
                    MetaCallbackPrx meta_callback = MetaCallbackPrxHelper.checkedCast(adapter.add(new MetaCallbackImpl(), metaCallbackIdent));
                    meta.addCallback(meta_callback);

                    m_log.InfoFormat("[MurmurVoice] using murmur server ice '{0}'", config.MetaIce);

                    // create a server and figure out the port name
                    Dictionary <string, string> defaults = meta.getDefaultConf();
                    m_server = ServerPrxHelper.checkedCast(meta.getServer(config.ServerID));

                    // start thread to ping glacier2 router and/or determine if con$
                    m_keepalive = new KeepAlive(m_server);
                    ThreadStart ka_d = new ThreadStart(m_keepalive.StartPinging);
                    m_keepalive_t = new Thread(ka_d);
                    m_keepalive_t.Start();

                    // first check the conf for a port, if not then use server id and default port to find the right one.
                    string conf_port = m_server.getConf("port");
                    if (!String.IsNullOrEmpty(conf_port))
                    {
                        m_murmurd_port = Convert.ToInt32(conf_port);
                    }
                    else
                    {
                        m_murmurd_port = Convert.ToInt32(defaults["port"]) + config.ServerID - 1;
                    }

                    try
                    {
                        m_server.start();
                    }
                    catch
                    {
                    }
                }

                // starts the server and gets a callback
                ServerManager manager = new ServerManager(m_server, config.ChannelName);

                // Create identity and callback for this current server
                AddServerCallback(scene, new ServerCallbackImpl(manager));
                AddServerManager(scene, manager);

                if (justStarted)
                {
                    Ice.Identity serverCallbackIdent = new Ice.Identity();
                    serverCallbackIdent.name = "serverCallback";
                    if (router != null)
                    {
                        serverCallbackIdent.category = router.getCategoryForClient();
                    }

                    m_server.addCallback(ServerCallbackPrxHelper.checkedCast(adapter.add(GetServerCallback(scene), serverCallbackIdent)));
                }

                // Show information on console for debugging purposes
                m_log.InfoFormat("[MurmurVoice] using murmur server '{0}:{1}', sid '{2}'", m_murmurd_host, m_murmurd_port, config.ServerID);
                m_log.Info("[MurmurVoice] plugin enabled");
                m_enabled = true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[MurmurVoice] plugin initialization failed: {0}", e.ToString());
                return;
            }
        }
Exemplo n.º 4
0
        public void Initialize(Scene scene)
        {
            try
            {
                if (!m_enabled)
                {
                    return;
                }

                if (!m_started)
                {
                    m_started = true;

                    scene.AddCommand(this, "mumble report", "mumble report",
                                     "Returns mumble report", MumbleReport);

                    scene.AddCommand(this, "mumble unregister", "mumble unregister <userid>",
                                     "Unregister User by userid", UnregisterUser);

                    scene.AddCommand(this, "mumble remove", "mumble remove <UUID>",
                                     "Remove Agent by UUID", RemoveAgent);

                    Ice.Communicator comm = Ice.Util.initialize();

                    if (m_glacier_enabled)
                    {
                        m_router = RouterPrxHelper.uncheckedCast(comm.stringToProxy(m_glacier_ice));
                        comm.setDefaultRouter(m_router);
                        m_router.createSession(m_glacier_user, m_glacier_pass);
                    }

                    MetaPrx meta = MetaPrxHelper.checkedCast(comm.stringToProxy(m_murmurd_ice));

                    // Create the adapter
                    comm.getProperties().setProperty("Ice.PrintAdapterReady", "0");
                    if (m_glacier_enabled)
                    {
                        m_adapter = comm.createObjectAdapterWithRouter("Callback.Client", comm.getDefaultRouter());
                    }
                    else
                    {
                        m_adapter = comm.createObjectAdapterWithEndpoints("Callback.Client", m_murmur_ice_cb);
                    }
                    m_adapter.activate();

                    // Create identity and callback for Metaserver
                    Ice.Identity metaCallbackIdent = new Ice.Identity();
                    metaCallbackIdent.name = "metaCallback";
                    if (m_router != null)
                    {
                        metaCallbackIdent.category = m_router.getCategoryForClient();
                    }
                    MetaCallbackPrx meta_callback = MetaCallbackPrxHelper.checkedCast(m_adapter.add(new MetaCallbackImpl(), metaCallbackIdent));
                    meta.addCallback(meta_callback);

                    m_log.InfoFormat("[MurmurVoice] using murmur server ice '{0}'", m_murmurd_ice);

                    // create a server and figure out the port name
                    Dictionary <string, string> defaults = meta.getDefaultConf();
                    m_server = ServerPrxHelper.checkedCast(meta.getServer(m_server_id));

                    // start thread to ping glacier2 router and/or determine if con$
                    m_keepalive = new KeepAlive(m_server);
                    ThreadStart ka_d = new ThreadStart(m_keepalive.StartPinging);
                    m_keepalive_t = new Thread(ka_d);
                    m_keepalive_t.Start();

                    // first check the conf for a port, if not then use server id and default port to find the right one.
                    string conf_port = m_server.getConf("port");
                    if (!String.IsNullOrEmpty(conf_port))
                    {
                        m_murmurd_port = Convert.ToInt32(conf_port);
                    }
                    else
                    {
                        m_murmurd_port = Convert.ToInt32(defaults["port"]) + m_server_id - 1;
                    }

                    try
                    {
                        m_server.start();
                    }
                    catch
                    {
                    }

                    m_log.Info("[MurmurVoice] started");
                }

                // starts the server and gets a callback
                ServerManager manager = new ServerManager(m_server, m_channel_name);

                // Create identity and callback for this current server
                AddServerCallback(scene, new ServerCallbackImpl(manager));
                AddServerManager(scene, manager);

                Ice.Identity serverCallbackIdent = new Ice.Identity();
                serverCallbackIdent.name = "serverCallback_" + scene.RegionInfo.RegionName.Replace(" ", "_");
                if (m_router != null)
                {
                    serverCallbackIdent.category = m_router.getCategoryForClient();
                }

                m_server.addCallback(ServerCallbackPrxHelper.checkedCast(m_adapter.add(GetServerCallback(scene), serverCallbackIdent)));

                // Show information on console for debugging purposes
                m_log.InfoFormat("[MurmurVoice] using murmur server '{0}:{1}', sid '{2}'", m_murmurd_host, m_murmurd_port, m_server_id);
                m_log.Info("[MurmurVoice] plugin enabled");
                m_enabled = true;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[MurmurVoice] plugin initialization failed: {0}", e.ToString());
                return;
            }
        }