Skip to content

Commit

Permalink
Merge branch 'release-v0.4.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
fedejaure committed Mar 28, 2021
2 parents 3dbb9cf + 5d980a3 commit 304bd63
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[bumpversion]
commit = True
tag = False
current_version = 0.3.0
current_version = 0.4.0

[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ jobs:
nox --force-color --session=coverage -- --fmt xml
- name: Upload coverage report
uses: codecov/codecov-action@v1.2.1
uses: codecov/codecov-action@v1.3.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: check-json
- id: end-of-file-fixer
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
rev: 5.8.0
hooks:
- id: isort
- repo: https://github.com/psf/black
Expand All @@ -30,11 +30,11 @@ repos:
'flake8>=3.8.4',
'flakehell>=0.6.1',
'flake8-builtins>=1.5.3',
'flake8-blind-except>=0.1.1',
'flake8-blind-except>=0.2.0',
'flake8-logging-format>=0.6.0',
'flake8-bugbear>=20.1.4',
'flake8-annotations>=2.1.0',
'flake8-docstrings>=1.5.0',
'flake8-bugbear>=21.3.2',
'flake8-annotations>=2.6.1',
'flake8-docstrings>=1.6.0',
'flake8-bandit>=2.1.2',
'darglint>=1.3.0'
'darglint>=1.7.0'
]
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.0] - 2021-03-28
### Added
- `delay-startup` option to the `blink` command.

## [0.3.0] - 2021-02-13
### Added
- `show` option to `listen` command.
Expand All @@ -23,7 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- First release on PyPI.

[Unreleased]: https://github.com/fedejaure/mdns-beacon/compare/v0.3.0...develop
[Unreleased]: https://github.com/fedejaure/mdns-beacon/compare/v0.4.0...develop
[0.4.0]: https://github.com/fedejaure/mdns-beacon/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/fedejaure/mdns-beacon/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/fedejaure/mdns-beacon/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/fedejaure/mdns-beacon/compare/releases/tag/v0.1.0
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

# mDNS Beacon


