Browse Source

cleaning

pull/123/head
notgiven688 3 years ago
parent
commit
812e9560ef
40 changed files with 962 additions and 422 deletions
  1. +0
    -39
      server/Server.userprefs
  2. +22
    -1
      server/Server/DataStructures.cs
  3. +25
    -9
      server/Server/Extensions.cs
  4. +24
    -1
      server/Server/Fleck/BufferPool.cs
  5. +24
    -1
      server/Server/Fleck/ConnectionNotAvailableException.cs
  6. +0
    -141
      server/Server/Fleck/Fleck.csproj
  7. +24
    -1
      server/Server/Fleck/FleckLog.cs
  8. +23
    -0
      server/Server/Fleck/FrameType.cs
  9. +23
    -0
      server/Server/Fleck/HandlerFactory.cs
  10. +23
    -0
      server/Server/Fleck/Handlers/ComposableHandler.cs
  11. +23
    -0
      server/Server/Fleck/Handlers/Draft76Handler.cs
  12. +23
    -0
      server/Server/Fleck/Handlers/FlashSocketPolicyRequestHandler.cs
  13. +23
    -0
      server/Server/Fleck/Handlers/Hybi13Handler.cs
  14. +23
    -0
      server/Server/Fleck/HandshakeException.cs
  15. +24
    -1
      server/Server/Fleck/Helpers/MonoHelper.cs
  16. +23
    -0
      server/Server/Fleck/IntExtensions.cs
  17. +23
    -0
      server/Server/Fleck/Interfaces/IHandler.cs
  18. +23
    -0
      server/Server/Fleck/Interfaces/ISocket.cs
  19. +24
    -1
      server/Server/Fleck/Interfaces/IWebSocketConnection.cs
  20. +24
    -1
      server/Server/Fleck/Interfaces/IWebSocketConnectionInfo.cs
  21. +24
    -1
      server/Server/Fleck/Interfaces/IWebSocketServer.cs
  22. +23
    -0
      server/Server/Fleck/QueuedStream.cs
  23. +23
    -0
      server/Server/Fleck/ReadState.cs
  24. +23
    -0
      server/Server/Fleck/RequestParser.cs
  25. +23
    -0
      server/Server/Fleck/SocketWrapper.cs
  26. +23
    -0
      server/Server/Fleck/SubProtocolNegotiationFailureException.cs
  27. +23
    -0
      server/Server/Fleck/SubProtocolNegotiator.cs
  28. +24
    -1
      server/Server/Fleck/WebSocketConnection.cs
  29. +24
    -1
      server/Server/Fleck/WebSocketConnectionInfo.cs
  30. +23
    -0
      server/Server/Fleck/WebSocketException.cs
  31. +23
    -0
      server/Server/Fleck/WebSocketHttpRequest.cs
  32. +23
    -0
      server/Server/Fleck/WebSocketServer.cs
  33. +23
    -0
      server/Server/Fleck/WebSocketStatusCodes.cs
  34. +47
    -0
      server/Server/Helper.cs
  35. +19
    -21
      server/Server/JSONParser.cs
  36. +119
    -153
      server/Server/PoolConnection.cs
  37. +31
    -25
      server/Server/Program.cs
  38. +22
    -0
      server/Server/Properties/AssemblyInfo.cs
  39. +1
    -1
      server/Server/Server.csproj
  40. +0
    -23
      server/Server/Server.sln

+ 0
- 39
server/Server.userprefs View File

@ -1,39 +0,0 @@
<Properties StartupConfiguration="{DC564972-9DEF-4897-A8F5-C4C21CEBDE2F}|Default" StartupItem="Server/Server.csproj">
<MonoDevelop.Ide.Workbench ActiveDocument="Server/Program.cs">
<Files>
<File FileName="Server/Program.cs" Line="907" Column="36" />
<File FileName="Server/PoolConnection.cs" Line="145" Column="1" />
<File FileName="Server/JSONParser.cs" Line="1" Column="1" />
<File FileName="Server/Extensions.cs" Line="1" Column="1" />
<File FileName="Server/EmptyWebsocket.cs" Line="1" Column="1" />
<File FileName="Server/DataStructures.cs" Line="1" Column="1" />
<File FileName="Server/Firewall.cs" Line="1" Column="1" />
<File FileName="Server/Properties/AssemblyInfo.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/IntExtensions.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/WebSocketServer.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/SocketWrapper.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/BufferPool.cs" Line="1" Column="1" />
<File FileName="Server/Helper.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/ConnectionNotAvailableException.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/FleckLog.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/FrameType.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/HandlerFactory.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/HandshakeException.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/RequestParser.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/WebSocketException.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/WebSocketConnection.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/WebSocketConnectionInfo.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/SubProtocolNegotiator.cs" Line="1" Column="1" />
<File FileName="Server/Fleck/WebSocketHttpRequest.cs" Line="1" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release|x86" />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches>
<Watch file="testproj/Program.cs" line="302" offsetX="509" offsetY="5419" expression="forward" liveUpdate="False" />
</MonoDevelop.Ide.DebuggingService.PinnedWatches>
<MultiItemStartupConfigurations />
<MonoDevelop.Ide.ItemProperties.server PreferredExecutionTarget="MonoDevelop.Default" />
</Properties>

