Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Source/RatioMaster.Tests/RatioMaster.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -59,9 +59,6 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
41 changes: 37 additions & 4 deletions Source/RatioMaster/RM.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace RatioMaster_source
namespace RatioMaster_source
{
using System;
using System.ComponentModel;
Expand Down Expand Up @@ -1622,10 +1622,42 @@ private TrackerResponse MakeWebRequestEx(Uri reqUri)
}
}

string cmd = "GET " + path + " " + currentClient.HttpProtocol + "\r\n" + currentClient.Headers.Replace("{host}", host) + "\r\n";
string headers = currentClient.Headers.Replace("{host}", host);
string lowerCaseHeaders = headers.ToLower();
if (!lowerCaseHeaders.Contains("connection: close"))
{
headers = headers.TrimEnd('\r', '\n') + "\r\nConnection: close\r\n";
}
else if (!headers.EndsWith("\r\n"))
{
headers += "\r\n";
}

string cmd = "GET " + path + " " + currentClient.HttpProtocol + "\r\n" + headers + "\r\n";
cmd = cmd.TrimEnd('\r', '\n') + "\r\n\r\n";

AddLogLine("======== Sending Command to Tracker ========");
AddLogLine(cmd);
sock.Send(_usedEnc.GetBytes(cmd));

Stream streamToUse;
NetworkStreamEx ns = new NetworkStreamEx(sock, false);
if (reqUri.Scheme.ToLower() == "https")
{
System.Net.Security.SslStream sslStream = new System.Net.Security.SslStream(
ns,
false,
delegate { return true; }
);
sslStream.AuthenticateAsClient(host, new System.Security.Cryptography.X509Certificates.X509CertificateCollection(), System.Security.Authentication.SslProtocols.None, false);
streamToUse = sslStream;
}
else
{
streamToUse = ns;
}

byte[] cmdBytes = _usedEnc.GetBytes(cmd);
streamToUse.Write(cmdBytes, 0, cmdBytes.Length);

// simple reading loop
// read while have the data
Expand All @@ -1635,11 +1667,12 @@ private TrackerResponse MakeWebRequestEx(Uri reqUri)
MemoryStream memStream = new MemoryStream();
while (true)
{
int dataLen = sock.Receive(data);
int dataLen = streamToUse.Read(data, 0, data.Length);
if (0 == dataLen)
break;
memStream.Write(data, 0, dataLen);
}
streamToUse.Dispose();

if (memStream.Length == 0)
{
Expand Down
7 changes: 2 additions & 5 deletions Source/RatioMaster/RatioMaster.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -23,7 +23,7 @@
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<NoWin32Manifest>true</NoWin32Manifest>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand Down Expand Up @@ -213,9 +213,6 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down