[![PyPI - Version](https://img.shields.io/pypi/v/mdns-beacon.svg)](https://pypi.python.org/pypi/mdns-beacon)
[![PyPI - License](https://img.shields.io/pypi/l/mdns-beacon.svg)](https://pypi.python.org/pypi/mdns-beacon)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mdns-beacon.svg)](https://pypi.python.org/pypi/mdns-beacon)
Expand All @@ -24,7 +22,6 @@ Multicast DNS (mDNS) Beacon to announce multiple CNAME aliases across your local

* ✅ Announce multiple aliases on the local network.
* ✅ Listening utility to discover services during development.
* ❌ Run as Unix daemon.
* ❌ Configuration file.
* ❌ Windows support.

Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sphinx==3.4.3
sphinx==3.5.3
recommonmark==0.7.1
21 changes: 21 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ Announce an example service on the local network:
$ mdns-beacon blink example --alias sub1.example --address 127.0.0.1 --type http --protocol tcp
⠋ Announcing services (Press CTRL+C to quit) ...
Supervisord
^^^^^^^^^^^

Supervisord example config.

.. code-block:: TOML
[program:mdns-beacon]
command=mdns-beacon blink example --alias sub1.example --address 127.0.0.1 --type http --protocol tcp --delay-startup 180
numprocs=1
autostart=true
autorestart=true
startsecs=140
startretries=3
redirect_stderr=true
stderr_logfile=/var/log/mdns-beacon-err.log
stdout_logfile=/var/log/mdns-beacon-out.log
stopsignal=INT
killasgroup=true
stopasgroup=true
Listen
------

Expand Down
245 changes: 124 additions & 121 deletions poetry.lock

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mdns-beacon"
version = "0.3.0"
version = "0.4.0"
description = "Multicast DNS (mDNS) Beacon to announce multiple CNAME aliases across your local network."
authors = ["Federico Jaureguialzo <fedejaure@gmail.com>"]

Expand Down Expand Up @@ -33,38 +33,38 @@ mdns-beacon = 'mdns_beacon.cli.main:main'
[tool.poetry.dependencies]
python = "<3.10,>=3.6.1"
click = "^7.1.2"
zeroconf = "^0.28.8"
rich = "^9.10.0"
zeroconf = "^0.29.0"
rich = "^9.13.0"
python-slugify = "^4.0.1"
typing-extensions = "^3.7.4"
click-option-group = "^0.5.2"


[tool.poetry.dev-dependencies]
pre-commit = "^2.10.1"
pre-commit = "^2.11.1"
invoke = "^1.4.1"
flake8 = "^3.8.4"
flakehell = "^0.9.0"
flake8-builtins = "^1.5.3"
flake8-blind-except = "^0.2.0"
flake8-logging-format = "^0.6.0"
flake8-bugbear = "^20.1.4"
flake8-annotations = "^2.1.0"
flake8-docstrings = "^1.5.0"
flake8-bugbear = "^21.3.2"
flake8-annotations = "^2.6.1"
flake8-docstrings = "^1.6.0"
flake8-bandit = "^2.1.2"
darglint = "^1.6.0"
isort = "^5.6.4"
darglint = "^1.7.0"
isort = "^5.8.0"
black = "^20.8b1"
safety = "^1.10.3"
mypy = "^0.800"
sphinx = "^3.4.3"
mypy = "^0.812"
sphinx = "^3.5.3"
recommonmark = "^0.7.1"
bump2version = "^1.0.1"
pytest = "^6.2.2"
xdoctest = "^0.15.4"
coverage = {version = "^5.4", extras = ["toml"]}
coverage = {version = "^5.5", extras = ["toml"]}
pytest-cov = "^2.11.1"
watchdog = {version = "^2.0.0", extras = ["watchmedo"]}
watchdog = {version = "^2.0.2", extras = ["watchmedo"]}
ipython = "^7.16"
pytest-asyncio = "^0.14.0"
pytest-mock = "^3.5.0"
Expand Down
2 changes: 1 addition & 1 deletion src/mdns_beacon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__author__ = """Federico Jaureguialzo"""
__email__ = "fedejaure@gmail.com"
__version__ = "0.3.0"
__version__ = "0.4.0"
14 changes: 13 additions & 1 deletion src/mdns_beacon/beacon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Beacon module."""
import logging
import time
from ipaddress import IPv4Address, IPv6Address, ip_address
from typing import Any, Dict, List, Optional, Union

Expand Down Expand Up @@ -27,6 +28,8 @@ class Beacon(BaseBeacon):
weight: Weight of the service.
priority: Priority of the service.
properties: Dict of properties (or a bytes object with the content of the `text` field).
delay_startup: Amount of time to wait before trying to start
the zeroconf service (in seconds).
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
"""
Expand All @@ -45,7 +48,8 @@ def __init__(
ttl: int = 60,
weight: int = 0,
priority: int = 0,
properties: Union[bytes, Dict[str, Any]] = None,
properties: Optional[Union[bytes, Dict[str, Any]]] = None,
delay_startup: int = 0,
*args: Any,
**kwargs: Any,
) -> None:
Expand All @@ -62,6 +66,8 @@ def __init__(
priority: Priority of the service.
properties: Dict of properties (or a bytes object with the
content of the `text` field) of the service.
delay_startup: Amount of time to wait before trying to start
the zeroconf service (in seconds).
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
"""
Expand All @@ -75,6 +81,7 @@ def __init__(
self.weight = weight
self.priority = priority
self.properties = properties or b""
self.delay_startup = delay_startup

def _build_service_host(self, name: str) -> str:
"""Build service host for a given name.
Expand Down Expand Up @@ -137,8 +144,13 @@ def stop(self) -> None:
self.zeroconf.unregister_service(service)
super().stop()

def _wait(self) -> None:
"""Wait before trying to start the zeroconf service."""
time.sleep(self.delay_startup)

def _execute(self) -> None:
"""Register aliases on the local network."""
self._wait()
logger.info("Registering %(services_len)s services", services_len=len(self.services))
for service in self.services:
logger.debug("Registering %(service_name)s", service_name=service.name)
Expand Down
14 changes: 14 additions & 0 deletions src/mdns_beacon/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ def main() -> None:
multiple=True,
default=[],
)
@click.option(
"--delay-startup",
"delay_startup",
default=0,
type=click.IntRange(0, 300),
help=(
"In certain configurations, you may want to wait a given amount of time before "
"trying to start the mDNS beacon. This is typically found when network interfaces "
"appear only late during system startup and the interface startup priorities are "
"configured incorrectly. This setting takes any integer value between 0 and 300 seconds."
),
)
def blink(
name: str,
aliases: Iterable[str],
Expand All @@ -92,6 +104,7 @@ def blink(
priority: int,
txt: bytes,
properties: Dict[str, bytes],
delay_startup: int,
) -> None:
"""Announce aliases on the local network."""
with Live(console=console, transient=True, auto_refresh=True) as live:
Expand All @@ -105,6 +118,7 @@ def blink(
weight=weight,
priority=priority,
properties=properties or txt,
delay_startup=delay_startup,
)
try:
beacon.run_forever()
Expand Down

0 comments on commit 304bd63

Please sign in to comment.