Beispiel #1
0
        public void Start(IScene scene)
        {
            m_scene = scene;

            m_scheduler = m_scene.Simian.GetAppModule <IScheduler>();
            if (m_scheduler == null)
            {
                m_log.Error("OARLoader requires an IScheduler");
                return;
            }

            m_assetClient = m_scene.Simian.GetAppModule <IAssetClient>();
            if (m_assetClient == null)
            {
                m_log.Error("OARLoader requires an IAssetClient");
                return;
            }

            m_primMesher  = m_scene.GetSceneModule <IPrimMesher>();
            m_terrain     = m_scene.GetSceneModule <ITerrain>();
            m_regionInfo  = m_scene.GetSceneModule <RegionInfo>();
            m_udp         = m_scene.GetSceneModule <LLUDP>();
            m_permissions = m_scene.GetSceneModule <LLPermissions>();

            m_scene.AddCommandHandler("loadoar", LoadOARHandler);
        }
Beispiel #2
0
        public void Start(IScene scene)
        {
            IPAddress bindAddress = IPAddress.Any;
            int port = DEFAULT_UDP_PORT;
            bool allowAlternatePort = true;

            IConfig config = scene.Config.Configs["LindenRegion"];
            if (config != null)
            {
                port = config.GetInt("Port", DEFAULT_UDP_PORT);
                allowAlternatePort = config.GetBoolean("AllowAlternatePort", true);
            }

            config = scene.Config.Configs["LLUDP"];
            if (config != null)
            {
                IPAddress.TryParse(config.GetString("BindAddress", "0.0.0.0"), out bindAddress);
                IPAddress.TryParse(config.GetString("MasqueradeAddress", String.Empty), out m_masqAddress);
            }

            if (bindAddress.Equals(IPAddress.Any))
                bindAddress = Util.GetLocalInterface();

            IScheduler scheduler = scene.Simian.GetAppModule<IScheduler>();
            if (scheduler == null)
            {
                m_log.Error("Cannot start LLUDP server without an IScheduler");
                throw new InvalidOperationException();
            }

            if (allowAlternatePort && m_nextUnusedPort != 0)
                port = m_nextUnusedPort;

            m_udpServer = new LLUDPServer(this, scene, bindAddress, port, scene.Config, scheduler);

            // Loop until we successfully bind to a port or run out of options
            while (true)
            {
                //m_log.Debug("Trying to bind LLUDP server to " + bindAddress + ":" + port);

                try
                {
                    m_udpServer.Address = bindAddress;
                    m_udpServer.Port = port;
                    m_udpServer.Start();

                    m_log.Info("Bound LLUDP server to " + bindAddress + ":" + port);

                    m_nextUnusedPort = port + 1;
                    IPAddress address = m_masqAddress == null ? bindAddress : m_masqAddress;

                    scene.ExtraData["ExternalAddress"] = OSD.FromString(address.ToString());
                    scene.ExtraData["ExternalPort"] = OSD.FromInteger(port);

                    break;
                }
                catch (System.Net.Sockets.SocketException)
                {
                    if (allowAlternatePort)
                    {
                        ++port;
                    }
                    else
                    {
                        m_log.Error("Failed to bind LLUDP server to port " + port);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    m_log.Error("Failed to bind LLUDP server to any port: " + ex.Message);
                    break;
                }
            }

            scene.AddCommandHandler("packetlog", PacketLogCommandHandler);
        }
Beispiel #3
0
        public void Start(IScene scene)
        {
            IPAddress bindAddress        = IPAddress.Any;
            int       port               = DEFAULT_UDP_PORT;
            bool      allowAlternatePort = true;

            IConfig config = scene.Config.Configs["LindenRegion"];

            if (config != null)
            {
                port = config.GetInt("Port", DEFAULT_UDP_PORT);
                allowAlternatePort = config.GetBoolean("AllowAlternatePort", true);
            }

            config = scene.Config.Configs["LLUDP"];
            if (config != null)
            {
                IPAddress.TryParse(config.GetString("BindAddress", "0.0.0.0"), out bindAddress);
                IPAddress.TryParse(config.GetString("MasqueradeAddress", String.Empty), out m_masqAddress);
            }

            if (bindAddress.Equals(IPAddress.Any))
            {
                bindAddress = Util.GetLocalInterface();
            }

            IScheduler scheduler = scene.Simian.GetAppModule <IScheduler>();

            if (scheduler == null)
            {
                m_log.Error("Cannot start LLUDP server without an IScheduler");
                throw new InvalidOperationException();
            }

            if (allowAlternatePort && m_nextUnusedPort != 0)
            {
                port = m_nextUnusedPort;
            }

            m_udpServer = new LLUDPServer(this, scene, bindAddress, port, scene.Config, scheduler);

            // Loop until we successfully bind to a port or run out of options
            while (true)
            {
                //m_log.Debug("Trying to bind LLUDP server to " + bindAddress + ":" + port);

                try
                {
                    m_udpServer.Address = bindAddress;
                    m_udpServer.Port    = port;
                    m_udpServer.Start();

                    m_log.Info("Bound LLUDP server to " + bindAddress + ":" + port);

                    m_nextUnusedPort = port + 1;
                    IPAddress address = m_masqAddress == null ? bindAddress : m_masqAddress;

                    scene.ExtraData["ExternalAddress"] = OSD.FromString(address.ToString());
                    scene.ExtraData["ExternalPort"]    = OSD.FromInteger(port);

                    break;
                }
                catch (System.Net.Sockets.SocketException)
                {
                    if (allowAlternatePort)
                    {
                        ++port;
                    }
                    else
                    {
                        m_log.Error("Failed to bind LLUDP server to port " + port);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    m_log.Error("Failed to bind LLUDP server to any port: " + ex.Message);
                    break;
                }
            }

            scene.AddCommandHandler("packetlog", PacketLogCommandHandler);
        }