Skip to content

Commit 40ccae7

Browse files
authored
Merge pull request #1105 from readthedocs/davidfischer/updated-ip2proxy-script
Handle no permission with ip2proxy
2 parents 0425593 + b4719a6 commit 40ccae7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

geoip/database-updater.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ def update_ipproxy_db(outdir):
8585
f"Failed to update IP2Proxy database: {url}. Status_code={resp.status_code}"
8686
)
8787

88+
# IP2Location returns a 200 with "NO PERMISSION" as the body on a failure
89+
if len(resp.content) < 1024 and b"NO PERMISSION" in resp.content:
90+
raise RuntimeError(
91+
"Permission denied fetching updated IP2Proxy database. IP2LOCATION_TOKEN is likely expired/bad."
92+
)
93+
8894
with zipfile.ZipFile(io.BytesIO(resp.content), mode="r") as myzip:
8995
for member in myzip.infolist():
9096
if member.filename.lower().endswith(".bin"):

0 commit comments

Comments
 (0)