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/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 +- .../Region/Communications/Local/LocalUserServices.cs | 6 +++--- OpenSim/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 ++++++++-------- 10 files changed, 53 insertions(+), 38 deletions(-) (limited to 'OpenSim/Region') 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