cloudflare-bp-go
cloudflare-bp-go copied to clipboard
Tests are failing, but works for me
I found this and am using it with success, but I did notice the tests are failing.
@apecollector Cannot say the same. I just give it a shot, and it's not working :(
I changed the credentials for my VPN accounts a while ago already, but never updated the secrets in all my github projects which caused the tests to fail.
Will check and update the tests if necessary.
@DaRealFreak, maybe I'm not doing this right but here is my example code.
package main
import (
"fmt"
"github.com/DaRealFreak/cloudflare-bp-go"
"net/http"
)
func main() {
url := "https://www.lexusofpembrokepines.com/inventory/58ADZ1B12MU096560?type=U"
client := &http.Client{}
client.Transport = cloudflarebp.AddCloudFlareByPass(client.Transport)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
fmt.Println("Status Code:", resp.Status)
}
@hcancelik That site enforces a JS/non-interactive challenge for that link regardless of TLS configuration.
This is (at least so far) NOT intended to solve challenges provided by CloudFlare, only to prevent CloudFlare from directly displaying you a challenge on the first request.
The RoundTripper is still working.
Try to request this URL https://www.lexusofpembrokepines.com/wp-content/cache/jellyfish-cache/new-vehicles-js.js?mt=1698335265
via the Go Roundtripper and then via curl.
You will see that the roundtripper gives 200 OK, but curl guarantees a 403 response
@m41k1n4177 Thanks for the response.
I'm still getting 403 for that url. This is the code I have used.
Additionally, there is also no way for me to find out that javascript URL in advance so I'm not sure how this would help.
type MyRoundTripper struct {
Transport http.RoundTripper
}
func (rt *MyRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
resp, err := rt.Transport.RoundTrip(req)
if err != nil {
return nil, err
}
fmt.Printf("Status Code: %d\n", resp.StatusCode)
return resp, nil
}
func main() {
url := "https://www.lexusofpembrokepines.com/wp-content/cache/jellyfish-cache/new-vehicles-js.js?mt=1698335265"
client := &http.Client{
Transport: &MyRoundTripper{Transport: http.DefaultTransport},
}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
_, err = client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
}
I don't think you should use that exact link as it seems to have some cache-busting added, I think it may have been suffixed with ?mt=time()
or something.
Also not sure this, the original repo supports use with http.DefaultTransport
.
Readme:
Using the http.DefaultTransport will currently still fail, nil or empty &http.Transport works. Didn't have the time to check what exactly is different causing the CloudFlare validation to fail though.