1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-04 01:23:21 +00:00

Fixed compiler warning

This commit is contained in:
Bryan Roe
2020-01-24 22:42:29 -08:00
parent 310e5c86c6
commit a5e30ab2c6

View File

@@ -449,6 +449,21 @@ duk_ret_t ILibDuktape_net_socket_connect(duk_context *ctx)
ILibResolveEx(host, (unsigned short)port, &dest);
if (dest.sin6_family == AF_UNSPEC || (duk_is_object(ctx, 0) && duk_has_prop_string(ctx, 0, "proxy") && proxy.sin6_family == AF_UNSPEC))
{
// Can't resolve, check to see if it's cached
duk_push_heap_stash(ctx);
if (duk_has_prop_string(ctx, -1, "_sharedDB"))
{
ILibSimpleDataStore db = (ILibSimpleDataStore)Duktape_GetPointerProperty(ctx, -1, "_sharedDB");
char *dnsCache = (char*)duk_push_sprintf(ctx, "DNS[%s]", host);
char dnsCacheBuffer[255];
if (ILibSimpleDataStore_Get(db, dnsCache, dnsCacheBuffer, sizeof(dnsCacheBuffer)) > 0)
{
ILibResolveEx(dnsCacheBuffer, (unsigned short)port, &dest);
}
}
}
if (dest.sin6_family == AF_UNSPEC || (duk_is_object(ctx, 0) && duk_has_prop_string(ctx, 0, "proxy") && proxy.sin6_family == AF_UNSPEC))
{
// Can't resolve... Delay event emit, until next event loop, because if app called net.createConnection(), they don't have the socket yet
duk_push_heapptr(ctx, ptrs->object); // [socket]
@@ -1963,6 +1978,21 @@ duk_ret_t ILibDuktape_TLS_connect(duk_context *ctx)
ILibResolveEx(host, (unsigned short)port, &dest);
}
if (dest.sin6_family == AF_UNSPEC || (duk_has_prop_string(ctx, 0, "proxy") && proxy.sin6_family == AF_UNSPEC))
{
// Can't resolve, check to see if it's cached
duk_push_heap_stash(ctx);
if (duk_has_prop_string(ctx, -1, "_sharedDB"))
{
ILibSimpleDataStore db = (ILibSimpleDataStore)Duktape_GetPointerProperty(ctx, -1, "_sharedDB");
char *dnsCache = (char*)duk_push_sprintf(ctx, "DNS[%s]", host);
char dnsCacheBuffer[255];
if (ILibSimpleDataStore_Get(db, dnsCache, dnsCacheBuffer, sizeof(dnsCacheBuffer)) > 0)
{
ILibResolveEx(dnsCacheBuffer, (unsigned short)port, &dest);
}
}
}
if (dest.sin6_family == AF_UNSPEC || (duk_has_prop_string(ctx, 0, "proxy") && proxy.sin6_family == AF_UNSPEC))
{
// Can't resolve... Delay event emit, until next event loop, because if app called net.createConnection(), they don't have the socket yet
duk_push_error_object(ctx, DUK_ERR_ERROR, "tls.socket.connect(): Cannot resolve host '%s'", host);