Browse Source

Changed canary message to pul from file.

pull/29/head
Teknikode 6 years ago
parent
commit
1c35fcfd7b
  1. 109
      Teknik/Areas/Transparency/Controllers/TransparencyController.cs
  2. 2
      Teknik/Areas/Transparency/ViewModels/TransparencyViewModel.cs
  3. 21
      Teknik/Areas/Transparency/Views/Transparency/Index.cshtml
  4. 123
      Teknik/Configuration/Config.cs
  5. 21
      Teknik/Configuration/TransparencyConfig.cs
  6. 1
      Teknik/Teknik.csproj

109
Teknik/Areas/Transparency/Controllers/TransparencyController.cs

@ -21,72 +21,81 @@ namespace Teknik.Areas.Transparency.Controllers @@ -21,72 +21,81 @@ namespace Teknik.Areas.Transparency.Controllers
ViewBag.Description = "Teknik transparency and statistics.";
TransparencyViewModel model = new TransparencyViewModel();
Upload.Models.Upload upload = db.Uploads.OrderByDescending(u => u.UploadId).FirstOrDefault();
model.UploadCount = (upload != null) ? upload.UploadId : 0;
model.UploadSize = (upload != null) ? db.Uploads.Sum(u => (long)u.ContentLength) : 0;
if (Config.TransparencyConfig.Enabled)
{
Upload.Models.Upload upload = db.Uploads.OrderByDescending(u => u.UploadId).FirstOrDefault();
model.UploadCount = (upload != null) ? upload.UploadId : 0;
model.UploadSize = (upload != null) ? db.Uploads.Sum(u => (long)u.ContentLength) : 0;
Paste.Models.Paste paste = db.Pastes.OrderByDescending(p => p.PasteId).FirstOrDefault();
model.PasteCount = (paste != null) ? paste.PasteId : 0;
Paste.Models.Paste paste = db.Pastes.OrderByDescending(p => p.PasteId).FirstOrDefault();
model.PasteCount = (paste != null) ? paste.PasteId : 0;
Profile.Models.User user = db.Users.OrderByDescending(u => u.UserId).FirstOrDefault();
model.UserCount = (user != null) ? user.UserId : 0;
Profile.Models.User user = db.Users.OrderByDescending(u => u.UserId).FirstOrDefault();
model.UserCount = (user != null) ? user.UserId : 0;
Shortener.Models.ShortenedUrl url = db.ShortenedUrls.OrderByDescending(s => s.ShortenedUrlId).FirstOrDefault();
model.ShortenedUrlCount = (url != null) ? url.ShortenedUrlId : 0;
Shortener.Models.ShortenedUrl url = db.ShortenedUrls.OrderByDescending(s => s.ShortenedUrlId).FirstOrDefault();
model.ShortenedUrlCount = (url != null) ? url.ShortenedUrlId : 0;
model.TotalNet = new Dictionary<string, double>();
model.TotalNet = new Dictionary<string, double>();
var billSums = db.Transactions.OfType<Bill>().GroupBy(b => b.Currency).Select(b => new { currency = b.Key, total = b.Sum(c => c.Amount) }).ToList();
model.TotalBills = new Dictionary<string, double>();
foreach (var sum in billSums)
{
model.TotalBills.Add(sum.currency, sum.total);
if (model.TotalNet.ContainsKey(sum.currency))
var billSums = db.Transactions.OfType<Bill>().GroupBy(b => b.Currency).Select(b => new { currency = b.Key, total = b.Sum(c => c.Amount) }).ToList();
model.TotalBills = new Dictionary<string, double>();
foreach (var sum in billSums)
{
model.TotalNet[sum.currency] += sum.total;
model.TotalBills.Add(sum.currency, sum.total);
if (model.TotalNet.ContainsKey(sum.currency))
{
model.TotalNet[sum.currency] += sum.total;
}
else
{
model.TotalNet.Add(sum.currency, sum.total);
}
}
else
{
model.TotalNet.Add(sum.currency, sum.total);
}
}
var oneSums = db.Transactions.OfType<OneTime>().GroupBy(b => b.Currency).Select(b => new { currency = b.Key, total = b.Sum(c => c.Amount) }).ToList();
model.TotalOneTimes = new Dictionary<string, double>();
foreach (var sum in oneSums)
{
model.TotalOneTimes.Add(sum.currency, sum.total);
if (model.TotalNet.ContainsKey(sum.currency))
{
model.TotalNet[sum.currency] += sum.total;
}
else
var oneSums = db.Transactions.OfType<OneTime>().GroupBy(b => b.Currency).Select(b => new { currency = b.Key, total = b.Sum(c => c.Amount) }).ToList();
model.TotalOneTimes = new Dictionary<string, double>();
foreach (var sum in oneSums)
{
model.TotalNet.Add(sum.currency, sum.total);
model.TotalOneTimes.Add(sum.currency, sum.total);
if (model.TotalNet.ContainsKey(sum.currency))
{
model.TotalNet[sum.currency] += sum.total;
}
else
{
model.TotalNet.Add(sum.currency, sum.total);
}
}
}
var donationSums = db.Transactions.OfType<Donation>().GroupBy(b => b.Currency).Select(b => new { currency = b.Key, total = b.Sum(c => c.Amount) }).ToList();
model.TotalDonations = new Dictionary<string, double>();
foreach (var sum in donationSums)
{
model.TotalDonations.Add(sum.currency, sum.total);
if (model.TotalNet.ContainsKey(sum.currency))
{
model.TotalNet[sum.currency] += sum.total;
}
else
var donationSums = db.Transactions.OfType<Donation>().GroupBy(b => b.Currency).Select(b => new { currency = b.Key, total = b.Sum(c => c.Amount) }).ToList();
model.TotalDonations = new Dictionary<string, double>();
foreach (var sum in donationSums)
{
model.TotalNet.Add(sum.currency, sum.total);
model.TotalDonations.Add(sum.currency, sum.total);
if (model.TotalNet.ContainsKey(sum.currency))
{
model.TotalNet[sum.currency] += sum.total;
}
else
{
model.TotalNet.Add(sum.currency, sum.total);
}
}
}
model.Bills = db.Transactions.OfType<Bill>().OrderByDescending(b => b.DateSent).ToList();
model.OneTimes = db.Transactions.OfType<OneTime>().OrderByDescending(b => b.DateSent).ToList();
model.Donations = db.Transactions.OfType<Donation>().OrderByDescending(b => b.DateSent).ToList();
model.Bills = db.Transactions.OfType<Bill>().OrderByDescending(b => b.DateSent).ToList();
model.OneTimes = db.Transactions.OfType<OneTime>().OrderByDescending(b => b.DateSent).ToList();
model.Donations = db.Transactions.OfType<Donation>().OrderByDescending(b => b.DateSent).ToList();
model.Takedowns = db.Takedowns.OrderByDescending(b => b.DateRequested).ToList();
model.Takedowns = db.Takedowns.OrderByDescending(b => b.DateRequested).ToList();
// Grab canary file
if (System.IO.File.Exists(Config.TransparencyConfig.CanaryPath))
{
model.Canary = System.IO.File.ReadAllText(Config.TransparencyConfig.CanaryPath);
}
}
return View(model);
}
}

