vpndetection-fastapi 2.1.27__tar.gz → 2.1.29__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.1.29 - 2026-11-22
6
+
7
+ ### Features
8
+
9
+ - Require vpndetection 5.20.0: is_bot and bot, and the AS's country and RPKI status required ([`6448579`](https://github.com/vpndetection-io/sdk-python-fastapi/commit/64485792c122bfe1c5a8684a9ec5ed9fd3896056))
10
+
11
+ ## 2.1.28 - 2026-11-20
12
+
13
+ ### Features
14
+
15
+ - Require vpndetection 5.19.0: the network, service, company and abuse members ([`66c0b08`](https://github.com/vpndetection-io/sdk-python-fastapi/commit/66c0b080a273e783c306e546c3bca48f31532123))
16
+
5
17
  ## 2.1.27 - 2026-11-19
6
18
 
7
19
  ### Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: vpndetection-fastapi
3
- Version: 2.1.27
3
+ Version: 2.1.29
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.18.1
23
+ Requires-Dist: vpndetection<6,>=5.20.0
24
24
  Provides-Extra: dev
25
25
  Requires-Dist: fastapi>=0.115; extra == 'dev'
26
26
  Requires-Dist: mypy>=1.11; extra == 'dev'
@@ -33,9 +33,9 @@ Description-Content-Type: text/markdown
33
33
  [![PyPI](https://img.shields.io/pypi/v/vpndetection-fastapi.svg)](https://pypi.org/project/vpndetection-fastapi/)
34
34
  [![license](https://img.shields.io/pypi/l/vpndetection-fastapi.svg)](LICENSE)
35
35
 
36
- The official FastAPI middleware for the [VPNDetection](https://vpndetection.io) API.
36
+ The official FastAPI middleware for the [VPNDetection](https://vpndetection.io) API: it checks each visitor's IP for VPN, Tor and proxy use, and can block them with a 403.
37
37
 
38
- It classifies the visitor behind each request — VPN, residential proxy, Tor, hosting, CDN, relay — and hands the answer to your code. Blocking is opt-in.
38
+ It classifies the visitor behind each request: VPN, residential proxy, Tor, hosting, CDN or relay. Then it hands the answer to your code. Blocking is opt-in.
39
39
 
40
40
  ## Getting Started
41
41
 
@@ -45,7 +45,7 @@ pip install vpndetection-fastapi
45
45
 
46
46
  Requires Python 3.11 or newer.
47
47
 
48
- You need an API key on a paid plan. Create one in the [console](https://app.vpndetection.io); without one a lookup is on Unlimited, the free plan, and leaves out the hosting, CDN and proxy flags, so a paid plan is what makes this usable in production rather than optional. A free account tries every field, 100 lookups a day.
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.
49
49
 
50
50
  ```python
51
51
  from fastapi import FastAPI
@@ -70,7 +70,7 @@ async def index(request: Request):
70
70
 
71
71
  A request your `skip` claims gets no answer, and `lookup(request)` is `None` for it.
72
72
 
73
- By default nothing is blocked. Every request gets an answer and your own code decides what that means — which is usually what you want, because whether a VPN visitor is a problem depends entirely on what they are doing.
73
+ By default nothing is blocked. Every request gets an answer and your own code decides what to do with it, since whether a VPN visitor is a problem depends on what they're doing.
74
74
 
75
75
  ## Blocking
76
76
 
@@ -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. 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`) is never matched, so block on its flag alone. 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.
93
93
 
94
94
  Replace the refusal with `on_blocked`.
95
95
 
@@ -110,7 +110,7 @@ A refused request gets an `HTTPException`, `403` with `{"detail": "access denied
110
110
 
111
111
  ## Where the client address comes from
112
112
 
113
- This is the setting that decides whether any of the above works, and it is the one thing only you can get right.
113
+ Get this setting right, or none of the above works.
114
114
 
115
115
  By default the middleware uses `request.client.host`. uvicorn, and `fastapi run` with it, reads proxy headers by default, but only from a peer that `--forwarded-allow-ips` trusts, and that defaults to `127.0.0.1,::1` (or `$FORWARDED_ALLOW_IPS`). So behind a proxy on the same machine, the visitor's address arrives with no setup. Behind one anywhere else, such as nginx in its own container or a load balancer in a VPC, every visitor looks like the proxy. That address is usually a private one, which the middleware answers locally: nobody is flagged, nothing is blocked, and the private-address warning below is the only sign. Name your proxy, by its address or its subnet: `--forwarded-allow-ips=172.28.5.0/28`. gunicorn's own `--forwarded-allow-ips` works the same way. Never pass `*`. It trusts every peer, so the left-most `X-Forwarded-For` entry wins, and that is whatever the visitor sent: someone on a VPN who sends `X-Forwarded-For: 1.1.1.1` is looked up as `1.1.1.1`.
116
116
 
@@ -122,7 +122,7 @@ from vpndetection_fastapi import header_ip_selector
122
122
  ip_selector = header_ip_selector("CF-Connecting-IP") # or True-Client-IP, or your own
123
123
  ```
124
124
 
125
- `xff_ip_selector()` reads `X-Forwarded-For` directly. Be aware that the left-most entry is whatever the caller sent, because proxies append to that header — it is only trustworthy when an edge you control overwrites it. If you know how many proxies sit in front, count from the right instead: `xff_ip_selector(1)` is the address your nearest proxy saw.
125
+ `xff_ip_selector()` reads `X-Forwarded-For` directly. The left-most entry is whatever the caller sent, since proxies append to that header, so trust it only when an edge you control overwrites it. If you know how many proxies sit in front, count from the right instead: `xff_ip_selector(1)` is the address your nearest proxy saw.
126
126
 
127
127
  Anything else, pass your own callable. It receives the request and returns an address.
128
128
 
@@ -134,7 +134,7 @@ The request is let through, and the reason is recorded on the answer's `error`.
134
134
 
135
135
  ## Cost and latency
136
136
 
137
- Answers are cached for an hour, so a returning visitor costs nothing, and private addresses never leave the process. A cache miss is one request to our API, bounded at 2.5 seconds by default and not retried — on a request path, failing open quickly beats holding a visitor while we try again. Both are adjustable, as is the cache, through a `vpndetection` client you build yourself and pass as `client`.
137
+ Answers are cached for an hour, so a returning visitor costs nothing, and private addresses never leave the process. A cache miss is one request to our API, bounded at 2.5 seconds by default and not retried: on a request path, failing open fast beats holding a visitor while we retry. Both are adjustable, as is the cache, through a `vpndetection` client you build yourself and pass as `client`.
138
138
 
139
139
  Skip what you do not care about:
140
140
 
@@ -146,7 +146,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
146
146
 
147
147
  ## Absent is not false
148
148
 
149
- Unlimited, with a key or without one, leaves out `is_hosting`, `is_cdn` and the four proxy flags, 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".
149
+ 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".
150
150
 
151
151
  ```python
152
152
  lookup(request).result.is_hosting # None when your plan does not include it
@@ -3,9 +3,9 @@
3
3
  [![PyPI](https://img.shields.io/pypi/v/vpndetection-fastapi.svg)](https://pypi.org/project/vpndetection-fastapi/)
4
4
  [![license](https://img.shields.io/pypi/l/vpndetection-fastapi.svg)](LICENSE)
5
5
 
6
- The official FastAPI middleware for the [VPNDetection](https://vpndetection.io) API.
6
+ The official FastAPI middleware for the [VPNDetection](https://vpndetection.io) API: it checks each visitor's IP for VPN, Tor and proxy use, and can block them with a 403.
7
7
 
8
- It classifies the visitor behind each request — VPN, residential proxy, Tor, hosting, CDN, relay — and hands the answer to your code. Blocking is opt-in.
8
+ It classifies the visitor behind each request: VPN, residential proxy, Tor, hosting, CDN or relay. Then it hands the answer to your code. Blocking is opt-in.
9
9
 
10
10
  ## Getting Started
11
11
 
@@ -15,7 +15,7 @@ pip install vpndetection-fastapi
15
15
 
16
16
  Requires Python 3.11 or newer.
17
17
 
18
- You need an API key on a paid plan. Create one in the [console](https://app.vpndetection.io); without one a lookup is on Unlimited, the free plan, and leaves out the hosting, CDN and proxy flags, so a paid plan is what makes this usable in production rather than optional. A free account tries every field, 100 lookups a day.
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.
19
19
 
20
20
  ```python
21
21
  from fastapi import FastAPI
@@ -40,7 +40,7 @@ async def index(request: Request):
40
40
 
41
41
  A request your `skip` claims gets no answer, and `lookup(request)` is `None` for it.
42
42
 
43
- By default nothing is blocked. Every request gets an answer and your own code decides what that means — which is usually what you want, because whether a VPN visitor is a problem depends entirely on what they are doing.
43
+ By default nothing is blocked. Every request gets an answer and your own code decides what to do with it, since whether a VPN visitor is a problem depends on what they're doing.
44
44
 
45
45
  ## Blocking
46
46
 
@@ -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. 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`) is never matched, so block on its flag alone. 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.
63
63
 
64
64
  Replace the refusal with `on_blocked`.
65
65
 
@@ -80,7 +80,7 @@ A refused request gets an `HTTPException`, `403` with `{"detail": "access denied
80
80
 
81
81
  ## Where the client address comes from
82
82
 
83
- This is the setting that decides whether any of the above works, and it is the one thing only you can get right.
83
+ Get this setting right, or none of the above works.
84
84
 
85
85
  By default the middleware uses `request.client.host`. uvicorn, and `fastapi run` with it, reads proxy headers by default, but only from a peer that `--forwarded-allow-ips` trusts, and that defaults to `127.0.0.1,::1` (or `$FORWARDED_ALLOW_IPS`). So behind a proxy on the same machine, the visitor's address arrives with no setup. Behind one anywhere else, such as nginx in its own container or a load balancer in a VPC, every visitor looks like the proxy. That address is usually a private one, which the middleware answers locally: nobody is flagged, nothing is blocked, and the private-address warning below is the only sign. Name your proxy, by its address or its subnet: `--forwarded-allow-ips=172.28.5.0/28`. gunicorn's own `--forwarded-allow-ips` works the same way. Never pass `*`. It trusts every peer, so the left-most `X-Forwarded-For` entry wins, and that is whatever the visitor sent: someone on a VPN who sends `X-Forwarded-For: 1.1.1.1` is looked up as `1.1.1.1`.
86
86
 
@@ -92,7 +92,7 @@ from vpndetection_fastapi import header_ip_selector
92
92
  ip_selector = header_ip_selector("CF-Connecting-IP") # or True-Client-IP, or your own
93
93
  ```
94
94
 
95
- `xff_ip_selector()` reads `X-Forwarded-For` directly. Be aware that the left-most entry is whatever the caller sent, because proxies append to that header — it is only trustworthy when an edge you control overwrites it. If you know how many proxies sit in front, count from the right instead: `xff_ip_selector(1)` is the address your nearest proxy saw.
95
+ `xff_ip_selector()` reads `X-Forwarded-For` directly. The left-most entry is whatever the caller sent, since proxies append to that header, so trust it only when an edge you control overwrites it. If you know how many proxies sit in front, count from the right instead: `xff_ip_selector(1)` is the address your nearest proxy saw.
96
96
 
97
97
  Anything else, pass your own callable. It receives the request and returns an address.
98
98
 
@@ -104,7 +104,7 @@ The request is let through, and the reason is recorded on the answer's `error`.
104
104
 
105
105
  ## Cost and latency
106
106
 
107
- Answers are cached for an hour, so a returning visitor costs nothing, and private addresses never leave the process. A cache miss is one request to our API, bounded at 2.5 seconds by default and not retried — on a request path, failing open quickly beats holding a visitor while we try again. Both are adjustable, as is the cache, through a `vpndetection` client you build yourself and pass as `client`.
107
+ Answers are cached for an hour, so a returning visitor costs nothing, and private addresses never leave the process. A cache miss is one request to our API, bounded at 2.5 seconds by default and not retried: on a request path, failing open fast beats holding a visitor while we retry. Both are adjustable, as is the cache, through a `vpndetection` client you build yourself and pass as `client`.
108
108
 
109
109
  Skip what you do not care about:
110
110
 
@@ -116,7 +116,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
116
116
 
117
117
  ## Absent is not false
118
118
 
119
- Unlimited, with a key or without one, leaves out `is_hosting`, `is_cdn` and the four proxy flags, 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".
119
+ 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".
120
120
 
121
121
  ```python
122
122
  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.18.1,<6", "starlette>=0.37"]
27
+ dependencies = ["vpndetection>=5.20.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.1.27"
48
+ __version__ = "2.1.29"
49
49
 
50
50
  # Set on a request ``skip`` claimed, so block_if can tell it from one the middleware
51
51
  # never saw.