Table of Contents

Class CloudflareLocationProvider

Namespace
VpnHood.Net.IpLocations.Providers.Onlines
Assembly
VpnHood.Net.IpLocations.dll

Provides the current location, the country only, from Cloudflare's trace page (cloudflare.com/cdn-cgi/trace).

public class CloudflareLocationProvider : ICurrentIpLocationProvider, IDisposable
Inheritance
CloudflareLocationProvider
Implements
Inherited Members

Constructors

CloudflareLocationProvider(HttpClient, string)

Provides the current location, the country only, from Cloudflare's trace page (cloudflare.com/cdn-cgi/trace).

public CloudflareLocationProvider(HttpClient httpClient, string userAgent)

Parameters

httpClient HttpClient

The HTTP client the requests go through; the caller keeps owning it.

userAgent string

The User-Agent header the requests send.

Methods

Dispose()

Does nothing: the provider holds nothing to release.

public void Dispose()

GetCurrentLocation(CancellationToken)

Finds where this device's public IP address is.

public Task<IpLocation> GetCurrentLocation(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<IpLocation>

A task whose result is the location.

Exceptions

NotSupportedException

The provider does not support the lookup.

HttpRequestException

The request failed.