python-ipware 4.1.0__py3-none-any.whl → 4.1.1__py3-none-any.whl
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.
- python_ipware/__version__.py +1 -1
- python_ipware/modern/parsers.py +22 -2
- {python_ipware-4.1.0.dist-info → python_ipware-4.1.1.dist-info}/METADATA +1 -1
- {python_ipware-4.1.0.dist-info → python_ipware-4.1.1.dist-info}/RECORD +6 -6
- {python_ipware-4.1.0.dist-info → python_ipware-4.1.1.dist-info}/WHEEL +0 -0
- {python_ipware-4.1.0.dist-info → python_ipware-4.1.1.dist-info}/licenses/LICENSE +0 -0
python_ipware/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "4.1.
|
|
1
|
+
__version__ = "4.1.1"
|
python_ipware/modern/parsers.py
CHANGED
|
@@ -20,6 +20,11 @@ _NAT64_LOCAL = ipaddress.IPv6Network("64:ff9b:1::/48")
|
|
|
20
20
|
_IPV4_MAPPED = ipaddress.IPv6Network("::ffff:0:0/96")
|
|
21
21
|
# RFC 1122 "this network": never a valid source address.
|
|
22
22
|
_THIS_NETWORK = ipaddress.IPv4Network("0.0.0.0/8")
|
|
23
|
+
# RFC 4007 sets no maximum zone-id length. RFC 9844 §6 asks implementations to
|
|
24
|
+
# apply one, typically the OS interface-name limit (15 on Linux, up to 255 on
|
|
25
|
+
# Windows). 255 stops a multi-kilobyte scope from being logged or stored
|
|
26
|
+
# without rejecting a real interface name.
|
|
27
|
+
_MAX_ZONE_ID_LEN = 255
|
|
23
28
|
|
|
24
29
|
# How good an address is as a client IP; higher wins. REJECT is never returned.
|
|
25
30
|
TIER_REJECT = 0
|
|
@@ -65,7 +70,22 @@ def ip_tier(ip: IpAddressType) -> int:
|
|
|
65
70
|
|
|
66
71
|
def _is_port(value: str) -> bool:
|
|
67
72
|
# isascii() guards against Unicode digits such as "²" that isdigit() accepts.
|
|
68
|
-
|
|
73
|
+
if not (value.isascii() and value.isdigit()):
|
|
74
|
+
return False
|
|
75
|
+
# Strip leading zeros, then bound the length before int(): a long digit
|
|
76
|
+
# string would otherwise exceed sys.get_int_max_str_digits() and raise.
|
|
77
|
+
digits = value.lstrip("0")
|
|
78
|
+
return len(digits) <= 5 and int(digits or "0") <= 65535
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _zone_id_ok(value: str) -> bool:
|
|
82
|
+
"""False when an IPv6 zone id is longer than ``_MAX_ZONE_ID_LEN``.
|
|
83
|
+
|
|
84
|
+
A missing ``%`` is fine. An empty zone (``fe80::1%``) is left to
|
|
85
|
+
``ipaddress``, which already rejects it.
|
|
86
|
+
"""
|
|
87
|
+
_host, sep, zone = value.partition("%")
|
|
88
|
+
return not sep or len(zone) <= _MAX_ZONE_ID_LEN
|
|
69
89
|
|
|
70
90
|
|
|
71
91
|
def strip_port(value: str) -> str:
|
|
@@ -155,7 +175,7 @@ def parse_ip(value: Optional[str]) -> Optional[IpAddressType]:
|
|
|
155
175
|
well-known prefix (``64:ff9b::a.b.c.d``) to the embedded IPv4 client.
|
|
156
176
|
"""
|
|
157
177
|
cleaned = clean_ip(value)
|
|
158
|
-
if not cleaned:
|
|
178
|
+
if not cleaned or not _zone_id_ok(cleaned):
|
|
159
179
|
return None
|
|
160
180
|
try:
|
|
161
181
|
return unwrap_ipv4(ipaddress.ip_address(cleaned))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: python-ipware
|
|
3
|
-
Version: 4.1.
|
|
3
|
+
Version: 4.1.1
|
|
4
4
|
Summary: A Python package to retrieve a client's real IP address.
|
|
5
5
|
Project-URL: Homepage, https://github.com/un33k/python-ipware
|
|
6
6
|
Project-URL: Documentation, https://github.com/un33k/python-ipware#readme
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
python_ipware/__init__.py,sha256=BuZ3sY_v_GTeXmATXqNc_GqRGVDLGP0mj8pWj_StKrA,199
|
|
2
|
-
python_ipware/__version__.py,sha256=
|
|
2
|
+
python_ipware/__version__.py,sha256=NtWqZUv_8plp1gndoYX_eAqe7K65oPMh-hIvB4Evdc8,22
|
|
3
3
|
python_ipware/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
python_ipware/router.py,sha256=ZLEBbBW3xoOfrvwFfBx_V8Bp2rF1tA1jAEjSY5Rnbqo,3097
|
|
5
5
|
python_ipware/legacy/README.md,sha256=h33u11bhkvmU3IJMnPE0p6lXI3f6QiYN1RrI3eIFHsk,14519
|
|
@@ -8,8 +8,8 @@ python_ipware/legacy/engine.py,sha256=IotMZQIGSOu2XCbmdYH4WuhBvXm-lJVJHe3FXylSMv
|
|
|
8
8
|
python_ipware/modern/__init__.py,sha256=uzxoWK47NOaeYVizW2-G7pQSXzQ1Zq9fSu2kru9sR70,109
|
|
9
9
|
python_ipware/modern/defaults.py,sha256=pZkXt6iMVUwfklpBzFQFF36Xd2n1_8Xej7VViBW3spY,2032
|
|
10
10
|
python_ipware/modern/engine.py,sha256=7CQL7O9z4dY85k_YmoyW4TxDjtdHODKS9wIZz2Amnjw,10942
|
|
11
|
-
python_ipware/modern/parsers.py,sha256=
|
|
12
|
-
python_ipware-4.1.
|
|
13
|
-
python_ipware-4.1.
|
|
14
|
-
python_ipware-4.1.
|
|
15
|
-
python_ipware-4.1.
|
|
11
|
+
python_ipware/modern/parsers.py,sha256=P2ZLdMGB1CqPKI0y8EM1jRtougATzu_7i9y6lz9U4ic,8978
|
|
12
|
+
python_ipware-4.1.1.dist-info/METADATA,sha256=Hqt9b48DczV_PBemNGnwH-dIShI9VCTabnZOM10DSLY,15650
|
|
13
|
+
python_ipware-4.1.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
14
|
+
python_ipware-4.1.1.dist-info/licenses/LICENSE,sha256=MLpNxpqfTc4TLdcDk3x6k7Vz4lJGBNLV-SxQZlFMDU8,1103
|
|
15
|
+
python_ipware-4.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|