diff --git a/README.md b/README.md index c872c7a..069fb93 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,16 @@ page.on('request', async request => { const proxy = 'https://user:pass@host:port'; ``` +Using socks authentication: +```js +const proxyOptions = { + protocol: 'socks5:', + auth: 'myUserName:p4$$w0rd', + host: '127.0.0.1', + port: 1080, +} +await useProxy(page, proxyOptions) +``` #### IP lookup: ```js // 1. Waits until done, 'then' continues diff --git a/src/lib/options.js b/src/lib/options.js index 21b63d0..592c73a 100644 --- a/src/lib/options.js +++ b/src/lib/options.js @@ -24,7 +24,7 @@ const setHeaders = (request) => { // For applying proxy const setAgent = (proxy) => { - if (proxy.startsWith("socks")) { + if (typeof proxy === 'object' || proxy.startsWith("socks")) { return { http: new SocksProxyAgent(proxy), https: new SocksProxyAgent(proxy) @@ -36,4 +36,4 @@ const setAgent = (proxy) => { }; }; -module.exports = {setHeaders, setAgent}; \ No newline at end of file +module.exports = {setHeaders, setAgent};