MAJOR IP RESTRUCTURING

* moving towards IPEndPoints all over the place
* trying to make the internal/external division
Sugilite
lbsa71 2007-07-01 16:07:41 +00:00
parent 5e805656db
commit 06a8c13200
13 changed files with 270 additions and 154 deletions

View File

@ -27,6 +27,7 @@
*/ */
using System; using System;
using System.IO; using System.IO;
using System.Net;
namespace OpenSim.Framework.Console namespace OpenSim.Framework.Console
{ {
@ -48,18 +49,18 @@ namespace OpenSim.Framework.Console
public string componentname; public string componentname;
private bool m_silent; 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.componentname = componentname;
this.cmdparser = cmdparser; this.cmdparser = cmdparser;
this.m_silent = silent; this.m_silent = silent;
System.Console.WriteLine("ServerConsole.cs - creating new local console"); System.Console.WriteLine("ServerConsole.cs - creating new local console");
if( String.IsNullOrEmpty( LogFile ) ) if (String.IsNullOrEmpty(LogFile))
{ {
LogFile = componentname + ".log"; LogFile = componentname + ".log";
} }
System.Console.WriteLine("Logs will be saved to current directory in " + LogFile); System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
Log = File.AppendText(LogFile); Log = File.AppendText(LogFile);
Log.WriteLine("========================================================================"); Log.WriteLine("========================================================================");
@ -74,10 +75,10 @@ namespace OpenSim.Framework.Console
public void Write(string format, params object[] args) public void Write(string format, params object[] args)
{ {
Notice(format,args); Notice(format, args);
return; return;
} }
public void WriteLine(LogPriority importance, string format, params object[] args) public void WriteLine(LogPriority importance, string format, params object[] args)
{ {
Log.WriteLine(format, args); Log.WriteLine(format, args);
@ -154,6 +155,49 @@ namespace OpenSim.Framework.Console
return TempInt; 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 // Displays a prompt and waits for the user to enter a string, then returns that string
// Done with no echo and suitable for passwords // Done with no echo and suitable for passwords
public string PasswdPrompt(string prompt) 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 // Displays a command prompt and returns a default value if the user simply presses enter
public string CmdPrompt(string prompt, string defaultresponse) 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 == "") if (temp == "")
{ {
return defaultresponse; return defaultresponse;

View File

@ -32,6 +32,7 @@ using OpenSim.Framework.Inventory;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework.Types; using OpenSim.Framework.Types;
using System.Net;
namespace OpenSim.Framework.Interfaces namespace OpenSim.Framework.Interfaces
{ {
@ -143,12 +144,12 @@ namespace OpenSim.Framework.Interfaces
void SendLayerData(float[] map); void SendLayerData(float[] map);
void SendLayerData(int px, int py, float[] map); void SendLayerData(int px, int py, float[] map);
void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look); 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(); 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<MapBlockData> mapBlocks); void SendMapBlock(List<MapBlockData> mapBlocks);
void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags); 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 SendTeleportCancel();
void SendTeleportLocationStart(); void SendTeleportLocationStart();
void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance); void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance);

View File

@ -33,6 +33,7 @@ using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Utilities; using OpenSim.Framework.Utilities;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using libsecondlife; using libsecondlife;
using System.Net;
namespace OpenSim.Framework.Types namespace OpenSim.Framework.Types
{ {
@ -41,6 +42,32 @@ namespace OpenSim.Framework.Types
public LLUUID SimUUID = new LLUUID(); public LLUUID SimUUID = new LLUUID();
public string RegionName = ""; 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; private uint? m_regionLocX;
public uint RegionLocX public uint RegionLocX
{ {
@ -81,43 +108,43 @@ namespace OpenSim.Framework.Types
public string MasterAvatarLastName = ""; public string MasterAvatarLastName = "";
public string MasterAvatarSandboxPassword = ""; public string MasterAvatarSandboxPassword = "";
private int? m_commsIPListenPort; //private int? m_commsIPListenPort;
/// <summary> ///// <summary>
/// Port used for listening (TCP and UDP) ///// Port used for listening (TCP and UDP)
/// </summary> ///// </summary>
/// <remarks>Seperate TCP and UDP</remarks> ///// <remarks>Seperate TCP and UDP</remarks>
public int CommsIPListenPort //public int CommsIPListenPort
{ //{
get // get
{ // {
return m_commsIPListenPort.Value; // return m_commsIPListenPort.Value;
} // }
} //}
private string m_commsIPListenAddr; //private string m_commsIPListenAddr;
/// <summary> ///// <summary>
/// Address used for internal listening (default: 0.0.0.0?) ///// Address used for internal listening (default: 0.0.0.0?)
/// </summary> ///// </summary>
public string CommsIPListenAddr //public string CommsIPListenAddr
{ //{
get // get
{ // {
return m_commsIPListenAddr; // return m_commsIPListenAddr;
} // }
} //}
private string m_commsExternalAddress; //private string m_commsExternalAddress;
/// <summary> ///// <summary>
/// Address used for external addressing (DNS or IP) ///// Address used for external addressing (DNS or IP)
/// </summary> ///// </summary>
public string CommsExternalAddress //public string CommsExternalAddress
{ //{
get // get
{ // {
return m_commsExternalAddress; // return m_commsExternalAddress;
} // }
} //}
public EstateSettings estateSettings; public EstateSettings estateSettings;
@ -126,15 +153,19 @@ namespace OpenSim.Framework.Types
{ {
estateSettings = new EstateSettings(); 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_regionLocX = regionLocX;
m_regionLocY = regionLocY; m_regionLocY = regionLocY;
m_commsIPListenAddr = simIp; //m_commsIPListenAddr = simIp;
m_commsIPListenPort = simPort; //m_commsIPListenPort = simPort;
m_commsExternalAddress = simUri; //m_commsExternalAddress = simUri;
m_internalEndPoint = internalEndPoint;
m_externalHostName = externalUri;
} }
public void InitConfig(bool sandboxMode, IGenericConfig configData) public void InitConfig(bool sandboxMode, IGenericConfig configData)
@ -195,7 +226,7 @@ namespace OpenSim.Framework.Types
} }
m_regionHandle = null; m_regionHandle = null;
// Local storage datastore // Local storage datastore
attri = ""; attri = "";
attri = configData.GetAttribute("Datastore"); attri = configData.GetAttribute("Datastore");
@ -210,71 +241,67 @@ namespace OpenSim.Framework.Types
this.DataStore = attri; this.DataStore = attri;
} }
//Sim Listen Port IPAddress internalAddress = GetIPAddress(configData, "InternalIPAddress", "0.0.0.0", "Internal IP Address for UDP client connections");
attri = ""; int internalPort = GetIPPort(configData, "InternalIPPort", "9000", "Internal IP Port for UDP client connections");
attri = configData.GetAttribute("SimListenPort"); m_internalEndPoint = new IPEndPoint(internalAddress, internalPort);
if (attri == "")
{ m_externalHostName = MainLog.Instance.CmdPrompt("External Host Name", "localhost");
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);
}
//Sim Listen Address //Sim Listen Address
attri = ""; //attri = "";
attri = configData.GetAttribute("SimListenAddress"); //attri = configData.GetAttribute("SimListenAddress");
if (attri == "") //if (attri == "")
{ //{
m_commsIPListenAddr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP Address to listen on for client connections", "0.0.0.0"); // m_commsIPListenAddr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP Address to listen on for client connections", "0.0.0.0");
configData.SetAttribute("SimListenAddress", CommsIPListenAddr ); // configData.SetAttribute("SimListenAddress", CommsIPListenAddr);
} //}
else //else
{ //{
// Probably belongs elsewhere, but oh well. // // Probably belongs elsewhere, but oh well.
if (attri.Trim().StartsWith("SYSTEMIP")) // if (attri.Trim().StartsWith("SYSTEMIP"))
{ // {
string localhostname = System.Net.Dns.GetHostName(); // string localhostname = System.Net.Dns.GetHostName();
System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(localhostname); // System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(localhostname);
try // try
{ // {
m_commsIPListenAddr = "0.0.0.0"; // Incase a IPv4 address isnt found // m_commsIPListenAddr = "0.0.0.0"; // Incase a IPv4 address isnt found
foreach (System.Net.IPAddress ip in ips) // foreach (System.Net.IPAddress ip in ips)
{ // {
if (ip.AddressFamily.ToString() == System.Net.Sockets.ProtocolFamily.InterNetwork.ToString()) // if (ip.AddressFamily.ToString() == System.Net.Sockets.ProtocolFamily.InterNetwork.ToString())
{ // {
m_commsIPListenAddr = ip.ToString(); // m_commsIPListenAddr = ip.ToString();
break; // break;
} // }
} // }
} // }
catch (Exception) // catch (Exception)
{ // {
m_commsIPListenAddr = "0.0.0.0"; // Use the default if we fail // m_commsIPListenAddr = "0.0.0.0"; // Use the default if we fail
} // }
} // }
else // else
{ // {
m_commsIPListenAddr = attri; // m_commsIPListenAddr = attri;
} // }
} //}
// Sim External Address //// Sim External Address
attri = ""; //attri = "";
attri = configData.GetAttribute("SimExternalAddress"); //attri = configData.GetAttribute("SimExternalAddress");
if (attri == "") //if (attri == "")
{ //{
m_commsExternalAddress = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP or DNS address to send external clients to", "localhost"); // m_commsExternalAddress = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP or DNS address to send external clients to", "localhost");
configData.SetAttribute("SimExternalAddress", CommsExternalAddress); // configData.SetAttribute("SimExternalAddress", CommsExternalAddress);
} //}
else //else
{ //{
m_commsExternalAddress = attri; // m_commsExternalAddress = attri;
} //}
attri = ""; attri = "";
attri = configData.GetAttribute("TerrainFile"); 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("Name: " + this.RegionName);
OpenSim.Framework.Console.MainLog.Instance.Verbose("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); 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("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()); 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;
}
} }
} }

