vpndetection_result (vpndetection v1.0.0)
View SourceThe wire body as an Erlang map, with absent and false kept apart.
A key that is ABSENT from a result is one your plan does not include. It never means "we could not check", so an absent key and false are genuinely different answers, and maps:get(is_hosting, Result, undefined) is how you tell them apart. maps:get(is_hosting, Result, false) is the reader for callers who only care whether the address is flagged.
A detail map that is present but empty (#{}) means the flag above it is false. A populated one always carries every one of its keys.
Summary
Functions
The answer a bogon gets, in the full shape the API serves at its widest plan.
Translate a decoded response body into a result.
Types
-type result() :: #{ip := binary(), is_vpn := boolean(), is_bogon := boolean(), raw := map(), is_hosting => boolean(), is_relay => boolean(), is_tor => boolean(), is_cdn => boolean(), is_resproxy => boolean(), is_dcproxy => boolean(), is_mobproxy => boolean(), vpn => detail(), hosting => detail(), relay => detail(), tor => detail(), cdn => detail(), resproxy => detail(), dcproxy => detail(), mobproxy => detail()}.
Functions
The answer a bogon gets, in the full shape the API serves at its widest plan.
This is deliberately the WIDEST shape whatever your plan is, so a caller must not infer which fields they are entitled to from a bogon answer.
Translate a decoded response body into a result.
Folding over what the body HAS is what preserves absent-versus-false: a key the server did not send cannot appear in the fold, so no plan-gated member can be invented as false.