+function getAgent () {
+ if (!isProxyEnabled()) return {}
+
+ const proxy = getProxy()
+
+ logger.info('Using proxy %s.', proxy)
+
+ const proxyAgentOptions = {
+ keepAlive: true,
+ keepAliveMsecs: 1000,
+ maxSockets: 256,
+ maxFreeSockets: 256,
+ scheduling: 'lifo' as 'lifo',
+ proxy
+ }
+
+ return {
+ agent: {
+ http: new HttpProxyAgent(proxyAgentOptions),
+ https: new HttpsProxyAgent(proxyAgentOptions)
+ }
+ }
+}
+