View File

@ -225,7 +225,7 @@ namespace OpenSim
regionDat.InitConfig(this.m_sandbox, regionConfig); regionDat.InitConfig(this.m_sandbox, regionConfig);
regionConfig.Close(); 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); m_udpServer.Add(udpServer);
this.regionData.Add(regionDat); this.regionData.Add(regionDat);

View File

@ -44,8 +44,8 @@ namespace OpenSim.Region.Capabilities
public class Caps public class Caps
{ {
private string httpListenerAddress; private string httpListenerHostName;
private uint httpListenPort; private int httpListenPort;
private string capsObjectPath = "00001-"; private string capsObjectPath = "00001-";
private string requestPath = "0000/"; private string requestPath = "0000/";
private string mapLayerPath = "0001/"; private string mapLayerPath = "0001/";
@ -58,12 +58,12 @@ namespace OpenSim.Region.Capabilities
private int eventQueueCount = 1; private int eventQueueCount = 1;
private Queue<string> CapsEventQueue = new Queue<string>(); private Queue<string> CapsEventQueue = new Queue<string>();
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; assetCache = assetCach;
capsObjectPath = capsPath; capsObjectPath = capsPath;
httpListener = httpServer; httpListener = httpServer;
httpListenerAddress = httpListen; httpListenerHostName = httpListen;
httpListenPort = httpPort; httpListenPort = httpPort;
agentID = agent; agentID = agent;
} }
@ -109,8 +109,11 @@ namespace OpenSim.Region.Capabilities
return capURLS;*/ return capURLS;*/
LLSDCapsDetails caps = new LLSDCapsDetails(); LLSDCapsDetails caps = new LLSDCapsDetails();
caps.MapLayer = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + mapLayerPath; string capsBaseUrl = "http://" + httpListenerHostName + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath;
caps.NewFileAgentInventory = "http://" + httpListenerAddress + ":" + httpListenPort.ToString() + "/CAPS/" + capsObjectPath + newInventory;
caps.MapLayer = capsBaseUrl + mapLayerPath;
caps.NewFileAgentInventory = capsBaseUrl + newInventory;
return caps; return caps;
} }
@ -206,7 +209,7 @@ namespace OpenSim.Region.Capabilities
string uploaderPath = capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000"); string uploaderPath = capsObjectPath + Util.RandomClass.Next(5000, 8000).ToString("0000");
AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener); AssetUploader uploader = new AssetUploader(newAsset, newInvItem, uploaderPath, this.httpListener);
httpListener.AddRestHandler("POST", "/CAPS/" + uploaderPath, uploader.uploaderCaps); 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); //Console.WriteLine("uploader url is " + uploaderURL);
res += "<llsd><map>"; res += "<llsd><map>";
res += "<key>uploader</key><string>" + uploaderURL + "</string>"; res += "<key>uploader</key><string>" + uploaderURL + "</string>";

