Restyled by black

This commit is contained in:
Restyled.io 2021-05-19 11:35:14 +00:00
parent 2e1f4a20bb
commit 7021ef4e69
2 changed files with 12 additions and 11 deletions

View File

@ -3,13 +3,13 @@ from librespot.zeroconf import Packet
class Record:
TYPE_A: int = 0x01
TYPE_PTR: int = 0x0c
TYPE_PTR: int = 0x0C
TYPE_CNAME: int = 0x05
TYPE_TXT: int = 0x10
TYPE_AAAA: int = 0x1c
TYPE_AAAA: int = 0x1C
TYPE_SRV: int = 0x21
TYPE_NSEC: int = 0x2f
TYPE_ANY: int = 0xff
TYPE_NSEC: int = 0x2F
TYPE_ANY: int = 0xFF
__type: int
_ttl: int
__name: str

View File

@ -16,11 +16,9 @@ class Zeroconf(Closeable):
def __init__(self):
try:
self.__BROADCAST4 = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)
self.__BROADCAST4 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.__BROADCAST4.connect(("224.0.0.251", 5353))
self.__BROADCAST6 = socket.socket(socket.AF_INET6,
socket.SOCK_DGRAM)
self.__BROADCAST6 = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
self.__BROADCAST6.connect(("FF02::FB", 5353))
except Exception as e:
pass
@ -31,9 +29,12 @@ class Zeroconf(Closeable):
def get_or_create_local_host_name() -> str:
host = socket.gethostname()
if host == "localhost":
host = base64.b64encode(
random.randint(-9223372036854775808,
9223372036854775807)).decode() + ".local"
host = (
base64.b64encode(
random.randint(-9223372036854775808, 9223372036854775807)
).decode()
+ ".local"
)
return host
def set_use_ipv4(self, ipv4: bool) -> Zeroconf: