diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index adffe13237..8f754a5ef2 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -138,8 +138,6 @@ namespace OpenSim.Framework protected uint m_httpPort; protected string m_serverURI; protected string m_regionName = String.Empty; - protected bool Allow_Alternate_Ports; - public bool m_allow_alternate_ports; protected string m_externalHostName; protected IPEndPoint m_internalEndPoint; protected uint m_remotingPort; @@ -673,20 +671,6 @@ namespace OpenSim.Framework } m_internalEndPoint = new IPEndPoint(address, port); - // AllowAlternatePorts - // - allKeys.Remove("AllowAlternatePorts"); - if (config.Contains("AllowAlternatePorts")) - { - m_allow_alternate_ports = config.GetBoolean("AllowAlternatePorts", true); - } - else - { - m_allow_alternate_ports = Convert.ToBoolean(MainConsole.Instance.CmdPrompt("Allow alternate ports", "False")); - - config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString()); - } - // ResolveAddress // allKeys.Remove("ResolveAddress"); @@ -925,8 +909,6 @@ namespace OpenSim.Framework config.Set("InternalAddress", m_internalEndPoint.Address.ToString()); config.Set("InternalPort", m_internalEndPoint.Port); - config.Set("AllowAlternatePorts", m_allow_alternate_ports.ToString()); - config.Set("ExternalHostName", m_externalHostName); if (m_nonphysPrimMin > 0) @@ -1019,10 +1001,6 @@ namespace OpenSim.Framework configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Internal IP Port for incoming UDP client connections", m_internalEndPoint.Port.ToString(), true); - configMember.addConfigurationOption("allow_alternate_ports", - ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, - "Allow sim to find alternate UDP ports when ports are in use?", - m_allow_alternate_ports.ToString(), true); configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "External Host Name", m_externalHostName, true); @@ -1092,9 +1070,6 @@ namespace OpenSim.Framework configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Internal IP Port for incoming UDP client connections", ConfigSettings.DefaultRegionHttpPort.ToString(), false); - configMember.addConfigurationOption("allow_alternate_ports", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, - "Allow sim to find alternate UDP ports when ports are in use?", - "false", true); configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "External Host Name", "127.0.0.1", false); @@ -1165,9 +1140,6 @@ namespace OpenSim.Framework case "internal_ip_port": m_internalEndPoint.Port = (int) configuration_result; break; - case "allow_alternate_ports": - m_allow_alternate_ports = (bool) configuration_result; - break; case "external_host_name": if ((string) configuration_result != "SYSTEMIP") { @@ -1244,7 +1216,6 @@ namespace OpenSim.Framework if ((RemotingAddress != null) && !RemotingAddress.Equals("")) args["remoting_address"] = OSD.FromString(RemotingAddress); args["remoting_port"] = OSD.FromString(RemotingPort.ToString()); - args["allow_alt_ports"] = OSD.FromBoolean(m_allow_alternate_ports); if ((proxyUrl != null) && !proxyUrl.Equals("")) args["proxy_url"] = OSD.FromString(proxyUrl); if (RegionType != String.Empty) @@ -1299,8 +1270,6 @@ namespace OpenSim.Framework RemotingAddress = args["remoting_address"].AsString(); if (args["remoting_port"] != null) UInt32.TryParse(args["remoting_port"].AsString(), out m_remotingPort); - if (args["allow_alt_ports"] != null) - m_allow_alternate_ports = args["allow_alt_ports"].AsBoolean(); if (args["proxy_url"] != null) proxyUrl = args["proxy_url"].AsString(); if (args["region_type"] != null) @@ -1338,7 +1307,8 @@ namespace OpenSim.Framework kvp["http_port"] = HttpPort.ToString(); kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); kvp["internal_port"] = InternalEndPoint.Port.ToString(); - kvp["alternate_ports"] = m_allow_alternate_ports.ToString(); + // TODO: Remove in next major version + kvp["alternate_ports"] = "False"; kvp["server_uri"] = ServerURI; return kvp; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index a868e3aa44..cedb9b4fec 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -81,7 +81,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP uint port = (uint)scene.RegionInfo.InternalEndPoint.Port; IPAddress listenIP = scene.RegionInfo.InternalEndPoint.Address; - Initialise(listenIP, ref port, scene.RegionInfo.ProxyOffset, scene.RegionInfo.m_allow_alternate_ports, m_Config, scene.AuthenticateHandler); + Initialise(listenIP, ref port, scene.RegionInfo.ProxyOffset, m_Config, scene.AuthenticateHandler); scene.RegionInfo.InternalEndPoint.Port = (int)port; AddScene(scene); @@ -98,9 +98,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - public virtual void Initialise(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) + public virtual void Initialise(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, IConfigSource configSource, AgentCircuitManager circuitManager) { - m_udpServer = new LLUDPServer(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager); + m_udpServer = new LLUDPServer(listenIP, ref port, proxyPortOffsetParm, configSource, circuitManager); } public virtual void AddScene(IScene scene) @@ -430,12 +430,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP public JobEngine OqrEngine { get; protected set; } public LLUDPServer( - IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, + IPAddress listenIP, ref uint port, int proxyPortOffsetParm, IConfigSource configSource, AgentCircuitManager circuitManager) : base(listenIP, (int)port) { #region Environment.TickCount Measurement + // Update the port with the one we actually got + port = (uint)Port; + // Measure the resolution of Environment.TickCount TickCountResolution = 0f; for (int i = 0; i < 10; i++) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index fffd02c347..831381e8ce 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs @@ -107,6 +107,11 @@ namespace OpenMetaverse /// public float AverageReceiveTicksForLastSamplePeriod { get; private set; } + public int Port + { + get { return m_udpPort; } + } + #region PacketDropDebugging /// /// For debugging purposes only... random number generator for dropping @@ -257,6 +262,9 @@ namespace OpenMetaverse m_udpSocket.Bind(ipep); + if (m_udpPort == 0) + m_udpPort = ((IPEndPoint)m_udpSocket.LocalEndPoint).Port; + IsRunningInbound = true; // kick off an async receive. The Start() method will return, the diff --git a/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs b/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs index 33cd8a2cd4..df9f6f22c8 100644 --- a/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/ClientStackHelpers.cs @@ -86,10 +86,10 @@ namespace OpenSim.Tests.Common uint port = 0; AgentCircuitManager acm = scene.AuthenticateHandler; - TestLLUDPServer udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm); + TestLLUDPServer udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, configSource, acm); udpServer.AddScene(scene); return udpServer; } } -} \ No newline at end of file +} diff --git a/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs index 26887c9ebd..b2c6a8cc4c 100644 --- a/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs +++ b/OpenSim/Tests/Common/Mock/TestLLUDPServer.cs @@ -43,8 +43,8 @@ namespace OpenSim.Tests.Common { public List PacketsSent { get; private set; } - public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) - : base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager) + public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, IConfigSource configSource, AgentCircuitManager circuitManager) + : base(listenIP, ref port, proxyPortOffsetParm, configSource, circuitManager) { PacketsSent = new List(); }