Main key for visits is now remote_ip and not remote_addr

This commit is contained in:
Gregory Soutade 2023-05-21 11:04:40 +02:00
parent 7507b8e77f
commit 7ef0911fa7
11 changed files with 28 additions and 27 deletions

15
iwla.py
View File

@ -92,7 +92,7 @@ days_stats :
nb_visitors nb_visitors
visits : visits :
remote_addr => remote_ip =>
remote_addr remote_addr
remote_ip remote_ip
viewed_pages{0..31} # 0 contains total viewed_pages{0..31} # 0 contains total
@ -323,22 +323,22 @@ class IWLA(object):
return hit['robot'] == True return hit['robot'] == True
def _appendHit(self, hit): def _appendHit(self, hit):
remote_addr = hit['remote_addr'] remote_ip = hit['remote_ip']
if not remote_addr: return if not remote_ip: return
for ip in self.excluded_ip: for ip in self.excluded_ip:
if ip.match(remote_addr): if ip.match(remote_ip):
return return
# Redirected page/hit # Redirected page/hit
if int(hit['status']) in (301, 302, 307, 308): if int(hit['status']) in (301, 302, 307, 308):
return return
if not remote_addr in self.current_analysis['visits'].keys(): if not remote_ip in self.current_analysis['visits'].keys():
self._createVisitor(hit) self._createVisitor(hit)
super_hit = self.current_analysis['visits'][remote_addr] super_hit = self.current_analysis['visits'][remote_ip]
# Don't keep all requests for robots # Don't keep all requests for robots
if not super_hit['robot']: if not super_hit['robot']:
super_hit['requests'].append(hit) super_hit['requests'].append(hit)
@ -424,6 +424,9 @@ class IWLA(object):
hit['extract_referer'] = referer_groups.groupdict("") hit['extract_referer'] = referer_groups.groupdict("")
hit['extract_referer']['extract_uri'] = self._normalizeURI(hit['extract_referer']['extract_uri'], True) hit['extract_referer']['extract_uri'] = self._normalizeURI(hit['extract_referer']['extract_uri'], True)
hit['extract_referer']['extract_parameters'] = self._normalizeParameters(hit['extract_referer']['extract_parameters']) hit['extract_referer']['extract_parameters'] = self._normalizeParameters(hit['extract_referer']['extract_parameters'])
hit['remote_ip'] = hit['remote_addr']
return True return True
def _decodeTime(self, hit): def _decodeTime(self, hit):

View File

@ -71,15 +71,14 @@ class IWLADisplayAllVisits(IPlugin):
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', '']) table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', ''])
for super_hit in last_access: for super_hit in last_access:
address = super_hit['remote_addr']
row = [ row = [
address, super_hit['remote_addr'],
super_hit['viewed_pages'][0], super_hit['viewed_pages'][0],
super_hit['viewed_hits'][0], super_hit['viewed_hits'][0],
super_hit['bandwidth'][0], super_hit['bandwidth'][0],
time.asctime(super_hit['last_access']) time.asctime(super_hit['last_access'])
] ]
table.appendRow(row, address) table.appendRow(row, super_hit['remote_ip'])
page.appendBlock(table) page.appendBlock(table)
display.addPage(page) display.addPage(page)

View File

@ -71,9 +71,9 @@ class IWLADisplayAllVisitsEnlight(IPlugin):
return return
for (idx, row) in enumerate(block.rows): for (idx, row) in enumerate(block.rows):
remote_addr = block.objects[idx] remote_ip = block.objects[idx]
if remote_addr is None or not remote_addr in visitors.keys(): continue if remote_ip is None or not remote_ip in visitors.keys(): continue
visitor = visitors[remote_addr] visitor = visitors[remote_ip]
if visitor.get('enlight', False) or\ if visitor.get('enlight', False) or\
visitor.get('filtered', False): visitor.get('filtered', False):
block.setCellCSSClass(idx, 0, 'iwla_enlight') block.setCellCSSClass(idx, 0, 'iwla_enlight')

View File

