add connections
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user