Browse Source

Added canary to transparency

tags/2.0.3
Teknikode 5 years ago
parent
commit
97284560be

+ 12
- 28
Teknik/Areas/Stream/Controllers/StreamController.cs View File

@@ -24,46 +24,30 @@ namespace Teknik.Areas.Stream.Controllers
[AllowAnonymous]
public ActionResult ViewStream(int id)
{
if (Config.StreamConfig.Enabled)
try
{
if (id > 0 && id <= Config.StreamConfig.Sources.Count)
if (Config.StreamConfig.Enabled)
{
// ID is valid, so let's get the stream
string source = Config.StreamConfig.Sources[id - 1];

System.IO.Stream stream = null;

//This controls how many bytes to read at a time and send to the client
int bytesToRead = 10000;

// Buffer to read bytes in chunk size specified above
byte[] buffer = new Byte[bytesToRead];


try
if (id > 0 && id <= Config.StreamConfig.Sources.Count)
{
// ID is valid, so let's get the stream
string source = Config.StreamConfig.Sources[id - 1];
//Create a WebRequest to get the file
HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(source);

//Create a response for this request
HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();

if (fileReq.ContentLength > 0)
fileResp.ContentLength = fileReq.ContentLength;

//Get the Stream returned from the response
stream = fileResp.GetResponseStream();

return File(stream, "image/jpeg");
}
catch (Exception ex)
{
return Redirect(Url.SubRouteUrl("error", "Error.Http404"));
return File(fileResp.GetResponseStream(), fileResp.ContentType);
}
return Redirect(Url.SubRouteUrl("error", "Error.Http404"));
}
return Redirect(Url.SubRouteUrl("error", "Error.Http404"));
return Redirect(Url.SubRouteUrl("error", "Error.Http403"));
}
catch (Exception ex)
{
return Redirect(Url.SubRouteUrl("error", "Error.Exception", new { exception = ex }));
}
return Redirect(Url.SubRouteUrl("error", "Error.Http403"));
}
}
}

+ 26
- 0
Teknik/Areas/Transparency/Views/Transparency/Index.cshtml View File

@@ -250,6 +250,32 @@
}
</div>
}
<br />
<p>
-----BEGIN PGP SIGNED MESSAGE-----<br />
Hash: SHA1<br />
<br />
Beginning January 1st, 2014 until today, May 12, 2016, Teknik has not recieved a national security letter, FISA order, or any other classified request for user information.<br />
<br />
This notice is valid until June 12, 2016.<br />
-----BEGIN PGP SIGNATURE-----<br />
Version: GnuPG v1<br />
<br />
iQIcBAEBAgAGBQJXNCtdAAoJEP4EVManSeNwn/MP/04nujsrABZyJyoE0MCP+gk2<br />
bKAwhQKsjv2UxP/eK2UD7E6W8B5uuMl9THYYQWZWkTYlGW2QWaeiI2jqwbAU5tWu<br />
WpmsmaPGWErTM32cTdcqJQOO3eo8xc8y9KIIDWhrilIkIttDNbmKohvu7nbLgo4Q<br />
r1ugDIcqu3J7TEueTik2tGNKuD7UyXH+mv+mkEp+FS7aqR9Ub7k4cDczTrVekoAv<br />
Ux+ol9Vm/RCwLGB3orLiPU8jhU2aqMMHy4+s7jnuqTiEGNNyUULXhF0yclIytdQE<br />
d2kDyQ1nnBCpuET9Y198e/1jQlxBHX0VCX0h6hE9BKk7s1y1B+WIt1fEgEdVHAn4<br />
Cc+bkp4aPmVT4tvSnncP+Lqpj7yBwlbFI/m6W1oQ5m6WL9aVMoreWh/AkU+HmaMc<br />
j4Hsjo3PuPOoaa4gcX8dQMSVtATsX1Hnnu3f0YNOZwb2UmYHe+FmaDdGryIp9qTw<br />
oVDOV8q5VfjyDDOJ3VbhztOPA3jEoG4bsb2S5eLVCbFrGka1In81W141aq9Lgbv3<br />
5L8gUpiqcv6HEfbwkEU8EzfMryep764PHVvquWIjirKabiPC0TUQoqabndhLQ5Ix<br />
onZCq5ObyeQxTrus/xjPogu2yZcboiydrav0J8PXwotvaVDUZmrGXuuqosQwfQ1T<br />
HvABK7OR5ZLetP0Co5LR<br />
=/G4U<br />
-----END PGP SIGNATURE-----
</p>
</div>
</div>
</div>

+ 87
- 0
Teknik/Helpers/ActionResultHelper.cs View File

@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;

namespace Teknik.Helpers
{
/// <summary>
/// Result for relaying an HttpWebResponse
/// </summary>
public class HttpWebResponseResult : ActionResult
{
private readonly HttpWebResponse _response;
private readonly ActionResult _innerResult;

/// <summary>
/// Relays an HttpWebResponse as verbatim as possible.
/// </summary>
/// <param name="responseToRelay">The HTTP response to relay</param>
public HttpWebResponseResult(HttpWebResponse responseToRelay)
{
if (responseToRelay == null)
{
throw new ArgumentNullException("response");
}

_response = responseToRelay;

Stream contentStream;
if (responseToRelay.ContentEncoding.Contains("gzip"))
{
contentStream = new GZipStream(responseToRelay.GetResponseStream(), CompressionMode.Decompress);
}
else if (responseToRelay.ContentEncoding.Contains("deflate"))
{
contentStream = new DeflateStream(responseToRelay.GetResponseStream(), CompressionMode.Decompress);
}
else
{
contentStream = responseToRelay.GetResponseStream();
}


if (string.IsNullOrEmpty(responseToRelay.CharacterSet))
{
// File result
_innerResult = new FileStreamResult(contentStream, responseToRelay.ContentType);
}
else
{
// Text result
var contentResult = new ContentResult();
contentResult = new ContentResult();
contentResult.Content = new StreamReader(contentStream).ReadToEnd();
_innerResult = contentResult;
}
}

public override void ExecuteResult(ControllerContext context)
{
var clientResponse = context.HttpContext.Response;
clientResponse.StatusCode = (int)_response.StatusCode;

foreach (var headerKey in _response.Headers.AllKeys)
{
switch (headerKey)
{
case "Content-Length":
case "Transfer-Encoding":
case "Content-Encoding":
// Handled by IIS
break;

default:
clientResponse.AddHeader(headerKey, _response.Headers[headerKey]);
break;
}
}

_innerResult.ExecuteResult(context);
}
}
}

+ 1
- 0
Teknik/Teknik.csproj View File

@@ -265,6 +265,7 @@
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Helpers\ActionResultHelper.cs" />
<Compile Include="Helpers\Constants.cs" />
<Compile Include="Helpers\Crypto.cs" />
<Compile Include="Areas\Profile\Models\Group.cs" />

Loading…
Cancel
Save