File: //usr/lib/python3/dist-packages/samba/tests/__pycache__/dns_packet.cpython-310.pyc
o
�/a� � @ s� d Z ddlZddlZddlZddlZddlmZmZ ddlm Z dd� Z
ejd Zejd � d ejd
� �Z
dZdd
� ZG dd� de �ZG dd� de�ZG dd� de�ZdS )ztSanity tests for DNS and NBT server parsing.
We don't use a proper client library so we can make improper packets.
� N)�dns�nbt)�TestCasec c s � t dd�D ]} | V qq)NT� i�� )�range)�i� r �8/usr/lib/python3/dist-packages/samba/tests/dns_packet.py�_msg_id! s
��r
� SERVER_IP�SERVER�.�REALMg �?c C sJ g }| d dd� } | D ]}|� |d? d � |� |d@ d � qt|�S )zEEven RFC 1002 uses distancing quotes when calling this "compression".s N� � �A � )�append�bytes)�chars�out�cr r r �encode_netbios_bytes, s r c @ sD e Zd Ze� Zdd� Zdd� Zdd� Zdd d
�Zdd� Z d
d� Z
dS )�TestDnsPacketBasec C s8 t d�D ]}| �� }|r d S qtddt � d�� d S )N�( z'the server is STILL unresponsive after z seconds)r �_known_good_query�print�TIMEOUT)�selfr �okr r r �tearDown9 s �zTestDnsPacketBase.tearDownc C s0 |d d� }t �d|�\}}}}}}d|d@ iS )N� �!6H�rcoder )�struct�unpack) r �data�header�id�flags�n_q�n_a�n_rec�n_extar r r �decode_replyB s ��zTestDnsPacketBase.decode_replyc C s� t �dt| j�dt|�ddd�}t �dd| jd�}g }|D ]'}t|t�r-|�d�� d�}n|}|D ]
}|�
dt|�|f � q1|�
|� q|d �|� S )
a� Create a query packet containing one query record.
*names* is either a single string name in the usual dotted
form, or a list of names. In the latter case, each name can
be a dotted string or a list of byte components, which allows
dots in components. Where I say list, I mean non-string
iterable.
Examples:
# these 3 are all the same
"example.com"
["example.com"]
[[b"example", b"com"]]
# this is three names in the same request
["example.com",
[b"example", b"com", b"..!"],
(b"first component", b" 2nd component")]
r"