@ -105,7 +105,7 @@ class IWLADisplayFilterUsers(IPlugin):
referer = '' referer = ''
uri = "%s%s" % (r.get('server_name', ''), uri = "%s%s" % (r.get('server_name', ''),
r['extract_request']['extract_uri']) r['extract_request']['extract_uri'])
table.appendRow([generateHTMLLink(uri), time.asctime(r['time_decoded']), r['http_user_agent'], referer], filtered_user['remote_addr']) table.appendRow([generateHTMLLink(uri), time.asctime(r['time_decoded']), r['http_user_agent'], referer], filtered_user['remote_ip'])
page.appendBlock(table) page.appendBlock(table)
display.addPage(page) display.addPage(page)
@ -121,8 +121,7 @@ class IWLADisplayFilterUsers(IPlugin):
table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Last Access')]) table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Last Access')])
table.setColsCSSClass(['', '', 'iwla_page', 'iwla_hit']) table.setColsCSSClass(['', '', 'iwla_page', 'iwla_hit'])
for filtered_user in self.filtered_users[:10]: for filtered_user in self.filtered_users[:10]:
ip_title = filtered_user['remote_ip'] table.appendRow([filtered_user['remote_addr'], filtered_user['viewed_pages'][0], filtered_user['viewed_hits'][0], time.asctime(filtered_user['last_access'])], filtered_user['remote_ip'])
table.appendRow([ip_title, filtered_user['viewed_pages'][0], filtered_user['viewed_hits'][0], time.asctime(hits[ip]['last_access'])], filtered_user['remote_addr'])
if len(self.filtered_users) > 10: if len(self.filtered_users) > 10:
table.appendRow([self.iwla._(u'Others'), len(self.filtered_users)-10, '', '']) table.appendRow([self.iwla._(u'Others'), len(self.filtered_users)-10, '', ''])
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')

View File

@ -64,10 +64,10 @@ class IWLADisplayIPToGeo(IPlugin):
return True return True
@staticmethod # Needed to have unbound method @staticmethod # Needed to have unbound method
def FlagFilter(host, remote_addr, self): def FlagFilter(host, remote_ip, self):
if remote_addr is None or not remote_addr in self.visitors.keys(): if remote_ip is None or not remote_ip in self.visitors.keys():
return None return None
visitor = self.visitors[remote_addr] visitor = self.visitors[remote_ip]
cc = visitor.get('country_code', None) cc = visitor.get('country_code', None)
if not cc: return None if not cc: return None
icon = '<img alt="%s flag" src="/%s/flags/%s.png"/>' % (cc, self.icon_path, cc) icon = '<img alt="%s flag" src="/%s/flags/%s.png"/>' % (cc, self.icon_path, cc)

View File

@ -82,7 +82,7 @@ class IWLADisplayTopVisitors(IPlugin):
total[1] -= super_hit['viewed_pages'][0] total[1] -= super_hit['viewed_pages'][0]
total[2] -= super_hit['viewed_hits'][0] total[2] -= super_hit['viewed_hits'][0]
total[3] -= super_hit['bandwidth'][0] total[3] -= super_hit['bandwidth'][0]
table.appendRow(row, super_hit['remote_addr']) table.appendRow(row, super_hit['remote_ip'])
if total[1] or total[2] or total[3]: if total[1] or total[2] or total[3]:
total[0] = self.iwla._(u'Others') total[0] = self.iwla._(u'Others')
total[4] = '' total[4] = ''

View File

@ -39,7 +39,7 @@ Output files :
Statistics creation : Statistics creation :
visits : visits :
remote_addr => remote_ip =>
browser browser
month_stats : month_stats :
@ -99,7 +99,7 @@ class IWLAPostAnalysisBrowsers(IPlugin):
for (k, super_hit) in stats.items(): for (k, super_hit) in stats.items():
if not 'browser' in super_hit: if not 'browser' in super_hit:
for r in super_hit['requests'][::-1]: for r in super_hit['requests']:
user_agent = r['http_user_agent'] user_agent = r['http_user_agent']
if not user_agent: continue if not user_agent: continue

View File

@ -45,7 +45,7 @@ Output files :
None None
Statistics creation : Statistics creation :
remote_addr => remote_ip =>
feed_parser feed_parser
feed_name_analysed feed_name_analysed
feed_parser_last_access (for merged parser) feed_parser_last_access (for merged parser)

View File

@ -66,13 +66,13 @@ Output files :
Statistics creation : Statistics creation :
visits : visits :
remote_addr => remote_ip =>
filtered filtered
geo_location geo_location
Statistics update : Statistics update :
visits : visits :
remote_addr => remote_ip =>
keep_requests keep_requests
Statistics deletion : Statistics deletion :
@ -92,7 +92,7 @@ class IWLAPostAnalysisFilterUsers(IPlugin):
raise Exception('Bad filter ' + ' '.join(_filter)) raise Exception('Bad filter ' + ' '.join(_filter))
except Exception as e: except Exception as e:
if field == 'ip': if field == 'ip':
_filter[0] = 'remote_addr' _filter[0] = 'remote_ip'
if operator not in ('=', '==', '!=', 'in', 'match'): if operator not in ('=', '==', '!=', 'in', 'match'):
raise Exception('Bad filter ' + ' '.join(_filter)) raise Exception('Bad filter ' + ' '.join(_filter))
if operator == 'match': if operator == 'match':

View File

@ -39,7 +39,7 @@ Output files :
Statistics creation : Statistics creation :
visits : visits :
remote_addr => remote_ip =>
ip_type ip_type
month_stats : month_stats :

View File

@ -41,7 +41,7 @@ Output files :
Statistics creation : Statistics creation :
visits : visits :
remote_addr => remote_ip =>
operating_system operating_system
month_stats : month_stats :