apnex / vmw-cli

CLI and API for programmatic access to my.vmware.com
MIT License
30 stars 9 forks source link

vmw-cli and proxy on "native" npm installation does not work w/ proxy #9

Open vMarkus opened 2 years ago

vMarkus commented 2 years ago

I am trying to get vmw-cli working over proxy server

what I did:

set npm proxy via .npmrc file for default user and root and logging out and back in again

install vmw-cli via npm as described (npm install vmw-cli --global)

vmw-cli ls fails, no local dns resolution (should be performed over proxy?):

root@ubuntu-npm:~# vmw-cli ls
[GET] https://customerconnect.vmware.com/channel/public/api/v1.0/products/getProductsAtoZ
[GET] https://customerconnect.vmware.com/channel/public/api/v1.0/products/getProductsAtoZ
[GET] https://customerconnect.vmware.com/channel/public/api/v1.0/products/getProductsAtoZ
(node:5811) UnhandledPromiseRejectionWarning: RequestError: getaddrinfo EAI_AGAIN customerconnect.vmware.com
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/vmw-cli/node_modules/got/dist/source/core/index.js:956:111)
    at Object.onceWrapper (events.js:421:26)
    at ClientRequest.emit (events.js:326:22)
    at ClientRequest.origin.emit (/usr/local/lib/node_modules/vmw-cli/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
    at TLSSocket.socketErrorListener (_http_client.js:427:9)
    at TLSSocket.emit (events.js:314:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
(node:5811) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5811) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

working curl over proxy

root@ubuntu-npm:~# curl web.de
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://web.de/">here</a>.</p>
</body></html>

Squid working with proxy and no local dns resolution on air-gapped Ubuntu VM

root@ubuntu-npm:~# ping web.de
ping: web.de: Temporary failure in name resolution

Squid access.log does not show any activity, when I run vmw-cli, so the proxy configuration somehow is not picked up,

This time with /etc/hosts setting for customerconnect.vmware.com to point to ip address to rule out dns resolution issue

root@ubuntu-npm:~# vmw-cli ls
[GET] https://customerconnect.vmware.com/channel/public/api/v1.0/products/getProductsAtoZ
[GET] https://customerconnect.vmware.com/channel/public/api/v1.0/products/getProductsAtoZ
[GET] https://customerconnect.vmware.com/channel/public/api/v1.0/products/getProductsAtoZ
(node:5919) UnhandledPromiseRejectionWarning: RequestError: connect ENETUNREACH 23.53.168.34:443 - Local (0.0.0.0:0)
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/vmw-cli/node_modules/got/dist/source/core/index.js:956:111)
    at Object.onceWrapper (events.js:421:26)
    at ClientRequest.emit (events.js:326:22)
    at ClientRequest.origin.emit (/usr/local/lib/node_modules/vmw-cli/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
    at TLSSocket.socketErrorListener (_http_client.js:427:9)
    at TLSSocket.emit (events.js:314:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
    at internalConnect (net.js:924:16)
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:364:12)
    at GetAddrInfoReqWrap.emitLookup [as callback] (net.js:1060:9)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:68:8)
(node:5919) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5919) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Not sure if this is a vmw-cli issue or more a nodejs/npm issue? Any pointers welcome to get this working for air-gapped deployments.

vMarkus commented 2 years ago

Meanwhile customerconnect.vmware.com ip changed to 104.125.72.51 - but the result is the same, not working over proxy.

OlesyaTishkina commented 2 years ago

Wondering if anybody figured out how to get vmw-cli to work over proxy

SilentT19 commented 2 years ago

You can use https://www.npmjs.com/package/global-agent

like That

export GLOBAL_AGENT_HTTP_PROXY=http://myproxy:8080
node -r 'global-agent/bootstrap' /root/node_modules/vmw-cli/lib/vmw.cli.js ls