Skip to main content

Crate vpndetection

Crate vpndetection 

Source
Expand description

The official Rust client library for the VPNDetection API: anonymity detection covering VPNs, residential proxies, Tor nodes, hosting servers, CDNs and relays.

Start with Client::new and Client::lookup. No API key is needed: without one a lookup is on Unlimited, the free plan, answering ip, is_vpn, the Tor and relay members, location and asn with no daily or monthly cap. A batch needs a paid plan.

let client = vpndetection::Client::new()?;

let result = client.lookup("45.83.91.1").await?;
println!("{}", result.is_vpn);

§Absent is not false

Every field beyond ip and is_vpn is an Option, because your key decides which of them the API sends. None means “not in your plan”, which is a different answer from Some(false). Read the option itself wherever that matters, or unwrap_or(false) when all you want to know is whether an address is flagged.

§Async only

Everything here is async on tokio, and there is no blocking facade. reqwest::blocking builds its own runtime and PANICS when constructed inside one, so a facade would fail for exactly the callers most likely to reach for it. A caller with no runtime writes the three lines that make the cost visible:

let runtime = tokio::runtime::Runtime::new()?;
let client = vpndetection::Client::new()?;
let result = runtime.block_on(client.lookup("45.83.91.1"))?;

Modules§

middleware
The framework-agnostic half of a web middleware: resolve a client address, classify it, and decide whether the condition matched.

Structs§

AuthorizationUrlOptions
What OauthApi::authorization_url_with asks for. A value left unset, or set empty, is left out of the URL rather than sent empty.
BatchOptions
One batch’s overrides for Client::lookup_batch.
ClassDetail
ClassDetail : The shared detail shape for the hosting, relay, tor and cdn datasets. Every key is present when the object is populated; the object is {} when its flag is false.
Client
A client for the VPNDetection API.
ClientBuilder
Builds a Client. With nothing set it queries production with no API key.
ClientRegistration
A registered client, from OauthApi::register: public and with no secret, it proves each sign-in with PKCE.
Database
Database : One database FAMILY, with your organization’s license beside it. A license covers the family, while a download names a specific version, so the IDs you pass to the download and checksum endpoints come from versions.
DatabaseApi
The licensed dataset downloads. Access is granted by contract rather than self-serve, and needs a key carrying the db.download scope.
DatabaseFormatSize
DatabaseMetadata
DatabaseMetadataColumn
DatabaseVersion
DbChecksums
DbChecksums : The published digests for one database file.
DeviceAuthorization
A device sign-in that has started and is waiting for the person.
DeviceAuthorizationOptions
What OauthApi::device_authorization_with asks for. A value left unset, or set empty, is left out of the request rather than sent empty.
Download
Download : One download ATTEMPT, refusals included - a denial is what answers "it stopped working", so they are listed rather than dropped.
DownloadOptions
Which file one download fetches, for DatabaseApi::download_url_with, DatabaseApi::download_with and DatabaseApi::download_bytes_with.
Entitlement
What an API key is entitled to, and what it has spent.
EntitlementApikey
The credential itself.
EntitlementPlan
The plan behind the key, and the field tier it buys.
EntitlementUsage
Consumption against the plan’s allowance, in the current window.
Lookup
What a lookup answers.
LookupOptions
One call’s overrides for Client::lookup_with, Client::my_ip_with and Client::my_entitlement_with.
LookupResponse
LookupResponse : The union of every tier’s answer. Every answer carries ip, is_bogon, is_vpn, the Tor and relay members, location and asn, with or without a key; each remaining field is present when your tier includes it, and absent otherwise. A client that must work across plans should treat an absent flag as unknown rather than as false.
OauthApi
The OAuth authorization server behind the API: the device flow, the authorization code flow with PKCE, token refresh and revocation.
OauthErrorResponse
What the authorization server said when it refused.
OauthMetadata
The authorization server’s discovery document (RFC 8414).
OauthOptions
One call’s overrides for an OauthApi method.
Pkce
One sign-in’s PKCE pair, from OauthApi::create_pkce: challenge goes into the authorization URL, verifier only to the exchange. Debug leaves the verifier out.
ProxyDetail
ProxyDetail : The shared detail shape for the residential, datacenter and mobile proxy families, measured over a rolling 90 day window. An address that leaves the window keeps its flag and the values of its last day in it, so last_seen is what says how recent they are. Every key is present when the object is populated; the object is {} when its flag is false.
PubproxyDetail
PubproxyDetail : The address in Public Proxy IP, open proxies anyone can connect through, measured over a rolling 90 day window. An address that leaves the window keeps its flag and the values of its last day in it, so last_seen is what says how recent they are. An address is either end of a proxy, or both: where it listens, and where its traffic leaves from. Every key is present when the object is populated; the object is {} when is_pubproxy is false.
RegisterOptions
What OauthApi::register_with asks for beyond the redirect URIs. A name left unset, or set empty, is left out of the request.
TokenResponse
What a successful token exchange hands over.
VpnDetail
VpnDetail : What is known about the VPN attribution. Every key is present when the object is populated, empty values included; the object is {} when is_vpn is false.

Enums§

DatabaseFormat
DatabaseFormat : A file format a database version is published in. A file format a database version is published in.
DownloadOutcome
Error
What every failure from this crate is.
ErrorKind
Why a request failed.
LicenseType
What a license permits you to do with the data. Null for a family you hold no license for, which is every one with standing unlicensed.
OauthError
What every OauthApi call fails with.
Standing
Standing : Where your license for a database family stands today. licensed is a live grant, expired one whose term has ended, and unlicensed a database published but never bought. Where your license for a database family stands today. licensed is a live grant, expired one whose term has ended, and unlicensed a database published but never bought.

Constants§

DEFAULT_BASE_URL
The production API. Override it with ClientBuilder::base_url.

Functions§

is_bogon
Whether an address is private, loopback, link-local, documentation, multicast or otherwise not routable on the public internet, including the IPv6 equivalents and the 6to4 and Teredo ranges that wrap them.