� u��g� � ���dZddlZddlZddlmZmZmZmZmZddl m Z deeee e e e fee e e fee e ffdeee fd�Z dd ee d ee ddfd �Zdeee e fee e e e ffdeeeje feeje e e fffd �Zd ee deee e fee e e e ffddfd �ZdS)z'Utility functions for aiohappyeyeballs.�N)�Dict�List�Optional�Tuple�Union�)� AddrInfoType�addr�returnc��|�dS|d}|d}d|v}|rBd}d}t|��}|dkr|d}|dkr|d}||||f}tj}n||f}tj}|tjtjd|fgS) z7Convert an address tuple to a list of addr_info tuples.Nrr�:����)�len�socket�AF_INET6�AF_INET� SOCK_STREAM� IPPROTO_TCP)r �host�port�is_ipv6�flowinfo�scopeid�addr_len�familys �f/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/aiohappyeyeballs/utils.py�addr_to_addr_infosr s���  �|��t� ��7�D� ��7�D��T�k�G��  ������t�9�9�� �q�=�=��1�g�G� �q�=�=��A�w�H��d�H�g�.�������d�|����� �V�'��);�R�� F� G�G�� addr_infos� interleavec���i}|�d}g}|D]D}|d}||vrd||<|||kr|�|��||xxdz cc<�E|D]}|�|���dS)z� Pop addr_info from the list of addr_infos by family up to interleave times. The interleave parameter is used to know how many addr_infos for each family should be popped of the top of the list. Nrr)�append�remove)r"r#�seen� to_remove� addr_infors r�pop_addr_infos_interleaver*%s����D���� �$&�I���� ��1��� �� � ��D��L� ��<�*� $� $� � � �Y� '� '� '� �V� � � ��� � � � ��%�%� ����)�$�$�$�$�%�%r!c�N�tj|d��g|dd��RS)z+Convert an address tuple to an IPv4Address.rrN)� ipaddress� ip_address)r s r�_addr_tuple_to_ip_addressr.=s,�� � ��a�� )� )� 5�D����H� 5� 5�5r!c�t�g}|D]#}|d|kr|�|���$|r|D]}|�|���dSt|��}|D]0}|t|d��kr|�|���1|r|D]}|�|���dStd|�d����)z� Remove an address from the list of addr_infos. The addr value is typically the return value of sock.getpeername(). �����NzAddress z not found in addr_infos)r%r&r.� ValueError)r"r �bad_addrs_infosr)� bad_addr_info� match_addrs r�remove_addr_infosr5Fs��+-�O��.�.� � �R�=�D� � � � "� "�9� -� -� -����,� -� -�M� � � �m� ,� ,� ,� ,���*�4�0�0�J��.�.� � �2�9�R�=�A�A� A� A� � "� "�9� -� -� -����,� -� -�M� � � �m� ,� ,� ,� ,��� �>��>�>�>� ?� ?�?r!)N)�__doc__r,r�typingrrrrr�typesr �str�intr r*� IPv4Address� IPv6Addressr.r5�r!r�<module>r>s���-�-����� � � � �5�5�5�5�5�5�5�5�5�5�5�5�5�5�������H� � �e�C��c�3�&�'��s�C��}�)=�u�S�#�X��N�O� �H��d�<� �!� H�H�H�H�8AE�%�%��\�"�%�08�� �%� �%�%�%�%�06� ��c�3�h���s�C��c�'9�!:�:� ;�6� � �)� �� $�%�u�Y�-B�C��c�-Q�'R�R��6�6�6�6�@��\�"�@� ��c�3�h���s�C��c�'9�!:�:� ;�@� �@�@�@�@�@�@r!
Memory