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
46902fdd
Commit
46902fdd
authored
Mar 04, 2013
by
Mark Teodoro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for IPv6 ASN and City editions
parent
6fafe9a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
pygeoip/__init__.py
+7
-3
pygeoip/const.py
+4
-2
No files found.
pygeoip/__init__.py
View file @
46902fdd
...
...
@@ -126,9 +126,11 @@ class GeoIP(GeoIPBase):
* REGION_EDITION_REV1
* CITY_EDITION_REV0
* CITY_EDITION_REV1
* CITY_EDITION_REV1_V6
* ORG_EDITION
* ISP_EDITION
* ASNUM_EDITION
* ASNUM_EDITION_V6
"""
self
.
_databaseType
=
const
.
COUNTRY_EDITION
...
...
@@ -167,9 +169,11 @@ class GeoIP(GeoIPBase):
elif
self
.
_databaseType
in
(
const
.
CITY_EDITION_REV0
,
const
.
CITY_EDITION_REV1
,
const
.
CITY_EDITION_REV1_V6
,
const
.
ORG_EDITION
,
const
.
ISP_EDITION
,
const
.
ASNUM_EDITION
):
const
.
ASNUM_EDITION
,
const
.
ASNUM_EDITION_V6
):
self
.
_databaseSegments
=
0
buf
=
self
.
_filehandle
.
read
(
const
.
SEGMENT_RECORD_LENGTH
)
...
...
@@ -378,7 +382,7 @@ class GeoIP(GeoIPBase):
record
[
'latitude'
]
=
(
latitude
/
10000.0
)
-
180.0
record
[
'longitude'
]
=
(
longitude
/
10000.0
)
-
180.0
if
self
.
_databaseType
==
const
.
CITY_EDITION_REV1
:
if
self
.
_databaseType
in
(
const
.
CITY_EDITION_REV1
,
const
.
CITY_EDITION_REV1_V6
)
:
dmaarea_combo
=
0
if
record
[
'country_code'
]
==
'US'
:
for
j
in
range
(
3
):
...
...
@@ -525,7 +529,7 @@ class GeoIP(GeoIPBase):
if
not
ipnum
:
raise
ValueError
(
'Invalid IP address'
)
valid
=
(
const
.
ORG_EDITION
,
const
.
ISP_EDITION
,
const
.
ASNUM_EDITION
)
valid
=
(
const
.
ORG_EDITION
,
const
.
ISP_EDITION
,
const
.
ASNUM_EDITION
,
const
.
ASNUM_EDITION_V6
)
if
self
.
_databaseType
not
in
valid
:
message
=
'Invalid database type, expected Org, ISP or ASNum'
raise
GeoIPError
(
message
)
...
...
pygeoip/const.py
View file @
46902fdd
...
...
@@ -402,16 +402,18 @@ REGION_EDITION_REV0 = 7
REGION_EDITION_REV1
=
3
CITY_EDITION_REV0
=
6
CITY_EDITION_REV1
=
2
CITY_EDITION_REV1_V6
=
30
ORG_EDITION
=
5
ISP_EDITION
=
4
ASNUM_EDITION
=
9
ASNUM_EDITION_V6
=
21
# Not yet supported databases
PROXY_EDITION
=
8
NETSPEED_EDITION
=
11
# Collection of databases
IPV6_EDITIONS
=
(
COUNTRY_EDITION_V6
,)
CITY_EDITIONS
=
(
CITY_EDITION_REV0
,
CITY_EDITION_REV1
)
IPV6_EDITIONS
=
(
COUNTRY_EDITION_V6
,
ASNUM_EDITION_V6
,
CITY_EDITION_REV1_V6
)
CITY_EDITIONS
=
(
CITY_EDITION_REV0
,
CITY_EDITION_REV1
,
CITY_EDITION_REV1_V6
)
REGION_EDITIONS
=
(
REGION_EDITION_REV0
,
REGION_EDITION_REV1
)
REGION_CITY_EDITIONS
=
REGION_EDITIONS
+
CITY_EDITIONS
...
...
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