From 4eaaf0f2443da1c737b18ab0d714c7cdfbf02e81 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Wed, 27 Nov 2024 11:33:53 +0100 Subject: [PATCH] Fix communication between applications. --- Backend/Handler/Communication.cs | 15 +++++++-------- Backend/Handler/ContentFilter.cs | 4 +++- Backend/Handler/IpScanner.cs | 2 -- Backend/Handler/ThreadHandler.cs | 2 +- Manager/Commands.cs | 3 +-- Manager/Program.cs | 3 +++ Models/Filtered.db | Bin 0 -> 12288 bytes Models/ScannerResume.db | Bin 0 -> 8192 bytes Models/mydb.db | Bin 0 -> 16384 bytes Proxy/Program.cs | 4 ++-- RSE.sln.DotSettings.user | 1 + 11 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 Models/Filtered.db create mode 100644 Models/ScannerResume.db create mode 100644 Models/mydb.db diff --git a/Backend/Handler/Communication.cs b/Backend/Handler/Communication.cs index 6086039..a9aebb1 100644 --- a/Backend/Handler/Communication.cs +++ b/Backend/Handler/Communication.cs @@ -43,6 +43,8 @@ public class Communication { using ResponseSocket rep = new(); + //rep.Options.IPv4Only = true; + rep.Bind("tcp://127.0.0.1:5556"); while (_isRunning) @@ -51,6 +53,8 @@ public class Communication CommunicationObject? communicationObject = JsonSerializer.Deserialize(message); + rep.SendFrame(JsonSerializer.SerializeToUtf8Bytes("Success")); + if (communicationObject is null) { continue; @@ -134,12 +138,7 @@ public class Communication case CommunicationCommand.ChangeRuntimeVariable: { - Console.WriteLine("lmao"); - - if (string.IsNullOrWhiteSpace(communicationObject.VariableValue)) - { - break; - } + if (string.IsNullOrWhiteSpace(communicationObject.VariableValue)) break; if (communicationObject.Variable == RuntimeVariable.DbContent.ToString()) { @@ -152,13 +151,13 @@ public class Communication int value = int.Parse(communicationObject.VariableValue); _dbHandler.SetDiscardedWaitTime(value); } - + if (communicationObject.Variable == RuntimeVariable.ScannerTimeout.ToString()) { int value = int.Parse(communicationObject.VariableValue); _ipScanner.SetTimeout(value); } - + if (communicationObject.Variable == RuntimeVariable.ContentFilter.ToString()) { int value = int.Parse(communicationObject.VariableValue); diff --git a/Backend/Handler/ContentFilter.cs b/Backend/Handler/ContentFilter.cs index f5be79d..0be4d0e 100644 --- a/Backend/Handler/ContentFilter.cs +++ b/Backend/Handler/ContentFilter.cs @@ -25,8 +25,10 @@ public class ContentFilter _getDomainPort80 = $"{basePath}/Backend/Scripts/GetDomainNamePort80.sh"; _getDomainPort443 = $"{basePath}/Backend/Scripts/GetDomainNamePort443.sh"; + + SetTimeout(60000); } - + public void SetTimeout(int timeOut) { _timeOut = timeOut; diff --git a/Backend/Handler/IpScanner.cs b/Backend/Handler/IpScanner.cs index 32fb10a..1614fc5 100644 --- a/Backend/Handler/IpScanner.cs +++ b/Backend/Handler/IpScanner.cs @@ -1,5 +1,4 @@ using System.Collections.Concurrent; -using System.Globalization; using System.Net; using System.Net.NetworkInformation; using Backend.Helper; @@ -35,7 +34,6 @@ public class IpScanner public void SetTimeout(int milliseconds) { - Console.WriteLine($"Setting timeout to {milliseconds}ms"); _timeout = milliseconds; } diff --git a/Backend/Handler/ThreadHandler.cs b/Backend/Handler/ThreadHandler.cs index f742acb..9267459 100644 --- a/Backend/Handler/ThreadHandler.cs +++ b/Backend/Handler/ThreadHandler.cs @@ -97,7 +97,7 @@ public class ThreadHandler Stop(); } - + private void Stop() { _ipScanner.Stop(); diff --git a/Manager/Commands.cs b/Manager/Commands.cs index 9837684..abccd18 100644 --- a/Manager/Commands.cs +++ b/Manager/Commands.cs @@ -60,7 +60,7 @@ public static class Commands VariableValue = value }; - SendAndRecieveStringMessage(communicationObject); + Console.WriteLine(SendAndRecieveStringMessage(communicationObject)); } public static void GetHelp() @@ -113,7 +113,6 @@ public static class Commands byte[] lol = JsonSerializer.SerializeToUtf8Bytes(communicationObject); - using RequestSocket client = new(); client.Connect("tcp://127.0.0.1:5556"); client.SendFrame(lol); diff --git a/Manager/Program.cs b/Manager/Program.cs index abd960a..787506a 100644 --- a/Manager/Program.cs +++ b/Manager/Program.cs @@ -39,7 +39,10 @@ do else if (string.Equals(input, "R")) { + Console.WriteLine("Variable name."); string? variable = Console.ReadLine(); + + Console.WriteLine("Variable value."); string? value = Console.ReadLine(); if (string.IsNullOrWhiteSpace(variable) || string.IsNullOrWhiteSpace(value)) diff --git a/Models/Filtered.db b/Models/Filtered.db new file mode 100644 index 0000000000000000000000000000000000000000..48380b104b163fc09888ac27e175777d56742c0a GIT binary patch literal 12288 zcmeH~L2KJE7>4b1ZArJmZiPWXc$b8h!CKgPUZ!=XspBO|X?7`&qb35!c4fIN`vW`f zx9uNI>6$fZzT9>yuRyl^z3(TkJ>!R$~ z#RYMBtRScOpi;Tre3+Y3TncKu zeT<&yF3D7OOKPL8RT3K+lw~D#E3Y!6X9UV6Ye$dcO#O)GSVOya2zO9i zyeGmUE$=5wh%Hr2r0!LA9~0`Cobm6;B+katPsh1dW-=vgQ8i3eV$GWtV#Po)Suvat zL-Ln177S z?~6_l+E4bJhoZUHoS)6@p&tbVKmY_l00ck)1V8`;KmY_l00cnb2@}Bi{|PTHUJV35 Y00ck)1V8`;KmY_l00ck)1nvp^0R_7|w*UYD literal 0 HcmV?d00001 diff --git a/Models/ScannerResume.db b/Models/ScannerResume.db new file mode 100644 index 0000000000000000000000000000000000000000..a44725c94c534967899d2392373bfd3dd9f212b2 GIT binary patch literal 8192 zcmeI1K}#D!6oB8%Mzfp5osBsZ6=cY%g(6D-z$UVa5K@zD&UI~86ETTyHiw=XQlUMz z;1AG?=hkCS=^rR1$KLu2gdpT1(zhEIDl~fY^oE_;+3(G~8NNLYQz;c1zAN|IUeodA zD=>gDFr@^5OROAgRF<$4i$3tp{^?KaUc$upm&Vu#7IPgV&--(AQ>&nmB372 z;XH(D1e1sc@a;b2&_meg3XF}os!i4~p_fN;m6?s^DmX|NzhRNj$3lh;GQ5i)C~%ur eCQQTJK{~90hsls*GE;?7imAAhV25TLZvFzJ^MOqO literal 0 HcmV?d00001 diff --git a/Models/mydb.db b/Models/mydb.db new file mode 100644 index 0000000000000000000000000000000000000000..8ad61fdd412e0581b69fd4f48e17630e8d5f7cba GIT binary patch literal 16384 zcmeI#-A=+V6bJB4Pyz|+l_Vy_(klqWM127#sb*me93_z}GF*uyY```iz>in)QG72u zWMM4e1CW1{rCrb3_58M*(|a~1p&;X#@7f``Q_dAtRqhE<6eTCGti0lOAqUBOH4gmK z=alQ=Wl=tmDSj(wrPCkTp+Nuw5P$##AOHafKmY;|fWSV1k8&ngs#Mgk3D)k2=?4$bQ(XHU!`W``5AZy1eeeoph8y~v5gq$Ps+ z%nL+w=7`o0b&pO;^}0G(=>&_ZtZ0XUSS*G2DpI$ZEvHnl>e;Sn$d$GCv6?HD%j)OV zYENtFg%ei7S|jlbP`q3wrUzMqoRw_3f7dCvYI zfAfXym`isgd`i-1D%7IdTo(Ok5P$##AOHafKmY;|fB*y_009UbumI}+1OB*34FV8= t00bZa0SG_<0uX=z1R$^$K>d$j0Rj+!00bZa0SG_<0uX=z1R!wu0>50^w*CMB literal 0 HcmV?d00001 diff --git a/Proxy/Program.cs b/Proxy/Program.cs index ae00150..d7e00e2 100644 --- a/Proxy/Program.cs +++ b/Proxy/Program.cs @@ -31,7 +31,7 @@ progressApi.MapGet("/", () => { Command = CommunicationCommand.GetScanningProgress }; - + byte[] bytes = JsonSerializer.SerializeToUtf8Bytes(communicationObject); using RequestSocket client = new(); @@ -50,7 +50,7 @@ searchApi.MapGet("/{term}", (string term) => CommunicationObject communicationObject = new(); communicationObject.Command = CommunicationCommand.GetSearches; communicationObject.SearchTerm = term; - + byte[] bytes = JsonSerializer.SerializeToUtf8Bytes(communicationObject); using RequestSocket client = new(); diff --git a/RSE.sln.DotSettings.user b/RSE.sln.DotSettings.user index 8248f74..d2fb5c5 100644 --- a/RSE.sln.DotSettings.user +++ b/RSE.sln.DotSettings.user @@ -20,6 +20,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded