diff options
Moved CheckSumServer (and added UDPServerBase ) to OpenSim.Servers
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/OpenSim.RegionServer.csproj | 1 | ||||
-rw-r--r-- | OpenSim.Servers/CheckSumServer.cs | 99 | ||||
-rw-r--r-- | OpenSim.Servers/OpenSim.Servers.csproj | 40 | ||||
-rw-r--r-- | OpenSim.Servers/OpenSim.Servers.dll.build | 2 | ||||
-rw-r--r-- | OpenSim.Servers/UDPServerBase.cs | 74 |
5 files changed, 200 insertions, 16 deletions
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj index 5b586fa..e736d04 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj | |||
@@ -144,7 +144,6 @@ | |||
144 | <Compile Include="AuthenticateSessionsRemote.cs"> | 144 | <Compile Include="AuthenticateSessionsRemote.cs"> |
145 | <SubType>Code</SubType> | 145 | <SubType>Code</SubType> |
146 | </Compile> | 146 | </Compile> |
147 | <Compile Include="CheckSumServer.cs" /> | ||
148 | <Compile Include="Grid.cs"> | 147 | <Compile Include="Grid.cs"> |
149 | <SubType>Code</SubType> | 148 | <SubType>Code</SubType> |
150 | </Compile> | 149 | </Compile> |
diff --git a/OpenSim.Servers/CheckSumServer.cs b/OpenSim.Servers/CheckSumServer.cs new file mode 100644 index 0000000..dc83192 --- /dev/null +++ b/OpenSim.Servers/CheckSumServer.cs | |||
@@ -0,0 +1,99 @@ | |||
1 | using System; | ||
2 | using System.Text; | ||
3 | using System.IO; | ||
4 | using System.Threading; | ||
5 | using System.Net; | ||
6 | using System.Net.Sockets; | ||
7 | using System.Timers; | ||
8 | using System.Reflection; | ||
9 | using System.Collections; | ||
10 | using System.Collections.Generic; | ||
11 | using libsecondlife; | ||
12 | using libsecondlife.Packets; | ||
13 | using OpenSim.Framework.Console; | ||
14 | |||
15 | |||
16 | namespace OpenSim.Servers | ||
17 | { | ||
18 | public class CheckSumServer : UDPServerBase | ||
19 | { | ||
20 | protected ConsoleBase m_console; | ||
21 | |||
22 | public CheckSumServer(int port, ConsoleBase console) | ||
23 | { | ||
24 | listenPort = port; | ||
25 | this.m_console = console; | ||
26 | } | ||
27 | |||
28 | protected override void OnReceivedData(IAsyncResult result) | ||
29 | { | ||
30 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
31 | epSender = (EndPoint)ipeSender; | ||
32 | Packet packet = null; | ||
33 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | ||
34 | int packetEnd = numBytes - 1; | ||
35 | |||
36 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | ||
37 | |||
38 | // do we already have a circuit for this endpoint | ||
39 | if (packet.Type == PacketType.SecuredTemplateChecksumRequest) | ||
40 | { | ||
41 | SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet; | ||
42 | TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket(); | ||
43 | checkreply.DataBlock.Checksum = 180572585; | ||
44 | checkreply.DataBlock.Flags = 0; | ||
45 | checkreply.DataBlock.MajorVersion = 1; | ||
46 | checkreply.DataBlock.MinorVersion = 15; | ||
47 | checkreply.DataBlock.PatchVersion = 0; | ||
48 | checkreply.DataBlock.ServerVersion = 2; | ||
49 | checkreply.TokenBlock.Token = checksum.TokenBlock.Token; | ||
50 | this.SendPacket(checkreply, epSender); | ||
51 | |||
52 | } | ||
53 | else | ||
54 | { // invalid client | ||
55 | // Console.Error.WriteLine("CheckSumServer.cs:OnReceivedData() - WARNING: Got a invalid packet from an invalid client - " + epSender.ToString()); | ||
56 | } | ||
57 | |||
58 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
59 | } | ||
60 | |||
61 | |||
62 | private void SendPacket(Packet Pack, EndPoint endp) | ||
63 | { | ||
64 | if (!Pack.Header.Resent) | ||
65 | { | ||
66 | // Set the sequence number | ||
67 | |||
68 | Pack.Header.Sequence = 1; | ||
69 | |||
70 | } | ||
71 | byte[] ZeroOutBuffer = new byte[4096]; | ||
72 | byte[] sendbuffer; | ||
73 | sendbuffer = Pack.ToBytes(); | ||
74 | |||
75 | try | ||
76 | { | ||
77 | if (Pack.Header.Zerocoded) | ||
78 | { | ||
79 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | ||
80 | this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp); | ||
81 | } | ||
82 | else | ||
83 | { | ||
84 | this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp); | ||
85 | } | ||
86 | } | ||
87 | catch (Exception) | ||
88 | { | ||
89 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection "); | ||
90 | |||
91 | } | ||
92 | } | ||
93 | |||
94 | private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp) | ||
95 | { | ||
96 | this.Server.SendTo(buffer, size, flags, endp); | ||
97 | } | ||
98 | } | ||
99 | } \ No newline at end of file | ||
diff --git a/OpenSim.Servers/OpenSim.Servers.csproj b/OpenSim.Servers/OpenSim.Servers.csproj index 6e04463..d59306a 100644 --- a/OpenSim.Servers/OpenSim.Servers.csproj +++ b/OpenSim.Servers/OpenSim.Servers.csproj | |||
@@ -1,4 +1,4 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | 1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
2 | <PropertyGroup> | 2 | <PropertyGroup> |
3 | <ProjectType>Local</ProjectType> | 3 | <ProjectType>Local</ProjectType> |
4 | <ProductVersion>8.0.50727</ProductVersion> | 4 | <ProductVersion>8.0.50727</ProductVersion> |
@@ -6,7 +6,8 @@ | |||
6 | <ProjectGuid>{8BB20F0A-0000-0000-0000-000000000000}</ProjectGuid> | 6 | <ProjectGuid>{8BB20F0A-0000-0000-0000-000000000000}</ProjectGuid> |
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | 7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | 8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
9 | <ApplicationIcon></ApplicationIcon> | 9 | <ApplicationIcon> |
10 | </ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | 11 | <AssemblyKeyContainerName> |
11 | </AssemblyKeyContainerName> | 12 | </AssemblyKeyContainerName> |
12 | <AssemblyName>OpenSim.Servers</AssemblyName> | 13 | <AssemblyName>OpenSim.Servers</AssemblyName> |
@@ -15,9 +16,11 @@ | |||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | 16 | <DefaultTargetSchema>IE50</DefaultTargetSchema> |
16 | <DelaySign>false</DelaySign> | 17 | <DelaySign>false</DelaySign> |
17 | <OutputType>Library</OutputType> | 18 | <OutputType>Library</OutputType> |
18 | <AppDesignerFolder></AppDesignerFolder> | 19 | <AppDesignerFolder> |
20 | </AppDesignerFolder> | ||
19 | <RootNamespace>OpenSim.Servers</RootNamespace> | 21 | <RootNamespace>OpenSim.Servers</RootNamespace> |
20 | <StartupObject></StartupObject> | 22 | <StartupObject> |
23 | </StartupObject> | ||
21 | <FileUpgradeFlags> | 24 | <FileUpgradeFlags> |
22 | </FileUpgradeFlags> | 25 | </FileUpgradeFlags> |
23 | </PropertyGroup> | 26 | </PropertyGroup> |
@@ -28,7 +31,8 @@ | |||
28 | <ConfigurationOverrideFile> | 31 | <ConfigurationOverrideFile> |
29 | </ConfigurationOverrideFile> | 32 | </ConfigurationOverrideFile> |
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | 33 | <DefineConstants>TRACE;DEBUG</DefineConstants> |
31 | <DocumentationFile></DocumentationFile> | 34 | <DocumentationFile> |
35 | </DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | 36 | <DebugSymbols>True</DebugSymbols> |
33 | <FileAlignment>4096</FileAlignment> | 37 | <FileAlignment>4096</FileAlignment> |
34 | <Optimize>False</Optimize> | 38 | <Optimize>False</Optimize> |
@@ -37,7 +41,8 @@ | |||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | 41 | <RemoveIntegerChecks>False</RemoveIntegerChecks> |
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | 42 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
39 | <WarningLevel>4</WarningLevel> | 43 | <WarningLevel>4</WarningLevel> |
40 | <NoWarn></NoWarn> | 44 | <NoWarn> |
45 | </NoWarn> | ||
41 | </PropertyGroup> | 46 | </PropertyGroup> |
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | 47 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | 48 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
@@ -46,7 +51,8 @@ | |||
46 | <ConfigurationOverrideFile> | 51 | <ConfigurationOverrideFile> |
47 | </ConfigurationOverrideFile> | 52 | </ConfigurationOverrideFile> |
48 | <DefineConstants>TRACE</DefineConstants> | 53 | <DefineConstants>TRACE</DefineConstants> |
49 | <DocumentationFile></DocumentationFile> | 54 | <DocumentationFile> |
55 | </DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | 56 | <DebugSymbols>False</DebugSymbols> |
51 | <FileAlignment>4096</FileAlignment> | 57 | <FileAlignment>4096</FileAlignment> |
52 | <Optimize>True</Optimize> | 58 | <Optimize>True</Optimize> |
@@ -55,18 +61,20 @@ | |||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | 61 | <RemoveIntegerChecks>False</RemoveIntegerChecks> |
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | 62 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> |
57 | <WarningLevel>4</WarningLevel> | 63 | <WarningLevel>4</WarningLevel> |
58 | <NoWarn></NoWarn> | 64 | <NoWarn> |
65 | </NoWarn> | ||
59 | </PropertyGroup> | 66 | </PropertyGroup> |
60 | <ItemGroup> | 67 | <ItemGroup> |
61 | <Reference Include="System" > | 68 | <Reference Include="System"> |
62 | <HintPath>System.dll</HintPath> | 69 | <HintPath>System.dll</HintPath> |
63 | <Private>False</Private> | 70 | <Private>False</Private> |
64 | </Reference> | 71 | </Reference> |
65 | <Reference Include="System.Xml" > | 72 | <Reference Include="System.Data" /> |
73 | <Reference Include="System.Xml"> | ||
66 | <HintPath>System.Xml.dll</HintPath> | 74 | <HintPath>System.Xml.dll</HintPath> |
67 | <Private>False</Private> | 75 | <Private>False</Private> |
68 | </Reference> | 76 | </Reference> |
69 | <Reference Include="libsecondlife.dll" > | 77 | <Reference Include="libsecondlife.dll"> |
70 | <HintPath>..\bin\libsecondlife.dll</HintPath> | 78 | <HintPath>..\bin\libsecondlife.dll</HintPath> |
71 | <Private>False</Private> | 79 | <Private>False</Private> |
72 | </Reference> | 80 | </Reference> |
@@ -76,19 +84,19 @@ | |||
76 | <Name>OpenSim.Framework</Name> | 84 | <Name>OpenSim.Framework</Name> |
77 | <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> | 85 | <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> |
78 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 86 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
79 | <Private>False</Private> | 87 | <Private>False</Private> |
80 | </ProjectReference> | 88 | </ProjectReference> |
81 | <ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj"> | 89 | <ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj"> |
82 | <Name>OpenSim.Framework.Console</Name> | 90 | <Name>OpenSim.Framework.Console</Name> |
83 | <Project>{A7CD0630-0000-0000-0000-000000000000}</Project> | 91 | <Project>{A7CD0630-0000-0000-0000-000000000000}</Project> |
84 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 92 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
85 | <Private>False</Private> | 93 | <Private>False</Private> |
86 | </ProjectReference> | 94 | </ProjectReference> |
87 | <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj"> | 95 | <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj"> |
88 | <Name>XMLRPC</Name> | 96 | <Name>XMLRPC</Name> |
89 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> | 97 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> |
90 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 98 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
91 | <Private>False</Private> | 99 | <Private>False</Private> |
92 | </ProjectReference> | 100 | </ProjectReference> |
93 | </ItemGroup> | 101 | </ItemGroup> |
94 | <ItemGroup> | 102 | <ItemGroup> |
@@ -98,6 +106,7 @@ | |||
98 | <Compile Include="BaseServer.cs"> | 106 | <Compile Include="BaseServer.cs"> |
99 | <SubType>Code</SubType> | 107 | <SubType>Code</SubType> |
100 | </Compile> | 108 | </Compile> |
109 | <Compile Include="CheckSumServer.cs" /> | ||
101 | <Compile Include="IRestHandler.cs"> | 110 | <Compile Include="IRestHandler.cs"> |
102 | <SubType>Code</SubType> | 111 | <SubType>Code</SubType> |
103 | </Compile> | 112 | </Compile> |
@@ -110,6 +119,7 @@ | |||
110 | <Compile Include="LoginServer.cs"> | 119 | <Compile Include="LoginServer.cs"> |
111 | <SubType>Code</SubType> | 120 | <SubType>Code</SubType> |
112 | </Compile> | 121 | </Compile> |
122 | <Compile Include="UDPServerBase.cs" /> | ||
113 | <Compile Include="XmlRpcMethod.cs"> | 123 | <Compile Include="XmlRpcMethod.cs"> |
114 | <SubType>Code</SubType> | 124 | <SubType>Code</SubType> |
115 | </Compile> | 125 | </Compile> |
@@ -121,4 +131,4 @@ | |||
121 | <PostBuildEvent> | 131 | <PostBuildEvent> |
122 | </PostBuildEvent> | 132 | </PostBuildEvent> |
123 | </PropertyGroup> | 133 | </PropertyGroup> |
124 | </Project> | 134 | </Project> \ No newline at end of file |
diff --git a/OpenSim.Servers/OpenSim.Servers.dll.build b/OpenSim.Servers/OpenSim.Servers.dll.build index 4ad29dd..5afd9e1 100644 --- a/OpenSim.Servers/OpenSim.Servers.dll.build +++ b/OpenSim.Servers/OpenSim.Servers.dll.build | |||
@@ -13,10 +13,12 @@ | |||
13 | <sources failonempty="true"> | 13 | <sources failonempty="true"> |
14 | <include name="BaseHttpServer.cs" /> | 14 | <include name="BaseHttpServer.cs" /> |
15 | <include name="BaseServer.cs" /> | 15 | <include name="BaseServer.cs" /> |
16 | <include name="CheckSumServer.cs" /> | ||
16 | <include name="IRestHandler.cs" /> | 17 | <include name="IRestHandler.cs" /> |
17 | <include name="LocalUserProfileManager.cs" /> | 18 | <include name="LocalUserProfileManager.cs" /> |
18 | <include name="LoginResponse.cs" /> | 19 | <include name="LoginResponse.cs" /> |
19 | <include name="LoginServer.cs" /> | 20 | <include name="LoginServer.cs" /> |
21 | <include name="UDPServerBase.cs" /> | ||
20 | <include name="XmlRpcMethod.cs" /> | 22 | <include name="XmlRpcMethod.cs" /> |
21 | </sources> | 23 | </sources> |
22 | <references basedir="${project::get-base-directory()}"> | 24 | <references basedir="${project::get-base-directory()}"> |
diff --git a/OpenSim.Servers/UDPServerBase.cs b/OpenSim.Servers/UDPServerBase.cs new file mode 100644 index 0000000..bdbc772 --- /dev/null +++ b/OpenSim.Servers/UDPServerBase.cs | |||
@@ -0,0 +1,74 @@ | |||
1 | using System; | ||
2 | using System.Text; | ||
3 | using System.IO; | ||
4 | using System.Threading; | ||
5 | using System.Net; | ||
6 | using System.Net.Sockets; | ||
7 | using System.Timers; | ||
8 | using System.Reflection; | ||
9 | using System.Collections; | ||
10 | using System.Collections.Generic; | ||
11 | using libsecondlife; | ||
12 | using libsecondlife.Packets; | ||
13 | |||
14 | namespace OpenSim.Servers | ||
15 | { | ||
16 | public class UDPServerBase | ||
17 | { | ||
18 | |||
19 | public Socket Server; | ||
20 | protected IPEndPoint ServerIncoming; | ||
21 | protected byte[] RecvBuffer = new byte[4096]; | ||
22 | protected byte[] ZeroBuffer = new byte[8192]; | ||
23 | protected IPEndPoint ipeSender; | ||
24 | protected EndPoint epSender; | ||
25 | protected AsyncCallback ReceivedData; | ||
26 | protected int listenPort; | ||
27 | |||
28 | public UDPServerBase() | ||
29 | { | ||
30 | } | ||
31 | |||
32 | protected virtual void OnReceivedData(IAsyncResult result) | ||
33 | { | ||
34 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
35 | epSender = (EndPoint)ipeSender; | ||
36 | Packet packet = null; | ||
37 | int numBytes = Server.EndReceiveFrom(result, ref epSender); | ||
38 | int packetEnd = numBytes - 1; | ||
39 | |||
40 | packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | ||
41 | |||
42 | |||
43 | |||
44 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
45 | } | ||
46 | |||
47 | protected virtual void AddNewClient(Packet packet) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | public void ServerListener() | ||
52 | { | ||
53 | |||
54 | ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort); | ||
55 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | ||
56 | Server.Bind(ServerIncoming); | ||
57 | |||
58 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | ||
59 | epSender = (EndPoint)ipeSender; | ||
60 | ReceivedData = new AsyncCallback(this.OnReceivedData); | ||
61 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | ||
62 | } | ||
63 | |||
64 | |||
65 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) | ||
66 | { | ||
67 | // find the endpoint for this circuit | ||
68 | |||
69 | } | ||
70 | |||
71 | |||
72 | } | ||
73 | } | ||
74 | |||