For any feature requests or API change requests, please feel free to open an issue.
Dependencies
node ^v14.0
golang ^v1.16x
Installation
$ npm install cycletls
Example CycleTLS Request (JS/TS)
You can run this test in tests/simple.test.ts
const initCycleTLS = require('cycletls');
(async () => {
const cycleTLS = await initCycleTLS();
const response = await cycleTLS('https://ja3er.com/json', {
body: '',
ja3: '771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0',
userAgent: 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0',
proxy: 'http://username:password@hostname.com:443'
}, 'get');
console.log(response);
cycleTLS.exit();
})();
Example CycleTLS Request (Golang)
package main
import (
"log"
"github.com/Danny-Dasilva/CycleTLS/cycletls"
)
func main() {
client := cycletls.Init()
response, err := client.Do("https://ja3er.com/json", cycletls.Options{
Body : "",
Ja3: "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0",
UserAgent: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0",
}, "GET");
if err != nil {
log.Print("Request Failed: " + err.Error())
}
log.Println(response)
}
Creating an instance
In order to create a cycleTLS
instance, you can run the following:
JavaScript
const initCycleTLS = require('cycletls');
const cycleTLS = await initCycleTLS();
initCycleTLS().then((cycleTLS) => {});
Golang
import (
"github.com/Danny-Dasilva/CycleTLS/cycletls"
)
client := cycletls.Init()
CycleTLS Alias Methods
The following methods exist in CycleTLS
cycleTLS([url], config)
cycleTLS.get([url], config)
cycleTLS.delete([url], config)
cycleTLS.head([url], config)
cycleTLS.options([url], config)
cycleTLS.post([url], config)
cycleTLS.put([url], config)
cycleTLS.patch([url], config)
If URL is not passed, one must be specified in the config.
CycleTLS Request Config
{
url: "https://example.com"
method: "get"
headers: { "Authorization": "Bearer someexampletoken" }
Cookies: [{
"name": "key",
"value": "val",
"path": "/docs",
"domain": "google.com",
"expires": "Mon, 02-Jan-2022 15:04:05 EST"
"maxAge": 90,
"secure": false,
"httpOnly": true,
"sameSite": "Lax"
}],
body: '',
ja3: '771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0',
userAgent: 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0',
proxy: 'http://username:password@hostname.com:443',
timeout: 2,
disableRedirect: true
headerOrder: ["cache-control", "connection", "host"]
}
);
CycleTLS Response Schema
{
status: 200,
body: "",
headers: {
"some": "header",
...
}
}
);
Multiple Requests Example for TS/JS
If CycleTLS is being used by in a JavaScript environment, CycleTLS will spawn a Golang process to handle requests. This Golang process handles requests concurrently
in a worker pool. Due to this, CycleTLS returns response objects as soon as they are made available
(in other terms, CycleTLS processes requests as they are received, but responses are returned asynchronously so they will NOT be returned in the order requested)
If you are using CycleTLS in JavaScript, it is necessary to exit out of the instance to prevent zombie processes. The example below shows one way to approach cleanly exiting CycleTLS if you need to process multiple requests (note: keep in mind that calling the exit()
function will kill any requests in progress). If your workflow requires requests running the entire time the process runs, modules such as exit-hook could serve as an alternative solution to cleanly exiting CycleTLS.
const initCycleTLS = require("cycletls");
"https://httpbin.org/user-agent": {
ja3: ja3,
userAgent: userAgent,
},
"http://httpbin.org/post": {
body: '{"field":"POST-VAL"}',
method: "POST",
},
"http://httpbin.org/cookies": {
cookies: [
{
name: "example1",
value: "aaaaaaa",
expires: "Mon, 02-Jan-2022 15:04:05 EST",
},
],
},
};
const promises = [];
(async () => {
const cycleTLS = await initCycleTLS();
for (const url in requestDict) {
const params = requestDict[url];
const response = cycleTLS(
url, {
body: params.body ?? "",
ja3: params.ja3 ?? ja3,
userAgent: params.userAgent ?? userAgent,
headers: params.headers,
cookies: params.cookies,
}, params.method ?? "GET");
response.then((out) => {
console.log(url, out);
});
promises.push(response);
}
Promise.all(promises).then(() => {
cycleTLS.exit();
});
})();
Dev Setup
If you would like to compile CycleTLS on your own, use the following commands:
Set module-aware mode
go env -w GO111MODULE=auto
Install golang dependencies
go get github.com/Danny-Dasilva/CycleTLS/cycletls
install npm packages
npm install
To recompile index.ts in the src folder
npm run build
To recompile Golang files in the golang folder
Windows
npm run build:windows
Linux
npm run build:linux
Mac
npm run build:mac: