Fixed udp source filtering
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Fri, 25 Jun 2010 10:01:21 +0000 (10:01 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Fri, 25 Jun 2010 10:01:21 +0000 (10:01 +0000)
bin/common.py
bin/inputs/udp.py
bin/ntools.py

index c322f12ab57a5872c3f5799af7d3c6f699080285..aec42f458e2d8e2607a878e08ee3afeee9e30893 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
+
 __all__ = [
     'DB_STARTDATE', 'DBPATH',
     'COUNTRIES_MID', 'STATUS_CODES', 'SHIP_TYPES',
index 9eaf91c77b62690e576d53d9ae0cc23345b0c3ec..373dba3d4b406ebdc1cfb2baec9cde16944a5d8b 100644 (file)
@@ -85,6 +85,7 @@ class UdpService(Service):
         separated decoding channels.
         '''
         addr, port = recv_from_info[:2]
+        addr = formataddr(addr)
         rhostrport2id4sdisc = self.rhostrport2id4sdisc
         id4, sdisc = rhostrport2id4sdisc.get((addr, port), (None, None))
         if id4:
index 9cb5e45debf6d4885c9852cfabb18157e47b1802..5e5b8df7eb42633ef3c52dafb4e2dbc1cd2f7cf9 100644 (file)
@@ -1,8 +1,25 @@
 # -*- coding: utf-8 -*-
 
+__all__ = [
+    'IPV4_IN_IPV6_PREFIX',
+    'datetime_to_timestamp',
+    'clean_ais_charset',
+    'clean_alnum',
+    'clean_alnum_unicode',
+    'open_with_mkdirs',
+    'logliner',
+    'dumpsource',
+    'xml_escape',
+    'alarm',
+    'str_split_column_ipv6',
+    'formataddr',
+    ]
+
 import os
 import calendar
 
+IPV4_IN_IPV6_PREFIX = '::ffff:'
+
 def datetime_to_timestamp(dt):
     return calendar.timegm(dt.utctimetuple())
 
@@ -11,7 +28,7 @@ def clean_ais_charset(txt):
     result = ''
     for c in txt:
         oc = ord(c)
-        if oc<32 or oc >95:
+        if oc < 32 or oc > 95:
             result += ''
         else:
             result += c
@@ -21,7 +38,7 @@ def clean_alnum(txt):
     assert isinstance(txt, str)
     result = ''
     for c in txt:
-        if ( c>='0' and c<='9' ) or ( c>='A' and c<='Z' ):
+        if ( c >= '0' and c <= '9' ) or ( c >= 'A' and c <= 'Z' ):
             result += c
     return result
 
@@ -84,7 +101,8 @@ def str_split_column_ipv6(txt):
 
 
 def formataddr(addr):
-    if addr.startswith('::ffff:'):
+    # FIXME: don't do that if address is IPv4
+    if addr.startswith(IPV4_IN_IPV6_PREFIX):
         return addr[7:]
     else:
         return '['+addr+']'