From 6e4273ef77d80efa9bacc305b3b3209521699fb5 Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Wed, 27 Apr 2016 09:19:38 +0200 Subject: [PATCH] place dnsq --- hbd | 8 ++++---- hbdclass.py | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hbd b/hbd index a3c42ec..87eb449 100755 --- a/hbd +++ b/hbd @@ -336,7 +336,7 @@ def log(host, m, service=None): def dnsupdatethread(): while True: - name, addr = dnsQ.get() + name, addr = Host.dnsQ.get() m = "changed address to %s" % (addr) err = nsupdate(name, addr) if err: @@ -344,7 +344,7 @@ def dnsupdatethread(): email("error: nsupdate failed", "%s: %s" % (name, m)) else: m += ", DNS updated." - dnsQ.task_done() + Host.dnsQ.task_done() log(name, m) # @@ -407,7 +407,7 @@ def readsock(sock): email("address change", "%s %s" % (host.name, res)) pushover("%s %s" % (host.name, res)) - if conn.getstate() != Connection.up and interval > 0: + if conn.getstate() != Connection.up: # XXX and interval > 0: lasts = conn.state d = conn.newstate(Connection.up, now) m = "%s back after being %s for %s" % (conn.afam, lasts, dur(d)) @@ -960,7 +960,7 @@ servthread = threading.Thread(target=serv.serve_forever) servthread.daemon = True servthread.start() -dnsQ = Queue.Queue() +Host.dnsQ = Queue.Queue() dnsT = threading.Thread(target=dnsupdatethread) dnsT.daemon = True dnsT.start() diff --git a/hbdclass.py b/hbdclass.py index 7005a3c..58fa9dd 100644 --- a/hbdclass.py +++ b/hbdclass.py @@ -18,6 +18,7 @@ class Connection: # map of addrs to names htab = {} + unknown = "unknown" up = "up" down = "down" overdue = "overdue" @@ -30,13 +31,13 @@ class Connection: self.rtts = [0] self.lastbeat = time.time() self.statetime = self.lastbeat - self.state = Connection.up + self.state = Connection.unknown if host: r = "new addr %s" % (addr) Connection.htab[addr] = self.host.name if self.host.isDynDns(): - dnsQ.put((self.host.name, self.addr)) + Host.dnsQ.put((self.host.name, self.addr)) def statedict(self, Null=False): @@ -107,7 +108,7 @@ class Connection: self.addr = addr Connection.htab[addr] = self.host.name if self.host.isDynDns(): - dnsQ.put((self.host.name, self.addr)) + Host.dnsQ.put((self.host.name, self.addr)) return r