509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
í«„^¥  ã               @   sZ   d dl Z d dlZd dlmZmZ ddlmZ ddlmZ ddl	m
Z
 G dd„ dee
ƒZdS )	é    N)ÚAF_INETÚAF_INET6é   )ÚMatchContext)ÚNodeconIPVersion)ÚPolicyQueryc                   sh   e Zd ZdZdZdZdZedd„ ƒZej	dd„ ƒZedd„ ƒZ
e
j	d	d„ ƒZ
‡ fd
d„Zdd„ Z‡  ZS )ÚNodeconQueryaI  
    Query nodecon statements.

    Parameter:
    policy          The policy to query.

    Keyword Parameters/Class attributes:
    network         The IPv4/IPv6 address or IPv4/IPv6 network address
                    with netmask, e.g. 192.168.1.0/255.255.255.0 or
                    "192.168.1.0/24".
    network_overlap If true, the net will match if it overlaps with
                    the nodecon's network instead of equality.
    ip_version      The IP version of the nodecon to match. (socket.AF_INET
                    for IPv4 or socket.AF_INET6 for IPv6)
    user            The criteria to match the context's user.
    user_regex      If true, regular expression matching
                    will be used on the user.
    role            The criteria to match the context's role.
    role_regex      If true, regular expression matching
                    will be used on the role.
    type_           The criteria to match the context's type.
    type_regex      If true, regular expression matching
                    will be used on the type.
    range_          The criteria to match the context's range.
    range_subset    If true, the criteria will match if it is a subset
                    of the context's range.
    range_overlap   If true, the criteria will match if it overlaps
                    any of the context's range.
    range_superset  If true, the criteria will match if it is a superset
                    of the context's range.
    range_proper    If true, use proper superset/subset operations.
                    No effect if not using set operations.
    NFc             C   s   | j S )N)Ú_ip_version)Úself© r   ú$/usr/lib64/python3.6/nodeconquery.pyÚ
ip_versionF   s    zNodeconQuery.ip_versionc             C   s   |rt j|ƒ| _nd | _d S )N)r   Úlookupr	   )r
   Úvaluer   r   r   r   J   s    c             C   s   | j S )N)Ú_network)r
   r   r   r   ÚnetworkQ   s    zNodeconQuery.networkc             C   s   |rt j|ƒ| _nd | _d S )N)Ú	ipaddressZ
ip_networkr   )r
   r   r   r   r   r   U   s    c                s$   t t| ƒj|f|Ž tjtƒ| _d S )N)Úsuperr   Ú__init__ÚloggingZ	getLoggerÚ__name__Úlog)r
   ÚpolicyÚkwargs)Ú	__class__r   r   r   \   s    zNodeconQuery.__init__c             c   s®   | j jdj| ƒƒ | j jdj| ƒƒ | j jdj| ƒƒ | j| j ƒ xf| jjƒ D ]X}| jr~| jrp| jj	|jƒs~qNn|j| jks~qN| j
r’| j
|j
kr’qN| j|jƒs qN|V  qNW dS )z-Generator which yields all matching nodecons.z*Generating nodecon results from {0.policy}z4Network: {0.network!r}, overlap: {0.network_overlap}zIP Version: {0.ip_version!r}N)r   ÚinfoÚformatÚdebugZ_match_context_debugr   Znodeconsr   Únetwork_overlapZoverlapsr   Z_match_contextÚcontext)r
   Znodeconr   r   r   Úresults`   s     zNodeconQuery.results)r   Ú
__module__Ú__qualname__Ú__doc__r   r   r	   Úpropertyr   Úsetterr   r   r    Ú__classcell__r   r   )r   r   r      s   "r   )r   r   Zsocketr   r   Zmixinsr   Z	policyrepr   Zqueryr   r   r   r   r   r   Ú<module>   s   