diff --git a/Backend/Handler/IpScanner.cs b/Backend/Handler/IpScanner.cs index 90ae450..b175b9c 100644 --- a/Backend/Handler/IpScanner.cs +++ b/Backend/Handler/IpScanner.cs @@ -155,7 +155,7 @@ public class IpScanner if (responseCode != IPStatus.Success) { - _discardedQueue.Enqueue(CreateDiscardedQueueItem(ip.ToString(), (int)responseCode)); + _discardedQueue.Enqueue(CreateDiscardedQueueItem(ip, (int)responseCode)); continue; } @@ -163,7 +163,7 @@ public class IpScanner if (ports is { Item1: 0, Item2: 0 }) { - _discardedQueue.Enqueue(CreateDiscardedQueueItem(ip.ToString(), (int)responseCode)); + _discardedQueue.Enqueue(CreateDiscardedQueueItem(ip, (int)responseCode)); continue; } @@ -203,7 +203,7 @@ public class IpScanner scanSettings.Handle!.Set(); } - private static Discarded CreateDiscardedQueueItem(string ip, int responseCode) + private static Discarded CreateDiscardedQueueItem(Ip ip, int responseCode) { Discarded discarded = new() { diff --git a/Models/Filtered.db b/Models/Filtered.db deleted file mode 100644 index 93bce66..0000000 Binary files a/Models/Filtered.db and /dev/null differ diff --git a/Models/Handler/DbHandler.cs b/Models/Handler/DbHandler.cs index 8705e8e..248b0d7 100644 --- a/Models/Handler/DbHandler.cs +++ b/Models/Handler/DbHandler.cs @@ -19,7 +19,7 @@ public class DbHandler 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 (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 (Ip1, Ip2, Ip3, Ip4, ResponseCode) VALUES (@ip1, @ip2, @ip3, @ip4, @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 ReadUnfilteredStatement = "SELECT * FROM Unfiltered WHERE Id = @id;"; @@ -156,9 +156,7 @@ public class DbHandler continue; } - _discardedQueue.TryDequeue(out Discarded? queueItem); - - if (queueItem is null) { continue; } + _discardedQueue.TryDequeue(out Discarded queueItem); InsertDiscarded(queueItem, connectionString); } @@ -194,7 +192,10 @@ public class DbHandler using SqliteCommand command = new(InsertIntoDiscarded, connection); - command.Parameters.AddWithValue("@ip", discarded.Ip); + command.Parameters.AddWithValue("@ip1", discarded.Ip.Ip1); + command.Parameters.AddWithValue("@ip2", discarded.Ip.Ip2); + command.Parameters.AddWithValue("@ip3", discarded.Ip.Ip3); + command.Parameters.AddWithValue("@ip4", discarded.Ip.Ip4); command.Parameters.AddWithValue("@responseCode", discarded.ResponseCode); _ = command.ExecuteNonQuery(); @@ -579,7 +580,7 @@ public class DbHandler { string databaseName = $"Data Source={_basePath}/Models/Discarded{threadNumber}.db"; - const string createStatement = "CREATE TABLE IF NOT EXISTS Discarded (Id INTEGER NOT NULL, Ip 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 TEXT NOT NULL, Ip2 TEXT NOT NULL, Ip3 TEXT NOT NULL, Ip4 TEXT NOT NULL, ResponseCode INTEGER NOT NULL, PRIMARY KEY(Id AUTOINCREMENT))"; _discardedConnectionStrings.Add(databaseName); diff --git a/Models/Model/Backend/Discarded.cs b/Models/Model/Backend/Discarded.cs index 8cc16fc..ccaa496 100644 --- a/Models/Model/Backend/Discarded.cs +++ b/Models/Model/Backend/Discarded.cs @@ -1,7 +1,8 @@ namespace Models.Model.Backend; -public class Discarded +public struct Discarded { - public string Ip { get; set; } = ""; + public Ip Ip { get; set; } + public int ResponseCode { get; set; } } \ No newline at end of file diff --git a/Models/ScannerResume.db b/Models/ScannerResume.db deleted file mode 100644 index a44725c..0000000 Binary files a/Models/ScannerResume.db and /dev/null differ diff --git a/Models/mydb.db b/Models/mydb.db deleted file mode 100644 index ef45e70..0000000 Binary files a/Models/mydb.db and /dev/null differ