aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMW2007-05-19 14:34:44 +0000
committerMW2007-05-19 14:34:44 +0000
commitdf6ec3ba6c47bb55b9c3ba011c3e2e58177f9109 (patch)
tree6f0cf235e93c0033cfcffef216f14edb77f188ff
parentMoved CheckSumServer (and added UDPServerBase ) to OpenSim.Servers (diff)
downloadopensim-SC-df6ec3ba6c47bb55b9c3ba011c3e2e58177f9109.zip
opensim-SC-df6ec3ba6c47bb55b9c3ba011c3e2e58177f9109.tar.gz
opensim-SC-df6ec3ba6c47bb55b9c3ba011c3e2e58177f9109.tar.bz2
opensim-SC-df6ec3ba6c47bb55b9c3ba011c3e2e58177f9109.tar.xz
Added the echo method for template checksum handling (idea from Hegemons_Login_Analysis page) to the CheckSumServer, but currently it is comment out as enabling it would mean that any version of client could connect which is very likely to lead to problem with pre 1.15 version clients.
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/CheckSumServer.cs120
-rw-r--r--OpenSim.Servers/CheckSumServer.cs29
-rw-r--r--OpenSim.Servers/UDPServerBase.cs3
3 files changed, 26 insertions, 126 deletions
diff --git a/OpenSim.RegionServer/CheckSumServer.cs b/OpenSim.RegionServer/CheckSumServer.cs
deleted file mode 100644
index 353383a..0000000
--- a/OpenSim.RegionServer/CheckSumServer.cs
+++ /dev/null
@@ -1,120 +0,0 @@
1using System;
2using System.Text;
3using System.IO;
4using System.Threading;
5using System.Net;
6using System.Net.Sockets;
7using System.Timers;
8using System.Reflection;
9using System.Collections;
10using System.Collections.Generic;
11using libsecondlife;
12using libsecondlife.Packets;
13using OpenSim.world;
14using OpenSim.Terrain;
15using OpenSim.Framework.Interfaces;
16using OpenSim.Framework.Types;
17using OpenSim.UserServer;
18using OpenSim.Assets;
19using OpenSim.CAPS;
20using OpenSim.Framework.Console;
21using Nwc.XmlRpc;
22using OpenSim.Servers;
23using OpenSim.GenericConfig;
24
25
26namespace OpenSim
27{
28 public class CheckSumServer : UDPServer
29 {
30 public CheckSumServer(int port, ConsoleBase console)
31 {
32 listenPort = port;
33 this.m_console = console;
34 }
35
36 protected override void CreatePacketServer()
37 {
38
39 }
40
41 public override void RegisterPacketServer(PacketServer server)
42 {
43
44 }
45
46 protected override void OnReceivedData(IAsyncResult result)
47 {
48 ipeSender = new IPEndPoint(IPAddress.Any, 0);
49 epSender = (EndPoint)ipeSender;
50 Packet packet = null;
51 int numBytes = Server.EndReceiveFrom(result, ref epSender);
52 int packetEnd = numBytes - 1;
53
54 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
55
56 // do we already have a circuit for this endpoint
57 if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
58 {
59 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
60 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
61 checkreply.DataBlock.Checksum = 180572585;
62 checkreply.DataBlock.Flags = 0;
63 checkreply.DataBlock.MajorVersion = 1;
64 checkreply.DataBlock.MinorVersion = 15;
65 checkreply.DataBlock.PatchVersion = 0;
66 checkreply.DataBlock.ServerVersion = 2;
67 checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
68 this.SendPacket(checkreply, epSender);
69
70 }
71 else
72 { // invalid client
73 // Console.Error.WriteLine("CheckSumServer.cs:OnReceivedData() - WARNING: Got a invalid packet from an invalid client - " + epSender.ToString());
74 }
75
76 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
77 }
78
79 protected override void AddNewClient(Packet packet)
80 {
81 }
82
83 private void SendPacket(Packet Pack, EndPoint endp)
84 {
85 if (!Pack.Header.Resent)
86 {
87 // Set the sequence number
88
89 Pack.Header.Sequence = 1;
90
91 }
92 byte[] ZeroOutBuffer = new byte[4096];
93 byte[] sendbuffer;
94 sendbuffer = Pack.ToBytes();
95
96 try
97 {
98 if (Pack.Header.Zerocoded)
99 {
100 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
101 this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
102 }
103 else
104 {
105 this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
106 }
107 }
108 catch (Exception)
109 {
110 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " );
111
112 }
113 }
114
115 private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
116 {
117 this.Server.SendTo(buffer, size, flags, endp);
118 }
119 }
120}
diff --git a/OpenSim.Servers/CheckSumServer.cs b/OpenSim.Servers/CheckSumServer.cs
index dc83192..2f79b7a 100644
--- a/OpenSim.Servers/CheckSumServer.cs
+++ b/OpenSim.Servers/CheckSumServer.cs
@@ -38,21 +38,42 @@ namespace OpenSim.Servers
38 // do we already have a circuit for this endpoint 38 // do we already have a circuit for this endpoint
39 if (packet.Type == PacketType.SecuredTemplateChecksumRequest) 39 if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
40 { 40 {
41
41 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet; 42 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
42 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket(); 43 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
43 checkreply.DataBlock.Checksum = 180572585; 44 checkreply.DataBlock.Checksum = 180572585;
44 checkreply.DataBlock.Flags = 0; 45 checkreply.DataBlock.Flags = 0;
45 checkreply.DataBlock.MajorVersion = 1; 46 checkreply.DataBlock.MajorVersion = 1;
46 checkreply.DataBlock.MinorVersion = 15; 47 checkreply.DataBlock.MinorVersion = 15;
47 checkreply.DataBlock.PatchVersion = 0; 48 checkreply.DataBlock.PatchVersion = 0;
48 checkreply.DataBlock.ServerVersion = 2; 49 checkreply.DataBlock.ServerVersion = 0;
49 checkreply.TokenBlock.Token = checksum.TokenBlock.Token; 50 checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
50 this.SendPacket(checkreply, epSender); 51 this.SendPacket(checkreply, epSender);
51 52
53 /*
54 //if we wanted to echo the the checksum/ version from the client (so that any client worked)
55 SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket();
56 checkrequest.TokenBlock.Token = checksum.TokenBlock.Token;
57 this.SendPacket(checkrequest, epSender);
58 */
59
60 }
61 else if (packet.Type == PacketType.TemplateChecksumReply)
62 {
63 TemplateChecksumReplyPacket checksum = (TemplateChecksumReplyPacket)packet;
64 TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket();
65 checkreply2.DataBlock.Checksum = checksum.DataBlock.Checksum;
66 checkreply2.DataBlock.Flags = checksum.DataBlock.Flags;
67 checkreply2.DataBlock.MajorVersion = checksum.DataBlock.MajorVersion;
68 checkreply2.DataBlock.MinorVersion = checksum.DataBlock.MinorVersion;
69 checkreply2.DataBlock.PatchVersion = checksum.DataBlock.PatchVersion;
70 checkreply2.DataBlock.ServerVersion = checksum.DataBlock.ServerVersion;
71 checkreply2.TokenBlock.Token = checksum.TokenBlock.Token;
72 this.SendPacket(checkreply2, epSender);
73
52 } 74 }
53 else 75 else
54 { // invalid client 76 {
55 // Console.Error.WriteLine("CheckSumServer.cs:OnReceivedData() - WARNING: Got a invalid packet from an invalid client - " + epSender.ToString());
56 } 77 }
57 78
58 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 79 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
diff --git a/OpenSim.Servers/UDPServerBase.cs b/OpenSim.Servers/UDPServerBase.cs
index bdbc772..e7feb01 100644
--- a/OpenSim.Servers/UDPServerBase.cs
+++ b/OpenSim.Servers/UDPServerBase.cs
@@ -15,7 +15,6 @@ namespace OpenSim.Servers
15{ 15{
16 public class UDPServerBase 16 public class UDPServerBase
17 { 17 {
18
19 public Socket Server; 18 public Socket Server;
20 protected IPEndPoint ServerIncoming; 19 protected IPEndPoint ServerIncoming;
21 protected byte[] RecvBuffer = new byte[4096]; 20 protected byte[] RecvBuffer = new byte[4096];
@@ -48,7 +47,7 @@ namespace OpenSim.Servers
48 { 47 {
49 } 48 }
50 49
51 public void ServerListener() 50 public virtual void ServerListener()
52 { 51 {
53 52
54 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort); 53 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);