iwla

iwla Commit Details

Date:2017-09-05 07:34:27 (2 years 10 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:9f9bfebe7a778c362dccdaeae4a4da2979cceecd
Parents: b2f37d83f423fe108e51b1699faeb5188bcdd5f0
Message:ip_to_geo : reset connection after 50 requests

Changes:
Mplugins/post_analysis/iptogeo.py (2 diffs)

File differences

plugins/post_analysis/iptogeo.py
4545
4646
4747
48
48
49
50
4951
5052
5153
5254
5355
56
5457
5558
5659
......
108111
109112
110113
111
114
115
116
117
118
119
120
121
122
123
124
125
126
127
112128
113129
114130
4 : 'Bad IP version',
5 : 'Unsupported IP version',
6 : 'IP not found'}
MAX_REQUESTS = 50
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._nb_requests_sent = 0
self._create_socket()
(cc0, cc1, cc2, cc3) = struct.unpack_from('BBBB', packet, 7*4)
return (ip_res, '%c%c%c%c' % (cc0, cc1, cc2, cc3))
def _send_request(self, packet):
self._nb_requests_sent += 1
if self._nb_requests_sent == self.MAX_REQUESTS:
self.close()
self._create_socket()
self._nb_requests_sent = 0
try:
self._socket.send(packet)
except IOError, e:
# Give another chance (we may have been disconnected due to timeout)
self._create_socket()
self._socket.send(packet)
def ip_to_geo(self, ip):
ip_type = IPToGeo.IPV4
if ip.find('.') >= 0:

Archive Download the corresponding diff file

Branches

Tags