vpndetection-flask 2.2.4__tar.gz → 2.2.6__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.6 - 2026-11-27
6
+
7
+ ### Features
8
+
9
+ - Require vpndetection 5.24.0: a keyless answer without the AS's type reads ([`cf3ee60`](https://github.com/vpndetection-io/sdk-python-flask/commit/cf3ee607eacf08cb22c9b6da55ca84a39c36dfd9))
10
+
11
+ ## 2.2.5 - 2026-11-26
12
+
13
+ ### Fixes
14
+
15
+ - Require vpndetection 5.23.1: a condition on the verdict is no plan gap for a request that sent no agent ([`da5a188`](https://github.com/vpndetection-io/sdk-python-flask/commit/da5a1880725a54125851d3fd9696ec9b6d3720e6))
16
+
5
17
  ## 2.2.4 - 2026-11-26
6
18
 
7
19
  ### Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: vpndetection-flask
3
- Version: 2.2.4
3
+ Version: 2.2.6
4
4
  Summary: Official Flask extension 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-flask
@@ -20,7 +20,7 @@ Classifier: Topic :: Security
20
20
  Classifier: Typing :: Typed
21
21
  Requires-Python: >=3.11
22
22
  Requires-Dist: flask>=3.0
23
- Requires-Dist: vpndetection<6,>=5.23.0
23
+ Requires-Dist: vpndetection<6,>=5.24.0
24
24
  Provides-Extra: dev
25
25
  Requires-Dist: mypy>=1.11; extra == 'dev'
26
26
  Requires-Dist: pytest>=8; extra == 'dev'
@@ -87,7 +87,7 @@ A condition is written in the shape of a result, keyed by the same names the API
87
87
  [{"is_tor": True}, {"is_resproxy": True}] # a list is OR
88
88
  ```
89
89
 
90
- 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.
90
+ 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.
91
91
 
92
92
  Replace the refusal with `on_blocked`.
93
93
 
@@ -104,7 +104,7 @@ VPNDetection(
104
104
  )
105
105
  ```
106
106
 
107
- 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.
107
+ 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. `bot` and `is_bot` are a paid plan's too, so a keyless app gets no bot pass.
108
108
 
109
109
  ### Blocking one view
110
110
 
@@ -159,7 +159,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
159
159
 
160
160
  ## Absent is not false
161
161
 
162
- 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".
162
+ Unlimited, with a key or without one, 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` is the exception: it stays a `str` and reads `""` when the answer leaves it out.
163
163
 
164
164
  ```python
165
165
  lookup().result.is_hosting # None when your plan does not include it
@@ -58,7 +58,7 @@ A condition is written in the shape of a result, keyed by the same names the API
58
58
  [{"is_tor": True}, {"is_resproxy": True}] # a list is OR
59
59
  ```
60
60
 
61
- 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.
61
+ 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.
62
62
 
63
63
  Replace the refusal with `on_blocked`.
64
64
 
@@ -75,7 +75,7 @@ VPNDetection(
75
75
  )
76
76
  ```
77
77
 
78
- 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.
78
+ 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. `bot` and `is_bot` are a paid plan's too, so a keyless app gets no bot pass.
79
79
 
80
80
  ### Blocking one view
81
81
 
@@ -130,7 +130,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
130
130
 
131
131
  ## Absent is not false
132
132
 
133
- 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".
133
+ Unlimited, with a key or without one, 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` is the exception: it stays a `str` and reads `""` when the answer leaves it out.
134
134
 
135
135
  ```python
136
136
  lookup().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.0,<6", "flask>=3.0"]
27
+ dependencies = ["vpndetection>=5.24.0,<6", "flask>=3.0"]
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.4"
48
+ __version__ = "2.2.6"
49
49
 
50
50
  View = TypeVar("View", bound=Callable[..., Any])
51
51
 
@@ -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"
@@ -2145,7 +2143,6 @@
2145
2143
  "asn": 9009,
2146
2144
  "name": "M247 Europe SRL",
2147
2145
  "domain": "m247global.com",
2148
- "type": "hosting",
2149
2146
  "prefix": "146.70.116.0/24",
2150
2147
  "country": "US",
2151
2148
  "rpki_status": "valid"
@@ -2196,7 +2193,6 @@
2196
2193
  "asn": 9009,
2197
2194
  "name": "M247 Europe SRL",
2198
2195
  "domain": "m247global.com",
2199
- "type": "hosting",
2200
2196
  "prefix": "146.70.116.0/24",
2201
2197
  "country": "US",
2202
2198
  "rpki_status": "valid"
@@ -2230,7 +2226,6 @@
2230
2226
  "asn": 9009,
2231
2227
  "name": "M247 Europe SRL",
2232
2228
  "domain": "m247global.com",
2233
- "type": "hosting",
2234
2229
  "prefix": "146.70.116.0/24",
2235
2230
  "country": "US",
2236
2231
  "rpki_status": "valid"
@@ -2282,7 +2277,6 @@
2282
2277
  "asn": 9009,
2283
2278
  "name": "M247 Europe SRL",
2284
2279
  "domain": "m247global.com",
2285
- "type": "hosting",
2286
2280
  "prefix": "146.70.116.0/24",
2287
2281
  "country": "US",
2288
2282
  "rpki_status": "valid"
@@ -2291,7 +2285,7 @@
2291
2285
  },
2292
2286
  {
2293
2287
  "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.",
2288
+ "why": "Unlimited'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
2289
  "status": 200,
2296
2290
  "body": {
2297
2291
  "ip": "1.1.1.1",
@@ -2299,7 +2293,6 @@
2299
2293
  "is_vpn": false,
2300
2294
  "is_relay": false,
2301
2295
  "is_tor": false,
2302
- "is_bot": false,
2303
2296
  "is_anycast": true,
2304
2297
  "relay": {},
2305
2298
  "tor": {},
@@ -2319,7 +2312,6 @@
2319
2312
  "asn": 13335,
2320
2313
  "name": "Cloudflare, Inc.",
2321
2314
  "domain": "cloudflare.com",
2322
- "type": "hosting",
2323
2315
  "prefix": "1.1.1.0/24",
2324
2316
  "country": "US",
2325
2317
  "rpki_status": "valid"
@@ -2333,12 +2325,12 @@
2333
2325
  "is_vpn": false,
2334
2326
  "is_relay": false,
2335
2327
  "is_tor": false,
2336
- "is_bot": false,
2337
2328
  "is_anycast": true
2338
2329
  },
2339
2330
  "absent": [
2340
2331
  "is_hosting",
2341
2332
  "is_cdn",
2333
+ "is_bot",
2342
2334
  "is_resproxy",
2343
2335
  "is_dcproxy",
2344
2336
  "is_mobproxy",
@@ -2388,7 +2380,6 @@
2388
2380
  "asn": 13335,
2389
2381
  "name": "Cloudflare, Inc.",
2390
2382
  "domain": "cloudflare.com",
2391
- "type": "hosting",
2392
2383
  "prefix": "1.1.1.0/24",
2393
2384
  "country": "US",
2394
2385
  "rpki_status": "valid"
@@ -3059,7 +3050,7 @@
3059
3050
  },
3060
3051
  {
3061
3052
  "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.",
3053
+ "why": "Unlimited'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
3054
  "status": 200,
3064
3055
  "body": {
3065
3056
  "ip": "66.249.66.1",
@@ -3067,7 +3058,6 @@
3067
3058
  "is_vpn": false,
3068
3059
  "is_relay": false,
3069
3060
  "is_tor": false,
3070
- "is_bot": true,
3071
3061
  "is_anycast": false,
3072
3062
  "relay": {},
3073
3063
  "tor": {},
@@ -3087,7 +3077,6 @@
3087
3077
  "asn": 15169,
3088
3078
  "name": "Google LLC",
3089
3079
  "domain": "google.com",
3090
- "type": "hosting",
3091
3080
  "prefix": "66.249.64.0/20",
3092
3081
  "country": "US",
3093
3082
  "rpki_status": "valid"
@@ -3101,12 +3090,12 @@
3101
3090
  "is_vpn": false,
3102
3091
  "is_relay": false,
3103
3092
  "is_tor": false,
3104
- "is_bot": true,
3105
3093
  "is_anycast": false
3106
3094
  },
3107
3095
  "absent": [
3108
3096
  "is_hosting",
3109
3097
  "is_cdn",
3098
+ "is_bot",
3110
3099
  "is_resproxy",
3111
3100
  "is_dcproxy",
3112
3101
  "is_mobproxy",
@@ -3156,7 +3145,6 @@
3156
3145
  "asn": 15169,
3157
3146
  "name": "Google LLC",
3158
3147
  "domain": "google.com",
3159
- "type": "hosting",
3160
3148
  "prefix": "66.249.64.0/20",
3161
3149
  "country": "US",
3162
3150
  "rpki_status": "valid"
@@ -8364,7 +8352,6 @@
8364
8352
  "asn": 9009,
8365
8353
  "name": "M247 Europe SRL",
8366
8354
  "domain": "m247global.com",
8367
- "type": "hosting",
8368
8355
  "prefix": "146.70.116.0/24",
8369
8356
  "country": "US",
8370
8357
  "rpki_status": "valid"
@@ -8406,7 +8393,6 @@
8406
8393
  "asn": 9009,
8407
8394
  "name": "M247 Europe SRL",
8408
8395
  "domain": "m247global.com",
8409
- "type": "hosting",
8410
8396
  "prefix": "146.70.116.0/24",
8411
8397
  "country": "US",
8412
8398
  "rpki_status": "valid"
@@ -8451,7 +8437,6 @@
8451
8437
  "asn": 9009,
8452
8438
  "name": "M247 Europe SRL",
8453
8439
  "domain": "m247global.com",
8454
- "type": "hosting",
8455
8440
  "prefix": "146.70.116.0/24",
8456
8441
  "country": "US",
8457
8442
  "rpki_status": "valid"
@@ -8469,7 +8454,7 @@
8469
8454
  },
8470
8455
  {
8471
8456
  "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.",
8457
+ "why": "The network's type is a paid plan's: Unlimited does not serve it, so the term can never match and is reported by its path.",
8473
8458
  "body": {
8474
8459
  "ip": "146.70.116.130",
8475
8460
  "is_vpn": true,
@@ -8493,7 +8478,6 @@
8493
8478
  "asn": 9009,
8494
8479
  "name": "M247 Europe SRL",
8495
8480
  "domain": "m247global.com",
8496
- "type": "hosting",
8497
8481
  "prefix": "146.70.116.0/24",
8498
8482
  "country": "US",
8499
8483
  "rpki_status": "valid"
@@ -8505,8 +8489,10 @@
8505
8489
  }
8506
8490
  },
8507
8491
  "expect": {
8508
- "blocked": true,
8509
- "missing": []
8492
+ "blocked": false,
8493
+ "missing": [
8494
+ "asn.type"
8495
+ ]
8510
8496
  }
8511
8497
  },
8512
8498
  {
@@ -8535,7 +8521,6 @@
8535
8521
  "asn": 9009,
8536
8522
  "name": "M247 Europe SRL",
8537
8523
  "domain": "m247global.com",
8538
- "type": "hosting",
8539
8524
  "prefix": "146.70.116.0/24",
8540
8525
  "country": "US",
8541
8526
  "rpki_status": "valid"
@@ -11473,6 +11458,9 @@
11473
11458
  "Dart/3.4 (dart:io)",
11474
11459
  "Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.19041.4291",
11475
11460
  "Mozilla/5.0 (Windows NT 10.0; Microsoft Windows 10.0.22631; en-US) PowerShell/7.4.5",
11461
+ "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",
11462
+ "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",
11463
+ "Debian APT-HTTP/1.3 (2.8.4)",
11476
11464
  "",
11477
11465
  "Mozilla/5.0",
11478
11466
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36",
@@ -121,6 +121,41 @@ def test_a_condition_on_a_bot_blocks_a_bot_and_passes_the_rest(
121
121
  assert served.asked == [PUBLIC_IP]
122
122
 
123
123
 
124
+ ASN = {
125
+ "asn": 9009,
126
+ "name": "M247 Europe SRL",
127
+ "domain": "m247global.com",
128
+ "prefix": "146.70.116.0/24",
129
+ "country": "US",
130
+ "rpki_status": "valid",
131
+ }
132
+
133
+
134
+ def test_an_answer_without_the_asn_type_is_read_and_a_condition_on_it_never_matches() -> None:
135
+ warnings: list[str] = []
136
+ keyless = serving({"is_vpn": True, "asn": ASN})
137
+ status, body = get(
138
+ app_with(
139
+ client=keyless,
140
+ ip_selector=fixed_ip,
141
+ block_condition={"asn": {"type": "hosting"}},
142
+ on_warn=warnings.append,
143
+ )
144
+ )
145
+ assert status == 200
146
+ assert body["error"] is None and body["is_vpn"] is True, "the answer was read and attached"
147
+ reported = [w for w in warnings if "does not include" in w]
148
+ assert len(reported) == 1 and "asn.type" in reported[0]
149
+
150
+ paid = serving({"is_vpn": True, "asn": {**ASN, "type": "hosting"}})
151
+ status, _ = get(
152
+ app_with(
153
+ client=paid, ip_selector=fixed_ip, block_condition={"asn": {"type": "hosting"}}
154
+ )
155
+ )
156
+ assert status == 403, "the same condition blocks an answer that carries the type"
157
+
158
+
124
159
  def test_a_condition_reaches_the_evidence_fields() -> None:
125
160
  nord = serving({"is_vpn": True, "vpn": {"provider": "nordvpn"}})
126
161
  status, _ = get(