
    |;i                    H    d Z ddlmZ ddlmZmZ ddlmZ eZ	 G d d      Z
y)	a  Multicast DNS Service Discovery for Python, v0.14-wmcbrine
Copyright 2003 Paul Scott-Murphy, 2014 William McBrine

This module provides a framework for the use of DNS Service Discovery
using IP multicast.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
    )annotations   )DNSQuestion	DNSRecord)_DUPLICATE_QUESTION_INTERVALc                  8    e Zd ZdZddZd	dZd
dZddZddZy)QuestionHistoryz%Remember questions and known answers.c                    i | _         y)zInit a new QuestionHistory.N_historyselfs    D/home/ubuntu/myenv/lib/python3.12/site-packages/zeroconf/_history.py__init__zQuestionHistory.__init__%   s	    IK    c                &    ||f| j                   |<   y)z'Remember a question with known answers.Nr   )r   questionnowknown_answerss       r   add_question_at_timez$QuestionHistory.add_question_at_time)   s    #&"6hr   c                n    | j                   j                  |      }|sy|\  }}||z
  t        kD  ry||z
   S )a/  Check to see if a question should be suppressed.

        https://datatracker.ietf.org/doc/html/rfc6762#section-7.3
        When multiple queriers on the network are querying
        for the same resource records, there is no need for them to all be
        repeatedly asking the same question.
        F)r   getr   )r   r   r   r   previous_questionthanprevious_known_answerss          r   
suppresseszQuestionHistory.suppresses-   sJ     !MM--h7 '8$$:44 *M999r   c                    g }| j                   j                         D ](  \  }}|\  }}||z
  t        kD  s|j                  |       * |D ]  }| j                   |=  y)z$Expire the history of old questions.N)r   itemsr   append)r   r   removesr   now_known_answersr   _s          r   async_expirezQuestionHistory.async_expireA   sh    %'+/==+>+>+@ 	)'H''GD!Tz88x(	)   	(Hh'	(r   c                8    | j                   j                          y)zClear the history.N)r   clearr   s    r   r%   zQuestionHistory.clearK   s    r   N)returnNone)r   r   r   _floatr   set[DNSRecord]r&   r'   )r   r   r   r(   r   r)   r&   bool)r   r(   r&   r'   )	__name__
__module____qualname____doc__r   r   r   r#   r%    r   r   r	   r	   "   s    /L7:((r   r	   N)r.   
__future__r   _dnsr   r   constr   floatr(   r	   r/   r   r   <module>r4      s&   , # ( /
 
+ +r   