How to use the proxy-chain.redactUrl function in proxy-chain

To help you get started, we’ve selected a few proxy-chain 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 apifytech / apify-js / src / puppeteer.js View on Github external
if (!/^(http|https|socks4|socks5)$/.test(parsedProxyUrl.scheme)) {
        throw new Error(`Invalid "proxyUrl" option: Unsupported scheme (${parsedProxyUrl.scheme}).`);
    }

    // Anonymize proxy URL if it has username or password
    let anonymizedProxyUrl = null;
    if (parsedProxyUrl.username || parsedProxyUrl.password) {
        if (parsedProxyUrl.scheme !== 'http') {
            throw new Error('Invalid "proxyUrl" option: authentication is only supported for HTTP proxy type.');
        }
        anonymizedProxyUrl = await anonymizeProxy(opts.proxyUrl);
    }

    opts.args.push(`--proxy-server=${anonymizedProxyUrl || opts.proxyUrl}`);
    const optsForLog = _.omit(opts, LAUNCH_PUPPETEER_LOG_OMIT_OPTS);
    optsForLog.proxyUrl = redactUrl(opts.proxyUrl);
    optsForLog.args = opts.args.slice(0, opts.args.length - 1);

    log.info('Launching Puppeteer', optsForLog);
    const browser = await puppeteer.launch(opts);

    // Close anonymization proxy server when Puppeteer finishes
    if (anonymizedProxyUrl) {
        const cleanUp = () => {
            // Don't wait for finish, only log errors
            closeAnonymizedProxy(anonymizedProxyUrl, true)
                .catch(err => log.exception(err, 'closeAnonymizedProxy() failed.'));
        };

        browser.on('disconnected', cleanUp);

        const prevClose = browser.close.bind(browser);

proxy-chain

Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.

Apache-2.0
Latest version published 7 months ago

Package Health Score

74 / 100
Full package analysis