View File

@ -34,6 +34,7 @@ using OpenSim.Framework.Types;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using System.Net;
namespace OpenSim.Region.ClientStack namespace OpenSim.Region.ClientStack
{ {
@ -293,8 +294,11 @@ namespace OpenSim.Region.ClientStack
/// <param name="neighbourHandle"></param> /// <param name="neighbourHandle"></param>
/// <param name="neighbourIP"></param> /// <param name="neighbourIP"></param>
/// <param name="neighbourPort"></param> /// <param name="neighbourPort"></param>
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(); EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
enablesimpacket.SimulatorInfo.Handle = neighbourHandle; enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
@ -326,7 +330,7 @@ namespace OpenSim.Region.ClientStack
return agentData; 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); 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.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 = new libsecondlife.Packets.CrossedRegionPacket.RegionDataBlock();
newSimPack.RegionData.RegionHandle = newRegionHandle; 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[3] << 24;
newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
newSimPack.RegionData.SimIP += (uint)byteIP[0]; newSimPack.RegionData.SimIP += (uint)byteIP[0];
newSimPack.RegionData.SimPort = newRegionPort; newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
newSimPack.RegionData.SeedCapability = new byte[0]; newSimPack.RegionData.SeedCapability = new byte[0];
this.OutPacket(newSimPack); this.OutPacket(newSimPack);
@ -386,7 +390,7 @@ namespace OpenSim.Region.ClientStack
OutPacket(tpLocal); 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(); TeleportFinishPacket teleport = new TeleportFinishPacket();
teleport.Info.AgentID = this.AgentID; teleport.Info.AgentID = this.AgentID;
@ -394,7 +398,7 @@ namespace OpenSim.Region.ClientStack
teleport.Info.SimAccess = simAccess; teleport.Info.SimAccess = simAccess;
teleport.Info.SeedCapability = new byte[0]; teleport.Info.SeedCapability = new byte[0];
System.Net.IPAddress oIP = System.Net.IPAddress.Parse(ipAddress); IPAddress oIP = newRegionEndPoint.Address;
byte[] byteIP = oIP.GetAddressBytes(); byte[] byteIP = oIP.GetAddressBytes();
uint ip = (uint)byteIP[3] << 24; uint ip = (uint)byteIP[3] << 24;
ip += (uint)byteIP[2] << 16; ip += (uint)byteIP[2] << 16;
@ -402,7 +406,7 @@ namespace OpenSim.Region.ClientStack
ip += (uint)byteIP[0]; ip += (uint)byteIP[0];
teleport.Info.SimIP = ip; teleport.Info.SimIP = ip;
teleport.Info.SimPort = ipPort; teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
teleport.Info.LocationID = 4; teleport.Info.LocationID = 4;
teleport.Info.TeleportFlags = 1 << 4; teleport.Info.TeleportFlags = 1 << 4;
OutPacket(teleport); OutPacket(teleport);

View File

@ -44,12 +44,10 @@ namespace OpenSim.Region.ClientStack
private IWorld _localWorld; private IWorld _localWorld;
public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>(); public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
public Dictionary<uint, IClientAPI> ClientAPIs = new Dictionary<uint, IClientAPI>(); public Dictionary<uint, IClientAPI> ClientAPIs = new Dictionary<uint, IClientAPI>();
protected uint serverPort;
public PacketServer(ClientStackNetworkHandler networkHandler, uint port) public PacketServer(ClientStackNetworkHandler networkHandler)
{ {
_networkHandler = networkHandler; _networkHandler = networkHandler;
this.serverPort = port;
_networkHandler.RegisterPacketServer(this); _networkHandler.RegisterPacketServer(this);
} }

View File

@ -107,7 +107,7 @@ namespace OpenSim.Region.ClientStack
protected virtual void CreatePacketServer() protected virtual void CreatePacketServer()
{ {
PacketServer packetServer = new PacketServer(this, (uint) listenPort); PacketServer packetServer = new PacketServer(this);
} }
protected virtual void OnReceivedData(IAsyncResult result) protected virtual void OnReceivedData(IAsyncResult result)

View File

@ -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() + "], " + "'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() + "]}"; "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
string capsPath = Util.GetRandomCapsPath(); string capsPath = Util.GetRandomCapsPath();
response.SimAddress = reg.CommsExternalAddress; response.SimAddress = reg.ExternalEndPoint.Address.ToString();
response.SimPort = (Int32)reg.CommsIPListenPort; response.SimPort = (Int32)reg.ExternalEndPoint.Port;
response.RegionX = reg.RegionLocX ; response.RegionX = reg.RegionLocX ;
response.RegionY = reg.RegionLocY ; 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.currentRegion = reg.SimUUID;
theUser.currentAgent.currentHandle = reg.RegionHandle; theUser.currentAgent.currentHandle = reg.RegionHandle;