+ 22
- 1
server/Server/DataStructures.cs View File

@ -1,4 +1,25 @@
using System.Collections.Concurrent;
// The MIT License (MIT)
// Copyright (c) 2018 - the webminerpool developer
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace Server {

+ 25
- 9
server/Server/Extensions.cs View File

@ -1,14 +1,30 @@
namespace System.Net.Sockets
{
// The MIT License (MIT)
public static class ObjectExtensionClass
{
public static string GetString(this object input)
{
// Copyright (c) 2018 - the webminerpool developer
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace System.Net.Sockets {
public static class ObjectExtensionClass {
public static string GetString (this object input) {
return input == null ? string.Empty : input.ToString ();
}
}
}
}

+ 24
- 1
server/Server/Fleck/BufferPool.cs View File

@ -1,4 +1,27 @@
using System;
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
namespace Fleck

+ 24
- 1
server/Server/Fleck/ConnectionNotAvailableException.cs View File

@ -1,4 +1,27 @@
using System;
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck
{

+ 0
- 141
server/Server/Fleck/Fleck.csproj View File

@ -1,141 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8B12D929-AFA9-4307-BEFF-2ED0F1070FEE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Fleck</RootNamespace>
<AssemblyName>Fleck</AssemblyName>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>True</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_XMR|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release_XMR</OutputPath>
<WarningLevel>4</WarningLevel>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_AEON|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release_AEON</OutputPath>
<WarningLevel>4</WarningLevel>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<Choose>
<When Condition="Exists('$(SolutionDir)\CommonAssemblyInfo.cs')">
<ItemGroup>
<Compile Include="$(SolutionDir)\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<Compile Include="ConnectionNotAvailableException.cs" />
<Compile Include="Handlers\ComposableHandler.cs" />
<Compile Include="Handlers\Draft76Handler.cs" />
<Compile Include="Handlers\FlashSocketPolicyRequestHandler.cs" />
<Compile Include="Handlers\Hybi13Handler.cs" />
<Compile Include="Interfaces\ISocket.cs" />
<Compile Include="Interfaces\IWebSocketConnection.cs" />
<Compile Include="FleckLog.cs" />
<Compile Include="Interfaces\IWebSocketServer.cs" />
<Compile Include="Interfaces\IWebSocketConnectionInfo.cs" />
<Compile Include="SocketWrapper.cs" />
<Compile Include="WebSocketConnectionInfo.cs" />
<Compile Include="WebSocketServer.cs" />
<Compile Include="WebSocketHttpRequest.cs" />
<Compile Include="RequestParser.cs" />
<Compile Include="HandlerFactory.cs" />
<Compile Include="WebSocketConnection.cs" />
<Compile Include="WebSocketException.cs" />
<Compile Include="IntExtensions.cs" />
<Compile Include="HandshakeException.cs" />
<Compile Include="FrameType.cs" />
<Compile Include="ReadState.cs" />
<Compile Include="Interfaces\IHandler.cs" />
<Compile Include="WebSocketStatusCodes.cs" />
<Compile Include="SubProtocolNegotiator.cs" />
<Compile Include="SubProtocolNegotiationFailureException.cs" />
<Compile Include="QueuedStream.cs" />
<Compile Include="Helpers\MonoHelper.cs" />
<Compile Include="Firewall.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup />
<ItemGroup>
<Folder Include="Helpers\" />
</ItemGroup>
</Project>

+ 24
- 1
server/Server/Fleck/FleckLog.cs View File

@ -1,4 +1,27 @@
using System;
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck
{

+ 23
- 0
server/Server/Fleck/FrameType.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck

+ 23
- 0
server/Server/Fleck/HandlerFactory.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using Fleck.Handlers;

+ 23
- 0
server/Server/Fleck/Handlers/ComposableHandler.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;

+ 23
- 0
server/Server/Fleck/Handlers/Draft76Handler.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;

+ 23
- 0
server/Server/Fleck/Handlers/FlashSocketPolicyRequestHandler.cs View File

@ -2,6 +2,29 @@ using System;
using System.Collections.Generic;
using System.Text;
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace Fleck.Handlers
{
public class FlashSocketPolicyRequestHandler

+ 23
- 0
server/Server/Fleck/Handlers/Hybi13Handler.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;

+ 23
- 0
server/Server/Fleck/HandshakeException.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck

+ 24
- 1
server/Server/Fleck/Helpers/MonoHelper.cs View File

@ -1,4 +1,27 @@
using System;
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck.Helpers
{

+ 23
- 0
server/Server/Fleck/IntExtensions.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck

+ 23
- 0
server/Server/Fleck/Interfaces/IHandler.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
namespace Fleck

+ 23
- 0
server/Server/Fleck/Interfaces/ISocket.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using System.Net;

+ 24
- 1
server/Server/Fleck/Interfaces/IWebSocketConnection.cs View File

@ -1,4 +1,27 @@
using System;
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Threading.Tasks;
namespace Fleck

+ 24
- 1
server/Server/Fleck/Interfaces/IWebSocketConnectionInfo.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
using System;
@ -16,4 +39,4 @@ namespace Fleck
Guid Id { get; }
string NegotiatedSubProtocol { get; }
}
}
}

+ 24
- 1
server/Server/Fleck/Interfaces/IWebSocketServer.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck
@ -6,4 +29,4 @@ namespace Fleck
{
void Start(Action<IWebSocketConnection> config);
}
}
}

+ 23
- 0
server/Server/Fleck/QueuedStream.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;

+ 23
- 0
server/Server/Fleck/ReadState.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;

+ 23
- 0
server/Server/Fleck/RequestParser.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Text;
using System.Text.RegularExpressions;

+ 23
- 0
server/Server/Fleck/SocketWrapper.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using System.Net;

+ 23
- 0
server/Server/Fleck/SubProtocolNegotiationFailureException.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck

+ 23
- 0
server/Server/Fleck/SubProtocolNegotiator.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Linq;
using System.Collections.Generic;

+ 24
- 1
server/Server/Fleck/WebSocketConnection.cs View File

@ -1,4 +1,27 @@
using System;
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

+ 24
- 1
server/Server/Fleck/WebSocketConnectionInfo.cs View File

@ -1,4 +1,27 @@
using System;
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

+ 23
- 0
server/Server/Fleck/WebSocketException.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck
{

+ 23
- 0
server/Server/Fleck/WebSocketHttpRequest.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
using System;

+ 23
- 0
server/Server/Fleck/WebSocketServer.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define __MonoCS__
using System;

+ 23
- 0
server/Server/Fleck/WebSocketStatusCodes.cs View File

@ -1,3 +1,26 @@
// https://github.com/statianzo/Fleck
// The MIT License
// Copyright (c) 2010-2016 Jason Staten
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace Fleck

+ 47
- 0
server/Server/Helper.cs View File

@ -0,0 +1,47 @@
// The MIT License (MIT)
// Copyright (c) 2018 - the webminerpool developer
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace Server {
public class Helper {
public static void WriteTextAsyncWrapper (string filePath, string text, FileMode fileMode = FileMode.Append) {
#pragma warning disable 4014
WriteTextAsync (filePath, text, fileMode);
#pragma warning restore 4014
}
public static async Task WriteTextAsync (string filePath, string text, FileMode fileMode = FileMode.Append) {
byte[] encodedText = Encoding.ASCII.GetBytes (text);
using (FileStream sourceStream = new FileStream (filePath,
fileMode, FileAccess.Write, FileShare.None,
bufferSize : 4096, useAsync : true)) {
await sourceStream.WriteAsync (encodedText, 0, encodedText.Length);
};
}
}
}

+ 19
- 21
server/Server/JSONParser.cs View File

@ -1,15 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
/*
https://github.com/zanders3/json
The MIT License (MIT)
Copyright (c) 2015 Alex Parker
@ -19,19 +9,27 @@ this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
namespace TinyJson
{

+ 119
- 153
server/Server/PoolConnection.cs View File

@ -1,25 +1,45 @@
using System;
// https://github.com/zanders3/json
// The MIT License (MIT)
// Copyright (c) 2015 Alex Parker
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using TinyJson;
using JsonData = System.Collections.Generic.Dictionary<string, object>;
using Fleck;
namespace Server
{
namespace Server {
public class PoolConnection
{
public class PoolConnection {
public TcpClient TcpClient;
public byte[] ReceiveBuffer;
public byte[] ReceiveBuffer;
public string Login;
public string Password;
@ -37,81 +57,57 @@ namespace Server
public DateTime LastInteraction = DateTime.Now;
public CcHashset<string> LastSolved;
public CcHashset<Client> WebClients = new CcHashset<Client>();
public CcHashset<Client> WebClients = new CcHashset<Client> ();
public void Send(Client client, string msg)
{
try {
Byte[] bytesSent = Encoding.ASCII.GetBytes(msg);
TcpClient.GetStream().BeginWrite(bytesSent,0,bytesSent.Length,SendCallback,null);
public void Send (Client client, string msg) {
try {
Byte[] bytesSent = Encoding.ASCII.GetBytes (msg);
TcpClient.GetStream ().BeginWrite (bytesSent, 0, bytesSent.Length, SendCallback, null);
this.LastSender = client;
}
catch { }
} catch { }
}
private void SendCallback(IAsyncResult result)
{
private void SendCallback (IAsyncResult result) {
if (!TcpClient.Connected) return;
try {
try {
NetworkStream networkStream = TcpClient.GetStream ();
networkStream.EndWrite(result); }
catch { }
networkStream.EndWrite (result);
} catch { }
}
}
public class PoolConnectionFactory
{
public delegate void ReceiveJobDelegate(Client client, JsonData json, CcHashset<string> hashset);
public delegate void ReceiveErrorDelegate(Client client, JsonData json);
public delegate void DisconnectedDelegate(Client client, string reason);
public class PoolConnectionFactory {
public delegate void ReceiveJobDelegate (Client client, JsonData json, CcHashset<string> hashset);
public delegate void ReceiveErrorDelegate (Client client, JsonData json);
public delegate void DisconnectedDelegate (Client client, string reason);
private static ReceiveErrorDelegate ReceiveError;
private static ReceiveJobDelegate ReceiveJob;
private static DisconnectedDelegate Disconnect;
public static CcDictionary<string, PoolConnection> Connections = new CcDictionary<string, PoolConnection> ();
public static CcDictionary<string,PoolConnection> Connections
= new CcDictionary<string,PoolConnection> ();
private static bool VerifyJob(JsonData data)
{
private static bool VerifyJob (JsonData data) {
if (data == null) return false;
if (!data.ContainsKey ("job_id")) {
return false;
}
if (!data.ContainsKey ("blob")) {
return false;
}
if (!data.ContainsKey ("target")) {
return false;
}
if (!data.ContainsKey ("job_id")) return false;
if (!data.ContainsKey ("blob")) return false;
if (!data.ContainsKey ("target")) return false;
string blob = data["blob"].GetString();
string target = data["target"].GetString();
string blob = data["blob"].GetString ();
string target = data["target"].GetString ();
if (blob.Length != 152) {
return false;
}
if (target.Length != 8) {
return false;
}
if (blob.Length != 152) return false;
if (target.Length != 8) return false;
if (!Regex.IsMatch (blob, MainClass.RegexIsHex)) {
return false;
}
if (!Regex.IsMatch (target, MainClass.RegexIsHex)) {
return false;
}
if (!Regex.IsMatch (blob, MainClass.RegexIsHex)) return false;
if (!Regex.IsMatch (target, MainClass.RegexIsHex)) return false;
return true;
}
private static void ReceiveCallback(IAsyncResult result) {
private static void ReceiveCallback (IAsyncResult result) {
PoolConnection mypc = result.AsyncState as PoolConnection;
TcpClient client = mypc.TcpClient;
@ -120,46 +116,39 @@ namespace Server
NetworkStream networkStream;
try { networkStream = client.GetStream (); }
catch { return; }
try { networkStream = client.GetStream (); } catch { return; }
int bytesread = 0;
try {
bytesread = networkStream.EndRead(result);
}
catch { return; }
try { bytesread = networkStream.EndRead (result); } catch { return; }
string json = string.Empty;
try {
if(bytesread == 0) // disconnect
if (bytesread == 0) // disconnected
{
// slow that down a bit
// slow that down a bit to avoid negative feedback loop
var t = Task.Run(async delegate
{
await Task.Delay(TimeSpan.FromSeconds(4));
Task.Run (async delegate {
await Task.Delay (TimeSpan.FromSeconds (4));
List<Client> cllist = new List<Client> (mypc.WebClients.Values);
foreach (Client ev in cllist) Disconnect(ev,"lost pool connection.");
});
List<Client> cllist = new List<Client> (mypc.WebClients.Values);
foreach (Client ev in cllist) Disconnect (ev, "lost pool connection.");
});
return;
}
json = ASCIIEncoding.ASCII.GetString (mypc.ReceiveBuffer, 0, bytesread);
networkStream.BeginRead (mypc.ReceiveBuffer, 0, mypc.ReceiveBuffer.Length, new AsyncCallback (ReceiveCallback), mypc);
networkStream.BeginRead(mypc.ReceiveBuffer, 0, mypc.ReceiveBuffer.Length, new AsyncCallback (ReceiveCallback), mypc);
}
catch { return; }
} catch { return; }
if (bytesread == 0 || string.IsNullOrEmpty(json)) return; //?!
if (bytesread == 0 || string.IsNullOrEmpty (json)) return; //?!
var msg = json.FromJson<JsonData>();
var msg = json.FromJson<JsonData> ();
if (msg == null) return;
if (string.IsNullOrEmpty (mypc.PoolId)) {
@ -171,21 +160,20 @@ namespace Server
// try to get the error
if (msg.ContainsKey ("error")) {
msg = msg ["error"] as JsonData;
msg = msg["error"] as JsonData;
if (msg != null && msg.ContainsKey ("message"))
additionalInfo = msg ["message"].GetString ();
additionalInfo = msg["message"].GetString ();
}
List<Client> cllist = new List<Client> (mypc.WebClients.Values);
foreach (Client ev in cllist)
Disconnect (ev, "can not connect. additional information: " + additionalInfo);
Disconnect (ev, "can not connect. additional information: " + additionalInfo);
return;
}
msg = msg ["result"] as JsonData;
msg = msg["result"] as JsonData;
if (msg == null)
return;
@ -194,9 +182,9 @@ namespace Server
if (!msg.ContainsKey ("job"))
return;
mypc.PoolId = msg ["id"].GetString ();
mypc.PoolId = msg["id"].GetString ();
var lastjob = msg ["job"] as JsonData;
var lastjob = msg["job"] as JsonData;
if (!VerifyJob (lastjob)) {
Console.WriteLine ("Failed to verify job.");
@ -210,17 +198,14 @@ namespace Server
List<Client> cllist2 = new List<Client> (mypc.WebClients.Values);
foreach (Client ev in cllist2) {
ReceiveJob (ev, mypc.LastJob, mypc.LastSolved );
ReceiveJob (ev, mypc.LastJob, mypc.LastSolved);
}
}
else if (msg.ContainsKey ("method") && msg ["method"].GetString () == "job")
{
} else if (msg.ContainsKey ("method") && msg["method"].GetString () == "job") {
if (!msg.ContainsKey ("params"))
return;
var lastjob = msg ["params"] as JsonData;
var lastjob = msg["params"] as JsonData;
if (!VerifyJob (lastjob)) {
Console.WriteLine ("Failed to verify job.");
@ -235,29 +220,22 @@ namespace Server
Console.WriteLine ("Sending to {0} clients!", cllist2.Count);
foreach (Client ev in cllist2) {
ReceiveJob (ev, mypc.LastJob, mypc.LastSolved );
ReceiveJob (ev, mypc.LastJob, mypc.LastSolved);
}
}
else
{
} else {
if (msg.ContainsKey ("error")) {
// who knows?
ReceiveError (mypc.LastSender, msg);
} else {
Console.WriteLine ("Pool is sending nonsense...");
}
}
}
}
private static void ConnectCallback(IAsyncResult result)
{
private static void ConnectCallback (IAsyncResult result) {
PoolConnection mypc = result.AsyncState as PoolConnection;
TcpClient client = mypc.TcpClient;
@ -265,72 +243,66 @@ namespace Server
if (!mypc.Closed && client.Connected) {
try {
NetworkStream networkStream = client.GetStream ();
mypc.ReceiveBuffer = new byte[client.ReceiveBufferSize];
NetworkStream networkStream = client.GetStream ();
mypc.ReceiveBuffer = new byte[client.ReceiveBufferSize];
networkStream.BeginRead (mypc.ReceiveBuffer, 0, mypc.ReceiveBuffer.Length, new AsyncCallback (ReceiveCallback), mypc);
networkStream.BeginRead(mypc.ReceiveBuffer, 0, mypc.ReceiveBuffer.Length, new AsyncCallback (ReceiveCallback), mypc);
/* keep things stupid and simple */
/* keep things stupid and simple */
string msg0 = "{\"method\":\"login\",\"params\":{\"login\":\"";
string msg1 = "\",\"pass\":\"";
string msg0 = "{\"method\":\"login\",\"params\":{\"login\":\"";
string msg1 = "\",\"pass\":\"";
string msg2 = "\",\"agent\":\"webminerpool.com\"},\"id\":1}";
string msg = msg0 + mypc.Login + msg1 + mypc.Password + msg2 + "\n";
string msg = msg0 + mypc.Login + msg1 + mypc.Password + msg2 + "\n";
mypc.Send(mypc.LastSender, msg);
}
catch { return; }
}
else {
mypc.Send (mypc.LastSender, msg);
} catch { return; }
} else {
// slow that down a bit
var t = Task.Run (async delegate {
Task.Run (async delegate {
await Task.Delay (TimeSpan.FromSeconds (4));
List<Client> cllist = new List<Client> (mypc.WebClients.Values);
foreach (Client ev in cllist)
Disconnect (ev, "can not connect to pool.");
});
}
}
}
}
public static void Close(PoolConnection connection, Client client)
{
connection.WebClients.TryRemove(client);
public static void Close (PoolConnection connection, Client client) {
connection.WebClients.TryRemove (client);
if (connection.WebClients.Count == 0) {
connection.Closed = true;
try {
var networkStream = connection.TcpClient.GetStream ();
networkStream.EndRead(null);
} catch{ }
var networkStream = connection.TcpClient.GetStream ();
networkStream.EndRead (null);
} catch { }
connection.TcpClient.Close ();
connection.TcpClient.Client.Close ();
connection.ReceiveBuffer = null;
try{ PoolConnection dummy; Connections.TryRemove(connection.Credentials, out dummy);}catch{}
try { PoolConnection dummy; Connections.TryRemove (connection.Credentials, out dummy); } catch { }
Console.WriteLine ("{0}: closed a pool connection.", client.WebSocket.ConnectionInfo.Id);
}
}
public static void RegisterCallbacks(ReceiveJobDelegate receiveJob, ReceiveErrorDelegate receiveError, DisconnectedDelegate disconnect)
{
public static void RegisterCallbacks (ReceiveJobDelegate receiveJob, ReceiveErrorDelegate receiveError, DisconnectedDelegate disconnect) {
PoolConnectionFactory.ReceiveJob = receiveJob;
PoolConnectionFactory.ReceiveError = receiveError;
PoolConnectionFactory.Disconnect = disconnect;
}
public static void CheckPoolConnection(PoolConnection connection)
{
public static void CheckPoolConnection (PoolConnection connection) {
if ((DateTime.Now - connection.LastInteraction).TotalMinutes < 10)
return;
@ -338,13 +310,13 @@ namespace Server
Console.WriteLine (connection.Credentials);
try {
var networkStream = connection.TcpClient.GetStream ();
networkStream.EndRead(null);
} catch{ }
var networkStream = connection.TcpClient.GetStream ();
networkStream.EndRead (null);
} catch { }
try {connection.TcpClient.Close ();} catch{ }
try {connection.TcpClient.Client.Close ();} catch{ }
try {connection.ReceiveBuffer = null;} catch{ }
try { connection.TcpClient.Close (); } catch { }
try { connection.TcpClient.Client.Close (); } catch { }
try { connection.ReceiveBuffer = null; } catch { }
connection.LastInteraction = DateTime.Now;
@ -353,34 +325,31 @@ namespace Server
connection.TcpClient = new TcpClient ();
Fleck.SocketExtensions.SetKeepAlive(connection.TcpClient.Client,60000, 1000);
connection.TcpClient.Client.ReceiveBufferSize = 4096*2;
Fleck.SocketExtensions.SetKeepAlive (connection.TcpClient.Client, 60000, 1000);
connection.TcpClient.Client.ReceiveBufferSize = 4096 * 2;
try{ connection.TcpClient.BeginConnect (connection.Url, connection.Port, new AsyncCallback (ConnectCallback), connection); }