IP to Geo

IP to Geo Commit Details

Date:2016-02-17 18:15:04 (4 years 8 months ago)
Author:Grégory Soutadé
Branch:master
Commit:501e5b2acfb82c9a5d2fe781a481e7b40fccca82
Parents: 2456039df1ee518705bdeec8a7157b1257bc2011
Message:Add IPv6 to tests

Changes:
Mtests/iptogeo.py (1 diff)
Mtests/test_ip_to_geo.py (1 diff)

File differences

tests/iptogeo.py
4646
4747
4848
49
49
5050
5151
5252
53
53
54
5455
5556
5657
57
58
5859
5960
6061
5 : 'Unsupported IP version',
6 : 'IP not found'}
def __init__(self, remote_addr='127.0.0.1', remote_port=53333, timeout=None):
def __init__(self, remote_addr='127.0.0.1', remote_port=53333, timeout=None, family=socket.AF_INET):
self._remote_addr = remote_addr
self._remote_port = remote_port
self._timeout = timeout
self._family = family
self._create_socket()
def _create_socket(self):
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket = socket.socket(self._family, socket.SOCK_STREAM)
if not self._timeout is None:
self._socket.settimeout(self._timeout)
self._socket.connect((self._remote_addr, self._remote_port))
tests/test_ip_to_geo.py
22
33
44
5
6
57
68
79
810
911
10
12
1113
1214
1315
# -*- coding: utf-8
import os
import sys
import socket
from iptogeo import IPToGeo, IPToGeoException
TIMEOUT = None
# TIMEOUT = 5.0
iptogeo = IPToGeo(timeout=TIMEOUT)
iptogeo = IPToGeo(timeout=TIMEOUT, family=socket.AF_INET6, remote_addr='::1')
def get_random_ip_v4():
ip = '%d.%d.%d.%d' % \

Archive Download the corresponding diff file

Branches

Tags