Fix the FileEventMonitor.cs

This commit is contained in:
Namhyeon Go 2024-09-09 16:47:51 +09:00
parent a18229afea
commit 91b73186d3
4 changed files with 12 additions and 12 deletions

View File

@ -114,13 +114,13 @@ namespace WelsonJS.Service
if (File.Exists(fileName))
{
parent.Log($"File created: {fileName}");
parent.DispatchServiceEvent("fileCreated", new string[] {
parent.Log($"> Detected the file creation: {fileName}");
parent.Log(parent.DispatchServiceEvent("fileCreated", new string[] {
ruleName,
processId,
image,
fileName
});
}));
}
else
{
@ -135,13 +135,15 @@ namespace WelsonJS.Service
string protocol = e.EventRecord.Properties[(int)NetworkConnectionEvent.Protocol]?.Value?.ToString();
string destinationIp = e.EventRecord.Properties[(int)NetworkConnectionEvent.DestinationIp]?.Value?.ToString();
string desinationPort = e.EventRecord.Properties[(int)NetworkConnectionEvent.DestinationPort]?.Value?.ToString();
string dstinationAddress = $"{protocol}://{destinationIp}:{desinationPort}";
parent.DispatchServiceEvent("networkConnected", new string[] {
parent.Log($"> Detected the network connection: {dstinationAddress}");
parent.Log(parent.DispatchServiceEvent("networkConnected", new string[] {
ruleName,
processId,
image,
$"{protocol}://{destinationIp}:{desinationPort}"
});
dstinationAddress
}));
}
}
catch (Exception ex)

View File

@ -9,7 +9,6 @@ using System.ServiceProcess;
using Grpc.Net.Client;
using Grpc.Net.Client.Web;
using System.Net.Http;
using System.Threading;
namespace WelsonJS.Service
{

3
app.js
View File

@ -626,10 +626,9 @@ function dispatchServiceEvent(name, eventType, w_args, argl) {
start: bind("ServiceStart"),
stop: bind("ServiceStop"),
elapsedTime: bind("ServiceElapsedTime"),
messageReceived: bind("MessageReceived"),
screenTime: bind("ServiceScreenTime"),
fileCreated: bind("FileCreated"),
fileRuleMatched: bind("FileRuleMatched")
networkConnected: bind("NetworkConnected")
});
} else {
console.error("Could not find", name + ".js");

View File

@ -32,8 +32,8 @@ function onFileCreated(args) {
return "onFileCreated recevied. " + args.join(', ');
}
function onFileRuleMatched(args) {
return "onFileCreated recevied. " + args.join(', ');
function onNetworkConnected(args) {
return "onNetworkConnected recevied. " + args.join(', ');
}
exports.main = main;
@ -43,4 +43,4 @@ exports.onServiceStop = onServiceStop;
exports.onServiceElapsedTime = onServiceElapsedTime;
exports.onServiceScreenTime = onServiceScreenTime;
exports.onFileCreated = onFileCreated;
exports.onFileRuleMatched = onFileRuleMatched;
exports.onNetworkConnected = onNetworkConnected;