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

1. Updated global-tunnel to always use the object cached by the module loader, fixing a bug where the native and JS instances didn't match

2. Updated proxy-helper to always end a global-tunnel before fetching the auto-proxy script, fixing a bug where auto-proxy couldn't be fetched correctly after autoproxy was configured
This commit is contained in:
Bryan Roe
2022-09-21 00:58:21 -07:00
parent 59efd7ab18
commit b21c7c380e
3 changed files with 18 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1998,7 +1998,18 @@ ILibDuktape_globalTunnel_data* ILibDuktape_GetNewGlobalTunnelEx(duk_context *ctx
{
ILibDuktape_globalTunnel_data *retVal;
if (native != 0) { duk_push_heap_stash(ctx); } // [stash]
if (native != 0)
{
//
// If native is calling us, we will use JavaScript to return the pointer value, becuase
// JS module loader caches entries, so we need to make sure we don't instantiate a new structure,
// but instead re-use the existing one.
//
duk_eval_string(ctx, "require('global-tunnel')"); // [global-tunnel]
retVal = (ILibDuktape_globalTunnel_data*)Duktape_GetBufferProperty(ctx, -1, ILibDuktape_GlobalTunnel_DataPtr);
duk_pop(ctx); // ...
return(retVal);
}
duk_push_object(ctx); // [stash][tunnel]
duk_dup(ctx, -1); // [stash][tunnel][dup]
@@ -2018,7 +2029,6 @@ ILibDuktape_globalTunnel_data* ILibDuktape_GetNewGlobalTunnelEx(duk_context *ctx
ILibDuktape_CreateEventWithGetter_SetEnumerable(ctx, "isProxying", ILibDuktape_globalTunnel_isProxying, 1);
ILibDuktape_CreateFinalizer(ctx, ILibDuktape_globalTunnel_finalizer);
if (native != 0) { duk_pop(ctx); } // ...
return retVal;
}

View File

@@ -582,6 +582,10 @@ function windows_getProxy()
function auto_proxy_helper(target)
{
// The first thing we need to do, is disable any existing proxy settings, otherwise we won't be able to find the autoconfig script
require('global-tunnel').end();
var promise = require('promise');
var ret = new promise(promise.defaultInit);