Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author='Paul Scott-Murphy, William McBrine, Jakub Stasiak',
url='https://github.com/jstasiak/python-zeroconf',
package_data={"zeroconf": ["py.typed"]},
packages=["zeroconf", "zeroconf._services", "zeroconf._utils"],
packages=["zeroconf", "zeroconf._protocol", "zeroconf._services", "zeroconf._utils"],
platforms=['unix', 'linux', 'osx'],
license='LGPL',
zip_safe=False,
Expand Down
7 changes: 4 additions & 3 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
from unittest.mock import patch

import zeroconf as r
from zeroconf import _core, _protocol, const, Zeroconf, current_time_millis
from zeroconf import _core, const, Zeroconf, current_time_millis
from zeroconf.asyncio import AsyncZeroconf
from zeroconf._protocol import outgoing

from . import has_working_ipv6, _clear_cache, _inject_response, _wait_for_start

Expand Down Expand Up @@ -670,8 +671,8 @@ def test_guard_against_oversized_packets():
)

# We are patching to generate an oversized packet
with patch.object(_protocol, "_MAX_MSG_ABSOLUTE", 100000), patch.object(
_protocol, "_MAX_MSG_TYPICAL", 100000
with patch.object(outgoing, "_MAX_MSG_ABSOLUTE", 100000), patch.object(
outgoing, "_MAX_MSG_TYPICAL", 100000
):
over_sized_packet = generated.packets()[0]
assert len(over_sized_packet) > const._MAX_MSG_ABSOLUTE
Expand Down
3 changes: 2 additions & 1 deletion zeroconf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
NonUniqueNameException,
ServiceNameAlreadyRegistered,
)
from ._protocol import DNSIncoming, DNSOutgoing # noqa # import needed for backwards compat
from ._protocol.incoming import DNSIncoming # noqa # import needed for backwards compat
from ._protocol.outgoing import DNSOutgoing # noqa # import needed for backwards compat
from ._services import ( # noqa # import needed for backwards compat
Signal,
SignalRegistrationInterface,
Expand Down
3 changes: 2 additions & 1 deletion zeroconf/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
)
from ._history import QuestionHistory
from ._logger import QuietLogger, log
from ._protocol import DNSIncoming, DNSOutgoing
from ._protocol.incoming import DNSIncoming
from ._protocol.outgoing import DNSOutgoing
from ._services import ServiceListener
from ._services.browser import ServiceBrowser
from ._services.info import ServiceInfo, instance_name_from_service_info
Expand Down
3 changes: 2 additions & 1 deletion zeroconf/_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@


if TYPE_CHECKING:
from ._protocol import DNSIncoming, DNSOutgoing
from ._protocol.incoming import DNSIncoming
from ._protocol.outgoing import DNSOutgoing


@enum.unique
Expand Down
3 changes: 2 additions & 1 deletion zeroconf/_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
from ._dns import DNSAddress, DNSNsec, DNSPointer, DNSQuestion, DNSRRSet, DNSRecord
from ._history import QuestionHistory
from ._logger import log
from ._protocol import DNSIncoming, DNSOutgoing
from ._protocol.incoming import DNSIncoming
from ._protocol.outgoing import DNSOutgoing
from ._services.info import ServiceInfo
from ._services.registry import ServiceRegistry
from ._updates import RecordUpdate, RecordUpdateListener
Expand Down
51 changes: 51 additions & 0 deletions zeroconf/_protocol/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
""" 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
"""

from ..const import (
_FLAGS_QR_MASK,
_FLAGS_QR_QUERY,
_FLAGS_QR_RESPONSE,
_FLAGS_TC,
)


class DNSMessage:
"""A base class for DNS messages."""

__slots__ = ('flags',)

def __init__(self, flags: int) -> None:
"""Construct a DNS message."""
self.flags = flags

def is_query(self) -> bool:
"""Returns true if this is a query."""
return (self.flags & _FLAGS_QR_MASK) == _FLAGS_QR_QUERY

def is_response(self) -> bool:
"""Returns true if this is a response."""
return (self.flags & _FLAGS_QR_MASK) == _FLAGS_QR_RESPONSE

@property
def truncated(self) -> bool:
"""Returns true if this is a truncated."""
return (self.flags & _FLAGS_TC) == _FLAGS_TC
Loading