From 06a8c132005b4ab804f25d54c0c0f899fc98e3a1 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Sun, 1 Jul 2007 16:07:41 +0000 Subject: MAJOR IP RESTRUCTURING * moving towards IPEndPoints all over the place * trying to make the internal/external division --- OpenSim/Framework/Console/LogBase.cs | 58 ++++- OpenSim/Framework/General/Interfaces/IClientAPI.cs | 7 +- OpenSim/Framework/General/Types/RegionInfo.cs | 270 +++++++++++++-------- OpenSim/Region/Application/OpenSimMain.cs | 2 +- OpenSim/Region/Capabilities/Caps.cs | 17 +- OpenSim/Region/ClientStack/ClientView.API.cs | 18 +- OpenSim/Region/ClientStack/PacketServer.cs | 4 +- OpenSim/Region/ClientStack/UDPServer.cs | 2 +- .../Communications/Local/LocalUserServices.cs | 6 +- .../Region/Communications/OGS1/OGS1GridServices.cs | 18 +- OpenSim/Region/Environment/Scenes/Scene.cs | 6 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 2 +- OpenSim/Region/Examples/SimpleApp/Program.cs | 16 +- 13 files changed, 271 insertions(+), 155 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs index 1a92d8e..a4a17e9 100644 --- a/OpenSim/Framework/Console/LogBase.cs +++ b/OpenSim/Framework/Console/LogBase.cs @@ -27,6 +27,7 @@ */ using System; using System.IO; +using System.Net; namespace OpenSim.Framework.Console { @@ -48,18 +49,18 @@ namespace OpenSim.Framework.Console public string componentname; private bool m_silent; - public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent ) + public LogBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent) { this.componentname = componentname; this.cmdparser = cmdparser; this.m_silent = silent; System.Console.WriteLine("ServerConsole.cs - creating new local console"); - - if( String.IsNullOrEmpty( LogFile ) ) + + if (String.IsNullOrEmpty(LogFile)) { LogFile = componentname + ".log"; } - + System.Console.WriteLine("Logs will be saved to current directory in " + LogFile); Log = File.AppendText(LogFile); Log.WriteLine("========================================================================"); @@ -74,10 +75,10 @@ namespace OpenSim.Framework.Console public void Write(string format, params object[] args) { - Notice(format,args); + Notice(format, args); return; } - + public void WriteLine(LogPriority importance, string format, params object[] args) { Log.WriteLine(format, args); @@ -154,6 +155,49 @@ namespace OpenSim.Framework.Console return TempInt; } + public IPAddress CmdPromptIPAddress(string prompt, string defaultvalue) + { + IPAddress address; + string addressStr; + + while (true) + { + addressStr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt(prompt, defaultvalue); + if (IPAddress.TryParse(addressStr, out address)) + { + break; + } + else + { + OpenSim.Framework.Console.MainLog.Instance.Error("Illegal address. Please re-enter."); + } + } + + return address; + } + + public int CmdPromptIPPort(string prompt, string defaultvalue) + { + int port; + string portStr; + + while (true) + { + portStr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt(prompt, defaultvalue); + if (int.TryParse(portStr, out port)) + { + if (port >= IPEndPoint.MinPort && port <= IPEndPoint.MaxPort) + { + break; + } + } + + OpenSim.Framework.Console.MainLog.Instance.Error("Illegal address. Please re-enter."); + } + + return port; + } + // Displays a prompt and waits for the user to enter a string, then returns that string // Done with no echo and suitable for passwords public string PasswdPrompt(string prompt) @@ -178,7 +222,7 @@ namespace OpenSim.Framework.Console // Displays a command prompt and returns a default value if the user simply presses enter public string CmdPrompt(string prompt, string defaultresponse) { - string temp = CmdPrompt(String.Format( "{0} [{1}]", prompt, defaultresponse )); + string temp = CmdPrompt(String.Format("{0} [{1}]", prompt, defaultresponse)); if (temp == "") { return defaultresponse; diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 4e8ac1a..ea4c5c9 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -32,6 +32,7 @@ using OpenSim.Framework.Inventory; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework.Types; +using System.Net; namespace OpenSim.Framework.Interfaces { @@ -143,12 +144,12 @@ namespace OpenSim.Framework.Interfaces void SendLayerData(float[] map); void SendLayerData(int px, int py, float[] map); void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look); - void InformClientOfNeighbour(ulong neighbourHandle, System.Net.IPAddress neighbourIP, ushort neighbourPort); + void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint ); AgentCircuitData RequestClientInfo(); - void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, System.Net.IPAddress newRegionIP, ushort newRegionPort); + void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint ); void SendMapBlock(List mapBlocks); void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags); - void SendRegionTeleport(ulong regionHandle, byte simAccess, string ipAddress, ushort ipPort, uint locationID, uint flags); + void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags); void SendTeleportCancel(); void SendTeleportLocationStart(); void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance); diff --git a/OpenSim/Framework/General/Types/RegionInfo.cs b/OpenSim/Framework/General/Types/RegionInfo.cs index 1ead3c4..d98dd60 100644 --- a/OpenSim/Framework/General/Types/RegionInfo.cs +++ b/OpenSim/Framework/General/Types/RegionInfo.cs @@ -33,6 +33,7 @@ using OpenSim.Framework.Interfaces; using OpenSim.Framework.Utilities; using OpenSim.Framework.Console; using libsecondlife; +using System.Net; namespace OpenSim.Framework.Types { @@ -41,6 +42,32 @@ namespace OpenSim.Framework.Types public LLUUID SimUUID = new LLUUID(); public string RegionName = ""; + private IPEndPoint m_internalEndPoint; + public IPEndPoint InternalEndPoint + { + get + { + return m_internalEndPoint; + } + } + + public IPEndPoint ExternalEndPoint + { + get + { + return new IPEndPoint( Dns.GetHostAddresses( m_externalHostName )[0], m_internalEndPoint.Port ); + } + } + + private string m_externalHostName; + public string ExternalHostName + { + get + { + return m_externalHostName; + } + } + private uint? m_regionLocX; public uint RegionLocX { @@ -81,43 +108,43 @@ namespace OpenSim.Framework.Types public string MasterAvatarLastName = ""; public string MasterAvatarSandboxPassword = ""; - private int? m_commsIPListenPort; + //private int? m_commsIPListenPort; - /// - /// Port used for listening (TCP and UDP) - /// - /// Seperate TCP and UDP - public int CommsIPListenPort - { - get - { - return m_commsIPListenPort.Value; - } - } - - private string m_commsIPListenAddr; - /// - /// Address used for internal listening (default: 0.0.0.0?) - /// - public string CommsIPListenAddr - { - get - { - return m_commsIPListenAddr; - } - } - - private string m_commsExternalAddress; - /// - /// Address used for external addressing (DNS or IP) - /// - public string CommsExternalAddress - { - get - { - return m_commsExternalAddress; - } - } + ///// + ///// Port used for listening (TCP and UDP) + ///// + ///// Seperate TCP and UDP + //public int CommsIPListenPort + //{ + // get + // { + // return m_commsIPListenPort.Value; + // } + //} + + //private string m_commsIPListenAddr; + ///// + ///// Address used for internal listening (default: 0.0.0.0?) + ///// + //public string CommsIPListenAddr + //{ + // get + // { + // return m_commsIPListenAddr; + // } + //} + + //private string m_commsExternalAddress; + ///// + ///// Address used for external addressing (DNS or IP) + ///// + //public string CommsExternalAddress + //{ + // get + // { + // return m_commsExternalAddress; + // } + //} public EstateSettings estateSettings; @@ -126,15 +153,19 @@ namespace OpenSim.Framework.Types { estateSettings = new EstateSettings(); } - - public RegionInfo( uint regionLocX, uint regionLocY, string simIp, int simPort, string simUri ) : this() + + public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) + : this() { m_regionLocX = regionLocX; - m_regionLocY = regionLocY; - - m_commsIPListenAddr = simIp; - m_commsIPListenPort = simPort; - m_commsExternalAddress = simUri; + m_regionLocY = regionLocY; + + //m_commsIPListenAddr = simIp; + //m_commsIPListenPort = simPort; + //m_commsExternalAddress = simUri; + + m_internalEndPoint = internalEndPoint; + m_externalHostName = externalUri; } public void InitConfig(bool sandboxMode, IGenericConfig configData) @@ -195,7 +226,7 @@ namespace OpenSim.Framework.Types } m_regionHandle = null; - + // Local storage datastore attri = ""; attri = configData.GetAttribute("Datastore"); @@ -210,71 +241,67 @@ namespace OpenSim.Framework.Types this.DataStore = attri; } - //Sim Listen Port - attri = ""; - attri = configData.GetAttribute("SimListenPort"); - if (attri == "") - { - string port = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("UDP port for client connections", "9000"); - configData.SetAttribute("SimListenPort", port); - m_commsIPListenPort = Convert.ToInt32(port); - } - else - { - m_commsIPListenPort = Convert.ToInt32(attri); - } + IPAddress internalAddress = GetIPAddress(configData, "InternalIPAddress", "0.0.0.0", "Internal IP Address for UDP client connections"); + int internalPort = GetIPPort(configData, "InternalIPPort", "9000", "Internal IP Port for UDP client connections"); + m_internalEndPoint = new IPEndPoint(internalAddress, internalPort); + + m_externalHostName = MainLog.Instance.CmdPrompt("External Host Name", "localhost"); + + + + //Sim Listen Address - attri = ""; - attri = configData.GetAttribute("SimListenAddress"); - if (attri == "") - { - m_commsIPListenAddr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP Address to listen on for client connections", "0.0.0.0"); - configData.SetAttribute("SimListenAddress", CommsIPListenAddr ); - } - else - { - // Probably belongs elsewhere, but oh well. - if (attri.Trim().StartsWith("SYSTEMIP")) - { - string localhostname = System.Net.Dns.GetHostName(); - System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(localhostname); - try - { - m_commsIPListenAddr = "0.0.0.0"; // Incase a IPv4 address isnt found - - foreach (System.Net.IPAddress ip in ips) - { - if (ip.AddressFamily.ToString() == System.Net.Sockets.ProtocolFamily.InterNetwork.ToString()) - { - m_commsIPListenAddr = ip.ToString(); - break; - } - } - } - catch (Exception) - { - m_commsIPListenAddr = "0.0.0.0"; // Use the default if we fail - } - } - else - { - m_commsIPListenAddr = attri; - } - } + //attri = ""; + //attri = configData.GetAttribute("SimListenAddress"); + //if (attri == "") + //{ + // m_commsIPListenAddr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP Address to listen on for client connections", "0.0.0.0"); + // configData.SetAttribute("SimListenAddress", CommsIPListenAddr); + //} + //else + //{ + // // Probably belongs elsewhere, but oh well. + // if (attri.Trim().StartsWith("SYSTEMIP")) + // { + // string localhostname = System.Net.Dns.GetHostName(); + // System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(localhostname); + // try + // { + // m_commsIPListenAddr = "0.0.0.0"; // Incase a IPv4 address isnt found - // Sim External Address - attri = ""; - attri = configData.GetAttribute("SimExternalAddress"); - if (attri == "") - { - m_commsExternalAddress = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP or DNS address to send external clients to", "localhost"); - configData.SetAttribute("SimExternalAddress", CommsExternalAddress); - } - else - { - m_commsExternalAddress = attri; - } + // foreach (System.Net.IPAddress ip in ips) + // { + // if (ip.AddressFamily.ToString() == System.Net.Sockets.ProtocolFamily.InterNetwork.ToString()) + // { + // m_commsIPListenAddr = ip.ToString(); + // break; + // } + // } + // } + // catch (Exception) + // { + // m_commsIPListenAddr = "0.0.0.0"; // Use the default if we fail + // } + // } + // else + // { + // m_commsIPListenAddr = attri; + // } + //} + + //// Sim External Address + //attri = ""; + //attri = configData.GetAttribute("SimExternalAddress"); + //if (attri == "") + //{ + // m_commsExternalAddress = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP or DNS address to send external clients to", "localhost"); + // configData.SetAttribute("SimExternalAddress", CommsExternalAddress); + //} + //else + //{ + // m_commsExternalAddress = attri; + //} attri = ""; attri = configData.GetAttribute("TerrainFile"); @@ -357,9 +384,38 @@ namespace OpenSim.Framework.Types OpenSim.Framework.Console.MainLog.Instance.Verbose("Name: " + this.RegionName); OpenSim.Framework.Console.MainLog.Instance.Verbose("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); OpenSim.Framework.Console.MainLog.Instance.Verbose("Region Handle: " + this.RegionHandle.ToString()); - OpenSim.Framework.Console.MainLog.Instance.Verbose("Listening on IP: " + this.CommsIPListenAddr + ":" + this.CommsIPListenPort); + OpenSim.Framework.Console.MainLog.Instance.Verbose("Listening on IP end point: " + m_internalEndPoint.ToString() ); OpenSim.Framework.Console.MainLog.Instance.Verbose("Sandbox Mode? " + isSandbox.ToString()); } + + private IPAddress GetIPAddress(IGenericConfig configData, string attrName, string defaultvalue, string prompt) + { + string addressStr = configData.GetAttribute(attrName); + + IPAddress address; + + if (!IPAddress.TryParse(addressStr, out address)) + { + address = MainLog.Instance.CmdPromptIPAddress(prompt, defaultvalue); + configData.SetAttribute(attrName, address.ToString()); + } + return address; + } + + private int GetIPPort(IGenericConfig configData, string attrName, string defaultvalue, string prompt) + { + string portStr = configData.GetAttribute(attrName); + + int port; + + if (!int.TryParse(portStr, out port)) + { + port = MainLog.Instance.CmdPromptIPPort(prompt, defaultvalue); + configData.SetAttribute(attrName, port.ToString()); + } + + return port; + } } } diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index fcb2493..32faed8 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -225,7 +225,7 @@ namespace OpenSim regionDat.InitConfig(this.m_sandbox, regionConfig); regionConfig.Close(); - udpServer = new UDPServer(regionDat.CommsIPListenPort, this.AssetCache, this.InventoryCache, this.m_log, authenBase); + udpServer = new UDPServer(regionDat.InternalEndPoint.Port, this.AssetCache, this.InventoryCache, this.m_log, authenBase); m_udpServer.Add(udpServer); this.regionData.Add(regionDat); diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index 416a6bc..2bbf656 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -44,8 +44,8 @@ namespace OpenSim.Region.Capabilities public class Caps { - private string httpListenerAddress; - private uint httpListenPort; + private string httpListenerHostName; + private int httpListenPort; private string capsObjectPath = "00001-"; private string requestPath = "0000/"; private string mapLayerPath = "0001/"; @@ -58,12 +58,12 @@ namespace OpenSim.Region.Capabilities private int eventQueueCount = 1; private Queue CapsEventQueue = new Queue(); - public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent) + public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent) { assetCache = assetCach; capsObjectPath = capsPath; httpListener = httpServer; - httpListenerAddress = httpListen; + httpListenerHostName = httpListen; httpListenPort = httpPort; agentID = agent; } @@ -109,8 +109,11 @@ namespace OpenSim.Region.Capabilities return capURLS;*/ LLSDCapsDetails caps = new LLSDCapsDetails(); - caps.MapLayer = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath; - caps.NewFileAgentInventory = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory; + string capsBaseUrl = "http://" + httpListenerHostName + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath; + + caps.MapLayer = capsBaseUrl + mapLayerPath; + caps.NewFileAgentInventory = capsBaseUrl + newInventory; + return caps; } @@ -206,7 +209,7 @@ namespace OpenSim.Region.Capabilities string uploaderPath = capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000"); AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); httpListener.AddRestHandler("POST", "/CAPS/" + uploaderPath, uploader.uploaderCaps); - string uploaderURL = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + uploaderPath; + string uploaderURL = "http://" + httpListenerHostName + ":" + httpListenPort.ToString() + "/CAPS/" + uploaderPath; //Console.WriteLine("uploader url is " + uploaderURL); res += ""; res += "uploader" + uploaderURL + ""; diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 9650b42..e683db2 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -34,6 +34,7 @@ using OpenSim.Framework.Types; using libsecondlife; using libsecondlife.Packets; +using System.Net; namespace OpenSim.Region.ClientStack { @@ -293,8 +294,11 @@ namespace OpenSim.Region.ClientStack /// /// /// - public void InformClientOfNeighbour(ulong neighbourHandle, System.Net.IPAddress neighbourIP, ushort neighbourPort) + public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint ) { + System.Net.IPAddress neighbourIP = neighbourEndPoint.Address; + ushort neighbourPort = (ushort) neighbourEndPoint.Port; + EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); enablesimpacket.SimulatorInfo.Handle = neighbourHandle; @@ -326,7 +330,7 @@ namespace OpenSim.Region.ClientStack return agentData; } - public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, System.Net.IPAddress newRegionIP, ushort newRegionPort) + public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint) { LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10); @@ -339,12 +343,12 @@ namespace OpenSim.Region.ClientStack newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! newSimPack.RegionData = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock(); newSimPack.RegionData.RegionHandle = newRegionHandle; - byte[] byteIP = newRegionIP.GetAddressBytes(); + byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; newSimPack.RegionData.SimIP += (uint)byteIP[0]; - newSimPack.RegionData.SimPort = newRegionPort; + newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port; newSimPack.RegionData.SeedCapability = new byte[0]; this.OutPacket(newSimPack); @@ -386,7 +390,7 @@ namespace OpenSim.Region.ClientStack OutPacket(tpLocal); } - public void SendRegionTeleport(ulong regionHandle, byte simAccess, string ipAddress, ushort ipPort, uint locationID, uint flags) + public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags) { TeleportFinishPacket teleport = new TeleportFinishPacket(); teleport.Info.AgentID = this.AgentID; @@ -394,7 +398,7 @@ namespace OpenSim.Region.ClientStack teleport.Info.SimAccess = simAccess; teleport.Info.SeedCapability = new byte[0]; - System.Net.IPAddress oIP = System.Net.IPAddress.Parse(ipAddress); + IPAddress oIP = newRegionEndPoint.Address; byte[] byteIP = oIP.GetAddressBytes(); uint ip = (uint)byteIP[3] << 24; ip += (uint)byteIP[2] << 16; @@ -402,7 +406,7 @@ namespace OpenSim.Region.ClientStack ip += (uint)byteIP[0]; teleport.Info.SimIP = ip; - teleport.Info.SimPort = ipPort; + teleport.Info.SimPort = (ushort)newRegionEndPoint.Port; teleport.Info.LocationID = 4; teleport.Info.TeleportFlags = 1 << 4; OutPacket(teleport); diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index ffd254e..6f20413 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -44,12 +44,10 @@ namespace OpenSim.Region.ClientStack private IWorld _localWorld; public Dictionary ClientThreads = new Dictionary(); public Dictionary ClientAPIs = new Dictionary(); - protected uint serverPort; - public PacketServer(ClientStackNetworkHandler networkHandler, uint port) + public PacketServer(ClientStackNetworkHandler networkHandler) { _networkHandler = networkHandler; - this.serverPort = port; _networkHandler.RegisterPacketServer(this); } diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index b764519..8ad5332 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -107,7 +107,7 @@ namespace OpenSim.Region.ClientStack protected virtual void CreatePacketServer() { - PacketServer packetServer = new PacketServer(this, (uint) listenPort); + PacketServer packetServer = new PacketServer(this); } protected virtual void OnReceivedData(IAsyncResult result) diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs index 5a2a5c8..db9d9b9 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs @@ -88,11 +88,11 @@ namespace OpenSim.Region.Communications.Local "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; string capsPath = Util.GetRandomCapsPath(); - response.SimAddress = reg.CommsExternalAddress; - response.SimPort = (Int32)reg.CommsIPListenPort; + response.SimAddress = reg.ExternalEndPoint.Address.ToString(); + response.SimPort = (Int32)reg.ExternalEndPoint.Port; response.RegionX = reg.RegionLocX ; response.RegionY = reg.RegionLocY ; - response.SeedCapability = "http://" + reg.CommsIPListenAddr + ":" + "9000" + "/CAPS/" + capsPath + "0000/"; + response.SeedCapability = "http://" + reg.ExternalHostName + ":" + reg.ExternalEndPoint.Port.ToString() + "/CAPS/" + capsPath + "0000/"; theUser.currentAgent.currentRegion = reg.SimUUID; theUser.currentAgent.currentHandle = reg.RegionHandle; diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 2ac7297..977b131 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -13,6 +13,7 @@ using OpenSim.Framework.Communications; using Nwc.XmlRpc; using libsecondlife; +using System.Net; namespace OpenSim.Region.Communications.OGS1 { @@ -32,13 +33,15 @@ namespace OpenSim.Region.Communications.OGS1 // Login / Authentication GridParams["authkey"] = gridInfo.GridServerSendKey; GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated(); - GridParams["sim_ip"] = regionInfo.CommsExternalAddress; - GridParams["sim_port"] = regionInfo.CommsIPListenPort.ToString(); + GridParams["sim_ip"] = regionInfo.InternalEndPoint.Address.ToString(); + GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); // Package into an XMLRPC Request ArrayList SendParams = new ArrayList(); SendParams.Add(GridParams); + + // Send Request XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); XmlRpcResponse GridResp = GridReq.Send(gridInfo.GridServerURI, 3000); @@ -56,7 +59,7 @@ namespace OpenSim.Region.Communications.OGS1 if (!this.listeners.ContainsKey(regionInfo.RegionHandle)) { // initialised = true; - httpListener = new BaseHttpServer(regionInfo.CommsIPListenPort); + httpListener = new BaseHttpServer( regionInfo.InternalEndPoint.Port ); httpListener.AddXmlRPCHandler("expect_user", this.ExpectUser); httpListener.Start(); } @@ -75,7 +78,14 @@ namespace OpenSim.Region.Communications.OGS1 foreach (Hashtable n in (Hashtable)respData.Values) { - RegionInfo neighbour = new RegionInfo( (uint)n["x"], (uint)n["y"], (string)n["sim_ip"], (int)n["sim_port"], (string)n["sim_uri"] ); + string internalIpStr = (string)n["sim_ip"]; + int port = (int)n["sim_port"]; + string externalUri = (string)n["sim_uri"]; + + IPEndPoint neighbourInternalEndPoint = new IPEndPoint( IPAddress.Parse( internalIpStr ), port); + string neighbourExternalUri = externalUri; + + RegionInfo neighbour = new RegionInfo((uint)n["x"], (uint)n["y"], neighbourInternalEndPoint, neighbourExternalUri ); //OGS1 //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d5406b6..dbf385d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -656,7 +656,7 @@ namespace OpenSim.Region.Environment.Scenes if (agent.CapsPath != "") { //Console.WriteLine("new user, so creating caps handler for it"); - Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.CommsIPListenAddr, 9000, agent.CapsPath, agent.AgentID); + Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.ExternalHostName, this.m_regInfo.ExternalEndPoint.Port, agent.CapsPath, agent.AgentID); cap.RegisterHandlers(); this.capsHandlers.Add(agent.AgentID, cap); } @@ -695,7 +695,7 @@ namespace OpenSim.Region.Environment.Scenes agent.startpos = new LLVector3(128, 128, 70); agent.child = true; this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent); - remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr), (ushort)neighbours[i].CommsIPListenPort); + remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint ); //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort); } } @@ -757,7 +757,7 @@ namespace OpenSim.Region.Environment.Scenes agent.child = true; this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position); - remoteClient.SendRegionTeleport(regionHandle, 13, reg.CommsIPListenAddr, (ushort)reg.CommsIPListenPort, 4, (1 << 4)); + remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4)); } //remoteClient.SendTeleportCancel(); } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index b90004e..8a8f5ae 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -481,7 +481,7 @@ namespace OpenSim.Region.Environment.Scenes if (res) { this.MakeChildAgent(); - this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, System.Net.IPAddress.Parse(neighbourRegion.CommsIPListenAddr), (ushort)neighbourRegion.CommsIPListenPort); + this.ControllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.InternalEndPoint ); } } } diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 0d5b4b3..f5c6999 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -15,6 +15,7 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Communications.Local; using OpenSim.Region.ClientStack; using OpenSim.Region.Physics.BasicPhysicsPlugin; +using System.Net; namespace SimpleApp { @@ -31,9 +32,8 @@ namespace SimpleApp // CheckSumServer checksumServer = new CheckSumServer(12036); // checksumServer.ServerListener(); - string simAddr = "127.0.0.1"; - int simPort = 9000; - + IPEndPoint internalEndPoint = new IPEndPoint( IPAddress.Parse( "127.0.0.1" ), 9000 ); + m_circuitManager = new AuthenticateSessionsBase(); InventoryCache inventoryCache = new InventoryCache(); @@ -44,8 +44,8 @@ namespace SimpleApp AssetCache assetCache = new AssetCache(assetServer); - UDPServer udpServer = new UDPServer(simPort, assetCache, inventoryCache, m_log, m_circuitManager ); - PacketServer packetServer = new PacketServer( udpServer, (uint) simPort ); + UDPServer udpServer = new UDPServer( internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager ); + PacketServer packetServer = new PacketServer(udpServer); udpServer.ServerListener(); ClientView.TerrainManager = new TerrainManager(new SecondLife()); @@ -53,9 +53,9 @@ namespace SimpleApp NetworkServersInfo serverInfo = new NetworkServersInfo(); CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo); - RegionInfo regionInfo = new RegionInfo( 1000, 1000, simAddr, simPort, simAddr ); - - BaseHttpServer httpServer = new BaseHttpServer(simPort); + RegionInfo regionInfo = new RegionInfo( 1000, 1000, internalEndPoint, "localhost" ); + + BaseHttpServer httpServer = new BaseHttpServer( internalEndPoint.Port ); MyWorld world = new MyWorld(packetServer.ClientAPIs, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer); world.PhysScene = new BasicScene(); udpServer.LocalWorld = world; -- cgit v1.1