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
f3b8087f
Commit
f3b8087f
authored
Nov 16, 2013
by
William Tisäter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add alias methods for ISP and ASN lookup
parent
1583506f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
10 deletions
+15
-10
README.md
+2
-2
pygeoip/__init__.py
+5
-0
tests/test_asnum.py
+4
-4
tests/test_isp.py
+4
-4
No files found.
README.md
View file @
f3b8087f
...
...
@@ -95,7 +95,7 @@ Create your GeoIP instance with appropriate access flag. `STANDARD` reads data f
```
python
>>>
gi
=
pygeoip
.
GeoIP
(
'/path/to/GeoIPISP.dat'
)
>>>
gi
.
org
_by_name
(
'cnn.com'
)
>>>
gi
.
isp
_by_name
(
'cnn.com'
)
'Turner Broadcasting System'
```
...
...
@@ -103,7 +103,7 @@ Create your GeoIP instance with appropriate access flag. `STANDARD` reads data f
```
python
>>>
gi
=
pygeoip
.
GeoIP
(
'/path/to/GeoIPASNum.dat'
)
>>>
gi
.
org
_by_name
(
'cnn.com'
)
>>>
gi
.
asn
_by_name
(
'cnn.com'
)
'AS5662 Turner Broadcasting'
```
...
...
pygeoip/__init__.py
View file @
f3b8087f
...
...
@@ -574,6 +574,11 @@ class GeoIP(object):
addr
=
self
.
_gethostbyname
(
hostname
)
return
self
.
org_by_addr
(
addr
)
isp_by_addr
=
org_by_addr
isp_by_name
=
org_by_name
asn_by_addr
=
org_by_addr
asn_by_name
=
org_by_name
def
record_by_addr
(
self
,
addr
):
"""
Look up the record for a given IP address.
...
...
tests/test_asnum.py
View file @
f3b8087f
...
...
@@ -19,15 +19,15 @@ class TestGeoIPASNumFunctions(unittest.TestCase):
self
.
gia
=
pygeoip
.
GeoIP
(
ASNUM_DB_PATH
)
def
testOrgByAddr
(
self
):
gb_as
=
self
.
gia
.
org
_by_addr
(
self
.
gb_ip
)
us_as
=
self
.
gia
.
org
_by_addr
(
self
.
us_ip
)
gb_as
=
self
.
gia
.
asn
_by_addr
(
self
.
gb_ip
)
us_as
=
self
.
gia
.
asn
_by_addr
(
self
.
us_ip
)
self
.
assertEqual
(
gb_as
,
self
.
gb_as
)
self
.
assertEqual
(
us_as
,
self
.
us_as
)
def
testOrgByName
(
self
):
gb_as
=
self
.
gia
.
org
_by_name
(
self
.
gb_hostname
)
us_as
=
self
.
gia
.
org
_by_name
(
self
.
us_hostname
)
gb_as
=
self
.
gia
.
asn
_by_name
(
self
.
gb_hostname
)
us_as
=
self
.
gia
.
asn
_by_name
(
self
.
us_hostname
)
self
.
assertEqual
(
gb_as
,
self
.
gb_as
)
self
.
assertEqual
(
us_as
,
self
.
us_as
)
...
...
tests/test_isp.py
View file @
f3b8087f
...
...
@@ -18,15 +18,15 @@ class TestGeOIPISPFunctions(unittest.TestCase):
self
.
gi
=
pygeoip
.
GeoIP
(
ISP_DB_PATH
)
def
testISPByAddr
(
self
):
se_isp
=
self
.
gi
.
org
_by_addr
(
self
.
se_ip
)
us_isp
=
self
.
gi
.
org
_by_addr
(
self
.
us_ip
)
se_isp
=
self
.
gi
.
isp
_by_addr
(
self
.
se_ip
)
us_isp
=
self
.
gi
.
isp
_by_addr
(
self
.
us_ip
)
self
.
assertEqual
(
se_isp
,
self
.
se_isp
)
self
.
assertEqual
(
us_isp
,
self
.
us_isp
)
def
testISPByName
(
self
):
se_isp
=
self
.
gi
.
org
_by_name
(
self
.
se_hostname
)
us_isp
=
self
.
gi
.
org
_by_name
(
self
.
us_hostname
)
se_isp
=
self
.
gi
.
isp
_by_name
(
self
.
se_hostname
)
us_isp
=
self
.
gi
.
isp
_by_name
(
self
.
us_hostname
)
self
.
assertEqual
(
se_isp
,
self
.
se_isp
)
self
.
assertEqual
(
us_isp
,
self
.
us_isp
)
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