Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pygeoip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pygeoip
Commits
e8136328
Commit
e8136328
authored
Oct 08, 2014
by
William Tisäter
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69 from Ironholds/patch-2
Improve exception handling
parents
c1259b45
f298b4fb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
pygeoip/__init__.py
+4
-2
No files found.
pygeoip/__init__.py
View file @
e8136328
...
...
@@ -408,11 +408,13 @@ class GeoIP(object):
:arg addr: IPv4 or IPv6 address (eg. 203.0.113.30)
"""
if
self
.
_databaseType
in
(
const
.
PROXY_EDITION
,
const
.
NETSPEED_EDITION_REV1
,
const
.
NETSPEED_EDITION_REV1_V6
):
raise
GeoIPError
(
'Invalid database type; this database is not supported'
)
ipv
=
6
if
addr
.
find
(
':'
)
>=
0
else
4
if
ipv
==
4
and
self
.
_databaseType
not
in
(
const
.
COUNTRY_EDITION
,
const
.
NETSPEED_EDITION
):
raise
GeoIPError
(
'Invalid database type;
expected IPv6 address
'
)
raise
GeoIPError
(
'Invalid database type;
this database supports IPv6 addresses, not IPv4
'
)
if
ipv
==
6
and
self
.
_databaseType
!=
const
.
COUNTRY_EDITION_V6
:
raise
GeoIPError
(
'Invalid database type;
expected IPv4 address
'
)
raise
GeoIPError
(
'Invalid database type;
this database supports IPv4 addresses, not IPv6
'
)
ipnum
=
util
.
ip2long
(
addr
)
return
self
.
_seek_country
(
ipnum
)
-
const
.
COUNTRY_BEGIN
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment