1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-06 00:13:33 +00:00

1. Updated CoInitializseEx() to MULTITHREAD when running service in console mode

2. Updated Cleanup code for COM, so that Release is not called from finalizer
3. Updated installer to create WebRTC UDP firewall rule
This commit is contained in:
Bryan Roe
2021-11-09 15:21:16 -08:00
parent 4fcdd211b1
commit bc40427b26
6 changed files with 40 additions and 10 deletions

View File

@@ -539,8 +539,7 @@ int wmain(int argc, char* wargv[])
integragedJavaScriptLen = (int)sizeof(script) - 1;
}
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (argc > 1 && strcasecmp(argv[1], "-updaterversion") == 0)
{
DWORD dummy;

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,6 @@
/*
Copyright 2020 Intel Corporation
@author Bryan Roe
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -250,6 +251,25 @@ function installService(params)
}
}
if(process.platform == 'win32')
{
var loc = svc.appLocation();
process.stdout.write(' -> Writing firewall rules for ' + options.name + ' Service...');
var rule =
{
DisplayName: options.name + ' WebRTC Traffic',
direction: 'inbound',
Program: loc,
Protocol: 'UDP',
Profile: 'Public, Private, Domain',
Description: 'Mesh Central Agent WebRTC P2P Traffic',
EdgeTraversalPolicy: 'allow',
Enabled: true
};
require('win-firewall').addFirewallRule(rule);
process.stdout.write(' [DONE]\n');
}
process.stdout.write(' -> Starting service...');
try
{

View File

@@ -1,5 +1,6 @@
/*
Copyright 2021 Intel Corporation
@author Bryan Roe
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -38,10 +39,8 @@ ole32.CreateMethod('StringFromIID');
function createInstance_finalizer()
{
var tmp = marshalFunctions(this, IUnknownMethods);
tmp.Release(this);
ole32.CoUninitialize();
console.info1('CoUninitialize()');
ole32.CoUninitialize();
}
function createInstance(RFCLSID, RFIID, options)
{
@@ -95,7 +94,7 @@ function IIDFromString(IIDString)
function marshalFunctions(obj, arr)
{
return (GM.MarshalFunctions(obj.Deref(), arr));IID_IUnknown
return (GM.MarshalFunctions(obj.Deref(), arr));
}
function marshalInterface(arr)
{

View File

@@ -1,5 +1,6 @@
/*
Copyright 2020-2021 Intel Corporation
@author Bryan Roe
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -363,6 +364,8 @@ function getFirewallRules(options)
}
}
}
NetFwPolicy2.funcs.Release(NetFwPolicy2);
return (ret);
}
@@ -430,8 +433,13 @@ function removeFirewallRule(arg)
ret = true;
}
}
NetFwPolicy2.funcs.Release(NetFwPolicy2);
return (ret);
}
else
{
return(removeFirewallRule(getFirewallRules(arg)));
}
}
function addFirewallRule(rule)
{
@@ -484,6 +492,9 @@ function addFirewallRule(rule)
rules.funcs = require('win-com').marshalFunctions(rules.Deref(), RulesFunctions);
hr = rules.funcs.Add(rules.Deref(), newrule);
newrule.funcs.Release(newrule);
rules.funcs.Release(rules.Deref());
}
//attachDebugger({ webport: 9995, wait: true }).then(console.log, console.log);

View File

@@ -339,6 +339,7 @@ function query(resourceString, queryString, fields)
results.funcs.Release(results.Deref());
services.funcs.Release(services.Deref());
locator.funcs.Release(locator);
return (ret);
}