From 22b6914f7e6e29f16981992bcfd4321526ca5ec1 Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Sat, 23 Apr 2016 12:43:15 -0400 Subject: [PATCH] add connections --- hbd | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hbd b/hbd index b40b906..532f7a2 100755 --- a/hbd +++ b/hbd @@ -82,10 +82,12 @@ def shortname(name): def isIPv4(addr): return addr.find('.') > 0 + class NullDevice: def write(self, s): pass + class LogDevice: def __init__(self): self.fh = open("/tmp/log1","a") @@ -139,6 +141,16 @@ def stodict(msg): def oldmtodict(msg): return stodict('HTB:'+msg) + +class Connection: + def __init__(self, name, cid, addr, port): + self.name = name + self.cid = cid + self.addr = addr + self.port = port + + + class Host: up = "up" down = "down" @@ -160,6 +172,7 @@ class Host: self.doesack = -1 self.cmds = [] self.cver = 0 + self.connections = {} self.latency = 0 self.hdwcounts = [[0,0],[0,0],[0,0]] num += 1 @@ -257,6 +270,11 @@ class Host: except: self.cver = 0 + try: + a=host.connections + except: + host.connections=[] + def getstate(self): return self.state @@ -503,6 +521,11 @@ def readsock(sock): host = hosts[name] newh=False + cid = msg.get('id', 0) + if cid not in host.connections: + host.connections[cid] = Connection(name, cid, addr) + conn = host.connections[cid] + host.doesack = msg.get('acks', -1) host.setcver(msg.get('ver', 0)) host.lastbeat = now