-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
351ae1f
commit 2650b08
Showing
2 changed files
with
39 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
// cycletls "github.com/Danny-Dasilva/CycleTLS/cycletls" | ||
"./cycletls" | ||
"log" | ||
"runtime" | ||
"time" | ||
// "net/http" | ||
) | ||
|
||
// Static variables | ||
var ( | ||
ja3 = "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0" | ||
userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36" | ||
) | ||
|
||
// RequestConfig holds the configuration for each request. | ||
type RequestConfig struct { | ||
URL string | ||
Method string | ||
Options cycletls.Options | ||
} | ||
|
||
func main() { | ||
client := cycletls.Init(true) // Initialize with worker pool | ||
|
||
// Define the requests | ||
requests := []RequestConfig{ | ||
{ | ||
URL: "http://httpbin.org/delay/4", | ||
Method: "GET", | ||
Options: cycletls.Options{ | ||
Ja3: ja3, | ||
UserAgent: userAgent, | ||
}, | ||
}, | ||
{ | ||
URL: "http://httpbin.org/post", | ||
Method: "POST", | ||
Options: cycletls.Options{ | ||
Body: `{"field":"POST-VAL"}`, | ||
Ja3: ja3, | ||
UserAgent: userAgent, | ||
}, | ||
}, | ||
{ | ||
URL: "http://httpbin.org/cookies", | ||
Method: "GET", | ||
Options: cycletls.Options{ | ||
Ja3: ja3, | ||
UserAgent: userAgent, | ||
Cookies: []cycletls.Cookie{ | ||
{ | ||
Name: "example1", | ||
Value: "aaaaaaa", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
// Queue the requests | ||
for _, req := range requests { | ||
client.Queue(req.URL, req.Options, req.Method) | ||
} | ||
|
||
// Asynchronously read responses as soon as they are available | ||
// They will return as soon as they are processed | ||
// e.g. Delay 3 will be returned last | ||
for i := 0; i < len(requests); i++ { | ||
response := <-client.RespChan | ||
log.Println("Response:", response) | ||
runtime.GOMAXPROCS(runtime.NumCPU()) | ||
|
||
start := time.Now() | ||
defer func() { | ||
log.Println("Execution Time: ", time.Since(start)) | ||
}() | ||
client := cycletls.Init() | ||
response, err := client.Do("https://www.google.com", cycletls.Options{ | ||
Body: "", | ||
Ja3: "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0", | ||
UserAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36", | ||
}, "GET") | ||
if err != nil { | ||
log.Print("Request Failed: " + err.Error()) | ||
} | ||
log.Println(response.Status,) | ||
|
||
// Close the client | ||
client.Close() | ||
} |