Duscarded object is now a struct.
This commit is contained in:
parent
90d1d6b429
commit
ec9cca59da
@ -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()
|
||||
{
|
||||
|
Binary file not shown.
@ -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);
|
||||
|
||||
|
@ -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; }
|
||||
}
|
Binary file not shown.
BIN
Models/mydb.db
BIN
Models/mydb.db
Binary file not shown.
Loading…
Reference in New Issue
Block a user