From 42c45a87167a7aeb55d5c813a1b1cb8e0cc8a6dc Mon Sep 17 00:00:00 2001 From: MW Date: Sat, 19 May 2007 13:28:31 +0000 Subject: Added a CheckSumServer (handles template checksum , so there is no longer the need to connect to LL userserver). Currently onlt active in sandbox mode (someone simple needs to add "CheckSumServer checkserver = new CheckSumServer(12036, m_console);" to the grid userserver). Then when starting up the SL client add " -user localhost" (or whatever the IP address that the sim or grid userserver is at) to the command line --- OpenSim.RegionServer/CheckSumServer.cs | 120 +++++++++++++++++++++++ OpenSim.RegionServer/OpenSim.RegionServer.csproj | 51 ++++++---- OpenSim.RegionServer/UDPServer.cs | 12 ++- 3 files changed, 158 insertions(+), 25 deletions(-) create mode 100644 OpenSim.RegionServer/CheckSumServer.cs (limited to 'OpenSim.RegionServer') diff --git a/OpenSim.RegionServer/CheckSumServer.cs b/OpenSim.RegionServer/CheckSumServer.cs new file mode 100644 index 0000000..353383a --- /dev/null +++ b/OpenSim.RegionServer/CheckSumServer.cs @@ -0,0 +1,120 @@ +using System; +using System.Text; +using System.IO; +using System.Threading; +using System.Net; +using System.Net.Sockets; +using System.Timers; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.world; +using OpenSim.Terrain; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.UserServer; +using OpenSim.Assets; +using OpenSim.CAPS; +using OpenSim.Framework.Console; +using Nwc.XmlRpc; +using OpenSim.Servers; +using OpenSim.GenericConfig; + + +namespace OpenSim +{ + public class CheckSumServer : UDPServer + { + public CheckSumServer(int port, ConsoleBase console) + { + listenPort = port; + this.m_console = console; + } + + protected override void CreatePacketServer() + { + + } + + public override void RegisterPacketServer(PacketServer server) + { + + } + + protected override void OnReceivedData(IAsyncResult result) + { + ipeSender = new IPEndPoint(IPAddress.Any, 0); + epSender = (EndPoint)ipeSender; + Packet packet = null; + int numBytes = Server.EndReceiveFrom(result, ref epSender); + int packetEnd = numBytes - 1; + + packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); + + // do we already have a circuit for this endpoint + if (packet.Type == PacketType.SecuredTemplateChecksumRequest) + { + SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet; + TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket(); + checkreply.DataBlock.Checksum = 180572585; + checkreply.DataBlock.Flags = 0; + checkreply.DataBlock.MajorVersion = 1; + checkreply.DataBlock.MinorVersion = 15; + checkreply.DataBlock.PatchVersion = 0; + checkreply.DataBlock.ServerVersion = 2; + checkreply.TokenBlock.Token = checksum.TokenBlock.Token; + this.SendPacket(checkreply, epSender); + + } + else + { // invalid client + // Console.Error.WriteLine("CheckSumServer.cs:OnReceivedData() - WARNING: Got a invalid packet from an invalid client - " + epSender.ToString()); + } + + Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); + } + + protected override void AddNewClient(Packet packet) + { + } + + private void SendPacket(Packet Pack, EndPoint endp) + { + if (!Pack.Header.Resent) + { + // Set the sequence number + + Pack.Header.Sequence = 1; + + } + byte[] ZeroOutBuffer = new byte[4096]; + byte[] sendbuffer; + sendbuffer = Pack.ToBytes(); + + try + { + if (Pack.Header.Zerocoded) + { + int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); + this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp); + } + else + { + this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp); + } + } + catch (Exception) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " ); + + } + } + + private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp) + { + this.Server.SendTo(buffer, size, flags, endp); + } + } +} diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj index 93285b4..5b586fa 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {632E1BFD-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenSim.RegionServer @@ -15,9 +16,11 @@ IE50 false Library - + + OpenSim.RegionServer - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,26 +61,28 @@ False False 4 - + + - + System.dll False - + + System.Xml.dll False - + ..\bin\libsecondlife.dll False - + ..\bin\Axiom.MathLib.dll False - + ..\bin\Db4objects.Db4o.dll False @@ -84,43 +92,43 @@ OpenSim.Terrain.BasicTerrain {2270B8FE-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Framework {8ACA2445-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Framework.Console {A7CD0630-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.GenericConfig.Xml {E88EF749-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Physics.Manager {8BE16150-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Servers {8BB20F0A-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False XMLRPC {8E81D43C-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False @@ -136,6 +144,7 @@ Code + Code @@ -255,4 +264,4 @@ - + \ No newline at end of file diff --git a/OpenSim.RegionServer/UDPServer.cs b/OpenSim.RegionServer/UDPServer.cs index 5c41485..0bab05a 100644 --- a/OpenSim.RegionServer/UDPServer.cs +++ b/OpenSim.RegionServer/UDPServer.cs @@ -72,7 +72,11 @@ namespace OpenSim } } - public UDPServer(int port, Grid gridServers, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, bool sandbox, bool accounts, ConsoleBase console , AuthenticateSessionsBase authenticateClass) + public UDPServer() + { + } + + public UDPServer(int port, Grid gridServers, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, bool sandbox, bool accounts, ConsoleBase console, AuthenticateSessionsBase authenticateClass) { listenPort = port; this.m_gridServers = gridServers; @@ -84,7 +88,7 @@ namespace OpenSim this.m_console = console; this.m_authenticateSessionsClass = authenticateClass; this.CreatePacketServer(); - + //set up delegate for authenticate sessions this.AuthenticateHandler = new AuthenticateSessionHandler(this.m_authenticateSessionsClass.AuthenticateSession); } @@ -145,7 +149,7 @@ namespace OpenSim ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort); Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Server.Bind(ServerIncoming); - + m_console.WriteLine("UDPServer.cs:ServerListener() - UDP socket bound, getting ready to listen"); ipeSender = new IPEndPoint(IPAddress.Any, 0); @@ -195,7 +199,7 @@ namespace OpenSim public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) { - return this.AuthenticateHandler(sessionID, agentID, circuitCode); + return this.AuthenticateHandler(sessionID, agentID, circuitCode); } } } \ No newline at end of file -- cgit v1.1