Zeroconf

Latest version: v0.136.2

Safety actively analyzes 681866 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 34 of 37

0.24.2

* Provide and enforce type hints everywhere except for tests

The tests' time will come too in the future, though, I think. I believe
nose has problems with running annotated tests right now so let's leave
it for later.

DNSEntry.to_string renamed to entry_to_string because DNSRecord
subclasses DNSEntry and overrides to_string with a different signature,
so just to be explicit and obvious here I renamed it – I don't think any
client code will break because of this.

I got rid of ServicePropertiesType in favor of generic Dict because
having to type all the properties got annoying when variance got
involved – maybe it'll be restored in the future but it seems like too
much hassle now. ([`f771587`](https://github.com/python-zeroconf/python-zeroconf/commit/f7715874c2242b95cf9815549344ea66ac107b6e))

* Fix get_expiration_time percent parameter annotation

It takes integer percentage values at the moment so let's document that. ([`5986bf6`](https://github.com/python-zeroconf/python-zeroconf/commit/5986bf66e77e77f9e0b6ba43a4758ecb0da04ff6))

* Add support for AWDL interface on macOS

The API is inspired by Apple's NetService.includesPeerToPeer
(see https://developer.apple.com/documentation/foundation/netservice/1414086-includespeertopeer) ([`fcafdc1`](https://github.com/python-zeroconf/python-zeroconf/commit/fcafdc1e285cc5c3c1f2c413ac9309d3426179f4))

0.24.1

* Bugfix: TXT record's name is never equal to Service Browser's type.

TXT record's name is never equal to Service Browser's type. We should
check whether TXT record's name ends with Service Browser's type.
Otherwise, we never get updates of TXT records. ([`2a597ee`](https://github.com/python-zeroconf/python-zeroconf/commit/2a597ee80906a27effd442d033de10b5129e6900))

* Bugfix: Flush outdated cache entries when incoming record is unique.

According to RFC 6762 10.2. Announcements to Flush Outdated Cache Entries,
when the incoming record's cache-flush bit is set (record.unique == True
in this module), "Instead of merging this new record additively into the
cache in addition to any previous records with the same name, rrtype, and
rrclass, all old records with that name, rrtype, and rrclass that were
received more than one second ago are declared invalid, and marked to
expire from the cache in one second." ([`1d39b3e`](https://github.com/python-zeroconf/python-zeroconf/commit/1d39b3edd141093f9e579ab83377fe8f5ecb357d))

* Change order of equality check to favor cheaper checks first

Comparing two strings is much cheaper than isinstance, so we should try
those first

A performance test was run on a network with 170 devices running Zeroconf.
There was a ServiceBrowser running on a separate thread while a timer ran
on the main thread that forced a thread switch every 2 seconds (to include
the effect of thread switching in the measurements). Every minute,
a Zeroconf broadcast was made on the network.

This was ran this for an hour on a Macbook Air from 2015 (Intel Core
i7-5650U) using Ubuntu 19.10 and Python 3.7, both before this commit and
after.

These are the results of the performance tests:
Function Before count Before time Before time per count After count After time After time per count Time reduction
DNSEntry.__eq__ 528 0.001s 1.9μs 538 0.001s 1.9μs 1.9%
DNSPointer.__eq__ 24369256 (24.3M) 134.641s 5.5μs 25989573 (26.0M) 86.405s 3.3μs 39.8%
DNSText.__eq__ 52966716 (53.0M) 190.640s 3.6μs 53604915 (53.6M) 169.104s 3.2μs 12.4%
DNSService.__eq__ 52620538 (52.6M) 171.660s 3.3μs 56557448 (56.6M) 170.222s 3.0μs 7.8% ([`815ac77`](https://github.com/python-zeroconf/python-zeroconf/commit/815ac77e9146c37afd7c5389ed45adee9f1e2e36))

* Dont recalculate the expiration and stale time every update

I have a network with 170 devices running Zeroconf. Every minute
a zeroconf request for broadcast is cast out. Then we were listening for
Zeroconf devices on that network.

To get a more realistic test, the Zeroconf ServiceBrowser is ran on
a separate thread from a main thread. On the main thread an I/O limited
call to QNetworkManager is made every 2 seconds,

in order to include performance penalties due to thread switching. The
experiment was ran on a MacBook Air 2015 (Intel Core i7-5650U) through
Ubuntu 19.10 and Python 3.7.

This was left running for exactly one hour, both before and after this commit.

Before this commit, there were 132107499 (132M) calls to the
get_expiration_time function, totalling 141.647s (just over 2 minutes).

After this commit, there were 1661203 (1.6M) calls to the
get_expiration_time function, totalling 2.068s.

This saved about 2 minutes of processing time out of the total 60 minutes,
on average 3.88% processing power on the tested CPU. It is expected to see
similar improvements on all CPU architectures. ([`2e9699c`](https://github.com/python-zeroconf/python-zeroconf/commit/2e9699c542f691fc605e4a1c03cbf496273a9835))

* Significantly improve the speed of the entries function of the cache

Tested this with Python 3.6.8, Fedora 28. This was done in a network with
a lot of discoverable devices.

before:
Total time: 1.43086 s

Line Hits Time Per Hit % Time Line Contents
==============================================================
1138 profile
1139 def entries(self):
1140 """Returns a list of all entries"""
1141 2063 3578.0 1.7 0.3 if not self.cache:
1142 2 3.0 1.5 0.0 return []
1143 else:
1144 avoid size change during iteration by copying the cache
1145 2061 22051.0 10.7 1.5 values = list(self.cache.values())
1146 2061 1405227.0 681.8 98.2 return reduce(lambda a, b: a + b, values)

After:
Total time: 0.43725 s

Line Hits Time Per Hit % Time Line Contents
==============================================================
1138 profile
1139 def entries(self):
1140 """Returns a list of all entries"""
1141 3651 10171.0 2.8 2.3 if not self.cache:
1142 2 7.0 3.5 0.0 return []
1143 else:
1144 avoid size change during iteration by copying the cache
1145 3649 67054.0 18.4 15.3 values = list(self.cache.values())
1146 3649 360018.0 98.7 82.3 return list(itertools.chain.from_iterable(values)) ([`157fc20`](https://github.com/python-zeroconf/python-zeroconf/commit/157fc2003318d785d07b362e1fd2ba3fe5d373f0))

* The the formatting of the IPv6 section in the readme ([`6ab7dbf`](https://github.com/python-zeroconf/python-zeroconf/commit/6ab7dbf27a2086e20f4486e693e2091d043af1db))

0.24.0

* Improve type hint coverage ([`c827f9f`](https://github.com/python-zeroconf/python-zeroconf/commit/c827f9fdc4c58433143ea8815029c3387b500ff5))

* Add py.typed marker (closes 199)

This required changing to a proper package. ([`41b31cb`](https://github.com/python-zeroconf/python-zeroconf/commit/41b31cb338e8a8a7d1a548662db70d9014e8a352))

* Link to the documentation ([`3db9d82`](https://github.com/python-zeroconf/python-zeroconf/commit/3db9d82d888abe880bfdd2fb2c3fe3eddcb48ae9))

* Setup basic Sphinx documentation

Closes 200 ([`1c33e5f`](https://github.com/python-zeroconf/python-zeroconf/commit/1c33e5f5b44732d446d629cc13000cff3527afef))

* ENOTCONN is not an error during shutdown

When `python-zeroconf` is used in conjunction with `eventlet`, `select.select()` will return with an error code equal to `errno.ENOTCONN` instead of `errno.EBADF`. As a consequence, an exception is shown in the console during shutdown. I believe that it should not cause any harm to treat `errno.ENOTCONN` the same way as `errno.EBADF` to prevent this exception. ([`c86423a`](https://github.com/python-zeroconf/python-zeroconf/commit/c86423ab0223bab682614e18a6a09050dfc80087))

* Rework exposing IPv6 addresses on ServiceInfo

* Return backward compatibility for ServiceInfo.addresses by making
it return V4 addresses only
* Add ServiceInfo.parsed_addresses for convenient access to addresses
* Raise TypeError if addresses are not provided as bytes (otherwise
an ugly assertion error is raised when sending)
* Add more IPv6 unit tests ([`98a1ce8`](https://github.com/python-zeroconf/python-zeroconf/commit/98a1ce8b99ddb03de9f6cccca49396fcf177e0d0))

* Finish AAAA records support

The correct record type was missing in a few places. Also use
addresses_by_version(All) in preparation for switching addresses
to V4 by default. ([`aae7fd3`](https://github.com/python-zeroconf/python-zeroconf/commit/aae7fd3ba851d1894732c4270cef745127cc03da))

* Test with pypy3.6

Right now this is available as pypy3 in Travis CI. Running black on PyPy
needs to be disabled for now because of an issue[1] that's been patched
only recently and it's not available in Travis yet.

[1] https://bitbucket.org/pypy/pypy/issues/2985/pypy36-osreplace-pathlike-typeerror ([`fec839a`](https://github.com/python-zeroconf/python-zeroconf/commit/fec839ae4fdcb870066fff855809583dcf7d7a17))

* Stop specifying precise pypy3.5 version

This allows us to test with the latest available one. ([`c2e8bde`](https://github.com/python-zeroconf/python-zeroconf/commit/c2e8bdebc6cec128d01197d53c3402278a4b62ed))

* Simplify Travis CI configuration regarding Python 3.7

Selecting xenial manually is no longer needed. ([`5359ea0`](https://github.com/python-zeroconf/python-zeroconf/commit/5359ea0a0b4cdca0854ae97c5d11036633102c67))

* Test with Python 3.8 ([`15118c8`](https://github.com/python-zeroconf/python-zeroconf/commit/15118c837a148a37edd29a20294e598ecf09c3cf))

* Make AAAA records work (closes 52) (191)

This PR incorporates changes from the earlier PR 179 (thanks to Mikael Pahmp), adding tests and a few more fixes to make AAAA records work in practice.

Note that changing addresses to container IPv6 addresses may be considered a breaking change, for example, for consumers that unconditionally apply inet_aton to them. I'm introducing a new function to be able to retries only addresses from one family. ([`5bb9531`](https://github.com/python-zeroconf/python-zeroconf/commit/5bb9531be48f6f1e119643677c36d9e714204a8b))

* Improve static typing coverage ([`e5323d8`](https://github.com/python-zeroconf/python-zeroconf/commit/e5323d8c9795c59019173b8d202a50a49c415039))

* Add additional recommended records to PTR responses (184)

RFC6763 indicates a server should include the SRV/TXT/A/AAAA records
when responding to a PTR record request. This optimization ensures
the client doesn't have to then query for these additional records.

It has been observed that when multiple Windows 10 machines are monitoring
for the same service, this unoptimized response to the PTR record
request can cause extremely high CPU usage in both the DHCP Client
& Device Association service (I suspect due to all clients having to
then sending/receiving the additional queries/responses). ([`ea64265`](https://github.com/python-zeroconf/python-zeroconf/commit/ea6426547f79c32c6d5d3bcc2d0a261bf503197a))

* Rename IpVersion to IPVersion

A follow up to 3d5787b8c5a92304b70c04f48dc7d5cec8d9aac8. ([`ceb602c`](https://github.com/python-zeroconf/python-zeroconf/commit/ceb602c0d1bc1d3a269fd233b072a9b929076438))

* First stab at supporting listening on IPv6 interfaces

This change adds basic support for listening on IPv6 interfaces.
Some limitations exist for non-POSIX platforms, pending fixes in
Python and in the ifaddr library. Also dual V4-V6 sockets may not
work on all BSD platforms. As a result, V4-only is used by default.

Unfortunately, Travis does not seem to support IPv6, so the tests
are disabled on it, which also leads to coverage decrease. ([`3d5787b`](https://github.com/python-zeroconf/python-zeroconf/commit/3d5787b8c5a92304b70c04f48dc7d5cec8d9aac8))

0.23.0

* Add support for multiple addresses when publishing a service (170)

This is a rebased and fixed version of PR 27, which also adds compatibility shim for ServiceInfo.address and does a proper deprecation for it.

* Present all addresses that are available.

* Add support for publishing multiple addresses.

* Add test for backwards compatibility.

* Provide proper deprecation of the "address" argument and field

* Raise deprecation warnings when address is used
* Add a compatibility property to avoid breaking existing code
(based on suggestion by Bas Stottelaar in PR 27)
* Make addresses keyword-only, so that address can be eventually
removed and replaced with it without breaking consumers
* Raise TypeError instead of an assertion on conflicting address
and addresses

* Disable black on ServiceInfo.__init__ until black is fixed

Due to https://github.com/python/black/issues/759 black produces
code that is invalid Python 3.5 syntax even with --target-version py35.
This patch disables reformatting for this call (it doesn't seem to be
possible per line) until it's fixed. ([`c787610`](https://github.com/python-zeroconf/python-zeroconf/commit/c7876108150cd251786db4ab52dadd1b2283d262))

* Makefile: be specific which files to check with black (169)

Otherwise black tries to check the "env" directory, which fails. ([`6b85a33`](https://github.com/python-zeroconf/python-zeroconf/commit/6b85a333de21fa36187f081c3c115c8af40d7055))

* Run black --check as part of CI to enforce code style ([`12477c9`](https://github.com/python-zeroconf/python-zeroconf/commit/12477c954e7f051d10152f9ab970e28fd4222b30))

* Refactor the CI script a bit to make adding black check easier ([`69ad22c`](https://github.com/python-zeroconf/python-zeroconf/commit/69ad22cf852a12622f78aa2f4e7cf20c2d395db2))

* Reformat the code using Black

We could use some style consistency in the project and Black looks like
the best tool for the job.

Two flake8 errors are being silenced from now on:

* E203 whitespace before :
* W503 line break before binary operator

Both are to satisfy Black-formatted code (and W503 is somemwhat against
the latest PEP8 recommendations regarding line breaks and binary
operators in new code). ([`beb596c`](https://github.com/python-zeroconf/python-zeroconf/commit/beb596c345b0764bdfe1a828cfa744bcc560cf32))

* Add support for MyListener call getting updates to service TXT records (2nd attempt) (166)

Add support for MyListener call getting updates to service TXT records

At the moment, the implementation supports notification to the ServiceListener class for additions and removals of service, but for service updates to the TXT record, the client must poll the ServiceInfo class. This draft PR provides a mechanism to have a callback on the ServiceListener class be invoked when the TXT record changes. ([`d4e06bc`](https://github.com/python-zeroconf/python-zeroconf/commit/d4e06bc54098bfa7a863bcc11bb9e2035738c8f5))

* Remove Python 3.4 from the Python compatibility section

I forgot to do this in 4a02d0489da80e8b9e8d012bb7451cd172c753ca. ([`e1c2b00`](https://github.com/python-zeroconf/python-zeroconf/commit/e1c2b00c772a1538a6682c45884bbe89c8efba60))

* Drop Python 3.4 support (it's dead now)

See https://devguide.python.org/#status-of-python-branches ([`4a02d04`](https://github.com/python-zeroconf/python-zeroconf/commit/4a02d0489da80e8b9e8d012bb7451cd172c753ca))

0.22.0

Unknown

* Prepare release 0.22.0 ([`db1dcf6`](https://github.com/python-zeroconf/python-zeroconf/commit/db1dcf682e453766b53773d70c0091b81a87a192))

* Add arguments to set TTLs via ServiceInfo ([`ecc021b`](https://github.com/python-zeroconf/python-zeroconf/commit/ecc021b7a3cec863eed5a3f71a1f28e3026c25b0))

* Use recommended TTLs with overrides via ServiceInfo ([`a7aedb5`](https://github.com/python-zeroconf/python-zeroconf/commit/a7aedb58649f557a5e372fc776f98457ce84eb39))

* ttl: modify default used to respond to _services queries ([`f25989d`](https://github.com/python-zeroconf/python-zeroconf/commit/f25989d8cdae8f77e19eba70f236dd8103b33e8f))

* Fix service removal packets not being sent on shutdown ([`57310e1`](https://github.com/python-zeroconf/python-zeroconf/commit/57310e185a4f924dd257edd64f866da685a786c6))

* Adjust query intervals to match RFC 6762 (159)

* Limit query backoff time to one hour as-per rfc6762 section 5.2
* tests: monkey patch backoff limit to focus testing on TTL expiry
* tests: speed up integration test
* tests: add test of query backoff interval and limit
* Set initial query interval to 1 second as-per rfc6762 sec 5.2
* Add comments around timing constants
* tests: fix linting errors
* tests: fix float assignment to integer var


Sets the repeated query backoff limit to one hour as opposed to 20 seconds, reducing unnecessary network traffic
Adds a test for the behaviour of the backoff procedure
Sets the first repeated query to happen after one second as opposed to 500ms ([`bee8abd`](https://github.com/python-zeroconf/python-zeroconf/commit/bee8abdba49e2275d203e3b0b4a3afac330ec4ea))

* Turn on and address mypy check_untyped_defs ([`4218d75`](https://github.com/python-zeroconf/python-zeroconf/commit/4218d757994467ee710b0cad034ea1fb6035d3ea))

* Turn on and address mypy warn-return-any ([`006e614`](https://github.com/python-zeroconf/python-zeroconf/commit/006e614315c12e5232e6168ce0bacf0dc056ba8a))

* Turn on and address mypy no-implicit-optional ([`071c6ed`](https://github.com/python-zeroconf/python-zeroconf/commit/071c6edb924b6bc9b67859dc9860cfe09cc98d07))

* Add reminder to enable disallow_untyped_calls for mypy ([`24bb44f`](https://github.com/python-zeroconf/python-zeroconf/commit/24bb44f858cd325d7ff2892c53dc1dd9f26ed768))

* Enable some more mypy warnings ([`183a846`](https://github.com/python-zeroconf/python-zeroconf/commit/183a84636a9d4fec6306d065a4f855fec95086e4))

* Run mypy on test_zeroconf.py too

This will reveal issues with current type hints as demonstrated by a
commit/issue to be submitted later, as well as prevent some others
from cropping up meanwhile. ([`74391d5`](https://github.com/python-zeroconf/python-zeroconf/commit/74391d5c124bf6f899059db93bbf7e99b96d8aad))

* Move mypy config to setup.cfg

Removes need for a separate file, better to have more in one place. ([`2973931`](https://github.com/python-zeroconf/python-zeroconf/commit/29739319ccf71f48c06bc1b74cd193f17fb6b272))

* Don't bother with a universal wheel as we're Python >= 3 only ([`9c0f1ab`](https://github.com/python-zeroconf/python-zeroconf/commit/9c0f1ab03b90f87ff1d58278a0b9b77c16195185))

* Add unit tests for default ServiceInfo properties. ([`a12c3b2`](https://github.com/python-zeroconf/python-zeroconf/commit/a12c3b2a3b4300849e0a4dcdd4df5386286b88d3))

* Modify ServiceInfo's __init__ properties' default value.

This commit modifies the default value of the argument properties of
ServiceInfo’s __init__() to byte array (properties=b’’). This enables
to instantiate it without setting the properties argument. As it is,
and because properties is not mandatory, if a user does not specify
the argument, an exception (AssertionError) is thrown:

Traceback (most recent call last):
File "src/zeroconf-test.py", line 72, in <module>
zeroconf.register_service(service)
File "/home/jmpcm/zeroconf-test/src/zeroconf.py", line 1864, in register_service
self.send(out)
File "/home/jmpcm/zeroconf-test/src/zeroconf.py", line 2091, in send
packet = out.packet()
File "/home/jmpcm/zeroconf-test/src/zeroconf.py", line 1026, in packet
overrun_answers += self.write_record(answer, time_)
File "/home/jmpcm/zeroconf-test/src/zeroconf.py", line 998, in write_record
record.write(self)
File "/home/jmpcm/zeroconf-test/src/zeroconf.py", line 579, in write
out.write_string(self.text)
File "/home/jmpcm/zeroconf-test/src/zeroconf.py", line 903, in write_string
assert isinstance(value, bytes)
AssertionError

The argument can be either a dictionary or a byte array. The function
_set_properties() will always create a byte array with the user's
properties. Changing the default value to a byte array, avoids the
conversion to byte array and avoids the exception. ([`9321007`](https://github.com/python-zeroconf/python-zeroconf/commit/93210079259bd0973e3b54a90dff971e14abf595))

* Fix some spelling errors ([`88fb0e3`](https://github.com/python-zeroconf/python-zeroconf/commit/88fb0e34f902498f6ceb583ce6fa9346745a14ca))

* Require flake8 >= 3.6.0, drop pycodestyle restriction

Fixes current build breakage related to flake8 dependencies.

The breakage:

$ make flake8
flake8 --max-line-length=110 examples *.py
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2329, in resolve
return functools.reduce(getattr, self.attrs, module)
AttributeError: module 'pycodestyle' has no attribute 'break_after_binary_operator'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/plugins/manager.py", line 182, in load_plugin
self._load(verify_requirements)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/plugins/manager.py", line 154, in _load
self._plugin = resolve()
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2331, in resolve
raise ImportError(str(exc))
ImportError: module 'pycodestyle' has no attribute 'break_after_binary_operator'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.5.6/bin/flake8", line 11, in <module>
sys.exit(main())
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/main/application.py", line 412, in run
self._run(argv)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/main/application.py", line 399, in _run
self.initialize(argv)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/main/application.py", line 381, in initialize
self.find_plugins()
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/main/application.py", line 197, in find_plugins
self.check_plugins.load_plugins()
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/plugins/manager.py", line 434, in load_plugins
plugins = list(self.manager.map(load_plugin))
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/plugins/manager.py", line 319, in map
yield func(self.plugins[name], *args, **kwargs)
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/plugins/manager.py", line 432, in load_plugin
return plugin.load_plugin()
File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/flake8/plugins/manager.py", line 189, in load_plugin
raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "pycodestyle.break_after_binary_operator" due to module 'pycodestyle' has no attribute 'break_after_binary_operator'. ([`73b3620`](https://github.com/python-zeroconf/python-zeroconf/commit/73b3620908cb5e2f54231692c17f6bbb8a42d09d))

* Drop flake8-blind-except

Obsoleted by pycodestyle 2.1's E722. ([`e3b7e40`](https://github.com/python-zeroconf/python-zeroconf/commit/e3b7e40af52d05264794e2e4d37dfdb1c5d3814a))

* Test with PyPy 3.5 5.10.1 ([`51a6f70`](https://github.com/python-zeroconf/python-zeroconf/commit/51a6f7081bd5590ca5ea5418b39172714b7ef1fe))

* Fix a changelog typo ([`e08db28`](https://github.com/python-zeroconf/python-zeroconf/commit/e08db282edd8459e35d17ae4e7278106056a0c94))

0.21.3

Unknown

* Prepare release 0.21.3 ([`059530d`](https://github.com/python-zeroconf/python-zeroconf/commit/059530d075fe1575ebbab535be67ac7d5ae7caed))

* Actually allow underscores in incoming service names

This was meant to be released earlier, but I failed to merge part of my
patch.

Fixes: ff4a262adc69 ("Allow underscores in incoming service names")
Closes 102 ([`ae3bd51`](https://github.com/python-zeroconf/python-zeroconf/commit/ae3bd517d84aae631db1cc294caf22541a7f4bd5))

Page 34 of 37

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.