1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-11 13:53:37 +00:00

Fixed macOS related issues with MeshCore tests.

Fixed bug in macOS clipboard where 0x0D0A was tacked on the end of the buffer
Fixed bug with customized agents, where MeshAgent.isService was returning the wrong value
This commit is contained in:
Bryan Roe
2022-06-30 14:47:02 -07:00
parent b493da68e4
commit fd59b52e89
4 changed files with 29 additions and 16 deletions

View File

@@ -2028,17 +2028,9 @@ void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain)
#endif #endif
ILibDuktape_CreateReadonlyProperty_SetEnumerable(ctx, "isService",1); ILibDuktape_CreateReadonlyProperty_SetEnumerable(ctx, "isService",1);
#else #else
#ifndef __APPLE__
// Determine if we're running as service on Linux // Determine if we're running as service on Linux
if (duk_peval_string(ctx, "require('service-manager').manager.getService('meshagent').isMe();") == 0) duk_push_boolean(ctx, agent->JSRunningAsService);
{ ILibDuktape_CreateReadonlyProperty_SetEnumerable(ctx, "isService",1);
ILibDuktape_CreateReadonlyProperty_SetEnumerable(ctx, "isService",1);
}
else
{
duk_pop(ctx);
}
#endif
#endif #endif
} }
@@ -2048,6 +2040,7 @@ void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain)
ILibRemoteLogging_printf(ILibChainGetLogger(agent->chain), ILibRemoteLogging_Modules_Microstack_Generic, ILibRemoteLogging_Flags_VerbosityLevel_1, "Acquired MeshAgent"); ILibRemoteLogging_printf(ILibChainGetLogger(agent->chain), ILibRemoteLogging_Modules_Microstack_Generic, ILibRemoteLogging_Flags_VerbosityLevel_1, "Acquired MeshAgent");
} }
void ILibDuktape_MeshAgent_Init(duk_context* ctx, void *chain, MeshAgentHostContainer *agent) void ILibDuktape_MeshAgent_Init(duk_context* ctx, void *chain, MeshAgentHostContainer *agent)
{ {
duk_push_heap_stash(ctx); // [stash] duk_push_heap_stash(ctx); // [stash]

File diff suppressed because one or more lines are too long

View File

@@ -952,6 +952,7 @@ function macos_messageBox()
ret.child.on('exit', function () ret.child.on('exit', function ()
{ {
var res = this.stdout.str.split('\x1e')[1]; var res = this.stdout.str.split('\x1e')[1];
if (res.length > 2) { res = res.substring(0, res.length - 2); }
this.promise._res(res); this.promise._res(res);
}); });
ret.child.stdin.write('su - ' + ret.name + '\n'); ret.child.stdin.write('su - ' + ret.name + '\n');
@@ -1128,6 +1129,7 @@ function macos_messageBox()
} }
else else
{ {
if (this._shell.stdout.str.length > 2) { this._shell.stdout.str = this._shell.stdout.str.substring(0, this._shell.stdout.str.length - 2); }
this.end(translateObject({ command: 'readClip', clipValue: this._shell.stdout.str })); this.end(translateObject({ command: 'readClip', clipValue: this._shell.stdout.str }));
} }
break; break;

View File

@@ -148,7 +148,7 @@ function resetPromises()
process.stdout.write('Generating Certificate...'); process.stdout.write('Generating Certificate...');
var cert = require('tls').generateCertificate('test', { certType: 2, noUsages: 1 }); var cert = require('tls').generateCertificate('test', { certType: 2, noUsages: 1 });
var server = require('https').createServer({ pfx: cert, passphrase: 'test' }); var server = require('https').createServer({ pfx: cert, passphrase: 'test' });
server.listen({ port: 9250 }); server.listen();
process.stdout.write('\rGenerating Certificate... [DONE]\n'); process.stdout.write('\rGenerating Certificate... [DONE]\n');
@@ -540,11 +540,28 @@ server.on('upgrade', function (msg, sck, head)
process.stdout.write('\r'); process.stdout.write('\r');
process.stdout.write(' Agent sent Network Info to server.......................[OK] \n'); process.stdout.write(' Agent sent Network Info to server.......................[OK] \n');
process.stdout.write(' Agent sent SMBIOS info to server........................[WAITING]'); process.stdout.write(' Agent sent SMBIOS info to server........................[WAITING]');
return (promises.smbios); switch(process.platform)
{
case 'linux':
case 'win32':
return (promises.smbios);
break;
default:
break;
}
}).then(function () }).then(function ()
{ {
process.stdout.write('\r'); process.stdout.write('\r');
process.stdout.write(' Agent sent SMBIOS info to server........................[OK] \n'); switch (process.platform)
{
case 'linux':
case 'win32':
process.stdout.write(' Agent sent SMBIOS info to server........................[OK] \n');
break;
default:
process.stdout.write(' Agent sent SMBIOS info to server........................[NA] \n');
break;
}
process.stdout.write(' Tunnel Test.............................................[WAITING]'); process.stdout.write(' Tunnel Test.............................................[WAITING]');
return (createTunnel(0, 0)); return (createTunnel(0, 0));
}).then(function (t) }).then(function (t)
@@ -613,6 +630,7 @@ server.on('upgrade', function (msg, sck, head)
return (promises.setclip); return (promises.setclip);
}).then(function (v) }).then(function (v)
{ {
console.info1(JSON.stringify(v));
if (!v.success) if (!v.success)
{ {
process.stdout.write('\r Clipboard Test..........................................[FAILED TO SET]\n'); process.stdout.write('\r Clipboard Test..........................................[FAILED TO SET]\n');
@@ -655,7 +673,7 @@ function createTunnel(rights, consent)
{ {
ret.reject('timeout'); ret.reject('timeout');
}, 2000); }, 2000);
ret.options = { action: 'msg', type: 'tunnel', rights: rights, consent: consent, username: '(test script)', value: 'wss://127.0.0.1:9250/tunnel' }; ret.options = { action: 'msg', type: 'tunnel', rights: rights, consent: consent, username: '(test script)', value: 'wss://127.0.0.1:' + server.address().port + '/tunnel' };
global._client.command(ret.options); global._client.command(ret.options);
return (ret); return (ret);
} }
@@ -837,7 +855,7 @@ if (process.argv.getParameter('NoInstall') == null)
[ [
{ {
newName: (process.platform == 'win32' ? 'MeshAgent.msh' : 'meshagent.msh'), newName: (process.platform == 'win32' ? 'MeshAgent.msh' : 'meshagent.msh'),
_buffer: 'logUpdate=1\nMeshID=0x43FEF862BF941B2BBE5964CC7CA02573BBFB94D5A717C5AA3FC103558347D0BE26840ACBD30FFF981F7F5A2083D0DABC\nMeshServer=wss://127.0.0.1:9250/agent.ashx\nmeshServiceName=TestAgent\nServerID=' + loadedCert.getKeyHash().toString('hex') _buffer: 'logUpdate=1\nMeshID=0x43FEF862BF941B2BBE5964CC7CA02573BBFB94D5A717C5AA3FC103558347D0BE26840ACBD30FFF981F7F5A2083D0DABC\nMeshServer=wss://127.0.0.1:' + server.address().port + '/agent.ashx\nmeshServiceName=TestAgent\nServerID=' + loadedCert.getKeyHash().toString('hex')
} }
], ],
binary: updateSource, binary: updateSource,