View File

@ -13,6 +13,7 @@ using OpenSim.Framework.Communications;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using libsecondlife; using libsecondlife;
using System.Net;
namespace OpenSim.Region.Communications.OGS1 namespace OpenSim.Region.Communications.OGS1
{ {
@ -32,13 +33,15 @@ namespace OpenSim.Region.Communications.OGS1
// Login / Authentication // Login / Authentication
GridParams["authkey"] = gridInfo.GridServerSendKey; GridParams["authkey"] = gridInfo.GridServerSendKey;
GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated(); GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated();
GridParams["sim_ip"] = regionInfo.CommsExternalAddress; GridParams["sim_ip"] = regionInfo.InternalEndPoint.Address.ToString();
GridParams["sim_port"] = regionInfo.CommsIPListenPort.ToString(); GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString();
// Package into an XMLRPC Request // Package into an XMLRPC Request
ArrayList SendParams = new ArrayList(); ArrayList SendParams = new ArrayList();
SendParams.Add(GridParams); SendParams.Add(GridParams);
// Send Request // Send Request
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
XmlRpcResponse GridResp = GridReq.Send(gridInfo.GridServerURI, 3000); XmlRpcResponse GridResp = GridReq.Send(gridInfo.GridServerURI, 3000);
@ -56,7 +59,7 @@ namespace OpenSim.Region.Communications.OGS1
if (!this.listeners.ContainsKey(regionInfo.RegionHandle)) if (!this.listeners.ContainsKey(regionInfo.RegionHandle))
{ {
// initialised = true; // initialised = true;
httpListener = new BaseHttpServer(regionInfo.CommsIPListenPort); httpListener = new BaseHttpServer( regionInfo.InternalEndPoint.Port );
httpListener.AddXmlRPCHandler("expect_user", this.ExpectUser); httpListener.AddXmlRPCHandler("expect_user", this.ExpectUser);
httpListener.Start(); httpListener.Start();
} }
@ -75,7 +78,14 @@ namespace OpenSim.Region.Communications.OGS1
foreach (Hashtable n in (Hashtable)respData.Values) 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 //OGS1
//neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally

View File

@ -656,7 +656,7 @@ namespace OpenSim.Region.Environment.Scenes
if (agent.CapsPath != "") if (agent.CapsPath != "")
{ {
//Console.WriteLine("new user, so creating caps handler for it"); //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(); cap.RegisterHandlers();
this.capsHandlers.Add(agent.AgentID, cap); this.capsHandlers.Add(agent.AgentID, cap);
} }
@ -695,7 +695,7 @@ namespace OpenSim.Region.Environment.Scenes
agent.startpos = new LLVector3(128, 128, 70); agent.startpos = new LLVector3(128, 128, 70);
agent.child = true; agent.child = true;
this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent); 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); //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; agent.child = true;
this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position); 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(); //remoteClient.SendTeleportCancel();
} }

