Skip to content

Commit 5830ea6

Browse files
committed
Add an mdns check to connected timeout
1 parent 7bcd980 commit 5830ea6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

comitup/mdns.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing import TYPE_CHECKING, Dict, List, Optional
1818

1919
import dbus
20+
import socket
2021

2122
from comitup import config, nm
2223

@@ -190,6 +191,22 @@ def add_hosts(hosts: List[str]) -> None:
190191
group.Commit()
191192

192193

194+
def check_mdns(hosts: List[str]) -> None:
195+
reset = False
196+
197+
log.debug("Checking mdns")
198+
199+
try:
200+
socket.gethostbyname(hosts[0])
201+
except socket.gaierror:
202+
reset = True
203+
204+
if reset:
205+
log.error("Mdns check failed - resetting records and services.")
206+
clear_entries(emphatic=True)
207+
add_hosts(*hosts)
208+
209+
193210
if __name__ == "__main__":
194211
add_hosts(["comitup-1111.local", "comitup.local"])
195212

comitup/states.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ def connected_timeout(dummy: int) -> None:
296296
log.error("AP is holding default route while CONNECTED, kicking")
297297
nm.disconnect(link_dev)
298298

299+
mdns.check_mdns(dns_names)
300+
299301

300302
#
301303
# State Management

0 commit comments

Comments
 (0)