Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #219 from pro-src/211_tls_ciphers
Browse files Browse the repository at this point in the history
Remove a few problematic TLSv1.0 ciphers
  • Loading branch information
codemanki authored May 23, 2019
2 parents 8652de3 + 0e31df1 commit 9938fb8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 50 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Saving the `request` module as a dependency is compulsory.
npm install --save request
```

Support for Brotli encoded responses is enabled by default when using Node.js v10 or later.
If you wish to enable support for older Node.js versions, you may install [brotli](https://npmjs.com/package/brotli).
It is recommended but not required.

Usage
============
Cloudscraper uses `request-promise` by default since v3. You can find the migration guide [here.](docs/migration-guide.md)
Expand Down Expand Up @@ -128,7 +132,11 @@ var options = {
// Support only this max challenges in row. If CF returns more, throw an error
challengesToSolve: 3,
// Remove Cloudflare's email protection, replace encoded email with decoded versions
decodeEmails: false
decodeEmails: false,
// Support gzip encoded responses (Should be enabled unless using custom headers)
gzip: true,
// Removes a few problematic TLSv1.0 ciphers to avoid CAPTCHA
agentOptions: { ciphers }
};

cloudscraper(options).then(console.log);
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const requestModule = require('request-promise');
const sandbox = require('./lib/sandbox');
const decodeEmails = require('./lib/email-decode.js');
const getDefaultHeaders = require('./lib/headers');
const agentOptions = require('./lib/agent-options');
const brotli = require('./lib/brotli');
const crypto = require('crypto');

const {
RequestError,
Expand Down Expand Up @@ -37,8 +37,10 @@ function defaults (params) {
decodeEmails: false,
// Support gzip encoded responses
gzip: true,
// Adds secure TLSv1.3 ciphers when using older openssl versions
agentOptions
agentOptions: {
// Removes a few problematic TLSv1.0 ciphers to avoid CAPTCHA
ciphers: crypto.constants.defaultCipherList + ':!ECDHE+SHA:!AES128-SHA'
}
};

// Object.assign requires at least nodejs v4, request only test/supports v6+
Expand Down
42 changes: 0 additions & 42 deletions lib/agent-options.js

This file was deleted.

9 changes: 5 additions & 4 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ var url = require('url');
var path = require('path');
var express = require('express');

// Clone the default headers for tests
var defaultHeaders = Object.assign({}, require('../').defaultParams.headers);
var agentOptions = require('../lib/agent-options');
// Clone a few defaults before testing
var opts = require('../').defaultParams;
var defaultHeaders = Object.assign({}, opts.headers);
var agentOptions = Object.assign({}, opts.agentOptions);

// Cache fixtures so they're only read from fs but once
var cache = {};
Expand All @@ -33,7 +34,7 @@ var helper = {
challengesToSolve: 3,
decodeEmails: false,
gzip: true,
agentOptions
agentOptions: Object.assign({}, agentOptions)
};
},
getFixture: function (fileName) {
Expand Down

0 comments on commit 9938fb8

Please sign in to comment.