Your IP : 3.138.60.175
3
���f+ � @ sX d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZG dd� de �Z
dS )� )�OrderedDictNc @ sl e Zd ZdZddddddd�Zd d
� Zdd� Zddd�Zdd� Zdd� Z dd� Z
dd� Zdd� Zdd� Z
dS )�rndczRNDC protocol client library� � � � � � )�md5Zsha1Zsha224Zsha256Zsha384Zsha512c C sb || _ |j� }|jd�r$|dd� }|| _tt|�| _tj|�| _ t
jdd�| _d| _
| j� dS )z�Creates a persistent connection to RNDC and logs in
host - (ip, port) tuple
algo - HMAC algorithm: one of md5, sha1, sha224, sha256, sha384, sha512
(with optional prefix 'hmac-')
secret - HMAC secret, base64 encodedzhmac-� Nr � � i )�host�lower�
startswith�algo�getattr�hashlib�hlalgo�base64� b64decode�secret�randomZrandint�ser�nonce�_rndc__connect_login)�selfr r r � r �/usr/lib/python3.6/rndc.py�__init__$ s
z
rndc.__init__c C s t | j|d�d �S )z�Call a RNDC command, all parsing is done on the server side
cmd - a complete string with a command (eg 'reload zone example.com')
)�type�_data)�dict�_rndc__command)r �cmdr r r �call5 s z rndc.callFc C s t � }�x |j� D ]�\}}|r(|dkr(q|tjdt|��|jd� 7 }t|�tkrt|tjddt|��|jd� 7 }qt|�tkr�|tjddt|��| 7 }qt|�t kr�|tjddt|��| 7 }qt|�t kr�| j
|�}|tjddt|��| 7 }qtdt|� ��qW |S )N�_auth�B�asciiz>BIr � z#Cannot serialize element of type %s)� bytearray�items�struct�pack�len�encoder �str�bytesr �_rndc__serialize_dict�NotImplementedError)r �data�ignore_auth�rv�k�vZsdr r r Z__serialize_dict; s"