Skip to content

Commit 741a6b1

Browse files
authored
Fix reconnecting when certificate is unchanged (#238)
1 parent 78fe18d commit 741a6b1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/remote_registration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def register_v2(details):
235235
elif success == util.CertProcessingResult.CERT_UPDATED:
236236
logging.debug("Successfully updated registration with %s (%s:%d) - api version 2"
237237
% (details.hostname, details.ip_info, details.auth_port))
238-
elif success == util.CertProcessingResult.CERT_UPDATED:
238+
elif success == util.CertProcessingResult.CERT_UP_TO_DATE:
239239
logging.debug("Certificate already up to date, nothing to do for %s (%s:%d) - api version 2"
240240
% (details.hostname, details.ip_info, details.auth_port))
241241
return success

src/server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def add_service(self, zeroconf, _type, name):
200200
return
201201

202202
cert_result = util.CertProcessingResult.FAILURE
203+
newly_discovered = False
203204
try:
204205
machine = self.remote_machines[ident]
205206
# Known remote machine
@@ -236,6 +237,7 @@ def add_service(self, zeroconf, _type, name):
236237
machine.api_version = api_version
237238
except KeyError:
238239
# New remote machine
240+
newly_discovered = True
239241
display_hostname = self.ensure_unique_hostname(remote_hostname)
240242

241243
logging.info(">>> Discovery: new remote: %s (%s:%d)"
@@ -263,7 +265,8 @@ def add_service(self, zeroconf, _type, name):
263265

264266
machine.has_zc_presence = True
265267

266-
if cert_result in (util.CertProcessingResult.CERT_INSERTED, util.CertProcessingResult.CERT_UPDATED):
268+
if cert_result in (util.CertProcessingResult.CERT_INSERTED, util.CertProcessingResult.CERT_UPDATED) or \
269+
(cert_result == util.CertProcessingResult.CERT_UP_TO_DATE and (newly_discovered or machine.status == RemoteStatus.OFFLINE)):
267270
machine.shutdown() # This does nothing if run more than once. It's here to make sure
268271
# the previous start thread is complete before starting a new one.
269272
# This is needed in the corner case where the remote has gone offline,

0 commit comments

Comments
 (0)