Skip to content

Commit 39b0ebe

Browse files
committed
Added checking logic for zip file.
1 parent 9b7d953 commit 39b0ebe

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
3.5.2 2025-10-31
2+
* Added checking logic for zip file.
3+
14
3.5.2 2025-10-17
25
* Fixed the database checking logic. (#9).
36

IP2Proxy.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,13 @@ def open(self, filename):
173173
self._productcode = struct.unpack('B', header_row[29:30])[0]
174174
self._licensecode = struct.unpack('B', header_row[30:31])[0]
175175
self._databasesize = struct.unpack('B', header_row[31:32])[0]
176-
if (self._productcode != 2) :
177-
if (self._dbyear <= 20 and self._productcode == 0) :
178-
self._f.close()
179-
del self._f
180-
raise ValueError("Incorrect IP2Location BIN file format. Please make sure that you are using the latest IP2Location BIN file.")
176+
177+
# check if is correct BIN (should be 2 for IP2Proxy BIN file), also checking for zipped file (PK being the first 2 chars)
178+
# only BINs from Jan 2021 onwards have _dbcolumn and _dbtype
179+
if ((self._productcode != 2 and self._dbyear >= 21) or (self._dbtype == 80 and self._dbcolumn == 75)):
180+
self._f.close()
181+
del self._f
182+
raise ValueError("Incorrect IP2Proxy BIN file format. Please make sure that you are using the latest IP2Proxy BIN file.")
181183

182184
def close(self):
183185
if hasattr(self, '_f'):

PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.0
22
Name: IP2Proxy
3-
Version: 3.5.2
3+
Version: 3.6.0
44
Summary: Python API for IP2Proxy database
55
Home-page: http://www.ip2location.com
66
Author: IP2Location

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="IP2Proxy",
8-
version="3.5.2",
8+
version="3.6.0",
99
author="IP2Location",
1010
author_email="[email protected]",
1111
description="Python API for IP2Proxy database. It can be used to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits.",

0 commit comments

Comments
 (0)