Misc changes such as performance tuning, added support for more than 64 threads for the scanner.
This commit is contained in:
parent
a1f5b08ac3
commit
5fe35192c6
@ -6,8 +6,8 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
<Platform>x64</Platform>
|
<!--<Platform>x64</Platform>-->
|
||||||
<Optimize>true</Optimize>
|
<Optimize>false</Optimize>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -161,19 +161,33 @@ public class ContentFilter
|
|||||||
|
|
||||||
for (int i = 0; i < ports.Length; i++)
|
for (int i = 0; i < ports.Length; i++)
|
||||||
{
|
{
|
||||||
string? html;
|
string? html = "";
|
||||||
|
|
||||||
if (ports[i] == 80)
|
if (ports[i] == 80)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(url1)) continue;
|
if (string.IsNullOrWhiteSpace(url1)) continue;
|
||||||
|
|
||||||
html = Task.Run(() => HttpClientHelper.GetHtml(url1, 80).Result).Result;
|
try
|
||||||
|
{
|
||||||
|
html = HttpClientHelper.GetHtml(url1, 80).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(url2)) continue;
|
if (string.IsNullOrWhiteSpace(url2)) continue;
|
||||||
|
|
||||||
html = Task.Run(() => HttpClientHelper.GetHtml(url2, 443).Result).Result;
|
try
|
||||||
|
{
|
||||||
|
html = HttpClientHelper.GetHtml(url2, 443).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(html)) continue;
|
if (string.IsNullOrWhiteSpace(html)) continue;
|
||||||
@ -182,8 +196,8 @@ public class ContentFilter
|
|||||||
if (ports[i] == 443 && string.IsNullOrWhiteSpace(title2)) { FilterHelper.GetTitle(html ,out title2); }
|
if (ports[i] == 443 && string.IsNullOrWhiteSpace(title2)) { FilterHelper.GetTitle(html ,out title2); }
|
||||||
if (ports[i] == 80 && string.IsNullOrWhiteSpace(description1)) { FilterHelper.GetDescription(html, out description1); }
|
if (ports[i] == 80 && string.IsNullOrWhiteSpace(description1)) { FilterHelper.GetDescription(html, out description1); }
|
||||||
if (ports[i] == 443 && string.IsNullOrWhiteSpace(description2)) { FilterHelper.GetDescription(html, out description2); }
|
if (ports[i] == 443 && string.IsNullOrWhiteSpace(description2)) { FilterHelper.GetDescription(html, out description2); }
|
||||||
if (ports[i] == 80 && !robotsTxt1) { robotsTxt1 = Task.Run(() => HttpClientHelper.HasRobotsTxt(url1, 80).Result).Result; }
|
if (ports[i] == 80 && !robotsTxt1) { robotsTxt1 = HttpClientHelper.HasRobotsTxt(url1, 80).GetAwaiter().GetResult(); }
|
||||||
if (ports[i] == 443 && !robotsTxt2) { robotsTxt2 = Task.Run(() => HttpClientHelper.HasRobotsTxt(url2, 443).Result).Result; }
|
if (ports[i] == 443 && !robotsTxt2) { robotsTxt2 = HttpClientHelper.HasRobotsTxt(url2, 443).GetAwaiter().GetResult(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
Filtered siteData = new()
|
Filtered siteData = new()
|
||||||
|
@ -41,7 +41,7 @@ public class IpScanner
|
|||||||
_timeout = milliseconds;
|
_timeout = milliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaitHandle[] Start(int threads)
|
public List<WaitHandle[]> Start(int threads)
|
||||||
{
|
{
|
||||||
int threadsAmount = 0;
|
int threadsAmount = 0;
|
||||||
if (threads % 2 == 0)
|
if (threads % 2 == 0)
|
||||||
@ -49,7 +49,22 @@ public class IpScanner
|
|||||||
threadsAmount = 256 / threads;
|
threadsAmount = 256 / threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitHandle[] waitHandles = new WaitHandle[threads];
|
WaitHandle[] waitHandle1;
|
||||||
|
WaitHandle[] waitHandle2;
|
||||||
|
|
||||||
|
if (threads <= 64)
|
||||||
|
{
|
||||||
|
waitHandle1 = new WaitHandle[threads];
|
||||||
|
waitHandle2 = new WaitHandle[threads];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
waitHandle1 = new WaitHandle[64];
|
||||||
|
waitHandle2 = new WaitHandle[64];
|
||||||
|
}
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
int counter2 = 0;
|
||||||
|
|
||||||
for (int i = 0; i < threads; i++)
|
for (int i = 0; i < threads; i++)
|
||||||
{
|
{
|
||||||
@ -63,15 +78,32 @@ public class IpScanner
|
|||||||
Handle = handle
|
Handle = handle
|
||||||
};
|
};
|
||||||
|
|
||||||
waitHandles[i] = handle;
|
if (i < 64)
|
||||||
|
{
|
||||||
|
waitHandle1[counter] = handle;
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
waitHandle2[counter2] = handle;
|
||||||
|
counter2++;
|
||||||
|
}
|
||||||
|
|
||||||
Thread f = new (Scan!);
|
Thread f = new (Scan!);
|
||||||
f.Start(scanSettings);
|
f.Start(scanSettings);
|
||||||
|
|
||||||
Console.WriteLine($"Scanner thread ({i}) started");
|
Console.WriteLine($"Scanner thread ({i}) started");
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<WaitHandle[]> waitHandles = new();
|
||||||
|
|
||||||
|
Console.WriteLine("Waithandle 1 count = " + waitHandle1.Length);
|
||||||
|
Console.WriteLine("Waithandle 2 count = " + waitHandle2.Length);
|
||||||
|
|
||||||
|
waitHandles.Add(waitHandle1);
|
||||||
|
waitHandles.Add(waitHandle2);
|
||||||
|
|
||||||
return waitHandles;
|
return waitHandles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +225,8 @@ public class IpScanner
|
|||||||
resumeObject.FirstByte = i;
|
resumeObject.FirstByte = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//Console.WriteLine($"Thread ({scanSettings.ThreadNumber}) is at index ({i}) out of ({scanSettings.End}). Remaining ({scanSettings.End - i})");
|
|
||||||
|
Console.WriteLine($"Thread ({scanSettings.ThreadNumber}) is at index ({i}) out of ({scanSettings.End}). Remaining ({scanSettings.End - i})");
|
||||||
}
|
}
|
||||||
|
|
||||||
_resumeQueue.Enqueue(resumeObject);
|
_resumeQueue.Enqueue(resumeObject);
|
||||||
|
@ -59,9 +59,12 @@ public class ThreadHandler
|
|||||||
{
|
{
|
||||||
Thread.Sleep(5000); // Let the database handler instantiate and warm up first.
|
Thread.Sleep(5000); // Let the database handler instantiate and warm up first.
|
||||||
|
|
||||||
WaitHandle[] wait = _ipScanner.Start(64);
|
List<WaitHandle[]> wait = _ipScanner.Start(128);
|
||||||
|
|
||||||
WaitHandle.WaitAll(wait);
|
for (int i = 0; i < wait.Count; i++)
|
||||||
|
{
|
||||||
|
WaitHandle.WaitAll(wait[i]);
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine("Scanner finished");
|
Console.WriteLine("Scanner finished");
|
||||||
|
|
||||||
@ -70,6 +73,8 @@ public class ThreadHandler
|
|||||||
|
|
||||||
private void StartContentFilter()
|
private void StartContentFilter()
|
||||||
{
|
{
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
|
||||||
WaitHandle[] wait = _contentFilter.Start();
|
WaitHandle[] wait = _contentFilter.Start();
|
||||||
|
|
||||||
WaitHandle.WaitAll(wait);
|
WaitHandle.WaitAll(wait);
|
||||||
@ -96,7 +101,7 @@ public class ThreadHandler
|
|||||||
|
|
||||||
private void StartDiscardedDbHandler()
|
private void StartDiscardedDbHandler()
|
||||||
{
|
{
|
||||||
WaitHandle[] wait = _dbHandler.Start(2);
|
WaitHandle[] wait = _dbHandler.Start(4);
|
||||||
|
|
||||||
WaitHandle.WaitAll(wait);
|
WaitHandle.WaitAll(wait);
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ public static class HttpClientHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.DefaultRequestHeaders.Accept.Clear();
|
client.DefaultRequestHeaders.Accept.Clear();
|
||||||
client.Timeout = TimeSpan.FromSeconds(30);
|
client.Timeout = TimeSpan.FromSeconds(1);
|
||||||
|
|
||||||
HttpResponseMessage? response = null;
|
HttpResponseMessage? response;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -28,10 +28,10 @@ public static class HttpClientHelper
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
//
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response is null || !response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -53,6 +53,7 @@ public static class HttpClientHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
client.DefaultRequestHeaders.Accept.Clear();
|
client.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
client.Timeout = TimeSpan.FromSeconds(1);
|
||||||
|
|
||||||
HttpResponseMessage? response = null;
|
HttpResponseMessage? response = null;
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Diagnostics;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using Models.Model.Backend;
|
using Models.Model.Backend;
|
||||||
using Models.Model.External;
|
using Models.Model.External;
|
||||||
@ -24,18 +25,45 @@ public class DbHandler
|
|||||||
" VALUES (@ip1, @ip2, @ip3, @ip4, @port1, @port2, @filtered)";
|
" VALUES (@ip1, @ip2, @ip3, @ip4, @port1, @port2, @filtered)";
|
||||||
|
|
||||||
private const string InsertIntoFiltered = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY;" +
|
private const string InsertIntoFiltered = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY;" +
|
||||||
" PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off;" +
|
" PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = on;" +
|
||||||
" INSERT INTO Filtered (Ip1, Ip2, Ip3, Ip4, Port1, Port2, Title1, Title2," +
|
" INSERT INTO Filtered (Ip1, Ip2, Ip3, Ip4, Port1, Port2, Title1, Title2," +
|
||||||
" Description1, Description2, Url1, Url2, ServerType1, ServerType2," +
|
" Description1, Description2, Url1, Url2, ServerType1, ServerType2," +
|
||||||
" RobotsTXT1, RobotsTXT2, HttpVersion1, HttpVersion2, CertificateIssuerCountry," +
|
" RobotsTXT1, RobotsTXT2, HttpVersion1, HttpVersion2, CertificateIssuerCountry," +
|
||||||
" CertificateOrganizationName, IpV6, TlsVersion, CipherSuite, KeyExchangeAlgorithm," +
|
" CertificateOrganizationName, IpV6, TlsVersion, CipherSuite, KeyExchangeAlgorithm," +
|
||||||
" PublicKeyType1, PublicKeyType2, PublicKeyType3, AcceptEncoding1, AcceptEncoding2," +
|
" PublicKeyType1, PublicKeyType2, PublicKeyType3, AcceptEncoding1, AcceptEncoding2," +
|
||||||
" ALPN, Connection1, Connection2) VALUES (@ip1, @ip2, @ip3, @ip4, @port1, @port2," +
|
" ALPN, Connection1, Connection2) VALUES (@ip1, @ip2, @ip3, @ip4, @port1, @port2, " +
|
||||||
" @title1, @title2, @description1, @description2, @url1, @url2, @serverType1," +
|
" @title1, @title2, @description1, @description2, @url1, @url2, " +
|
||||||
" @serverType2, @robotsTXT1, @robotsTXT2, @httpVersion1, @httpVersion2," +
|
" (SELECT ServerId FROM ServerType WHERE Type = @serverType1), " +
|
||||||
" @certificateIssuerCountry, @certificateOrganizationName, @ipV6, @tlsVersion," +
|
" (SELECT ServerId FROM ServerType WHERE Type = @serverType2), " +
|
||||||
" @cipherSuite, @keyExchangeAlgorithm, @publicKeyType1, @publicKeyType2," +
|
" @robotsTXT1, @robotsTXT2," +
|
||||||
" @publicKeyType3, @acceptEncoding1, @acceptEncoding2, @aLPN, @connection1, @connection2)";
|
" (SELECT HttpId FROM HttpVersion WHERE Version = @httpVersion1)," +
|
||||||
|
" (SELECT HttpId FROM HttpVersion WHERE Version = @httpVersion2)," +
|
||||||
|
" (SELECT CertificateIssuerId FROM CertificateIssuerCountry WHERE Country = @certificateIssuerCountry)," +
|
||||||
|
" (SELECT CertificateOrganizationId FROM CertificateOrganizationName WHERE Name = @certificateOrganizationName), " +
|
||||||
|
" @ipV6, " +
|
||||||
|
" (SELECT TlsId FROM TlsVersion WHERE Version = @tlsVersion)," +
|
||||||
|
" (SELECT CipherId FROM CipherSuite WHERE Suite = @cipherSuite)," +
|
||||||
|
" (SELECT KeyExchangeId FROM KeyExchangeAlgorithm WHERE Algorithm = @keyExchangeAlgorithm)," +
|
||||||
|
" (SELECT PublicKeyId FROM PublicKeyType WHERE Type = @publicKeyType1)," +
|
||||||
|
" (SELECT PublicKeyId FROM PublicKeyType WHERE Type = @publicKeyType2)," +
|
||||||
|
" (SELECT PublicKeyId FROM PublicKeyType WHERE Type = @publicKeyType3)," +
|
||||||
|
" (SELECT AcceptId FROM AcceptEncoding WHERE Encoding = @acceptEncoding1)," +
|
||||||
|
" (SELECT AcceptId FROM AcceptEncoding WHERE Encoding = @acceptEncoding2)," +
|
||||||
|
" (SELECT ALPNId FROM ALPN WHERE ALPNValue = @aLPN)," +
|
||||||
|
" (SELECT ConnectionId FROM Connection WHERE ConnectionValue = @connection1)," +
|
||||||
|
" (SELECT ConnectionId FROM Connection WHERE ConnectionValue = @connection2))";
|
||||||
|
|
||||||
|
private const string InsertIntoFilteredServerType = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO ServerType (Type) VALUES (@type)";
|
||||||
|
private const string InsertIntoFilteredHttpVersion = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO HttpVersion (Version) VALUES (@version)";
|
||||||
|
private const string InsertIntoFilteredCertificateIssuerCountry = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO CertificateIssuerCountry (Country) VALUES (@country)";
|
||||||
|
private const string InsertIntoFilteredCertificateOrganizationName = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO CertificateOrganizationName (Name) VALUES (@name)";
|
||||||
|
private const string InsertIntoFilteredTlsVersion = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO TlsVersion (Version) VALUES (@version)";
|
||||||
|
private const string InsertIntoFilteredCipherSuite = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO CipherSuite (Suite) VALUES (@suite)";
|
||||||
|
private const string InsertIntoFilteredKeyExchangeAlgorithm = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO KeyExchangeAlgorithm (Algorithm) VALUES (@algorithm)";
|
||||||
|
private const string InsertIntoFilteredPublicKeyType = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO PublicKeyType (Type) VALUES (@type)";
|
||||||
|
private const string InsertIntoFilteredAcceptEncoding = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO AcceptEncoding (Encoding) VALUES (@encoding)";
|
||||||
|
private const string InsertIntoFilteredALPN = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO ALPN (ALPNValue) VALUES (@alpnValue)";
|
||||||
|
private const string InsertIntoFilteredConnection = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; INSERT OR IGNORE INTO Connection (ConnectionValue) VALUES (@connectionValue)";
|
||||||
|
|
||||||
private const string InsertIntoDiscarded = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY;" +
|
private const string InsertIntoDiscarded = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY;" +
|
||||||
" PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off;" +
|
" PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off;" +
|
||||||
@ -270,8 +298,75 @@ public class DbHandler
|
|||||||
using SqliteConnection connection = new(_filteredConnectionString);
|
using SqliteConnection connection = new(_filteredConnectionString);
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
using SqliteCommand command = new(InsertIntoFiltered, connection);
|
SqliteCommand command = new(InsertIntoFilteredServerType, connection);
|
||||||
|
command.Parameters.AddWithValue("@type", filtered.ServerType1);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredServerType, connection);
|
||||||
|
command.Parameters.AddWithValue("@type", filtered.ServerType2);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredHttpVersion, connection);
|
||||||
|
command.Parameters.AddWithValue("@version", filtered.HttpVersion1);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredHttpVersion, connection);
|
||||||
|
command.Parameters.AddWithValue("@version", filtered.HttpVersion2);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredCertificateIssuerCountry, connection);
|
||||||
|
command.Parameters.AddWithValue("@country", filtered.CertificateIssuerCountry);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredCertificateOrganizationName, connection);
|
||||||
|
command.Parameters.AddWithValue("@name", filtered.CertificateOrganizationName);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredTlsVersion, connection);
|
||||||
|
command.Parameters.AddWithValue("@version", filtered.TlsVersion);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredCipherSuite, connection);
|
||||||
|
command.Parameters.AddWithValue("@suite", filtered.CipherSuite);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredKeyExchangeAlgorithm, connection);
|
||||||
|
command.Parameters.AddWithValue("@algorithm", filtered.KeyExchangeAlgorithm);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredPublicKeyType, connection);
|
||||||
|
command.Parameters.AddWithValue("@type", filtered.PublicKeyType1);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredPublicKeyType, connection);
|
||||||
|
command.Parameters.AddWithValue("@type", filtered.PublicKeyType2);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredPublicKeyType, connection);
|
||||||
|
command.Parameters.AddWithValue("@type", filtered.PublicKeyType3);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredAcceptEncoding, connection);
|
||||||
|
command.Parameters.AddWithValue("@encoding", filtered.AcceptEncoding1);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredAcceptEncoding, connection);
|
||||||
|
command.Parameters.AddWithValue("@encoding", filtered.AcceptEncoding2);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredALPN, connection);
|
||||||
|
command.Parameters.AddWithValue("@alpnValue", filtered.ALPN);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredConnection, connection);
|
||||||
|
command.Parameters.AddWithValue("@connectionValue", filtered.Connection1);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFilteredConnection, connection);
|
||||||
|
command.Parameters.AddWithValue("@connectionValue", filtered.Connection2);
|
||||||
|
_ = command.ExecuteNonQuery();
|
||||||
|
|
||||||
|
command = new(InsertIntoFiltered, connection);
|
||||||
command.Parameters.AddWithValue("@ip1", filtered.Ip.Ip1);
|
command.Parameters.AddWithValue("@ip1", filtered.Ip.Ip1);
|
||||||
command.Parameters.AddWithValue("@ip2", filtered.Ip.Ip2);
|
command.Parameters.AddWithValue("@ip2", filtered.Ip.Ip2);
|
||||||
command.Parameters.AddWithValue("@ip3", filtered.Ip.Ip3);
|
command.Parameters.AddWithValue("@ip3", filtered.Ip.Ip3);
|
||||||
@ -304,8 +399,9 @@ public class DbHandler
|
|||||||
command.Parameters.AddWithValue("@aLPN", filtered.ALPN);
|
command.Parameters.AddWithValue("@aLPN", filtered.ALPN);
|
||||||
command.Parameters.AddWithValue("@connection1", filtered.Connection1);
|
command.Parameters.AddWithValue("@connection1", filtered.Connection1);
|
||||||
command.Parameters.AddWithValue("@connection2", filtered.Connection2);
|
command.Parameters.AddWithValue("@connection2", filtered.Connection2);
|
||||||
|
|
||||||
_ = command.ExecuteNonQuery();
|
_ = command.ExecuteNonQuery();
|
||||||
|
command.Dispose();
|
||||||
|
|
||||||
connection.Close();
|
connection.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,7 +736,7 @@ public class DbHandler
|
|||||||
{
|
{
|
||||||
string databaseName = $"Data Source={_basePath}/Models/Discarded{threadNumber}.db";
|
string databaseName = $"Data Source={_basePath}/Models/Discarded{threadNumber}.db";
|
||||||
|
|
||||||
const string createStatement = "CREATE TABLE IF NOT EXISTS Discarded (Id INTEGER NOT NULL, Ip1 TEXT NOT NULL, Ip2 TEXT NOT NULL, Ip3 TEXT NOT NULL, Ip4 TEXT NOT NULL, ResponseCode INTEGER NOT NULL, PRIMARY KEY(Id AUTOINCREMENT))";
|
const string createStatement = "CREATE TABLE IF NOT EXISTS Discarded (Id INTEGER NOT NULL, Ip1 INTEGER NOT NULL, Ip2 INTEGER NOT NULL, Ip3 INTEGER NOT NULL, Ip4 INTEGER NOT NULL, ResponseCode INTEGER NOT NULL, PRIMARY KEY(Id AUTOINCREMENT))";
|
||||||
|
|
||||||
_discardedConnectionStrings.Add(databaseName);
|
_discardedConnectionStrings.Add(databaseName);
|
||||||
|
|
||||||
|
@ -8,6 +8,5 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.10" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.10" />
|
||||||
<PackageReference Include="SQLite" Version="3.13.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,10 +1,68 @@
|
|||||||
VACUUM;
|
VACUUM;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "ServerType" (
|
||||||
|
"ServerId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"Type" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "HttpVersion" (
|
||||||
|
"HttpId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"Version" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "CertificateIssuerCountry" (
|
||||||
|
"CertificateIssuerId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"Country" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "CertificateOrganizationName" (
|
||||||
|
"CertificateOrganizationId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"Name" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "TlsVersion" (
|
||||||
|
"TlsId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"Version" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "CipherSuite" (
|
||||||
|
"CipherId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"Suite" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "KeyExchangeAlgorithm" (
|
||||||
|
"KeyExchangeId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"Algorithm" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "PublicKeyType" (
|
||||||
|
"PublicKeyId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"Type" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "AcceptEncoding" (
|
||||||
|
"AcceptId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"Encoding" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "ALPN" (
|
||||||
|
"ALPNId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"ALPNValue" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "Connection" (
|
||||||
|
"ConnectionId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"ConnectionValue" TEXT NOT NULL UNIQUE
|
||||||
|
);
|
||||||
|
|
||||||
DROP TABLE Filtered;
|
DROP TABLE Filtered;
|
||||||
|
|
||||||
CREATE TABLE "Filtered" (
|
CREATE TABLE "Filtered" (
|
||||||
"Id" INTEGER NOT NULL,
|
"Id" INTEGER NOT NULL,
|
||||||
"Ip" TEXT NOT NULL,
|
"Ip1" INTEGER NOT NULL,
|
||||||
|
"Ip2" INTEGER NOT NULL,
|
||||||
|
"Ip3" INTEGER NOT NULL,
|
||||||
|
"Ip4" INTEGER NOT NULL,
|
||||||
"Port1" INTEGER NOT NULL,
|
"Port1" INTEGER NOT NULL,
|
||||||
"Port2" INTEGER NOT NULL,
|
"Port2" INTEGER NOT NULL,
|
||||||
"Title1" TEXT NOT NULL,
|
"Title1" TEXT NOT NULL,
|
||||||
@ -13,25 +71,42 @@ CREATE TABLE "Filtered" (
|
|||||||
"Description2" TEXT NOT NULL,
|
"Description2" TEXT NOT NULL,
|
||||||
"Url1" TEXT NOT NULL,
|
"Url1" TEXT NOT NULL,
|
||||||
"Url2" TEXT NOT NULL,
|
"Url2" TEXT NOT NULL,
|
||||||
"ServerType1" TEXT NOT NULL,
|
"ServerType1" INTEGER NOT NULL,
|
||||||
"ServerType2" TEXT NOT NULL,
|
"ServerType2" INTEGER NOT NULL,
|
||||||
"RobotsTXT1" TEXT NOT NULL,
|
"RobotsTXT1" TEXT NOT NULL,
|
||||||
"RobotsTXT2" TEXT NOT NULL,
|
"RobotsTXT2" TEXT NOT NULL,
|
||||||
"HttpVersion1" TEXT NOT NULL,
|
"HttpVersion1" INTEGER NOT NULL,
|
||||||
"HttpVersion2" TEXT NOT NULL,
|
"HttpVersion2" INTEGER NOT NULL,
|
||||||
"CertificateIssuerCountry" TEXT NOT NULL,
|
"CertificateIssuerCountry" INTEGER NOT NULL,
|
||||||
"CertificateOrganizationName" TEXT NOT NULL,
|
"CertificateOrganizationName" INTEGER NOT NULL,
|
||||||
"IpV6" TEXT NOT NULL,
|
"IpV6" TEXT NOT NULL,
|
||||||
"TlsVersion" TEXT NOT NULL,
|
"TlsVersion" INTEGER NOT NULL,
|
||||||
"CipherSuite" TEXT NOT NULL,
|
"CipherSuite" INTEGER NOT NULL,
|
||||||
"KeyExchangeAlgorithm" TEXT NOT NULL,
|
"KeyExchangeAlgorithm" INTEGER NOT NULL,
|
||||||
"PublicKeyType1" TEXT NOT NULL,
|
"PublicKeyType1" INTEGER NOT NULL,
|
||||||
"PublicKeyType2" TEXT NOT NULL,
|
"PublicKeyType2" INTEGER NOT NULL,
|
||||||
"PublicKeyType3" TEXT NOT NULL,
|
"PublicKeyType3" INTEGER NOT NULL,
|
||||||
"AcceptEncoding1" TEXT NOT NULL,
|
"AcceptEncoding1" INTEGER NOT NULL,
|
||||||
"AcceptEncoding2" TEXT NOT NULL,
|
"AcceptEncoding2" INTEGER NOT NULL,
|
||||||
"ALPN" TEXT NOT NULL,
|
"ALPN" INTEGER NOT NULL,
|
||||||
"Connection1" TEXT NOT NULL,
|
"Connection1" INTEGER NOT NULL,
|
||||||
"Connection2" TEXT NOT NULL,
|
"Connection2" INTEGER NOT NULL,
|
||||||
PRIMARY KEY("Id" AUTOINCREMENT)
|
PRIMARY KEY("Id" AUTOINCREMENT),
|
||||||
|
FOREIGN KEY("ALPN") REFERENCES "ALPN"("ALPNId"),
|
||||||
|
FOREIGN KEY("AcceptEncoding1") REFERENCES "AcceptEncoding"("AcceptId"),
|
||||||
|
FOREIGN KEY("AcceptEncoding2") REFERENCES "AcceptEncoding"("AcceptId"),
|
||||||
|
FOREIGN KEY("CertificateIssuerCountry") REFERENCES "CertificateIssuerCountry"("CertificateIssuerId"),
|
||||||
|
FOREIGN KEY("CertificateOrganizationName") REFERENCES "CertificateOrganizationName"("CertificateOrganizationId"),
|
||||||
|
FOREIGN KEY("CipherSuite") REFERENCES "CipherSuite"("CipherId"),
|
||||||
|
FOREIGN KEY("Connection1") REFERENCES "Connection"("ConnectionId"),
|
||||||
|
FOREIGN KEY("Connection2") REFERENCES "Connection"("ConnectionId"),
|
||||||
|
FOREIGN KEY("HttpVersion1") REFERENCES "HttpVersion"("HttpId"),
|
||||||
|
FOREIGN KEY("HttpVersion2") REFERENCES "HttpVersion"("HttpId"),
|
||||||
|
FOREIGN KEY("KeyExchangeAlgorithm") REFERENCES "KeyExchangeAlgorithm"("KeyExchangeId"),
|
||||||
|
FOREIGN KEY("PublicKeyType1") REFERENCES "PublicKeyType"("PublicKeyId"),
|
||||||
|
FOREIGN KEY("PublicKeyType2") REFERENCES "PublicKeyType"("PublicKeyId"),
|
||||||
|
FOREIGN KEY("PublicKeyType3") REFERENCES "PublicKeyType"("PublicKeyId"),
|
||||||
|
FOREIGN KEY("ServerType1") REFERENCES "ServerType"("ServerId"),
|
||||||
|
FOREIGN KEY("ServerType2") REFERENCES "ServerType"("ServerId"),
|
||||||
|
FOREIGN KEY("TlsVersion") REFERENCES "TlsVersion"("TlsId")
|
||||||
)
|
)
|
@ -2,4 +2,5 @@
|
|||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003A0200000Cpdb6Low_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003FILViewer_003Fb53c196a821648e4ae3b142a6ae58d7b9400_003Fa8_003F21a43479_003F0200000Cpdb6Low_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003A0200000Cpdb6Low_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003FILViewer_003Fb53c196a821648e4ae3b142a6ae58d7b9400_003Fa8_003F21a43479_003F0200000Cpdb6Low_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003A02000011pdb3Low_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003FILViewer_003F7c3ed02c2ce44598b7f304f8ac45e58f8600_003F6d_003F99b875d1_003F02000011pdb3Low_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003A02000011pdb3Low_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003FILViewer_003F7c3ed02c2ce44598b7f304f8ac45e58f8600_003F6d_003F99b875d1_003F02000011pdb3Low_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADirectoryInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe4ec446cfe0489bc3ef68a45c6766d183e999ebdc657e94fb1ad059de2bb9_003FDirectoryInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADirectoryInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe4ec446cfe0489bc3ef68a45c6766d183e999ebdc657e94fb1ad059de2bb9_003FDirectoryInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpResponseMessage_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F85e97f467d698c9e98eae9e3a1b39d58541173e57992d8f7111eabdd3db3526_003FHttpResponseMessage_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThread_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F693e634d7742afaf486acd69d84fe2a9e1ee1b11ba84f29cd1d67668d20dd59_003FThread_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThread_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F693e634d7742afaf486acd69d84fe2a9e1ee1b11ba84f29cd1d67668d20dd59_003FThread_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
Loading…
Reference in New Issue
Block a user