vpndetection-fastapi 2.2.5__tar.gz → 2.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,18 @@
2
2
 
3
3
  What each release changed for you, newest first. Each line is a commit's summary, linked to its full description and diff. Releases before 2.0.5 are described by their release commits.
4
4
 
5
+ ## 2.2.7 - 2026-11-29
6
+
7
+ ### Features
8
+
9
+ - Require vpndetection 5.25.0: an answer without is_vpn reads, and a condition on it is a plan gap ([`73a5288`](https://github.com/vpndetection-io/sdk-python-fastapi/commit/73a5288079a200b728fa3b118f529a27e6b5b643))
10
+
11
+ ## 2.2.6 - 2026-11-27
12
+
13
+ ### Features
14
+
15
+ - Require vpndetection 5.24.0: a keyless answer without the AS's type reads ([`6ca2adb`](https://github.com/vpndetection-io/sdk-python-fastapi/commit/6ca2adb351dd321c3eaee07e4b6f3ba3ec65452b))
16
+
5
17
  ## 2.2.5 - 2026-11-26
6
18
 
7
19
  ### Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: vpndetection-fastapi
3
- Version: 2.2.5
3
+ Version: 2.2.7
4
4
  Summary: Official FastAPI and Starlette middleware for the VPNDetection API. Detect VPNs, proxies, Tor, hosting and CDN visitors on every request.
5
5
  Project-URL: Homepage, https://vpndetection.io
6
6
  Project-URL: Source, https://github.com/vpndetection-io/sdk-python-fastapi
@@ -20,7 +20,7 @@ Classifier: Topic :: Security
20
20
  Classifier: Typing :: Typed
21
21
  Requires-Python: >=3.11
22
22
  Requires-Dist: starlette>=0.37
23
- Requires-Dist: vpndetection<6,>=5.23.1
23
+ Requires-Dist: vpndetection<6,>=5.25.0
24
24
  Provides-Extra: dev
25
25
  Requires-Dist: fastapi>=0.115; extra == 'dev'
26
26
  Requires-Dist: mypy>=1.11; extra == 'dev'
@@ -45,7 +45,7 @@ pip install vpndetection-fastapi
45
45
 
46
46
  Requires Python 3.11 or newer.
47
47
 
48
- No API key needed to start. Without one, a lookup is on Unlimited, the free plan, which answers VPN, Tor and relay detection with no daily or monthly cap. A paid plan's key adds the hosting, CDN and proxy flags and the provider behind each flag: create one in the [console](https://app.vpndetection.io). A free account tries every field.
48
+ Lookups need no API key to try: the free plan answers each address's first lookups of the day without one. A free API key answers your organization's first lookups each day with every field, and the basics with no cap. The Data plan answers every field on every lookup, with the hosting, CDN and proxy flags and the provider behind each flag: create a key in the [console](https://app.vpndetection.io).
49
49
 
50
50
  ```python
51
51
  from fastapi import FastAPI
@@ -89,7 +89,7 @@ A condition is written in the shape of a result, keyed by the same names the API
89
89
  [{"is_tor": True}, {"is_resproxy": True}] # a list is OR
90
90
  ```
91
91
 
92
- Values are matched by equality, strings without regard to case. A list means any-of. A dict of `gte`/`gt`/`lte`/`lt` compares numbers, and every bound you give must hold, so two of them are a range. A member the answer holds as a list (`web`, `pubproxy.protocols`, `bittorrent.clients`, `bot.agents`, `bot.categories`) matches when any one element does: `{"pubproxy": {"protocols": "socks5"}}` blocks a proxy that speaks SOCKS5 among others, and an object term such as `{"web": {"port": 443}}` must match a single row. Members set to `False` or `None` are ignored, so a condition states the signals you act on; one that constrains nothing would match every request, and is refused when the middleware is built rather than silently blocking all your traffic.
92
+ Values are matched by equality, strings without regard to case. A list means any-of. A dict of `gte`/`gt`/`lte`/`lt` compares numbers, and every bound you give must hold, so two of them are a range. A member the answer holds as a list (`web`, `pubproxy.protocols`, `bittorrent.clients`, `bot.agents`, `bot.categories`) matches when any one element does: `{"pubproxy": {"protocols": "socks5"}}` blocks a proxy that speaks SOCKS5 among others, and an object term such as `{"web": {"port": 443}}` must match a single row. Members set to `False` or `None` are ignored, so a condition states the signals you act on; one that constrains nothing would match every request, and is refused when the middleware is built rather than silently blocking all your traffic. A condition on `is_bot` or `asn.type` without a paid key is reported as a member your plan does not include and never matches.
93
93
 
94
94
  Replace the refusal with `on_blocked`.
95
95
 
@@ -106,7 +106,7 @@ app.add_middleware(
106
106
  )
107
107
  ```
108
108
 
109
- With it on, a condition can name the verdict, refusing a forged crawler: `{"user_agent": {"verdict": "spoofed"}}`. Only a paid plan's answer carries `user_agent`: a keyless client, or a free key past its trial, never gets a verdict and lets no crawler through, and the middleware warns once when that happens.
109
+ With it on, a condition can name the verdict, refusing a forged crawler: `{"user_agent": {"verdict": "spoofed"}}`. Only a paid plan's answer carries `user_agent`: a keyless client, or a free key past its organization's full answers for the day, never gets a verdict and lets no crawler through, and the middleware warns once when that happens. `bot` and `is_bot` are a paid plan's too, so a keyless app gets no bot pass.
110
110
 
111
111
  ### Blocking one endpoint
112
112
 
@@ -161,7 +161,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
161
161
 
162
162
  ## Absent is not false
163
163
 
164
- Unlimited, with a key or without one, leaves out `is_hosting`, `is_cdn`, the four proxy flags, the carrier, satellite and service flags, `bot`, `company` and `abuse`, and of the detail behind each flag it answers only Tor's and relay's. A field your plan does not include is `None`, which means "not in your plan" rather than "checked, and no".
164
+ The free plan's answer, without a key or past a free key's full answers for the day, leaves out `is_hosting`, `is_cdn`, the four proxy flags, `is_bot`, the carrier, satellite and service flags, `bot`, `company` and `abuse`, the AS's `type`, and of the detail behind each flag it answers only Tor's and relay's. A field your plan does not include is `None`, which means "not in your plan" rather than "checked, and no". The AS's `type` and `is_vpn` are the exceptions: they stay a `str` and a `bool`, and read `""` and `False` when the answer leaves them out. `is_vpn` is absent from a free key's answer past its organization's full answers for the day, when `trial_expired` is true, and that `False` means "not in this answer", never "not a VPN": a `block_condition` on it never matches such an answer, and the middleware reports it as a member the plan does not include.
165
165
 
166
166
  ```python
167
167
  lookup(request).result.is_hosting # None when your plan does not include it
@@ -15,7 +15,7 @@ pip install vpndetection-fastapi
15
15
 
16
16
  Requires Python 3.11 or newer.
17
17
 
18
- No API key needed to start. Without one, a lookup is on Unlimited, the free plan, which answers VPN, Tor and relay detection with no daily or monthly cap. A paid plan's key adds the hosting, CDN and proxy flags and the provider behind each flag: create one in the [console](https://app.vpndetection.io). A free account tries every field.
18
+ Lookups need no API key to try: the free plan answers each address's first lookups of the day without one. A free API key answers your organization's first lookups each day with every field, and the basics with no cap. The Data plan answers every field on every lookup, with the hosting, CDN and proxy flags and the provider behind each flag: create a key in the [console](https://app.vpndetection.io).
19
19
 
20
20
  ```python
21
21
  from fastapi import FastAPI
@@ -59,7 +59,7 @@ A condition is written in the shape of a result, keyed by the same names the API
59
59
  [{"is_tor": True}, {"is_resproxy": True}] # a list is OR
60
60
  ```
61
61
 
62
- Values are matched by equality, strings without regard to case. A list means any-of. A dict of `gte`/`gt`/`lte`/`lt` compares numbers, and every bound you give must hold, so two of them are a range. A member the answer holds as a list (`web`, `pubproxy.protocols`, `bittorrent.clients`, `bot.agents`, `bot.categories`) matches when any one element does: `{"pubproxy": {"protocols": "socks5"}}` blocks a proxy that speaks SOCKS5 among others, and an object term such as `{"web": {"port": 443}}` must match a single row. Members set to `False` or `None` are ignored, so a condition states the signals you act on; one that constrains nothing would match every request, and is refused when the middleware is built rather than silently blocking all your traffic.
62
+ Values are matched by equality, strings without regard to case. A list means any-of. A dict of `gte`/`gt`/`lte`/`lt` compares numbers, and every bound you give must hold, so two of them are a range. A member the answer holds as a list (`web`, `pubproxy.protocols`, `bittorrent.clients`, `bot.agents`, `bot.categories`) matches when any one element does: `{"pubproxy": {"protocols": "socks5"}}` blocks a proxy that speaks SOCKS5 among others, and an object term such as `{"web": {"port": 443}}` must match a single row. Members set to `False` or `None` are ignored, so a condition states the signals you act on; one that constrains nothing would match every request, and is refused when the middleware is built rather than silently blocking all your traffic. A condition on `is_bot` or `asn.type` without a paid key is reported as a member your plan does not include and never matches.
63
63
 
64
64
  Replace the refusal with `on_blocked`.
65
65
 
@@ -76,7 +76,7 @@ app.add_middleware(
76
76
  )
77
77
  ```
78
78
 
79
- With it on, a condition can name the verdict, refusing a forged crawler: `{"user_agent": {"verdict": "spoofed"}}`. Only a paid plan's answer carries `user_agent`: a keyless client, or a free key past its trial, never gets a verdict and lets no crawler through, and the middleware warns once when that happens.
79
+ With it on, a condition can name the verdict, refusing a forged crawler: `{"user_agent": {"verdict": "spoofed"}}`. Only a paid plan's answer carries `user_agent`: a keyless client, or a free key past its organization's full answers for the day, never gets a verdict and lets no crawler through, and the middleware warns once when that happens. `bot` and `is_bot` are a paid plan's too, so a keyless app gets no bot pass.
80
80
 
81
81
  ### Blocking one endpoint
82
82
 
@@ -131,7 +131,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
131
131
 
132
132
  ## Absent is not false
133
133
 
134
- Unlimited, with a key or without one, leaves out `is_hosting`, `is_cdn`, the four proxy flags, the carrier, satellite and service flags, `bot`, `company` and `abuse`, and of the detail behind each flag it answers only Tor's and relay's. A field your plan does not include is `None`, which means "not in your plan" rather than "checked, and no".
134
+ The free plan's answer, without a key or past a free key's full answers for the day, leaves out `is_hosting`, `is_cdn`, the four proxy flags, `is_bot`, the carrier, satellite and service flags, `bot`, `company` and `abuse`, the AS's `type`, and of the detail behind each flag it answers only Tor's and relay's. A field your plan does not include is `None`, which means "not in your plan" rather than "checked, and no". The AS's `type` and `is_vpn` are the exceptions: they stay a `str` and a `bool`, and read `""` and `False` when the answer leaves them out. `is_vpn` is absent from a free key's answer past its organization's full answers for the day, when `trial_expired` is true, and that `False` means "not in this answer", never "not a VPN": a `block_condition` on it never matches such an answer, and the middleware reports it as a member the plan does not include.
135
135
 
136
136
  ```python
137
137
  lookup(request).result.is_hosting # None when your plan does not include it
@@ -24,7 +24,7 @@ classifiers = [
24
24
  "Topic :: Security",
25
25
  "Typing :: Typed",
26
26
  ]
27
- dependencies = ["vpndetection>=5.23.1,<6", "starlette>=0.37"]
27
+ dependencies = ["vpndetection>=5.25.0,<6", "starlette>=0.37"]
28
28
 
29
29
  [project.urls]
30
30
  Homepage = "https://vpndetection.io"
@@ -45,7 +45,7 @@ __all__ = [
45
45
  "xff_ip_selector",
46
46
  ]
47
47
 
48
- __version__ = "2.2.5"
48
+ __version__ = "2.2.7"
49
49
 
50
50
  # Set on a request ``skip`` claimed, so block_if can tell it from one the middleware
51
51
  # never saw.
@@ -1839,8 +1839,8 @@
1839
1839
  }
1840
1840
  },
1841
1841
  {
1842
- "name": "unlimited-location-asn",
1843
- "why": "The Unlimited tier's answer, with a key or without one: Tor and relay beside the VPN flag, and where the address is and which AS announces it. location and asn carry every key whenever present, so each maps whole.",
1842
+ "name": "free-location-asn",
1843
+ "why": "The free plan's answer, with a key or without one: Tor and relay beside the VPN flag, and where the address is and which AS announces it. location and asn carry every key whenever present, so each maps whole.",
1844
1844
  "status": 200,
1845
1845
  "body": {
1846
1846
  "ip": "146.70.116.130",
@@ -1865,7 +1865,6 @@
1865
1865
  "asn": 9009,
1866
1866
  "name": "M247 Europe SRL",
1867
1867
  "domain": "m247global.com",
1868
- "type": "hosting",
1869
1868
  "prefix": "146.70.116.0/24",
1870
1869
  "country": "US",
1871
1870
  "rpki_status": "valid"
@@ -1915,7 +1914,6 @@
1915
1914
  "asn": 9009,
1916
1915
  "name": "M247 Europe SRL",
1917
1916
  "domain": "m247global.com",
1918
- "type": "hosting",
1919
1917
  "prefix": "146.70.116.0/24",
1920
1918
  "country": "US",
1921
1919
  "rpki_status": "valid"
@@ -1924,7 +1922,7 @@
1924
1922
  },
1925
1923
  {
1926
1924
  "name": "flags-without-detail",
1927
- "why": "Every flag, but no detail object behind the six flags past the Unlimited tier's and no vpn object. Each flag maps on its own, and the detail it lacks stays absent rather than empty.",
1925
+ "why": "Every flag, but no detail object behind the six flags past the free plan's and no vpn object. Each flag maps on its own, and the detail it lacks stays absent rather than empty.",
1928
1926
  "status": 200,
1929
1927
  "body": {
1930
1928
  "ip": "146.70.116.130",
@@ -2012,8 +2010,8 @@
2012
2010
  }
2013
2011
  },
2014
2012
  {
2015
- "name": "trial-full-answer",
2016
- "why": "A free-plan key within its trial: every field, as a paid plan answers it, and trial_expired false. trial_expired maps on presence like any flag.",
2013
+ "name": "free-key-full-answer",
2014
+ "why": "A free-plan key within its organization's full answers for the day: every field, as a paid plan answers it, and trial_expired false. trial_expired maps on presence like any flag.",
2017
2015
  "status": 200,
2018
2016
  "body": {
2019
2017
  "ip": "146.70.116.130",
@@ -2119,12 +2117,11 @@
2119
2117
  }
2120
2118
  },
2121
2119
  {
2122
- "name": "trial-expired-answer",
2123
- "why": "A free-plan key past its trial: Unlimited's answer, and trial_expired true. What the trial no longer answers is absent, never false.",
2120
+ "name": "free-key-basics",
2121
+ "why": "A free-plan key past its organization's full answers for the day: the basics, with no is_vpn and no AS type, and trial_expired true. What the day no longer answers is absent, never false. A binding whose public is_vpn is a plain boolean reads it false here and keeps it among the members the wire left out, as it keeps asn.type, so a condition on it is a plan gap.",
2124
2122
  "status": 200,
2125
2123
  "body": {
2126
2124
  "ip": "146.70.116.130",
2127
- "is_vpn": true,
2128
2125
  "is_relay": false,
2129
2126
  "is_tor": false,
2130
2127
  "relay": {},
@@ -2145,7 +2142,6 @@
2145
2142
  "asn": 9009,
2146
2143
  "name": "M247 Europe SRL",
2147
2144
  "domain": "m247global.com",
2148
- "type": "hosting",
2149
2145
  "prefix": "146.70.116.0/24",
2150
2146
  "country": "US",
2151
2147
  "rpki_status": "valid"
@@ -2156,12 +2152,12 @@
2156
2152
  "ip": "146.70.116.130",
2157
2153
  "isBogon": false,
2158
2154
  "present": {
2159
- "is_vpn": true,
2160
2155
  "is_relay": false,
2161
2156
  "is_tor": false,
2162
2157
  "trial_expired": true
2163
2158
  },
2164
2159
  "absent": [
2160
+ "is_vpn",
2165
2161
  "is_hosting",
2166
2162
  "is_cdn",
2167
2163
  "is_resproxy",
@@ -2196,7 +2192,6 @@
2196
2192
  "asn": 9009,
2197
2193
  "name": "M247 Europe SRL",
2198
2194
  "domain": "m247global.com",
2199
- "type": "hosting",
2200
2195
  "prefix": "146.70.116.0/24",
2201
2196
  "country": "US",
2202
2197
  "rpki_status": "valid"
@@ -2205,7 +2200,7 @@
2205
2200
  },
2206
2201
  {
2207
2202
  "name": "cap-reached-answer",
2208
- "why": "A paid-plan key past its organization's overage cap: Unlimited's answer, not billed, and cap_reached true. What the cap no longer answers is absent, never false.",
2203
+ "why": "A paid-plan key past its organization's overage cap: the basics and is_vpn, not billed, and cap_reached true. What the cap no longer answers is absent, never false.",
2209
2204
  "status": 200,
2210
2205
  "body": {
2211
2206
  "ip": "146.70.116.130",
@@ -2230,7 +2225,6 @@
2230
2225
  "asn": 9009,
2231
2226
  "name": "M247 Europe SRL",
2232
2227
  "domain": "m247global.com",
2233
- "type": "hosting",
2234
2228
  "prefix": "146.70.116.0/24",
2235
2229
  "country": "US",
2236
2230
  "rpki_status": "valid"
@@ -2282,7 +2276,6 @@
2282
2276
  "asn": 9009,
2283
2277
  "name": "M247 Europe SRL",
2284
2278
  "domain": "m247global.com",
2285
- "type": "hosting",
2286
2279
  "prefix": "146.70.116.0/24",
2287
2280
  "country": "US",
2288
2281
  "rpki_status": "valid"
@@ -2290,8 +2283,8 @@
2290
2283
  }
2291
2284
  },
2292
2285
  {
2293
- "name": "unlimited-anycast-hostname",
2294
- "why": "Unlimited's answer, with a key or without one, also carries is_bot, is_anycast, hostname, and the AS's country and RPKI status. The paid members stay absent, never false or empty.",
2286
+ "name": "free-anycast-hostname",
2287
+ "why": "The free plan's answer, with a key or without one, also carries is_anycast, hostname, and the AS's country and RPKI status. The paid members, is_bot among them, stay absent, never false or empty.",
2295
2288
  "status": 200,
2296
2289
  "body": {
2297
2290
  "ip": "1.1.1.1",
@@ -2299,7 +2292,6 @@
2299
2292
  "is_vpn": false,
2300
2293
  "is_relay": false,
2301
2294
  "is_tor": false,
2302
- "is_bot": false,
2303
2295
  "is_anycast": true,
2304
2296
  "relay": {},
2305
2297
  "tor": {},
@@ -2319,7 +2311,6 @@
2319
2311
  "asn": 13335,
2320
2312
  "name": "Cloudflare, Inc.",
2321
2313
  "domain": "cloudflare.com",
2322
- "type": "hosting",
2323
2314
  "prefix": "1.1.1.0/24",
2324
2315
  "country": "US",
2325
2316
  "rpki_status": "valid"
@@ -2333,12 +2324,12 @@
2333
2324
  "is_vpn": false,
2334
2325
  "is_relay": false,
2335
2326
  "is_tor": false,
2336
- "is_bot": false,
2337
2327
  "is_anycast": true
2338
2328
  },
2339
2329
  "absent": [
2340
2330
  "is_hosting",
2341
2331
  "is_cdn",
2332
+ "is_bot",
2342
2333
  "is_resproxy",
2343
2334
  "is_dcproxy",
2344
2335
  "is_mobproxy",
@@ -2388,7 +2379,6 @@
2388
2379
  "asn": 13335,
2389
2380
  "name": "Cloudflare, Inc.",
2390
2381
  "domain": "cloudflare.com",
2391
- "type": "hosting",
2392
2382
  "prefix": "1.1.1.0/24",
2393
2383
  "country": "US",
2394
2384
  "rpki_status": "valid"
@@ -3058,8 +3048,8 @@
3058
3048
  }
3059
3049
  },
3060
3050
  {
3061
- "name": "unlimited-bot",
3062
- "why": "Unlimited answers is_bot, true for an address a bot uses, here a verified Googlebot crawler's; whose bot it is, the bot object, is a paid plan's and stays absent, never empty.",
3051
+ "name": "free-bot",
3052
+ "why": "The free plan's answer for an address a bot uses, here a verified Googlebot crawler's: is_bot and the bot object are a paid plan's and stay absent, never false or empty.",
3063
3053
  "status": 200,
3064
3054
  "body": {
3065
3055
  "ip": "66.249.66.1",
@@ -3067,7 +3057,6 @@
3067
3057
  "is_vpn": false,
3068
3058
  "is_relay": false,
3069
3059
  "is_tor": false,
3070
- "is_bot": true,
3071
3060
  "is_anycast": false,
3072
3061
  "relay": {},
3073
3062
  "tor": {},
@@ -3087,7 +3076,6 @@
3087
3076
  "asn": 15169,
3088
3077
  "name": "Google LLC",
3089
3078
  "domain": "google.com",
3090
- "type": "hosting",
3091
3079
  "prefix": "66.249.64.0/20",
3092
3080
  "country": "US",
3093
3081
  "rpki_status": "valid"
@@ -3101,12 +3089,12 @@
3101
3089
  "is_vpn": false,
3102
3090
  "is_relay": false,
3103
3091
  "is_tor": false,
3104
- "is_bot": true,
3105
3092
  "is_anycast": false
3106
3093
  },
3107
3094
  "absent": [
3108
3095
  "is_hosting",
3109
3096
  "is_cdn",
3097
+ "is_bot",
3110
3098
  "is_resproxy",
3111
3099
  "is_dcproxy",
3112
3100
  "is_mobproxy",
@@ -3156,7 +3144,6 @@
3156
3144
  "asn": 15169,
3157
3145
  "name": "Google LLC",
3158
3146
  "domain": "google.com",
3159
- "type": "hosting",
3160
3147
  "prefix": "66.249.64.0/20",
3161
3148
  "country": "US",
3162
3149
  "rpki_status": "valid"
@@ -3396,14 +3383,14 @@
3396
3383
  }
3397
3384
  },
3398
3385
  {
3399
- "name": "unlimited-rate-limit-is-retryable",
3400
- "why": "Retry-After present. A lookup on Unlimited, the free plan, with a key or without one, that the API is protecting itself from is told when to come back, which is a rate limit, so retrying after the wait WILL succeed.",
3386
+ "name": "free-rate-limit-is-retryable",
3387
+ "why": "Retry-After present. A lookup on the free plan, with a key or without one, that the API is protecting itself from is told when to come back, which is a rate limit, so retrying after the wait WILL succeed.",
3401
3388
  "status": 429,
3402
3389
  "headers": {
3403
3390
  "Retry-After": "1"
3404
3391
  },
3405
3392
  "body": {
3406
- "error": "rate limit for Unlimited lookups exceeded; retry shortly, or use a paid plan"
3393
+ "error": "rate limit for free lookups exceeded; retry shortly, or use a paid plan"
3407
3394
  },
3408
3395
  "expect": {
3409
3396
  "kind": "rate_limited",
@@ -3438,6 +3425,19 @@
3438
3425
  "retryable": false
3439
3426
  }
3440
3427
  },
3428
+ {
3429
+ "name": "keyless-day-spent-is-not-retryable",
3430
+ "why": "No Retry-After. A lookup with no key past its address's lookups for the day: a spent allowance, which a free API key answers past, so it is sent once and reaches the caller as quota_exceeded with the API's message.",
3431
+ "status": 429,
3432
+ "headers": {},
3433
+ "body": {
3434
+ "error": "lookups without an API key are used up for today; a free key answers on: https://app.vpndetection.io/auth/signup"
3435
+ },
3436
+ "expect": {
3437
+ "kind": "quota_exceeded",
3438
+ "retryable": false
3439
+ }
3440
+ },
3441
3441
  {
3442
3442
  "name": "server-error-is-retryable",
3443
3443
  "status": 500,
@@ -8364,7 +8364,6 @@
8364
8364
  "asn": 9009,
8365
8365
  "name": "M247 Europe SRL",
8366
8366
  "domain": "m247global.com",
8367
- "type": "hosting",
8368
8367
  "prefix": "146.70.116.0/24",
8369
8368
  "country": "US",
8370
8369
  "rpki_status": "valid"
@@ -8406,7 +8405,6 @@
8406
8405
  "asn": 9009,
8407
8406
  "name": "M247 Europe SRL",
8408
8407
  "domain": "m247global.com",
8409
- "type": "hosting",
8410
8408
  "prefix": "146.70.116.0/24",
8411
8409
  "country": "US",
8412
8410
  "rpki_status": "valid"
@@ -8451,7 +8449,6 @@
8451
8449
  "asn": 9009,
8452
8450
  "name": "M247 Europe SRL",
8453
8451
  "domain": "m247global.com",
8454
- "type": "hosting",
8455
8452
  "prefix": "146.70.116.0/24",
8456
8453
  "country": "US",
8457
8454
  "rpki_status": "valid"
@@ -8469,7 +8466,7 @@
8469
8466
  },
8470
8467
  {
8471
8468
  "name": "asn-type-matches",
8472
- "why": "asn is a member like any other: even an answer without a key says which kind of network announces the address.",
8469
+ "why": "The network's type is a paid plan's: the free plan does not serve it, so the term can never match and is reported by its path.",
8473
8470
  "body": {
8474
8471
  "ip": "146.70.116.130",
8475
8472
  "is_vpn": true,
@@ -8493,7 +8490,6 @@
8493
8490
  "asn": 9009,
8494
8491
  "name": "M247 Europe SRL",
8495
8492
  "domain": "m247global.com",
8496
- "type": "hosting",
8497
8493
  "prefix": "146.70.116.0/24",
8498
8494
  "country": "US",
8499
8495
  "rpki_status": "valid"
@@ -8505,8 +8501,51 @@
8505
8501
  }
8506
8502
  },
8507
8503
  "expect": {
8508
- "blocked": true,
8509
- "missing": []
8504
+ "blocked": false,
8505
+ "missing": [
8506
+ "asn.type"
8507
+ ]
8508
+ }
8509
+ },
8510
+ {
8511
+ "name": "is-vpn-past-the-days-full-answers",
8512
+ "why": "A free-plan key past its organization's full answers for the day gets the basics, with no is_vpn: the term can never match, so it is reported as a plan gap, never read as false.",
8513
+ "body": {
8514
+ "ip": "146.70.116.130",
8515
+ "is_relay": false,
8516
+ "is_tor": false,
8517
+ "relay": {},
8518
+ "tor": {},
8519
+ "location": {
8520
+ "continent": "EU",
8521
+ "continent_name": "Europe",
8522
+ "country": "AT",
8523
+ "country_name": "Austria",
8524
+ "timezone": "Europe/Vienna",
8525
+ "currency_code": "EUR",
8526
+ "currency_name": "Euro",
8527
+ "currency_symbol": "€",
8528
+ "flag_emoji": "🇦🇹",
8529
+ "flag_unicode": "U+1F1E6 U+1F1F9"
8530
+ },
8531
+ "asn": {
8532
+ "asn": 9009,
8533
+ "name": "M247 Europe SRL",
8534
+ "domain": "m247global.com",
8535
+ "prefix": "146.70.116.0/24",
8536
+ "country": "US",
8537
+ "rpki_status": "valid"
8538
+ },
8539
+ "trial_expired": true
8540
+ },
8541
+ "condition": {
8542
+ "is_vpn": true
8543
+ },
8544
+ "expect": {
8545
+ "blocked": false,
8546
+ "missing": [
8547
+ "is_vpn"
8548
+ ]
8510
8549
  }
8511
8550
  },
8512
8551
  {
@@ -8535,7 +8574,6 @@
8535
8574
  "asn": 9009,
8536
8575
  "name": "M247 Europe SRL",
8537
8576
  "domain": "m247global.com",
8538
- "type": "hosting",
8539
8577
  "prefix": "146.70.116.0/24",
8540
8578
  "country": "US",
8541
8579
  "rpki_status": "valid"
@@ -11024,7 +11062,7 @@
11024
11062
  "cases": [
11025
11063
  {
11026
11064
  "name": "entitlement-plan-name",
11027
- "why": "The plan's name is what a client shows, and key is what it compares: the free plan's key is free and its name Unlimited. A binding that drops name leaves a client building one from the key, which a renamed plan then gets wrong.",
11065
+ "why": "The plan's name is what a client shows, and key is what it compares: the free plan's key is free and its name Free. A binding that drops name leaves a client building one from the key, which a renamed plan then gets wrong.",
11028
11066
  "call": "myEntitlement",
11029
11067
  "answer": {
11030
11068
  "org_id": "85bb51e4-2eb6-4a31-8e4d-02ba8b98fe61",
@@ -11035,7 +11073,7 @@
11035
11073
  },
11036
11074
  "plan": {
11037
11075
  "key": "free",
11038
- "name": "Unlimited",
11076
+ "name": "Free",
11039
11077
  "tier": "free"
11040
11078
  },
11041
11079
  "usage": {
@@ -11048,7 +11086,7 @@
11048
11086
  },
11049
11087
  "expect": {
11050
11088
  "plan.key": "free",
11051
- "plan.name": "Unlimited",
11089
+ "plan.name": "Free",
11052
11090
  "plan.tier": "free"
11053
11091
  }
11054
11092
  },
@@ -11473,6 +11511,9 @@
11473
11511
  "Dart/3.4 (dart:io)",
11474
11512
  "Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.19041.4291",
11475
11513
  "Mozilla/5.0 (Windows NT 10.0; Microsoft Windows 10.0.22631; en-US) PowerShell/7.4.5",
11514
+ "aws-cli/2.34.54 md/awscrt#0.32.2 ua/2.1 os/linux#6.8.0-71-generic md/arch#x86_64 lang/python#3.14.5 md/pyimpl#CPython m/G,Z,E,N,b cfg/retry-mode#standard md/installer#exe md/distrib#ubuntu.24 md/prompt#off md/command#s3.cp",
11515
+ "aws-sdk-go-v2/1.32.7 ua/2.1 os/linux lang/go#1.25.6 md/GOOS#linux md/GOARCH#amd64 api/s3#1.72.0 ft/s3-transfer m/E,G",
11516
+ "Debian APT-HTTP/1.3 (2.8.4)",
11476
11517
  "",
11477
11518
  "Mozilla/5.0",
11478
11519
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36",
@@ -119,6 +119,66 @@ def test_a_condition_on_a_bot_blocks_a_bot_and_passes_the_rest(
119
119
  assert served.asked == [PUBLIC_IP]
120
120
 
121
121
 
122
+ ASN = {
123
+ "asn": 9009,
124
+ "name": "M247 Europe SRL",
125
+ "domain": "m247global.com",
126
+ "prefix": "146.70.116.0/24",
127
+ "country": "US",
128
+ "rpki_status": "valid",
129
+ }
130
+
131
+
132
+ def test_an_answer_without_the_asn_type_is_read_and_a_condition_on_it_never_matches() -> None:
133
+ warnings: list[str] = []
134
+ keyless = serving({"is_vpn": True, "asn": ASN})
135
+ status, body = get(
136
+ app_with(
137
+ client=keyless,
138
+ ip_selector=fixed_ip,
139
+ block_condition={"asn": {"type": "hosting"}},
140
+ on_warn=warnings.append,
141
+ )
142
+ )
143
+ assert status == 200
144
+ assert body["error"] is None and body["is_vpn"] is True, "the answer was read and attached"
145
+ reported = [w for w in warnings if "does not include" in w]
146
+ assert len(reported) == 1 and "asn.type" in reported[0]
147
+
148
+ paid = serving({"is_vpn": True, "asn": {**ASN, "type": "hosting"}})
149
+ status, _ = get(
150
+ app_with(
151
+ client=paid, ip_selector=fixed_ip, block_condition={"asn": {"type": "hosting"}}
152
+ )
153
+ )
154
+ assert status == 403, "the same condition blocks an answer that carries the type"
155
+
156
+
157
+ def test_an_answer_without_is_vpn_is_read_and_a_condition_on_it_never_matches() -> None:
158
+ """A free key past its organization's full answers for the day gets the basics, with no
159
+ ``is_vpn``: read, attached as false, and a condition on it is a plan gap, never a block."""
160
+ warnings: list[str] = []
161
+ basics = serving({"is_relay": False, "is_tor": False, "asn": ASN, "trial_expired": True})
162
+ status, body = get(
163
+ app_with(
164
+ client=basics,
165
+ ip_selector=fixed_ip,
166
+ block_condition={"is_vpn": True},
167
+ on_warn=warnings.append,
168
+ )
169
+ )
170
+ assert status == 200
171
+ assert body["error"] is None and body["is_vpn"] is False, "the answer was read and attached"
172
+ reported = [w for w in warnings if "does not include" in w]
173
+ assert len(reported) == 1 and "is_vpn" in reported[0]
174
+
175
+ full = serving({"is_vpn": True, "asn": {**ASN, "type": "hosting"}})
176
+ status, _ = get(
177
+ app_with(client=full, ip_selector=fixed_ip, block_condition={"is_vpn": True})
178
+ )
179
+ assert status == 403, "the same condition blocks an answer that carries it"
180
+
181
+
122
182
  def test_a_condition_reaches_the_evidence_fields() -> None:
123
183
  nord = serving({"is_vpn": True, "vpn": {"provider": "nordvpn"}})
124
184
  status, _ = get(
@@ -429,7 +489,7 @@ def api_answering(
429
489
  ) -> list[str | None]:
430
490
  """The API's host, answering every lookup as a match for ``{"is_hosting": True}`` and,
431
491
  for a sent agent, with the verdict ``verdicts`` holds for it (None: no verdict, as
432
- Unlimited answers). Returns the ``user_agent`` each lookup sent."""
492
+ the free plan's answers). Returns the ``user_agent`` each lookup sent."""
433
493
  sent: list[str | None] = []
434
494
 
435
495
  async def handle(
@@ -535,3 +595,32 @@ def test_an_answer_without_a_verdict_warns_once(monkeypatch: pytest.MonkeyPatch)
535
595
 
536
596
  assert sent == [GOOGLEBOT, GOOGLEBOT]
537
597
  assert len([w for w in warnings if "user_agent verdict" in w]) == 1, warnings
598
+
599
+
600
+ @pytest.mark.parametrize("url", ["/", "/guarded"])
601
+ @pytest.mark.parametrize("action", ["raise", "warn"])
602
+ @pytest.mark.parametrize("peer", ["127.0.0.1", "10.0.0.1", "::1"])
603
+ def test_a_bogon_peer_with_a_crawlers_agent_is_no_plan_gap(
604
+ monkeypatch: pytest.MonkeyPatch, peer: str, action: str, url: str
605
+ ) -> None:
606
+ # Local development behind no proxy. This is NOT the public-peer test above: the peer is
607
+ # answered locally, so the question is only that no plan gap is reported for it.
608
+ sent = api_answering(monkeypatch, {GOOGLEBOT: "spoofed"})
609
+ warnings: list[str] = []
610
+ forged = {"user_agent": {"verdict": "spoofed"}}
611
+ options: dict[str, Any] = {
612
+ "allow_bots": True,
613
+ "on_missing_field": action,
614
+ "on_warn": warnings.append,
615
+ }
616
+ if url == "/":
617
+ options["block_condition"] = forged
618
+ app = fastapi_with(
619
+ {"condition": forged, "on_missing_field": "raise"},
620
+ api_key=os.environ["VPNDETECTION_API_KEY"],
621
+ **options,
622
+ )
623
+
624
+ assert visit(app, (GOOGLEBOT, url, peer)) == [200]
625
+ assert sent == [], "a bogon reached the API"
626
+ assert [w for w in warnings if "does not include" in w] == []