View File

@ -481,7 +481,7 @@ namespace OpenSim.Region.Environment.Scenes
if (res) if (res)
{ {
this.MakeChildAgent(); 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 );
} }
} }
} }

View File

@ -15,6 +15,7 @@ using OpenSim.Framework.Communications;
using OpenSim.Region.Communications.Local; using OpenSim.Region.Communications.Local;
using OpenSim.Region.ClientStack; using OpenSim.Region.ClientStack;
using OpenSim.Region.Physics.BasicPhysicsPlugin; using OpenSim.Region.Physics.BasicPhysicsPlugin;
using System.Net;
namespace SimpleApp namespace SimpleApp
{ {
@ -31,9 +32,8 @@ namespace SimpleApp
// CheckSumServer checksumServer = new CheckSumServer(12036); // CheckSumServer checksumServer = new CheckSumServer(12036);
// checksumServer.ServerListener(); // checksumServer.ServerListener();
string simAddr = "127.0.0.1"; IPEndPoint internalEndPoint = new IPEndPoint( IPAddress.Parse( "127.0.0.1" ), 9000 );
int simPort = 9000;
m_circuitManager = new AuthenticateSessionsBase(); m_circuitManager = new AuthenticateSessionsBase();
InventoryCache inventoryCache = new InventoryCache(); InventoryCache inventoryCache = new InventoryCache();
@ -44,8 +44,8 @@ namespace SimpleApp
AssetCache assetCache = new AssetCache(assetServer); AssetCache assetCache = new AssetCache(assetServer);
UDPServer udpServer = new UDPServer(simPort, assetCache, inventoryCache, m_log, m_circuitManager ); UDPServer udpServer = new UDPServer( internalEndPoint.Port, assetCache, inventoryCache, m_log, m_circuitManager );
PacketServer packetServer = new PacketServer( udpServer, (uint) simPort ); PacketServer packetServer = new PacketServer(udpServer);
udpServer.ServerListener(); udpServer.ServerListener();
ClientView.TerrainManager = new TerrainManager(new SecondLife()); ClientView.TerrainManager = new TerrainManager(new SecondLife());
@ -53,9 +53,9 @@ namespace SimpleApp
NetworkServersInfo serverInfo = new NetworkServersInfo(); NetworkServersInfo serverInfo = new NetworkServersInfo();
CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo); CommunicationsLocal communicationsManager = new CommunicationsLocal(serverInfo);
RegionInfo regionInfo = new RegionInfo( 1000, 1000, simAddr, simPort, simAddr ); RegionInfo regionInfo = new RegionInfo( 1000, 1000, internalEndPoint, "localhost" );
BaseHttpServer httpServer = new BaseHttpServer(simPort); BaseHttpServer httpServer = new BaseHttpServer( internalEndPoint.Port );
MyWorld world = new MyWorld(packetServer.ClientAPIs, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer); MyWorld world = new MyWorld(packetServer.ClientAPIs, regionInfo, m_circuitManager, communicationsManager, assetCache, httpServer);
world.PhysScene = new BasicScene(); world.PhysScene = new BasicScene();
udpServer.LocalWorld = world; udpServer.LocalWorld = world;