o
    Û1j  ã                   @   s4   d dl Z d dlmZ d dlmZ G dd„ deƒZdS )é    N)ÚSoSCleanerParser)Ú
SoSIPv6Mapc                       sd   e Zd ZdZdZdZe dej¡Z	e d¡Z
ddgZdZ‡ fd	d
„Zg f‡ fdd„	Zdd„ Z‡  ZS )ÚSoSIPv6Parserz/Parser for handling IPv6 networks and addresseszIPv6 ParserÚipv6_mapz::|[0-9a-f]{1,4}:[0-9a-f]{1,4}:zÏ(?<![:\\.\\-a-zA-Z0-9])((([0-9a-fA-F]{1,4})(:[0-9a-fA-F]{1,4}){7})|(([0-9a-fA-F]{1,4}(:[0-9a-fA-F]{0,4}){0,5}))([^.])::(([0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){0,5})?)(\/\d{1,3})?)(?!([a-zA-Z0-9]|:[a-zA-Z0-9]))zetc/dnsmasq.conf.*z.*modinfo.*Fc                    s    | j  |¡s
|dfS tƒ  |¡S )Nr   )Ú_quick_checkÚsearchÚsuperÚ_parse_line)ÚselfÚline©Ú	__class__© úA/usr/lib/python3/dist-packages/sos/cleaner/parsers/ipv6_parser.pyr	   /   s   zSoSIPv6Parser._parse_linec                    s    t || jƒ| _tƒ  ||¡ d S )N)r   Úregex_patternÚmappingr   Ú__init__)r
   ÚconfigÚworkdirÚskip_cleaning_filesr   r   r   r   4   s   zSoSIPv6Parser.__init__c                 C   sj   | j ji dœ}| j j ¡ D ]%\}}|ji dœ|d |j< |jD ]}|j| }||d |j d |< qq|S )zsStructure the dataset contents properly so that they can be reloaded
        on subsequent runs correctly.
        )ÚversionÚnetworks)Ú
obfuscatedÚhostsr   r   )r   r   r   ÚitemsÚobfuscated_addressÚoriginal_addressr   )r
   Ú_dÚ_Ú_netÚhostÚ_ob_hostr   r   r   Úget_map_contents8   s   þþ

þzSoSIPv6Parser.get_map_contents)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚmap_file_keyÚreÚcompileÚIr   r   Úparser_skip_filesÚcompile_regexesr	   r   r"   Ú__classcell__r   r   r   r   r      s"    ÿøþr   )r)   Úsos.cleaner.parsersr   Úsos.cleaner.mappings.ipv6_mapr   r   r   r   r   r   Ú<module>   s   
