TooTallNate / proxy-agents

Node.js HTTP Proxy Agents Monorepo
https://proxy-agents.n8.io
871 stars 229 forks source link

Uesrname and password for socks-proxy-agents #307

Closed 1965514404 closed 2 months ago

1965514404 commented 2 months ago

the older version use username and password with:

{
    hostname: '127.0.0.1',
    port: 10806,
    userId: '9DDFQFUODO',
    password: '7h88l87sojqed3'
}

on the newer version use it with error tell:

switch (url.protocol.replace(':', '')) {
                         ^

TypeError: Cannot read properties of undefined (reading 'replace')
    at parseSocksURL (d:\2script\node\js\node_modules\socks-proxy-agent\dist\index.js:47:26)      
    at new SocksProxyAgent (d:\2script\node\js\node_modules\socks-proxy-agent\dist\index.js:93:35)
    at Object.<anonymous> (d:\2script\node\js\test1.js:130:20)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.18.0

TooTallNate commented 2 months ago

The API changed, you now need to pass a URL as the first argument to new SocksProxyAgent(). You specify the username/password in the URL:

new SocksProxyAgent('socks://username:password@example.com:9128');