mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-10 04:30:20 +02:00
fix(publicip/api/cloudflare): add Referer header (#3058)
This commit is contained in:
@@ -40,7 +40,8 @@ func (c *cloudflare) Token() (token string) {
|
|||||||
func (c *cloudflare) FetchInfo(ctx context.Context, ip netip.Addr) (
|
func (c *cloudflare) FetchInfo(ctx context.Context, ip netip.Addr) (
|
||||||
result models.PublicIP, err error,
|
result models.PublicIP, err error,
|
||||||
) {
|
) {
|
||||||
url := "https://speed.cloudflare.com/meta"
|
urlBase := "https://speed.cloudflare.com"
|
||||||
|
url := urlBase + "/meta"
|
||||||
if ip.IsValid() {
|
if ip.IsValid() {
|
||||||
return result, fmt.Errorf("%w: cloudflare cannot provide information on the arbitrary IP address %s",
|
return result, fmt.Errorf("%w: cloudflare cannot provide information on the arbitrary IP address %s",
|
||||||
ErrServiceLimited, ip)
|
ErrServiceLimited, ip)
|
||||||
@@ -50,6 +51,7 @@ func (c *cloudflare) FetchInfo(ctx context.Context, ip netip.Addr) (
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
request.Header.Add("Referer", urlBase) // returns HTTP 403 otherwise
|
||||||
|
|
||||||
response, err := c.client.Do(request)
|
response, err := c.client.Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user