2
Teknik/Areas/Transparency/ViewModels/TransparencyViewModel.cs

@ -20,6 +20,8 @@ namespace Teknik.Areas.Transparency.ViewModels @@ -20,6 +20,8 @@ namespace Teknik.Areas.Transparency.ViewModels
public int ShortenedUrlCount { get; set; }
public string Canary { get; set; }
public Dictionary<string, double> TotalBills { get; set; }
public Dictionary<string, double> TotalOneTimes { get; set; }

21
Teknik/Areas/Transparency/Views/Transparency/Index.cshtml

@ -255,26 +255,7 @@ @@ -255,26 +255,7 @@
</div>
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<pre>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Beginning January 1st, 2014 until today, May 12, 2016, Teknik has not received a national security letter, FISA order, or any other classified request for user information.
This notice is valid until June 12, 2016.
-----BEGIN PGP SIGNATURE-----
Version: Keybase OpenPGP v2.0.53
Comment: https://keybase.io/crypto
wsBcBAABCgAGBQJXNhfXAAoJEFEhCHsN5mi3R2EH/24A7o0FVGtYOV6mY+0I6AYP
dRu58ocp4Q+N5LMPxXAhYu9lHeu9hWOp/x5UxtPA3uKILtq7sAeBa6iA0jyu9b4C
xKcY9iLy2lntN8lWr9w6qjtKp4JTWHR/R1J1vkQUrC+/HQZS/gFRVyopDjXes5Sj
mLBaweep4ejYMLWed0kJWJLqXmJk6U/ONLdN2GrfqEPDhdfX8DCy3RADNozgyIz/
sdDAV25Wa9Gq4ZIG+TJQhaQ3hm6UADesV4IAy2L/tREGQSvpX9ADb3oOCsTn4YqJ
lfmyMyljqic67qmAr6ffHv7ptm0DLtNSBOTL8puhK0C9zlu52yCkg/w5UfWIw2M=
=6s3W
-----END PGP SIGNATURE-----
</pre>
<pre>@Model.Canary</pre>
</div>
</div>
</div>

