(pushEndpoint, env, log)
| 39 | |
| 40 | // No wildcard nor cidr/mask match for now |
| 41 | function createWSAgent(pushEndpoint, env, log) { |
| 42 | const url = new _URL(pushEndpoint); |
| 43 | const noProxy = (env.NO_PROXY || env.no_proxy |
| 44 | || '').split(','); |
| 45 | |
| 46 | if (noProxy.includes(url.hostname)) { |
| 47 | log.info('push server ws has proxy exclusion', { noProxy }); |
| 48 | return null; |
| 49 | } |
| 50 | |
| 51 | if (url.protocol === 'https:' || url.protocol === 'wss:') { |
| 52 | const httpsProxy = (env.HTTPS_PROXY || env.https_proxy); |
| 53 | if (httpsProxy) { |
| 54 | log.info('push server ws using https proxy', { httpsProxy }); |
| 55 | return new HttpsProxyAgent(httpsProxy); |
| 56 | } |
| 57 | } else if (url.protocol === 'http:' || url.protocol === 'ws:') { |
| 58 | const httpProxy = (env.HTTP_PROXY || env.http_proxy); |
| 59 | if (httpProxy) { |
| 60 | log.info('push server ws using http proxy', { httpProxy }); |
| 61 | return new HttpsProxyAgent(httpProxy); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | const allProxy = (env.ALL_PROXY || env.all_proxy); |
| 66 | if (allProxy) { |
| 67 | log.info('push server ws using wildcard proxy', { allProxy }); |
| 68 | return new HttpsProxyAgent(allProxy); |
| 69 | } |
| 70 | |
| 71 | log.info('push server ws not using proxy'); |
| 72 | return null; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Starts background task that updates configuration and pushes stats. |
no test coverage detected