o
    j                     @   s.   d dl Z dd Zedkre Zee dS dS )    Nc                  C   s  ddg} dd }i }t dt j}d}t ||}tdD ]^}zt ||}t ||}| D ]}	|||	D ]}
d||
< q5q.W q tyf } z|jd d	krTW Y d}~ n(|jd d
kraW Y d}~q d}~w ty{ } z
t	| W Y d}~qd}~ww t
| S )z
	Returns a list of IP addresses which potentially an active DNS server used by the current machine.
	Please be aware that it's not at all precise!
	
NameServerDhcpNameServerc              
   S   s   zKz*i }t | |\}}t|dkr*|ddkr&|dD ]}d||< qnd||< W n ty= } zW Y d }~nd }~ww W t| S W t| S t|      Y S )Nr   ,)winregQueryValueExlenfindsplit	Exceptionlistkeys)ifacekeynameresultres_xe r   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/winacl/functions/winregistry.pyget_ips
   s$   
$z*get_nameserver_candidates.<locals>.get_ipsNz=System\CurrentControlSet\Services\Tcpip\Parameters\Interfacesi   r      i  )r   ConnectRegistryHKEY_LOCAL_MACHINEOpenKeyrangeEnumKeyOSErrorargsr   printr   r   )keynamesr   ipshklmkeyaKeyiasubkey_namer   r   r   r   r   r   r   get_nameserver_candidates   s6   
r(   __main__)r   r(   __name__r   r    r   r   r   r   <module>   s    -