25 changed files with 193 additions and 100 deletions
-19
View File
@@ -1,19 +0,0 @@
DROP TABLE Unfiltered;
DROP TABLE Runtimes;
CREATE TABLE "Unfiltered" (
"Id" INTEGER NOT NULL,
"Ip" TEXT NOT NULL,
"ResponseCode" INTEGER NOT NULL,
"Port1" INTEGER NOT NULL,
"Port2" INTEGER NOT NULL,
"Filtered" INTEGER NOT NULL,
CONSTRAINT "PK_Unfiltered" PRIMARY KEY("Id" AUTOINCREMENT)
);
CREATE TABLE "Runtimes" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_Runtimes" PRIMARY KEY AUTOINCREMENT,
"StartTime" TEXT NOT NULL,
"EndTime" TEXT NOT NULL,
"ThreadNumber" INTEGER NOT NULL
);
+3 -1
View File
@@ -53,7 +53,7 @@ public class Communication
CommunicationObject? communicationObject = JsonSerializer.Deserialize<CommunicationObject>(message); CommunicationObject? communicationObject = JsonSerializer.Deserialize<CommunicationObject>(message);
rep.SendFrame(JsonSerializer.SerializeToUtf8Bytes("Success")); //rep.SendFrame(JsonSerializer.SerializeToUtf8Bytes("Success"));
if (communicationObject is null) if (communicationObject is null)
{ {
@@ -164,6 +164,8 @@ public class Communication
_contentFilter.SetTimeout(value); _contentFilter.SetTimeout(value);
} }
rep.SendFrame(JsonSerializer.SerializeToUtf8Bytes("Success"));
break; break;
} }
} }
+19 -16
View File
@@ -1,6 +1,5 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Diagnostics; using System.Diagnostics;
using System.Text;
using Backend.Helper; using Backend.Helper;
using Models.Handler; using Models.Handler;
using Models.Model.Backend; using Models.Model.Backend;
@@ -15,7 +14,7 @@ public class ContentFilter
private readonly string _getDomainPort443; private readonly string _getDomainPort443;
private bool _stop; private bool _stop;
private int _timeOut; private int _timeOut;
private string _basePath; private readonly string _basePath;
public ContentFilter(ConcurrentQueue<QueueItem> queue, DbHandler dbHandler, string basePath) public ContentFilter(ConcurrentQueue<QueueItem> queue, DbHandler dbHandler, string basePath)
{ {
@@ -26,7 +25,7 @@ public class ContentFilter
_getDomainPort80 = $"{basePath}/Backend/Scripts/GetDomainNamePort80.sh"; _getDomainPort80 = $"{basePath}/Backend/Scripts/GetDomainNamePort80.sh";
_getDomainPort443 = $"{basePath}/Backend/Scripts/GetDomainNamePort443.sh"; _getDomainPort443 = $"{basePath}/Backend/Scripts/GetDomainNamePort443.sh";
SetTimeout(60000); SetTimeout(3000);
} }
public void SetTimeout(int timeOut) public void SetTimeout(int timeOut)
@@ -39,6 +38,7 @@ public class ContentFilter
WaitHandle[] waitHandles = new WaitHandle[1]; WaitHandle[] waitHandles = new WaitHandle[1];
EventWaitHandle handle = new(false, EventResetMode.ManualReset); EventWaitHandle handle = new(false, EventResetMode.ManualReset);
waitHandles[0] = handle; waitHandles[0] = handle;
Thread f = new (Filter!); Thread f = new (Filter!);
f.Start(handle); f.Start(handle);
@@ -55,26 +55,29 @@ public class ContentFilter
{ {
if (_stop) break; if (_stop) break;
Unfiltered? unfiltered = _dbHandler.ReadUnfilteredWithId(i); Unfiltered unfiltered = _dbHandler.ReadUnfilteredWithId(i);
if (unfiltered is null || unfiltered.Filtered == 1) continue; if (unfiltered.Filtered) continue;
unfiltered.Filtered = 1; Ip ip = unfiltered.Ip;
unfiltered.Filtered = true;
QueueItem superUnfilteredObject = new() QueueItem superUnfilteredObject = new()
{ {
Unfiltered = unfiltered, Unfiltered = unfiltered,
Operations = Operations.Update Operations = Operations.Update,
DbType = DbType.Unfiltered
}; };
_queue.Enqueue(superUnfilteredObject); _queue.Enqueue(superUnfilteredObject);
if (_dbHandler.GetFilteredIp(unfiltered.Ip)) if (_dbHandler.FilteredIpExists(unfiltered.Ip))
{ {
continue; continue;
} }
Filtered filtered = GetSiteData(unfiltered.Ip); Filtered filtered = GetSiteData(ip);
filtered.Port1 = unfiltered.Port1; filtered.Port1 = unfiltered.Port1;
filtered.Port2 = unfiltered.Port2; filtered.Port2 = unfiltered.Port2;
@@ -82,7 +85,8 @@ public class ContentFilter
QueueItem superFilteredObject = new() QueueItem superFilteredObject = new()
{ {
Filtered = filtered, Filtered = filtered,
Operations = Operations.Insert Operations = Operations.Insert,
DbType = DbType.Filtered
}; };
_queue.Enqueue(superFilteredObject); _queue.Enqueue(superFilteredObject);
@@ -94,7 +98,7 @@ public class ContentFilter
((EventWaitHandle) obj).Set(); ((EventWaitHandle) obj).Set();
} }
private Filtered GetSiteData(string ip) private Filtered GetSiteData(Ip ip)
{ {
StartProcess(ip, 80); StartProcess(ip, 80);
StartProcess(ip, 443); StartProcess(ip, 443);
@@ -222,19 +226,18 @@ public class ContentFilter
return siteData; return siteData;
} }
private void StartProcess(string ip, int port) private void StartProcess(Ip ip, int port)
{ {
string fileName = port == 80 ? _getDomainPort80 : _getDomainPort443; string fileName = port == 80 ? _getDomainPort80 : _getDomainPort443;
//Console.WriteLine($"{ip.Ip1}.{ip.Ip2}.{ip.Ip3}.{ip.Ip4}");
Process proc = new(); Process proc = new();
proc.StartInfo = new() proc.StartInfo = new()
{ {
FileName = fileName, FileName = "/bin/bash",
Arguments = $"{ip}", Arguments = $"{fileName} {ip.Ip1}.{ip.Ip2}.{ip.Ip3}.{ip.Ip4} {_basePath}/Backend/Scripts/{port}Header.txt",
UseShellExecute = false, UseShellExecute = false,
RedirectStandardOutput = false, RedirectStandardOutput = false,
RedirectStandardError = false, RedirectStandardError = false,
RedirectStandardInput = false,
CreateNoWindow = true CreateNoWindow = true
}; };
+18 -13
View File
@@ -117,7 +117,6 @@ public class IpScanner
if (_discardedQueue.Count >= 2000) if (_discardedQueue.Count >= 2000)
{ {
Console.WriteLine("loooooooooooooooooooooooooooool");
Thread.Sleep(500); Thread.Sleep(500);
} }
@@ -129,7 +128,13 @@ public class IpScanner
break; break;
} }
string ip = $"{i}.{j}.{k}.{l}"; Ip ip = new()
{
Ip1 = i,
Ip2 = j,
Ip3 = k,
Ip4 = l
};
IPStatus responseCode = IPStatus.Unknown; IPStatus responseCode = IPStatus.Unknown;
@@ -137,32 +142,32 @@ public class IpScanner
{ {
// Sometimes, if the pinger gets a Destination Unreachable Communication administratively prohibited response, the pinger will throw an exception. // Sometimes, if the pinger gets a Destination Unreachable Communication administratively prohibited response, the pinger will throw an exception.
// https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol?useskin=vector#Control_messages // https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol?useskin=vector#Control_messages
_ = IPAddress.TryParse(ip, out IPAddress? address); _ = IPAddress.TryParse(ip.ToString(), out IPAddress? address);
if (address is not null) if (address is not null)
{ {
responseCode = ping.Send(address, _timeout, buf, null).Status; responseCode = ping.Send(address, _timeout, buf, null).Status;
} }
} }
catch (Exception e) catch
{ {
Console.WriteLine(e); //
} }
if (responseCode != IPStatus.Success) if (responseCode != IPStatus.Success)
{ {
_discardedQueue.Enqueue(CreateDiscardedQueueItem(ip, (int)responseCode)); _discardedQueue.Enqueue(CreateDiscardedQueueItem(ip.ToString(), (int)responseCode));
continue; continue;
} }
(int, int) ports = TcpClientHelper.CheckPort(ip, 80, 443); (int, int) ports = TcpClientHelper.CheckPort(ip.ToString(), 80, 443);
if (ports is { Item1: 0, Item2: 0 }) if (ports is { Item1: 0, Item2: 0 })
{ {
_discardedQueue.Enqueue(CreateDiscardedQueueItem(ip, (int)responseCode)); _discardedQueue.Enqueue(CreateDiscardedQueueItem(ip.ToString(), (int)responseCode));
continue; continue;
} }
_queue.Enqueue(CreateUnfilteredQueueItem(ip, (int)responseCode, ports)); _queue.Enqueue(CreateUnfilteredQueueItem(ip, ports));
} }
if (_stop) if (_stop)
@@ -209,21 +214,21 @@ public class IpScanner
return discarded; return discarded;
} }
private static QueueItem CreateUnfilteredQueueItem(string ip, int responseCode, (int, int) ports) private static QueueItem CreateUnfilteredQueueItem(Ip ip, (int, int) ports)
{ {
Unfiltered unfiltered = new() Unfiltered unfiltered = new()
{ {
Ip = ip, Ip = ip,
ResponseCode = responseCode,
Port1 = ports.Item1, Port1 = ports.Item1,
Port2 = ports.Item2, Port2 = ports.Item2,
Filtered = 0 Filtered = false
}; };
QueueItem superUnfilteredObject = new() QueueItem superUnfilteredObject = new()
{ {
Unfiltered = unfiltered, Unfiltered = unfiltered,
Operations = Operations.Insert Operations = Operations.Insert,
DbType = DbType.Unfiltered
}; };
return superUnfilteredObject; return superUnfilteredObject;
+2 -2
View File
@@ -49,9 +49,9 @@ public class ThreadHandler
private void StartScanner() private void StartScanner()
{ {
Thread.Sleep(10000); // 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(2); WaitHandle[] wait = _ipScanner.Start(64);
WaitHandle.WaitAll(wait); WaitHandle.WaitAll(wait);
+4 -4
View File
@@ -23,9 +23,9 @@ public static class HttpClientHelper
{ {
response = await client.GetAsync("/"); response = await client.GetAsync("/");
} }
catch (Exception e) catch
{ {
Console.WriteLine(e); //
} }
if (response is null || !response.IsSuccessStatusCode) if (response is null || !response.IsSuccessStatusCode)
@@ -57,9 +57,9 @@ public static class HttpClientHelper
{ {
response = await client.GetAsync("/robots.txt"); response = await client.GetAsync("/robots.txt");
} }
catch (Exception e) catch
{ {
Console.WriteLine(e); //
} }
return response is not null && response.IsSuccessStatusCode; return response is not null && response.IsSuccessStatusCode;
+1 -1
View File
@@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
curl -k -vvI -m 10 https://"$1" &> 443Header.txt curl -k -vvI -m 10 https://"$1" &> "$2"
+2 -1
View File
@@ -1,3 +1,4 @@
#!/bin/bash #!/bin/bash
curl -k -vvI -m 10 http://"$1" &> 80Header.txt curl -k -vvI -m 10 http://"$1" &> "$2"
#80Header.txt
+13
View File
@@ -0,0 +1,13 @@
DROP TABLE Unfiltered;
CREATE TABLE "Unfiltered" (
"Id" INTEGER NOT NULL,
"Ip1" INTEGER NOT NULL,
"Ip2" INTEGER NOT NULL,
"Ip3" INTEGER NOT NULL,
"Ip4" INTEGER NOT NULL,
"Port1" INTEGER NOT NULL,
"Port2" INTEGER NOT NULL,
"Filtered" INTEGER NOT NULL,
CONSTRAINT "PK_Unfiltered" PRIMARY KEY("Id" AUTOINCREMENT)
)
-2
View File
@@ -109,8 +109,6 @@ public static class Commands
[RequiresDynamicCode("Calls System.Text.Json.JsonSerializer.SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)")] [RequiresDynamicCode("Calls System.Text.Json.JsonSerializer.SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)")]
private static ScanningStatus GetProgress(CommunicationObject communicationObject) private static ScanningStatus GetProgress(CommunicationObject communicationObject)
{ {
//byte[] bytes = MessagePackSerializer.Serialize(communicationObject, ContractlessStandardResolver.Options);
byte[] lol = JsonSerializer.SerializeToUtf8Bytes(communicationObject); byte[] lol = JsonSerializer.SerializeToUtf8Bytes(communicationObject);
using RequestSocket client = new(); using RequestSocket client = new();
Binary file not shown.
Binary file not shown.
Binary file not shown.
+91 -25
View File
@@ -1,3 +1,4 @@
using System.Collections;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using Microsoft.Data.Sqlite; using Microsoft.Data.Sqlite;
using Models.Model.Backend; using Models.Model.Backend;
@@ -16,8 +17,8 @@ public class DbHandler
private readonly string _resumeConnectionString; private readonly string _resumeConnectionString;
private readonly List<string> _discardedConnectionStrings = []; private readonly List<string> _discardedConnectionStrings = [];
private const string InsertStatement = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off; INSERT INTO Unfiltered (Ip, ResponseCode, Port1, Port2, Filtered) VALUES (@ip, @responseCode, @port1, @port2, @filtered)"; private const string InsertStatement = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off; INSERT INTO Unfiltered (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; PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off; INSERT INTO Filtered (Ip, Port1, Port2, Title1, Title2, Description1, Description2, Url1, Url2, ServerType1, ServerType2, RobotsTXT1, RobotsTXT2, HttpVersion1, HttpVersion2, CertificateIssuerCountry, CertificateOrganizationName, IpV6, TlsVersion, CipherSuite, KeyExchangeAlgorithm, PublicKeyType1, PublicKeyType2, PublicKeyType3, AcceptEncoding1, AcceptEncoding2, ALPN, Connection1, Connection2) VALUES (@ip, @port1, @port2, @title1, @title2, @description1, @description2, @url1, @url2, @serverType1, @serverType2, @robotsTXT1, @robotsTXT2, @httpVersion1, @httpVersion2, @certificateIssuerCountry, @certificateOrganizationName, @ipV6, @tlsVersion, @cipherSuite, @keyExchangeAlgorithm, @publicKeyType1, @publicKeyType2, @publicKeyType3, @acceptEncoding1, @acceptEncoding2, @aLPN, @connection1, @connection2)"; private const string InsertIntoFiltered = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off; INSERT INTO Filtered (Ip1, Ip2, Ip3, Ip4, Port1, Port2, Title1, Title2, Description1, Description2, Url1, Url2, ServerType1, ServerType2, RobotsTXT1, RobotsTXT2, HttpVersion1, HttpVersion2, CertificateIssuerCountry, CertificateOrganizationName, IpV6, TlsVersion, CipherSuite, KeyExchangeAlgorithm, PublicKeyType1, PublicKeyType2, PublicKeyType3, AcceptEncoding1, AcceptEncoding2, ALPN, Connection1, Connection2) VALUES (@ip1, @ip2, @ip3, @ip4, @port1, @port2, @title1, @title2, @description1, @description2, @url1, @url2, @serverType1, @serverType2, @robotsTXT1, @robotsTXT2, @httpVersion1, @httpVersion2, @certificateIssuerCountry, @certificateOrganizationName, @ipV6, @tlsVersion, @cipherSuite, @keyExchangeAlgorithm, @publicKeyType1, @publicKeyType2, @publicKeyType3, @acceptEncoding1, @acceptEncoding2, @aLPN, @connection1, @connection2)";
private const string InsertIntoDiscarded = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off; INSERT INTO Discarded (Ip, ResponseCode) VALUES (@ip, @responseCode)"; private const string InsertIntoDiscarded = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off; INSERT INTO Discarded (Ip, ResponseCode) VALUES (@ip, @responseCode)";
private const string InsertIntoResume = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off; INSERT INTO Resume (ThreadNumber, StartRange, EndRange, FirstByte, SecondByte, ThirdByte, FourthByte) VALUES (@threadNumber, @startRange, @endRange, @firstByte, @secondByte, @thirdByte, @fourthByte);"; private const string InsertIntoResume = "PRAGMA synchronous = OFF; PRAGMA temp_store = MEMORY; PRAGMA journal_mode = MEMORY; PRAGMA foreign_keys = off; INSERT INTO Resume (ThreadNumber, StartRange, EndRange, FirstByte, SecondByte, ThirdByte, FourthByte) VALUES (@threadNumber, @startRange, @endRange, @firstByte, @secondByte, @thirdByte, @fourthByte);";
@@ -25,6 +26,7 @@ public class DbHandler
private const string ReadUnfilteredIdsStatement = "SELECT Id FROM Unfiltered WHERE Id != 0 ORDER BY Id DESC LIMIT 1;"; private const string ReadUnfilteredIdsStatement = "SELECT Id FROM Unfiltered WHERE Id != 0 ORDER BY Id DESC LIMIT 1;";
private const string ReadFilteredStatement = "SELECT Title2, Url2 FROM Filtered WHERE (Url2 NOT NULL AND Url2 != '') AND (Title2 NOT NULL AND Title2 != '') ORDER BY Url2 DESC;"; private const string ReadFilteredStatement = "SELECT Title2, Url2 FROM Filtered WHERE (Url2 NOT NULL AND Url2 != '') AND (Title2 NOT NULL AND Title2 != '') ORDER BY Url2 DESC;";
private const string ReadFilteredIdsStatement = "SELECT Id FROM Filtered WHERE Id != 0 ORDER BY Id DESC LIMIT 1;"; private const string ReadFilteredIdsStatement = "SELECT Id FROM Filtered WHERE Id != 0 ORDER BY Id DESC LIMIT 1;";
private const string ReadFilteredIpStatement = "SELECT Ip1, Ip2, Ip3, Ip4 FROM Filtered WHERE Ip1 == @ip1 AND Ip2 == @ip1 AND Ip3 == @ip1 AND Ip4 == @ip1 ORDER BY Ip1 DESC LIMIT 1;";
private const string ReadDiscardedSeqIdsStatement = "SELECT seq FROM sqlite_sequence;"; private const string ReadDiscardedSeqIdsStatement = "SELECT seq FROM sqlite_sequence;";
private const string ReadAndDeleteResumeStatement = "SELECT * FROM Resume WHERE ThreadNumber == @threadNumber; DELETE FROM RESUME WHERE ThreadNumber == @threadNumber;"; private const string ReadAndDeleteResumeStatement = "SELECT * FROM Resume WHERE ThreadNumber == @threadNumber; DELETE FROM RESUME WHERE ThreadNumber == @threadNumber;";
@@ -89,20 +91,24 @@ public class DbHandler
if (queueItem is null) { continue; } if (queueItem is null) { continue; }
switch (queueItem.Operations) if (queueItem.Operations == Operations.Insert && queueItem.DbType == DbType.Unfiltered)
{ {
case Operations.Insert when queueItem.Unfiltered is not null: InsertUnfiltered(queueItem.Unfiltered);
InsertUnfiltered(queueItem.Unfiltered); }
break;
case Operations.Insert when queueItem.Filtered is not null: else if (queueItem.Operations == Operations.Insert && queueItem.DbType == DbType.Filtered)
InsertFiltered(queueItem.Filtered); {
break; InsertFiltered(queueItem.Filtered!);
case Operations.Insert when queueItem.ResumeObject is not null: }
InsertResumeObject(queueItem.ResumeObject);
break; else if (queueItem.Operations == Operations.Insert && queueItem.ResumeObject is not null)
case Operations.Update when queueItem.Unfiltered is not null: {
UpdateUnfiltered(queueItem.Unfiltered); InsertResumeObject(queueItem.ResumeObject);
break; }
else if (queueItem.Operations == Operations.Update && queueItem.DbType == DbType.Unfiltered)
{
UpdateUnfiltered(queueItem.Unfiltered);
} }
} }
@@ -169,8 +175,10 @@ public class DbHandler
using SqliteCommand command = new(InsertStatement, connection); using SqliteCommand command = new(InsertStatement, connection);
command.Parameters.AddWithValue("@ip", unfiltered.Ip); command.Parameters.AddWithValue("@ip1", unfiltered.Ip.Ip1);
command.Parameters.AddWithValue("@responseCode", unfiltered.ResponseCode); command.Parameters.AddWithValue("@ip2", unfiltered.Ip.Ip2);
command.Parameters.AddWithValue("@ip3", unfiltered.Ip.Ip3);
command.Parameters.AddWithValue("@ip4", unfiltered.Ip.Ip4);
command.Parameters.AddWithValue("@port1", unfiltered.Port1); command.Parameters.AddWithValue("@port1", unfiltered.Port1);
command.Parameters.AddWithValue("@port2", unfiltered.Port2); command.Parameters.AddWithValue("@port2", unfiltered.Port2);
command.Parameters.AddWithValue("@filtered", unfiltered.Filtered); command.Parameters.AddWithValue("@filtered", unfiltered.Filtered);
@@ -200,7 +208,10 @@ public class DbHandler
using SqliteCommand command = new(InsertIntoFiltered, connection); using SqliteCommand command = new(InsertIntoFiltered, connection);
command.Parameters.AddWithValue("@ip", filtered.Ip); command.Parameters.AddWithValue("@ip1", filtered.Ip.Ip1);
command.Parameters.AddWithValue("@ip2", filtered.Ip.Ip2);
command.Parameters.AddWithValue("@ip3", filtered.Ip.Ip3);
command.Parameters.AddWithValue("@ip4", filtered.Ip.Ip4);
command.Parameters.AddWithValue("@port1", filtered.Port1); command.Parameters.AddWithValue("@port1", filtered.Port1);
command.Parameters.AddWithValue("@port2", filtered.Port2); command.Parameters.AddWithValue("@port2", filtered.Port2);
command.Parameters.AddWithValue("@url1", filtered.Url1); command.Parameters.AddWithValue("@url1", filtered.Url1);
@@ -266,7 +277,7 @@ public class DbHandler
connection.Close(); connection.Close();
} }
public Unfiltered? ReadUnfilteredWithId(long id) public Unfiltered ReadUnfilteredWithId(long id)
{ {
using SqliteConnection connection = new(_unfilteredConnectionString); using SqliteConnection connection = new(_unfilteredConnectionString);
connection.Open(); connection.Open();
@@ -275,19 +286,28 @@ public class DbHandler
command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@id", id);
using SqliteDataReader reader = command.ExecuteReader(); using SqliteDataReader reader = command.ExecuteReader();
if (!reader.HasRows) return null; if (!reader.HasRows) return new();
Unfiltered unfiltered = new(); Unfiltered unfiltered = new();
Ip ip = new();
while (reader.Read()) while (reader.Read())
{ {
unfiltered.Id = reader.GetInt32(0); unfiltered.Id = reader.GetInt32(0);
unfiltered.Ip = reader.GetString(1); ip.Ip1 = reader.GetInt32(1);
unfiltered.Port1 = reader.GetInt32(3); ip.Ip2 = reader.GetInt32(2);
unfiltered.Port2 = reader.GetInt32(4); ip.Ip3 = reader.GetInt32(3);
unfiltered.Filtered = reader.GetInt32(5); ip.Ip4 = reader.GetInt32(4);
//Console.WriteLine(ip + "lmo");
unfiltered.Port1 = reader.GetInt32(5);
unfiltered.Port2 = reader.GetInt32(6);
unfiltered.Filtered = reader.GetBoolean(7);
} }
//Console.WriteLine(ip + "aaaaa");
unfiltered.Ip = ip;
//Console.WriteLine(unfiltered.Ip + "adfgdgfdgfsdfgs");
return unfiltered; return unfiltered;
} }
@@ -363,8 +383,54 @@ public class DbHandler
return rowId; return rowId;
} }
public bool GetFilteredIp(string ip) public bool FilteredIpExists(Ip ip)
{ {
using SqliteConnection connection = new(_filteredConnectionString);
connection.Open();
using SqliteCommand command = new(ReadFilteredIpStatement, connection);
command.Parameters.AddWithValue("@ip1", ip.Ip1);
command.Parameters.AddWithValue("@ip2", ip.Ip2);
command.Parameters.AddWithValue("@ip3", ip.Ip3);
command.Parameters.AddWithValue("@ip4", ip.Ip4);
using SqliteDataReader reader = command.ExecuteReader();
if (!reader.HasRows)
{
return false;
}
Ip tempIp = new();
while (reader.Read())
{
tempIp.Ip1 = reader.GetInt32(0);
tempIp.Ip2 = reader.GetInt32(1);
tempIp.Ip3 = reader.GetInt32(2);
tempIp.Ip4 = reader.GetInt32(3);
}
if (tempIp.Ip1 != ip.Ip1)
{
return false;
}
if (tempIp.Ip2 != ip.Ip2)
{
return false;
}
if (tempIp.Ip3 != ip.Ip3)
{
return false;
}
if (tempIp.Ip4 != ip.Ip4)
{
return false;
}
return true; return true;
} }
+7
View File
@@ -0,0 +1,7 @@
namespace Models.Model.Backend;
public enum DbType
{
Unfiltered,
Filtered,
}
+1 -1
View File
@@ -2,7 +2,7 @@ namespace Models.Model.Backend;
public class Filtered public class Filtered
{ {
public string Ip { get; set; } = ""; public Ip Ip { get; set; }
public string Title1 { get; set; } = ""; public string Title1 { get; set; } = "";
public string Title2 { get; set; } = ""; public string Title2 { get; set; } = "";
public string Description1 { get; set; } = ""; public string Description1 { get; set; } = "";
+17
View File
@@ -0,0 +1,17 @@
namespace Models.Model.Backend;
public struct Ip
{
public int Ip1 { get; set; }
public int Ip2 { get; set; }
public int Ip3 { get; set; }
public int Ip4 { get; set; }
public override string ToString()
{
return $"{Ip1}.{Ip2}.{Ip3}.{Ip4}";
}
}
+2 -1
View File
@@ -2,8 +2,9 @@ namespace Models.Model.Backend;
public class QueueItem public class QueueItem
{ {
public Unfiltered? Unfiltered { get; init; } public Unfiltered Unfiltered { get; init; }
public Filtered? Filtered { get; init; } public Filtered? Filtered { get; init; }
public ScannerResumeObject? ResumeObject { get; init; } public ScannerResumeObject? ResumeObject { get; init; }
public Operations Operations { get; init; } public Operations Operations { get; init; }
public DbType DbType { get; init; }
} }
+3 -5
View File
@@ -1,16 +1,14 @@
namespace Models.Model.Backend; namespace Models.Model.Backend;
public class Unfiltered public struct Unfiltered
{ {
public int Id { get; set; } public int Id { get; set; }
public string Ip { get; set; } = ""; public Ip Ip { get; set; }
public int ResponseCode { get; init; }
public int Port1 { get; set; } public int Port1 { get; set; }
public int Port2 { get; set; } public int Port2 { get; set; }
public int Filtered { get; set; } public bool Filtered { get; set; }
} }
BIN
View File
Binary file not shown.
+1
View File
@@ -18,6 +18,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIPStatus_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8fe420eaf60c4dfca87ce1d5f1cdfa4816200_003Fbd_003F71bcce16_003FIPStatus_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIPStatus_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8fe420eaf60c4dfca87ce1d5f1cdfa4816200_003Fbd_003F71bcce16_003FIPStatus_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMessagePackReader_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F5cffb8c94881849b6aa8abe7ba5e7cafe05d991f859903020362d6aac371_003FMessagePackReader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMessagePackReader_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F5cffb8c94881849b6aa8abe7ba5e7cafe05d991f859903020362d6aac371_003FMessagePackReader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMessagePackSerializer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe5f8b0187e62d74a4b9fefd657c192dab367bb342ef5ffbd90a4ed2ea428ec7a_003FMessagePackSerializer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMessagePackSerializer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fe5f8b0187e62d74a4b9fefd657c192dab367bb342ef5ffbd90a4ed2ea428ec7a_003FMessagePackSerializer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AOutgoingSocketExtensions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fc4824d483bf85fa615ad2125f13f6d75788d45d1510ec1cfb8226831da54f_003FOutgoingSocketExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APingOptions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F77bf2fbffc5491eadd62f1dbebc233798cd7fcb9b39ab7ee3bb35519f4d94ecc_003FPingOptions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APingOptions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F77bf2fbffc5491eadd62f1dbebc233798cd7fcb9b39ab7ee3bb35519f4d94ecc_003FPingOptions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APing_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F3080b18e3637ea741b5b65abd6aee06e41494a82a58b3e2ed87d4ddb5cc62_003FPing_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APing_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F3080b18e3637ea741b5b65abd6aee06e41494a82a58b3e2ed87d4ddb5cc62_003FPing_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APing_002ERawSocket_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F2f645da43e51b8be94c9217511b45c23384f041ffa9aad041f0ddc158d732f0_003FPing_002ERawSocket_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APing_002ERawSocket_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F2f645da43e51b8be94c9217511b45c23384f041ffa9aad041f0ddc158d732f0_003FPing_002ERawSocket_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>