Fix communication between applications.

This commit is contained in:
Rasmus Rasmussen 2024-11-27 11:33:53 +01:00
parent a160992c08
commit 4eaaf0f244
11 changed files with 18 additions and 16 deletions

View File

@ -43,6 +43,8 @@ public class Communication
{ {
using ResponseSocket rep = new(); using ResponseSocket rep = new();
//rep.Options.IPv4Only = true;
rep.Bind("tcp://127.0.0.1:5556"); rep.Bind("tcp://127.0.0.1:5556");
while (_isRunning) while (_isRunning)
@ -51,6 +53,8 @@ public class Communication
CommunicationObject? communicationObject = JsonSerializer.Deserialize<CommunicationObject>(message); CommunicationObject? communicationObject = JsonSerializer.Deserialize<CommunicationObject>(message);
rep.SendFrame(JsonSerializer.SerializeToUtf8Bytes("Success"));
if (communicationObject is null) if (communicationObject is null)
{ {
continue; continue;
@ -134,12 +138,7 @@ public class Communication
case CommunicationCommand.ChangeRuntimeVariable: case CommunicationCommand.ChangeRuntimeVariable:
{ {
Console.WriteLine("lmao"); if (string.IsNullOrWhiteSpace(communicationObject.VariableValue)) break;
if (string.IsNullOrWhiteSpace(communicationObject.VariableValue))
{
break;
}
if (communicationObject.Variable == RuntimeVariable.DbContent.ToString()) if (communicationObject.Variable == RuntimeVariable.DbContent.ToString())
{ {
@ -152,13 +151,13 @@ public class Communication
int value = int.Parse(communicationObject.VariableValue); int value = int.Parse(communicationObject.VariableValue);
_dbHandler.SetDiscardedWaitTime(value); _dbHandler.SetDiscardedWaitTime(value);
} }
if (communicationObject.Variable == RuntimeVariable.ScannerTimeout.ToString()) if (communicationObject.Variable == RuntimeVariable.ScannerTimeout.ToString())
{ {
int value = int.Parse(communicationObject.VariableValue); int value = int.Parse(communicationObject.VariableValue);
_ipScanner.SetTimeout(value); _ipScanner.SetTimeout(value);
} }
if (communicationObject.Variable == RuntimeVariable.ContentFilter.ToString()) if (communicationObject.Variable == RuntimeVariable.ContentFilter.ToString())
{ {
int value = int.Parse(communicationObject.VariableValue); int value = int.Parse(communicationObject.VariableValue);

View File

@ -25,8 +25,10 @@ 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);
} }
public void SetTimeout(int timeOut) public void SetTimeout(int timeOut)
{ {
_timeOut = timeOut; _timeOut = timeOut;

View File

@ -1,5 +1,4 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Globalization;
using System.Net; using System.Net;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using Backend.Helper; using Backend.Helper;
@ -35,7 +34,6 @@ public class IpScanner
public void SetTimeout(int milliseconds) public void SetTimeout(int milliseconds)
{ {
Console.WriteLine($"Setting timeout to {milliseconds}ms");
_timeout = milliseconds; _timeout = milliseconds;
} }

View File

@ -97,7 +97,7 @@ public class ThreadHandler
Stop(); Stop();
} }
private void Stop() private void Stop()
{ {
_ipScanner.Stop(); _ipScanner.Stop();

View File

@ -60,7 +60,7 @@ public static class Commands
VariableValue = value VariableValue = value
}; };
SendAndRecieveStringMessage(communicationObject); Console.WriteLine(SendAndRecieveStringMessage(communicationObject));
} }
public static void GetHelp() public static void GetHelp()
@ -113,7 +113,6 @@ public static class Commands
byte[] lol = JsonSerializer.SerializeToUtf8Bytes(communicationObject); byte[] lol = JsonSerializer.SerializeToUtf8Bytes(communicationObject);
using RequestSocket client = new(); using RequestSocket client = new();
client.Connect("tcp://127.0.0.1:5556"); client.Connect("tcp://127.0.0.1:5556");
client.SendFrame(lol); client.SendFrame(lol);

View File

@ -39,7 +39,10 @@ do
else if (string.Equals(input, "R")) else if (string.Equals(input, "R"))
{ {
Console.WriteLine("Variable name.");
string? variable = Console.ReadLine(); string? variable = Console.ReadLine();
Console.WriteLine("Variable value.");
string? value = Console.ReadLine(); string? value = Console.ReadLine();
if (string.IsNullOrWhiteSpace(variable) || string.IsNullOrWhiteSpace(value)) if (string.IsNullOrWhiteSpace(variable) || string.IsNullOrWhiteSpace(value))

BIN
Models/Filtered.db Normal file

Binary file not shown.

BIN
Models/ScannerResume.db Normal file

Binary file not shown.

BIN
Models/mydb.db Normal file

Binary file not shown.

View File

@ -31,7 +31,7 @@ progressApi.MapGet("/", () =>
{ {
Command = CommunicationCommand.GetScanningProgress Command = CommunicationCommand.GetScanningProgress
}; };
byte[] bytes = JsonSerializer.SerializeToUtf8Bytes(communicationObject); byte[] bytes = JsonSerializer.SerializeToUtf8Bytes(communicationObject);
using RequestSocket client = new(); using RequestSocket client = new();
@ -50,7 +50,7 @@ searchApi.MapGet("/{term}", (string term) =>
CommunicationObject communicationObject = new(); CommunicationObject communicationObject = new();
communicationObject.Command = CommunicationCommand.GetSearches; communicationObject.Command = CommunicationCommand.GetSearches;
communicationObject.SearchTerm = term; communicationObject.SearchTerm = term;
byte[] bytes = JsonSerializer.SerializeToUtf8Bytes(communicationObject); byte[] bytes = JsonSerializer.SerializeToUtf8Bytes(communicationObject);
using RequestSocket client = new(); using RequestSocket client = new();

View File

@ -20,6 +20,7 @@
<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_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_002EUnix_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F8d57f5f5fd3290d6a89a5b767ad89988dd893c988eba430cd461b8b88d7ad9d_003FPing_002EUnix_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APing_002EUnix_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F8d57f5f5fd3290d6a89a5b767ad89988dd893c988eba430cd461b8b88d7ad9d_003FPing_002EUnix_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARep_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Feea8e921c916164ccc376e162da148b8215450dfae96e08bdd29119165c67f_003FRep_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARep_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Feea8e921c916164ccc376e162da148b8215450dfae96e08bdd29119165c67f_003FRep_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AReq_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F33fafcc2bb6e91ae8abb5a52936d39cd93951ad9208861e758ca93efa619eaf3_003FReq_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AReq_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F33fafcc2bb6e91ae8abb5a52936d39cd93951ad9208861e758ca93efa619eaf3_003FReq_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>