vpndetection-fastapi 2.1.16__tar.gz → 2.1.18__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.18 - 2026-11-11
6
+
7
+ ### Features
8
+
9
+ - Require vpndetection 5.14.0: a lookup without a key answers more ([`3161128`](https://github.com/vpndetection-io/sdk-python-fastapi/commit/3161128e6758efdb9ba3ccc546b8f328db8c73a3))
10
+
11
+ ## 2.1.17 - 2026-11-11
12
+
13
+ ### Fixes
14
+
15
+ - Require vpndetection 5.13.1: a client concurrency is checked where it is set ([`9fe9b92`](https://github.com/vpndetection-io/sdk-python-fastapi/commit/9fe9b924446f4c8fdd4358a0f78b754d00b56ef0))
16
+
5
17
  ## 2.1.16 - 2026-11-07
6
18
 
7
19
  ### Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: vpndetection-fastapi
3
- Version: 2.1.16
3
+ Version: 2.1.18
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.13.0
23
+ Requires-Dist: vpndetection<6,>=5.14.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
- You need an API key. Create one in the [console](https://app.vpndetection.io); without one the allowance is counted per source address, and a server is a single source address, so a key is what makes this usable in production rather than optional.
48
+ You need an API key. Create one in the [console](https://app.vpndetection.io); without one, lookups are limited to 60 a minute from each source address, and a server is a single source address, so a key is what makes this usable in production rather than optional.
49
49
 
50
50
  ```python
51
51
  from fastapi import FastAPI
@@ -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
- Without a key only `ip` and `is_vpn` come back, and a free key adds Tor, relay, `location` and `asn`. A field your plan does not include is `None`, which means "not in your plan" rather than "checked, and no".
149
+ Without a key a lookup leaves out `is_hosting`, `is_cdn` and the four proxy flags, and a free key leaves out `vpn` and the detail behind each flag. 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
@@ -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. Create one in the [console](https://app.vpndetection.io); without one the allowance is counted per source address, and a server is a single source address, so a key is what makes this usable in production rather than optional.
18
+ You need an API key. Create one in the [console](https://app.vpndetection.io); without one, lookups are limited to 60 a minute from each source address, and a server is a single source address, so a key is what makes this usable in production rather than optional.
19
19
 
20
20
  ```python
21
21
  from fastapi import FastAPI
@@ -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
- Without a key only `ip` and `is_vpn` come back, and a free key adds Tor, relay, `location` and `asn`. A field your plan does not include is `None`, which means "not in your plan" rather than "checked, and no".
119
+ Without a key a lookup leaves out `is_hosting`, `is_cdn` and the four proxy flags, and a free key leaves out `vpn` and the detail behind each flag. 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.13.0,<6", "starlette>=0.37"]
27
+ dependencies = ["vpndetection>=5.14.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.16"
48
+ __version__ = "2.1.18"
49
49
 
50
50
  # Set on a request ``skip`` claimed, so block_if can tell it from one the middleware
51
51
  # never saw.
@@ -341,8 +341,8 @@
341
341
  },
342
342
  "lookup": [
343
343
  {
344
- "name": "free-not-vpn",
345
- "why": "The free shape. Every tier-gated member is absent, which means not-in-your-plan and must not read as false.",
344
+ "name": "required-only-not-vpn",
345
+ "why": "Only the two members every answer must carry. Every other member is absent, which means not in this answer and must not read as false.",
346
346
  "status": 200,
347
347
  "body": {
348
348
  "ip": "1.1.1.1",
@@ -639,8 +639,8 @@
639
639
  }
640
640
  },
641
641
  {
642
- "name": "free-location-asn",
643
- "why": "A free key's shape since 2026-10-20: 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.",
642
+ "name": "keyless-location-asn",
643
+ "why": "The answer without a key since 2026-11-11: 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.",
644
644
  "status": 200,
645
645
  "body": {
646
646
  "ip": "146.70.116.130",
@@ -716,6 +716,91 @@
716
716
  "prefix": "146.70.116.0/24"
717
717
  }
718
718
  }
719
+ },
720
+ {
721
+ "name": "free-flags-without-detail",
722
+ "why": "A free key's answer since 2026-11-11: every flag, but no detail object behind the six it adds to the keyless answer and no vpn object. Each flag maps on its own, and the detail it lacks stays absent rather than empty.",
723
+ "status": 200,
724
+ "body": {
725
+ "ip": "146.70.116.130",
726
+ "is_vpn": true,
727
+ "is_hosting": true,
728
+ "is_relay": false,
729
+ "is_tor": false,
730
+ "is_cdn": false,
731
+ "is_resproxy": false,
732
+ "is_dcproxy": false,
733
+ "is_mobproxy": false,
734
+ "is_pubproxy": false,
735
+ "relay": {},
736
+ "tor": {},
737
+ "location": {
738
+ "continent": "EU",
739
+ "continent_name": "Europe",
740
+ "country": "AT",
741
+ "country_name": "Austria",
742
+ "timezone": "Europe/Vienna",
743
+ "currency_code": "EUR",
744
+ "currency_name": "Euro",
745
+ "currency_symbol": "€",
746
+ "flag_emoji": "🇦🇹",
747
+ "flag_unicode": "U+1F1E6 U+1F1F9"
748
+ },
749
+ "asn": {
750
+ "asn": 9009,
751
+ "name": "M247 Europe SRL",
752
+ "domain": "m247global.com",
753
+ "type": "hosting",
754
+ "prefix": "146.70.116.0/24"
755
+ }
756
+ },
757
+ "expect": {
758
+ "ip": "146.70.116.130",
759
+ "isBogon": false,
760
+ "present": {
761
+ "is_vpn": true,
762
+ "is_hosting": true,
763
+ "is_relay": false,
764
+ "is_tor": false,
765
+ "is_cdn": false,
766
+ "is_resproxy": false,
767
+ "is_dcproxy": false,
768
+ "is_mobproxy": false,
769
+ "is_pubproxy": false
770
+ },
771
+ "absent": [
772
+ "vpn",
773
+ "hosting",
774
+ "cdn",
775
+ "resproxy",
776
+ "dcproxy",
777
+ "mobproxy",
778
+ "pubproxy"
779
+ ],
780
+ "emptyPresent": [
781
+ "relay",
782
+ "tor"
783
+ ],
784
+ "location": {
785
+ "continent": "EU",
786
+ "continent_name": "Europe",
787
+ "country": "AT",
788
+ "country_name": "Austria",
789
+ "timezone": "Europe/Vienna",
790
+ "currency_code": "EUR",
791
+ "currency_name": "Euro",
792
+ "currency_symbol": "€",
793
+ "flag_emoji": "🇦🇹",
794
+ "flag_unicode": "U+1F1E6 U+1F1F9"
795
+ },
796
+ "asn": {
797
+ "asn": 9009,
798
+ "name": "M247 Europe SRL",
799
+ "domain": "m247global.com",
800
+ "type": "hosting",
801
+ "prefix": "146.70.116.0/24"
802
+ }
803
+ }
719
804
  }
720
805
  ],
721
806
  "errors": [
@@ -800,16 +885,19 @@
800
885
  }
801
886
  },
802
887
  {
803
- "name": "keyless-daily-quota-is-not-retryable",
804
- "why": "No Retry-After. The keyless daily allowance is spent and retrying will not help.",
888
+ "name": "keyless-per-minute-limit-is-retryable",
889
+ "why": "Retry-After present. A caller with no API key is past 60 requests a minute from its address, which is a rate limit, so retrying after the wait WILL succeed.",
805
890
  "status": 429,
806
- "headers": {},
891
+ "headers": {
892
+ "Retry-After": "1"
893
+ },
807
894
  "body": {
808
- "error": "daily limit for unauthenticated requests exceeded; use an API key"
895
+ "error": "per-minute limit for requests without an API key exceeded; retry shortly or use an API key"
809
896
  },
810
897
  "expect": {
811
- "kind": "quota_exceeded",
812
- "retryable": false
898
+ "kind": "rate_limited",
899
+ "retryable": true,
900
+ "retryAfterSeconds": 1
813
901
  }
814
902
  },
815
903
  {
@@ -5698,7 +5786,7 @@
5698
5786
  },
5699
5787
  {
5700
5788
  "name": "location-country-matches",
5701
- "why": "location is a member like any other: a country term matches the served country, without regard to case, on the free key's shape.",
5789
+ "why": "location is a member like any other: a country term matches the served country, without regard to case, on the answer a lookup gets without a key.",
5702
5790
  "body": {
5703
5791
  "ip": "146.70.116.130",
5704
5792
  "is_vpn": true,
@@ -5821,7 +5909,7 @@
5821
5909
  },
5822
5910
  {
5823
5911
  "name": "asn-type-matches",
5824
- "why": "asn is a member like any other: a free key's answer says which kind of network announces the address.",
5912
+ "why": "asn is a member like any other: even an answer without a key says which kind of network announces the address.",
5825
5913
  "body": {
5826
5914
  "ip": "146.70.116.130",
5827
5915
  "is_vpn": true,
@@ -5900,8 +5988,8 @@
5900
5988
  }
5901
5989
  },
5902
5990
  {
5903
- "name": "location-and-asn-absent-without-a-key",
5904
- "why": "No key answers ip and is_vpn alone, so terms on location and asn can never match and both are reported.",
5991
+ "name": "location-and-asn-absent-are-reported",
5992
+ "why": "An answer carrying ip and is_vpn alone has no location or asn, so terms on them can never match and both are reported.",
5905
5993
  "body": {
5906
5994
  "ip": "146.70.116.130",
5907
5995
  "is_vpn": true
@@ -375,3 +375,34 @@ def test_the_middleware_starts_the_way_the_readme_builds_it(
375
375
  assert body["attached"] is True
376
376
  assert body["is_bogon"] is True
377
377
  assert body["error"] is None
378
+
379
+
380
+ # The README's middleware again, served a PUBLIC peer with a forged X-Forwarded-For: the key must
381
+ # reach the API, and the socket address must be the one looked up. The test above is answered
382
+ # with no request, so it passed with the key dropped. httpx's own transport answers for the
383
+ # API's host alone, so nothing leaves the machine.
384
+ def test_the_readme_middleware_sends_its_key_for_a_public_peer(
385
+ monkeypatch: pytest.MonkeyPatch,
386
+ ) -> None:
387
+ sent: list[tuple[str, str | None]] = []
388
+
389
+ async def handle(
390
+ _transport: httpx.AsyncHTTPTransport, request: httpx.Request
391
+ ) -> httpx.Response:
392
+ if request.url.host != "api.vpndetection.io":
393
+ raise httpx.ConnectError("only the API's host answers here", request=request)
394
+ sent.append((request.url.path, request.headers.get("Authorization")))
395
+ return httpx.Response(200, json={"ip": PUBLIC_IP, "is_vpn": True})
396
+
397
+ monkeypatch.setattr(httpx.AsyncHTTPTransport, "handle_async_request", handle)
398
+ monkeypatch.setenv("VPNDETECTION_API_KEY", "a-key")
399
+ app = app_with(api_key=os.environ["VPNDETECTION_API_KEY"])
400
+ with TestClient(app, client=(PUBLIC_IP, 12345)) as client:
401
+ response = client.get("/", headers={"X-Forwarded-For": "1.1.1.1"})
402
+ status, body = response.status_code, response.json()
403
+
404
+ assert status == 200
405
+ assert body["ip"] == PUBLIC_IP, "the socket peer is looked up; the header is a forgery"
406
+ assert body["error"] is None and body["is_vpn"] is True
407
+ assert len(sent) == 1 and sent[0][0].endswith(PUBLIC_IP)
408
+ assert sent[0][1] == "Bearer a-key"