File: //lib64/python3.6/site-packages/zmq/auth/__pycache__/base.cpython-36.pyc
3
VS�_�9 � @ st d Z ddlZddlZddlmZ ddlmZmZmZm Z ddl
mZ ddlm
Z
dZd ZG d
d� de�ZddgZdS )
z*Base implementation of 0MQ authentication.� N)�z85)�bytes�unicode�b�u)�_check_version� )�load_certificates�*s 1.0c @ s� e Zd ZdZd$dd�Zdd� Zdd � Zd
d� Zdd
� Zd%dd�Z d&dd�Z
d'dd�Zdd� Zd(dd�Z
dd� Zdd� Zdd� Zdd � Zd)d"d#�ZdS )*�
Authenticatora� Implementation of ZAP authentication for zmq connections.
Note:
- libzmq provides four levels of security: default NULL (which the Authenticator does
not see), and authenticated NULL, PLAIN, CURVE, and GSSAPI, which the Authenticator can see.
- until you add policies, all incoming NULL connections are allowed.
(classic ZeroMQ behavior), and all PLAIN and CURVE connections are denied.
- GSSAPI requires no configuration.
N�utf-8c C sb t dd� |ptjj� | _|| _d| _i | _d | _t � | _
t � | _i | _i | _
|pZtjd�| _d S )N� r ZsecurityFzzmq.auth)r
r )r �zmqZContext�instance�context�encoding� allow_any�credentials_providers�
zap_socket�set� whitelist� blacklist� passwords�certs�loggingZ getLogger�log)�selfr r r � r �/usr/lib64/python3.6/base.py�__init__ s
zAuthenticator.__init__c C s4 | j jtj�| _d| j_| jjd� | jjd� dS )zCreate and bind the ZAP socketr zinproc://zeromq.zap.01ZStartingN) r Zsocketr ZREPr ZlingerZbindr �debug)r r r r �start0 s zAuthenticator.startc C s | j r| j j� d| _ dS )zClose the ZAP socketN)r �close)r r r r �stop7 s
zAuthenticator.stopc G s2 | j rtd��| jjddj|�� | jj|� dS )aa Allow (whitelist) IP address(es).
Connections from addresses not in the whitelist will be rejected.
- For NULL, all clients from this address will be accepted.
- For real auth setups, they will be allowed to continue with authentication.
whitelist is mutually exclusive with blacklist.
z-Only use a whitelist or a blacklist, not bothzAllowing %s�,N)r �
ValueErrorr r �joinr �update)r � addressesr r r �allow= s
zAuthenticator.allowc G s2 | j rtd��| jjddj|�� | jj|� dS )z�Deny (blacklist) IP address(es).
Addresses not in the blacklist will be allowed to continue with authentication.
Blacklist is mutually exclusive with whitelist.
z-Only use a whitelist or a blacklist, not bothz
Denying %sr$ N)r r% r r r&