| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,7 @@ | |||
| 42 | 42 | _UNIQUE_RECORD_TYPES = (DNSAddress, DNSHinfo, DNSPointer, DNSText, DNSService) | |
| 43 | 43 | _UniqueRecordsType = DNSAddress | DNSHinfo | DNSPointer | DNSText | DNSService | |
| 44 | 44 | _DNSRecordCacheType = dict[str, dict[DNSRecord, DNSRecord]] | |
| 45 | + _UniqueType = tuple[str, int, int] | ||
| 45 | 46 | _DNSRecord = DNSRecord | |
| 46 | 47 | _str = str | |
| 47 | 48 | _float = float | |
@@ -324,7 +325,7 @@ def names(self) -> list[str]: | |||
| 324 | 325 | ||
| 325 | 326 | def async_mark_unique_records_older_than_1s_to_expire( | |
| 326 | 327 | self, | |
| 327 | - unique_types: set[tuple[_str, _int, _int]], | ||
| 328 | + unique_types: set[_UniqueType], | ||
| 328 | 329 | answers: Iterable[DNSRecord], | |
| 329 | 330 | now: _float, | |
| 330 | 331 | ) -> None: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,7 +96,6 @@ cdef class QueryHandler: | |||
| 96 | 96 | question=DNSQuestion, | |
| 97 | 97 | answer_set=cython.dict, | |
| 98 | 98 | known_answers=DNSRRSet, | |
| 99 | - known_answers_set=cython.set, | ||
| 100 | 99 | is_unicast=bint, | |
| 101 | 100 | is_probe=object, | |
| 102 | 101 | now=double | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,6 +61,8 @@ | |||
| 61 | 61 | ||
| 62 | 62 | _int = int | |
| 63 | 63 | _str = str | |
| 64 | + _ServiceInfo = ServiceInfo | ||
| 65 | + _DNSIncoming = DNSIncoming | ||
| 64 | 66 | ||
| 65 | 67 | _ANSWER_STRATEGY_SERVICE_TYPE_ENUMERATION = 0 | |
| 66 | 68 | _ANSWER_STRATEGY_POINTER = 1 | |
@@ -212,7 +214,7 @@ def __init__(self, zc: Zeroconf) -> None: | |||
| 212 | 214 | ||
| 213 | 215 | def _add_service_type_enumeration_query_answers( | |
| 214 | 216 | self, | |
| 215 | - types: list[str], | ||
| 217 | + types: list[_str], | ||
| 216 | 218 | answer_set: _AnswerWithAdditionalsType, | |
| 217 | 219 | known_answers: DNSRRSet, | |
| 218 | 220 | ) -> None: | |
@@ -234,7 +236,7 @@ def _add_service_type_enumeration_query_answers( | |||
| 234 | 236 | ||
| 235 | 237 | def _add_pointer_answers( | |
| 236 | 238 | self, | |
| 237 | - services: list[ServiceInfo], | ||
| 239 | + services: list[_ServiceInfo], | ||
| 238 | 240 | answer_set: _AnswerWithAdditionalsType, | |
| 239 | 241 | known_answers: DNSRRSet, | |
| 240 | 242 | ) -> None: | |
@@ -253,7 +255,7 @@ def _add_pointer_answers( | |||
| 253 | 255 | ||
| 254 | 256 | def _add_address_answers( | |
| 255 | 257 | self, | |
| 256 | - services: list[ServiceInfo], | ||
| 258 | + services: list[_ServiceInfo], | ||
| 257 | 259 | answer_set: _AnswerWithAdditionalsType, | |
| 258 | 260 | known_answers: DNSRRSet, | |
| 259 | 261 | type_: _int, | |
@@ -284,8 +286,8 @@ def _answer_question( | |||
| 284 | 286 | self, | |
| 285 | 287 | question: DNSQuestion, | |
| 286 | 288 | strategy_type: _int, | |
| 287 | - types: list[str], | ||
| 288 | - services: list[ServiceInfo], | ||
| 289 | + types: list[_str], | ||
| 290 | + services: list[_ServiceInfo], | ||
| 289 | 291 | known_answers: DNSRRSet, | |
| 290 | 292 | ) -> _AnswerWithAdditionalsType: | |
| 291 | 293 | """Answer a question.""" | |
@@ -313,7 +315,7 @@ def _answer_question( | |||
| 313 | 315 | return answer_set | |
| 314 | 316 | ||
| 315 | 317 | def async_response( # pylint: disable=unused-argument | |
| 316 | - self, msgs: list[DNSIncoming], ucast_source: bool | ||
| 318 | + self, msgs: list[_DNSIncoming], ucast_source: bool | ||
| 317 | 319 | ) -> QuestionAnswers | None: | |
| 318 | 320 | """Deal with incoming query packets. Provides a response if possible. | |
| 319 | 321 | ||
@@ -435,7 +437,7 @@ def _get_answer_strategies( | |||
| 435 | 437 | ||
| 436 | 438 | def handle_assembled_query( | |
| 437 | 439 | self, | |
| 438 | - packets: list[DNSIncoming], | ||
| 440 | + packets: list[_DNSIncoming], | ||
| 439 | 441 | addr: _str, | |
| 440 | 442 | port: _int, | |
| 441 | 443 | transport: _WrappedTransport, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,8 @@ | |||
| 37 | 37 | from .._core import Zeroconf | |
| 38 | 38 | ||
| 39 | 39 | _float = float | |
| 40 | + _RecordUpdate = RecordUpdate | ||
| 41 | + _DNSQuestion = DNSQuestion | ||
| 40 | 42 | ||
| 41 | 43 | ||
| 42 | 44 | class RecordManager: | |
@@ -50,7 +52,7 @@ def __init__(self, zeroconf: Zeroconf) -> None: | |||
| 50 | 52 | self.cache = zeroconf.cache | |
| 51 | 53 | self.listeners: set[RecordUpdateListener] = set() | |
| 52 | 54 | ||
| 53 | - def async_updates(self, now: _float, records: list[RecordUpdate]) -> None: | ||
| 55 | + def async_updates(self, now: _float, records: list[_RecordUpdate]) -> None: | ||
| 54 | 56 | """Used to notify listeners of new information that has updated | |
| 55 | 57 | a record. | |
| 56 | 58 | ||
@@ -190,7 +192,7 @@ def async_add_listener( | |||
| 190 | 192 | self._async_update_matching_records(listener, questions) | |
| 191 | 193 | ||
| 192 | 194 | def _async_update_matching_records( | |
| 193 | - self, listener: RecordUpdateListener, questions: list[DNSQuestion] | ||
| 195 | + self, listener: RecordUpdateListener, questions: list[_DNSQuestion] | ||
| 194 | 196 | ) -> None: | |
| 195 | 197 | """Calls back any existing entries in the cache that answer the question. | |
| 196 | 198 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -455,7 +455,7 @@ def _read_name(self) -> str: | |||
| 455 | 455 | return name | |
| 456 | 456 | ||
| 457 | 457 | def _decode_labels_at_offset( | |
| 458 | - self, off: _int, labels: list[str], seen_pointers: set[int], depth: _int | ||
| 458 | + self, off: _int, labels: list[_str], seen_pointers: set[_int], depth: _int | ||
| 459 | 459 | ) -> int: | |
| 460 | 460 | # This is a tight loop that is called frequently, small optimizations can make a difference. | |
| 461 | 461 | if depth > MAX_DNS_LABELS: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,7 +56,7 @@ cpdef list generate_service_query( | |||
| 56 | 56 | ) | |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | - @cython.locals(answer=DNSPointer, query_buckets=list, question=DNSQuestion, max_compressed_size=cython.uint, max_bucket_size=cython.uint, query_bucket=_DNSPointerOutgoingBucket) | ||
| 59 | + @cython.locals(answer=DNSPointer, question=DNSQuestion, max_compressed_size=cython.uint, max_bucket_size=cython.uint, query_bucket=_DNSPointerOutgoingBucket) | ||
| 60 | 60 | cdef list _group_ptr_queries_with_known_answers(double now_millis, bint multicast, cython.dict question_with_known_answers) | |
| 61 | 61 | ||
| 62 | 62 | ||
@@ -92,7 +92,7 @@ cdef class QueryScheduler: | |||
| 92 | 92 | ||
| 93 | 93 | cpdef void _process_startup_queries(self) | |
| 94 | 94 | ||
| 95 | - @cython.locals(query=_ScheduledPTRQuery, next_scheduled=_ScheduledPTRQuery, next_when=double) | ||
| 95 | + @cython.locals(query=_ScheduledPTRQuery, next_when=double) | ||
| 96 | 96 | cpdef void _process_ready_types(self) | |
| 97 | 97 | ||
| 98 | 98 | cpdef void async_send_ready_queries(self, bint first_request, double now_millis, set ready_types) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,6 +95,9 @@ | |||
| 95 | 95 | str_ = str | |
| 96 | 96 | ||
| 97 | 97 | _QuestionWithKnownAnswers = dict[DNSQuestion, set[DNSPointer]] | |
| 98 | + DNSPointer_ = DNSPointer | ||
| 99 | + DNSOutgoing_ = DNSOutgoing | ||
| 100 | + RecordUpdate_ = RecordUpdate | ||
| 98 | 101 | ||
| 99 | 102 | heappop = heapq.heappop | |
| 100 | 103 | heappush = heapq.heappush | |
@@ -193,7 +196,7 @@ def __init__(self, now_millis: float, multicast: bool) -> None: | |||
| 193 | 196 | self.out = DNSOutgoing(_FLAGS_QR_QUERY, multicast) | |
| 194 | 197 | self.bytes = 0 | |
| 195 | 198 | ||
| 196 | - def add(self, max_compressed_size: int_, question: DNSQuestion, answers: set[DNSPointer]) -> None: | ||
| 199 | + def add(self, max_compressed_size: int_, question: DNSQuestion, answers: set[DNSPointer_]) -> None: | ||
| 197 | 200 | """Add a new set of questions and known answers to the outgoing.""" | |
| 198 | 201 | self.out.add_question(question) | |
| 199 | 202 | for answer in answers: | |
@@ -259,10 +262,10 @@ def _group_ptr_queries_with_known_answers( | |||
| 259 | 262 | def generate_service_query( | |
| 260 | 263 | zc: Zeroconf, | |
| 261 | 264 | now_millis: float_, | |
| 262 | - types_: set[str], | ||
| 265 | + types_: set[str_], | ||
| 263 | 266 | multicast: bool, | |
| 264 | 267 | question_type: DNSQuestionType | None, | |
| 265 | - ) -> list[DNSOutgoing]: | ||
| 268 | + ) -> list[DNSOutgoing_]: | ||
| 266 | 269 | """Generate a service query for sending with zeroconf.send.""" | |
| 267 | 270 | questions_with_known_answers: _QuestionWithKnownAnswers = {} | |
| 268 | 271 | qu_question = not multicast if question_type is None else question_type is QU_QUESTION | |
@@ -533,7 +536,7 @@ def _process_ready_types(self) -> None: | |||
| 533 | 536 | self._next_run = self._loop.call_at(millis_to_seconds(next_when_millis), self._process_ready_types) | |
| 534 | 537 | ||
| 535 | 538 | def async_send_ready_queries( | |
| 536 | - self, first_request: bool, now_millis: float_, ready_types: set[str] | ||
| 539 | + self, first_request: bool, now_millis: float_, ready_types: set[str_] | ||
| 537 | 540 | ) -> None: | |
| 538 | 541 | """Send any ready queries.""" | |
| 539 | 542 | # If they did not specify and this is the first request, ask QU questions | |
@@ -665,7 +668,7 @@ def _enqueue_callback( | |||
| 665 | 668 | ): | |
| 666 | 669 | self._pending_handlers[key] = state_change | |
| 667 | 670 | ||
| 668 | - def async_update_records(self, zc: Zeroconf, now: float_, records: list[RecordUpdate]) -> None: | ||
| 671 | + def async_update_records(self, zc: Zeroconf, now: float_, records: list[RecordUpdate_]) -> None: | ||
| 669 | 672 | """Callback invoked by Zeroconf when new information arrives. | |
| 670 | 673 | ||
| 671 | 674 | Updates information required by browser in the Zeroconf cache. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -99,6 +99,7 @@ | |||
| 99 | 99 | float_ = float | |
| 100 | 100 | int_ = int | |
| 101 | 101 | str_ = str | |
| 102 | + RecordUpdate_ = RecordUpdate | ||
| 102 | 103 | ||
| 103 | 104 | QU_QUESTION = DNSQuestionType.QU | |
| 104 | 105 | QM_QUESTION = DNSQuestionType.QM | |
@@ -547,7 +548,7 @@ def _set_ipv4_addresses_from_cache(self, zc: Zeroconf, now: float_) -> None: | |||
| 547 | 548 | else: | |
| 548 | 549 | self._ipv4_addresses = self._get_ip_addresses_from_cache_lifo(zc, now, _TYPE_A) | |
| 549 | 550 | ||
| 550 | - def async_update_records(self, zc: Zeroconf, now: float_, records: list[RecordUpdate]) -> None: | ||
| 551 | + def async_update_records(self, zc: Zeroconf, now: float_, records: list[RecordUpdate_]) -> None: | ||
| 551 | 552 | """Updates service information from a DNS record. | |
| 552 | 553 | ||
| 553 | 554 | This method will be run in the event loop. | |
@@ -741,7 +742,7 @@ def dns_nsec(self, missing_types: list[int], override_ttl: int_ | None = None) - | |||
| 741 | 742 | """Return DNSNsec from ServiceInfo.""" | |
| 742 | 743 | return self._dns_nsec(missing_types, override_ttl) | |
| 743 | 744 | ||
| 744 | - def _dns_nsec(self, missing_types: list[int], override_ttl: int_ | None) -> DNSNsec: | ||
| 745 | + def _dns_nsec(self, missing_types: list[int_], override_ttl: int_ | None) -> DNSNsec: | ||
| 745 | 746 | """Return DNSNsec from ServiceInfo.""" | |
| 746 | 747 | return DNSNsec( | |
| 747 | 748 | self._name, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ | |||
| 26 | 26 | from .info import ServiceInfo | |
| 27 | 27 | ||
| 28 | 28 | _str = str | |
| 29 | + _ServiceInfo = ServiceInfo | ||
| 29 | 30 | ||
| 30 | 31 | ||
| 31 | 32 | class ServiceRegistry: | |
@@ -79,7 +80,7 @@ def async_get_infos_server(self, server: str) -> list[ServiceInfo]: | |||
| 79 | 80 | """Return all ServiceInfo matching server.""" | |
| 80 | 81 | return self._async_get_by_index(self.servers, server) | |
| 81 | 82 | ||
| 82 | - def _async_get_by_index(self, records: dict[str, list], key: _str) -> list[ServiceInfo]: | ||
| 83 | + def _async_get_by_index(self, records: dict[_str, list], key: _str) -> list[_ServiceInfo]: | ||
| 83 | 84 | """Return all ServiceInfo matching the index.""" | |
| 84 | 85 | record_list = records.get(key) | |
| 85 | 86 | if record_list is None: | |
@@ -98,7 +99,7 @@ def _add(self, info: ServiceInfo) -> None: | |||
| 98 | 99 | self.servers.setdefault(info.server_key, []).append(info.key) | |
| 99 | 100 | self.has_entries = True | |
| 100 | 101 | ||
| 101 | - def _remove(self, infos: list[ServiceInfo]) -> None: | ||
| 102 | + def _remove(self, infos: list[_ServiceInfo]) -> None: | ||
| 102 | 103 | """Remove a services under the lock.""" | |
| 103 | 104 | for info in infos: | |
| 104 | 105 | old_service_info = self._services.get(info.key) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments