Merge pull request #11 from yuvelq/patch-2

Add 'DNS_TIME' for 'XLXPEER' instances
This commit is contained in:
hacknix 2021-09-12 12:33:32 +01:00 committed by GitHub
commit 2e5c8c82e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,6 @@ from collections import deque
from twisted.internet.protocol import DatagramProtocol, Factory, Protocol
from twisted.protocols.basic import NetstringReceiver
from twisted.internet import reactor, task
from twisted.names import client
# Other files we pull from -- this is mostly for readability and segmentation
import log
@ -314,6 +313,7 @@ class HBSYSTEM(DatagramProtocol):
elif self._config['MODE'] == 'XLXPEER':
self._stats = self._config['XLXSTATS']
self._stats['DNS_TIME'] = time()
self.send_system = self.send_master
self.maintenance_loop = self.peer_maintenance_loop
self.datagramReceived = self.peer_datagramReceived
@ -364,7 +364,7 @@ class HBSYSTEM(DatagramProtocol):
self._stats['CONNECTION'] = 'RPTL_SENT'
if self._stats['DNS_TIME'] < (time() - 600):
self._stats['DNS_TIME'] = time()
_d = client.getHostByName(self._config['_MASTER_IP'])
_d = reactor.resolve(self._config['_MASTER_IP'])
_d.addCallback(self.updateSockaddr)
_d.addErrback(self.updateSockaddr_errback)
self.send_master(b''.join([RPTL, self._config['RADIO_ID']]))