Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transport): Add binary support #350

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
399 changes: 250 additions & 149 deletions cycletls/index.go

Large diffs are not rendered by default.

30 changes: 8 additions & 22 deletions cycletls/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"compress/gzip"
"compress/zlib"
"crypto/sha256"
"encoding/base64"
"encoding/json"
"strconv"
"strings"
Expand Down Expand Up @@ -39,42 +38,29 @@ func parseUserAgent(userAgent string) UserAgent {
}

// DecompressBody unzips compressed data
func DecompressBody(Body []byte, encoding []string, content []string) (parsedBody string) {
func DecompressBody(Body []byte, encoding []string, content []string) (parsedBody []byte) {
if len(encoding) > 0 {
if encoding[0] == "gzip" {
unz, err := gUnzipData(Body)
if err != nil {
return string(Body)
return Body
}
return string(unz)
return unz
} else if encoding[0] == "deflate" {
unz, err := enflateData(Body)
if err != nil {
return string(Body)
return Body
}
return string(unz)
return unz
} else if encoding[0] == "br" {
unz, err := unBrotliData(Body)
if err != nil {
return string(Body)
return Body
}
return string(unz)
}
} else if len(content) > 0 {
decodingTypes := map[string]bool{
"image/svg+xml": true,
"image/webp": true,
"image/jpeg": true,
"image/png": true,
"image/gif": true,
"image/avif": true,
"application/pdf": true,
}
if decodingTypes[content[0]] {
return base64.StdEncoding.EncodeToString(Body)
return unz
}
}
parsedBody = string(Body)

return parsedBody

}
Expand Down
Empty file modified docs/setup.sh
100644 → 100755
Empty file.
8 changes: 3 additions & 5 deletions examples/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ const initCycleTLS = require('../dist/index.js');
(async () => {
const cycleTLS = await initCycleTLS();

const response = cycleTLS('https://example.com', {
const response = await cycleTLS('https://example.com', {
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: ''
});

response.then((out) => {
response.text().then((out) => {
console.log(out)
})


});
})();

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ func main() {
if err != nil {
log.Print("Request Failed: " + err.Error())
}
log.Println(response.Status,)
log.Println(response.Status)

}
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,22 @@
},
"homepage": "https://github.com/Danny-Dasilva/CycleTLS#readme",
"dependencies": {
"@types/node": "^17.0.24",
"ws": "^7.5.7"
"@types/node": "^20.14.0",
"form-data": "^4.0.0",
"ws": "^8.17.0"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"concurrently": "^7.2.2",
"@types/jest": "^29.5.12",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"eslint": "^8.51.0",
"eslint": "^8.56.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"jest": "^27.5.1",
"jsdom": "^23.2.0",
"ts-jest": "^27.1.4",
"typescript": "^4.6.3"
"jest": "^29.7.0",
"jsdom": "^24.1.0",
"ts-jest": "^29.1.4",
"typescript": "^5.4.5"
}
}
Loading
Loading