How to use socks-proxy-agent - 2 common examples

To help you get started, we’ve selected a few socks-proxy-agent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github assnctr / unfx-proxy-checker / src / core / checker.js View on Github external
getAgent(proxy, protocol) {
        if (protocol == 'socks4' || protocol == 'socks5') {
            const agent = new SocksProxyAgent(protocol + '://' + proxy);
            agent.timeout = this.initialRequestConfig.timeout;

            return { agent };
        }

        return { proxy: 'http://' + proxy };
    }
github h3poteto / megalodon / src / proxy_config.ts View on Github external
const proxyAgent = (proxyConfig: ProxyConfig): HttpsProxyAgent | SocksProxyAgent => {
  let auth = ''
  if (proxyConfig.auth) {
    auth = `${proxyConfig.auth.username}:${proxyConfig.auth.password}@`
  }
  switch (proxyConfig.protocol) {
    case 'http':
    case 'https':
      const httpsAgent = new HttpsProxyAgent(`${proxyConfig.protocol}://${auth}${proxyConfig.host}:${proxyConfig.port}`)
      return httpsAgent
    case 'socks4':
    case 'socks4a':
    case 'socks5':
    case 'socks5h':
    case 'socks':
      const socksAgent = new SocksProxyAgent(`${proxyConfig.protocol}://${auth}${proxyConfig.host}:${proxyConfig.port}`)
      return socksAgent
    default:
      throw new ProxyProtocolError('protocol is not accepted')
  }
}
export default proxyAgent

socks-proxy-agent

A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS

MIT
Latest version published 20 days ago

Package Health Score

89 / 100
Full package analysis

Popular socks-proxy-agent functions