Implement database compression
This commit is contained in:
@@ -87,6 +87,7 @@ public class Communication
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a workaround for the frontend not understanding a 0f as an actual float, so we use a very small float.
|
||||
status.PercentageOfIpv4Scanned = 0.0000000001f;
|
||||
}
|
||||
|
||||
@@ -96,7 +97,7 @@ public class Communication
|
||||
status.MyDbSize = databaseSizes.MyDbSize;
|
||||
status.FilteredDbSize = databaseSizes.FilteredDbSize;
|
||||
status.DiscardedDbSize = databaseSizes.DiscardedDbSize;
|
||||
|
||||
|
||||
byte[] serializedResult = JsonSerializer.SerializeToUtf8Bytes(status);
|
||||
|
||||
rep.SendFrame(serializedResult);
|
||||
|
||||
@@ -48,10 +48,11 @@ public class IpScanner
|
||||
{
|
||||
threadsAmount = 256 / threads;
|
||||
}
|
||||
|
||||
|
||||
WaitHandle[] waitHandle1;
|
||||
WaitHandle[] waitHandle2;
|
||||
|
||||
// This is jank. But it was to get it production ready.
|
||||
if (threads <= 64)
|
||||
{
|
||||
waitHandle1 = new WaitHandle[threads];
|
||||
@@ -77,7 +78,7 @@ public class IpScanner
|
||||
ThreadNumber = i,
|
||||
Handle = handle
|
||||
};
|
||||
|
||||
|
||||
if (i < 64)
|
||||
{
|
||||
waitHandle1[counter] = handle;
|
||||
@@ -131,6 +132,7 @@ public class IpScanner
|
||||
fourthByte = resumeNow.FourthByte;
|
||||
}
|
||||
|
||||
// Empty buffer so we use the lowest abstracted ping.Send() method.
|
||||
byte[] buf = [];
|
||||
using Ping ping = new();
|
||||
|
||||
@@ -181,8 +183,7 @@ public class IpScanner
|
||||
_ = IPAddress.TryParse(ip.ToString(), out IPAddress? address);
|
||||
if (address is not null)
|
||||
{
|
||||
responseCode = IPStatus.TimedOut; //ping.Send(address, _timeout, buf, null).Status;
|
||||
Thread.Sleep(1);
|
||||
responseCode = ping.Send(address, _timeout, buf, null).Status;
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ThreadHandler
|
||||
public void Start()
|
||||
{
|
||||
Thread scanner = new(StartScanner);
|
||||
//Thread indexer = new(StartContentFilter);
|
||||
Thread indexer = new(StartContentFilter);
|
||||
Thread database = new(StartDbHandler);
|
||||
Thread discarded = new(StartDiscardedDbHandler);
|
||||
Thread filtered = new(StartFilteredDbHandler);
|
||||
@@ -39,7 +39,7 @@ public class ThreadHandler
|
||||
Thread communication = new(StartCommunicationHandler);
|
||||
|
||||
scanner.Start();
|
||||
//indexer.Start();
|
||||
indexer.Start();
|
||||
database.Start();
|
||||
discarded.Start();
|
||||
filtered.Start();
|
||||
@@ -47,7 +47,7 @@ public class ThreadHandler
|
||||
communication.Start();
|
||||
|
||||
scanner.Join();
|
||||
//indexer.Join();
|
||||
indexer.Join();
|
||||
database.Join();
|
||||
discarded.Join();
|
||||
filtered.Join();
|
||||
@@ -101,7 +101,7 @@ public class ThreadHandler
|
||||
|
||||
private void StartDiscardedDbHandler()
|
||||
{
|
||||
WaitHandle[] wait = _dbHandler.Start(3);
|
||||
WaitHandle[] wait = _dbHandler.Start(4);
|
||||
|
||||
WaitHandle.WaitAll(wait);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user