123
Teknik/Configuration/Config.cs

@ -12,29 +12,30 @@ namespace Teknik.Configuration @@ -12,29 +12,30 @@ namespace Teknik.Configuration
private ReaderWriterLockSlim _ConfigFileRWLock;
private JsonSerializerSettings _JsonSettings;
private bool _DevEnvironment;
private bool _Migrate;
private string _Title;
private string _Description;
private string _Author;
private string _Host;
private string _SupportEmail;
private string _BitcoinAddress;
private string _Salt1;
private string _Salt2;
private UserConfig _UserConfig;
private ContactConfig _ContactConfig;
private EmailConfig _EmailConfig;
private GitConfig _GitConfig;
private UploadConfig _UploadConfig;
private PasteConfig _PasteConfig;
private BlogConfig _BlogConfig;
private ApiConfig _ApiConfig;
private PodcastConfig _PodcastConfig;
private StreamConfig _StreamConfig;
private ShortenerConfig _ShortenerConfig;
private DatabaseConfig _DatabaseConfig;
private PiwikConfig _PiwikConfig;
private bool _DevEnvironment;
private bool _Migrate;
private string _Title;
private string _Description;
private string _Author;
private string _Host;
private string _SupportEmail;
private string _BitcoinAddress;
private string _Salt1;
private string _Salt2;
private UserConfig _UserConfig;
private ContactConfig _ContactConfig;
private EmailConfig _EmailConfig;
private GitConfig _GitConfig;
private UploadConfig _UploadConfig;
private PasteConfig _PasteConfig;
private BlogConfig _BlogConfig;
private ApiConfig _ApiConfig;
private PodcastConfig _PodcastConfig;
private StreamConfig _StreamConfig;
private ShortenerConfig _ShortenerConfig;
private TransparencyConfig _TransparencyConfig;
private DatabaseConfig _DatabaseConfig;
private PiwikConfig _PiwikConfig;
public bool DevEnvironment { get { return _DevEnvironment; } set { _DevEnvironment = value; } }
public bool Migrate { get { return _Migrate; } set { _Migrate = value; } }
@ -50,43 +51,46 @@ namespace Teknik.Configuration @@ -50,43 +51,46 @@ namespace Teknik.Configuration
public string Salt2 { get { return _Salt2; } set { _Salt2 = value; } }
// User Configuration
public UserConfig UserConfig { get { return _UserConfig; } set { _UserConfig = value; } }
public UserConfig UserConfig { get { return _UserConfig; } set { _UserConfig = value; } }
// Contact Configuration
public ContactConfig ContactConfig { get { return _ContactConfig; } set { _ContactConfig = value; } }
public ContactConfig ContactConfig { get { return _ContactConfig; } set { _ContactConfig = value; } }
// Mail Server Configuration
public EmailConfig EmailConfig { get { return _EmailConfig; } set { _EmailConfig = value; } }
public EmailConfig EmailConfig { get { return _EmailConfig; } set { _EmailConfig = value; } }
// Git Service Configuration
public GitConfig GitConfig { get { return _GitConfig; } set { _GitConfig = value; } }
public GitConfig GitConfig { get { return _GitConfig; } set { _GitConfig = value; } }
// Blog Configuration
public BlogConfig BlogConfig { get { return _BlogConfig; } set { _BlogConfig = value; } }
public BlogConfig BlogConfig { get { return _BlogConfig; } set { _BlogConfig = value; } }
// Upload Configuration
public UploadConfig UploadConfig { get { return _UploadConfig; } set { _UploadConfig = value; } }
public UploadConfig UploadConfig { get { return _UploadConfig; } set { _UploadConfig = value; } }
// Paste Configuration
public PasteConfig PasteConfig { get { return _PasteConfig; } set { _PasteConfig = value; } }
public PasteConfig PasteConfig { get { return _PasteConfig; } set { _PasteConfig = value; } }
// API Configuration
public ApiConfig ApiConfig { get { return _ApiConfig; } set { _ApiConfig = value; } }
public ApiConfig ApiConfig { get { return _ApiConfig; } set { _ApiConfig = value; } }
// Podcast Configuration
public PodcastConfig PodcastConfig { get { return _PodcastConfig; } set { _PodcastConfig = value; } }
public PodcastConfig PodcastConfig { get { return _PodcastConfig; } set { _PodcastConfig = value; } }
// Stream Configuration
public StreamConfig StreamConfig { get { return _StreamConfig; } set { _StreamConfig = value; } }
public StreamConfig StreamConfig { get { return _StreamConfig; } set { _StreamConfig = value; } }
// Shortener Configuration
public ShortenerConfig ShortenerConfig { get { return _ShortenerConfig; } set { _ShortenerConfig = value; } }
public ShortenerConfig ShortenerConfig { get { return _ShortenerConfig; } set { _ShortenerConfig = value; } }
// Shortener Configuration
public TransparencyConfig TransparencyConfig { get { return _TransparencyConfig; } set { _TransparencyConfig = value; } }
// Database Configuration
public DatabaseConfig DatabaseConfig { get { return _DatabaseConfig; } set { _DatabaseConfig = value; } }
public DatabaseConfig DatabaseConfig { get { return _DatabaseConfig; } set { _DatabaseConfig = value; } }
// Piwik Configuration
public PiwikConfig PiwikConfig { get { return _PiwikConfig; } set { _PiwikConfig = value; } }
public PiwikConfig PiwikConfig { get { return _PiwikConfig; } set { _PiwikConfig = value; } }
public Config()
{
@ -100,29 +104,30 @@ namespace Teknik.Configuration @@ -100,29 +104,30 @@ namespace Teknik.Configuration
public void SetDefaults()
{
DevEnvironment = false;
Migrate = false;
Title = string.Empty;
Description = string.Empty;
Author = string.Empty;
Host = string.Empty;
SupportEmail = string.Empty;
BitcoinAddress = string.Empty;
Salt1 = string.Empty;
Salt2 = string.Empty;
UserConfig = new UserConfig();
EmailConfig = new EmailConfig();
ContactConfig = new ContactConfig();
GitConfig = new GitConfig();
BlogConfig = new BlogConfig();
UploadConfig = new UploadConfig();
PasteConfig = new PasteConfig();
ApiConfig = new ApiConfig();
PodcastConfig = new PodcastConfig();
StreamConfig = new StreamConfig();
ShortenerConfig = new ShortenerConfig();
DatabaseConfig = new DatabaseConfig();
PiwikConfig = new PiwikConfig();
DevEnvironment = false;
Migrate = false;
Title = string.Empty;
Description = string.Empty;
Author = string.Empty;
Host = string.Empty;
SupportEmail = string.Empty;
BitcoinAddress = string.Empty;
Salt1 = string.Empty;
Salt2 = string.Empty;
UserConfig = new UserConfig();
EmailConfig = new EmailConfig();
ContactConfig = new ContactConfig();
GitConfig = new GitConfig();
BlogConfig = new BlogConfig();
UploadConfig = new UploadConfig();
PasteConfig = new PasteConfig();
ApiConfig = new ApiConfig();
PodcastConfig = new PodcastConfig();
StreamConfig = new StreamConfig();
ShortenerConfig = new ShortenerConfig();
TransparencyConfig = new TransparencyConfig();
DatabaseConfig = new DatabaseConfig();
PiwikConfig = new PiwikConfig();
}
public static Config Deserialize(string text)

21
Teknik/Configuration/TransparencyConfig.cs

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Teknik.Configuration
{
public class TransparencyConfig
{
public bool Enabled { get; set; }
public string CanaryPath { get; set; }
public TransparencyConfig()
{
Enabled = false;
CanaryPath = string.Empty;
}
}
}

1
Teknik/Teknik.csproj

@ -246,6 +246,7 @@ @@ -246,6 +246,7 @@
<Compile Include="Areas\Upload\ViewModels\UploadViewModel.cs" />
<Compile Include="Configuration\PiwikConfig.cs" />
<Compile Include="Configuration\ShortenerConfig.cs" />
<Compile Include="Configuration\TransparencyConfig.cs" />
<Compile Include="Configuration\StreamConfig.cs" />
<Compile Include="Configuration\ApiConfig.cs" />
<Compile Include="Configuration\DatabaseConfig.cs" />

Loading…
Cancel
Save