add connections
This commit is contained in:
@@ -82,10 +82,12 @@ def shortname(name):
|
|||||||
def isIPv4(addr):
|
def isIPv4(addr):
|
||||||
return addr.find('.') > 0
|
return addr.find('.') > 0
|
||||||
|
|
||||||
|
|
||||||
class NullDevice:
|
class NullDevice:
|
||||||
def write(self, s):
|
def write(self, s):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class LogDevice:
|
class LogDevice:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.fh = open("/tmp/log1","a")
|
self.fh = open("/tmp/log1","a")
|
||||||
@@ -139,6 +141,16 @@ def stodict(msg):
|
|||||||
def oldmtodict(msg):
|
def oldmtodict(msg):
|
||||||
return stodict('HTB:'+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:
|
class Host:
|
||||||
up = "up"
|
up = "up"
|
||||||
down = "down"
|
down = "down"
|
||||||
@@ -160,6 +172,7 @@ class Host:
|
|||||||
self.doesack = -1
|
self.doesack = -1
|
||||||
self.cmds = []
|
self.cmds = []
|
||||||
self.cver = 0
|
self.cver = 0
|
||||||
|
self.connections = {}
|
||||||
self.latency = 0
|
self.latency = 0
|
||||||
self.hdwcounts = [[0,0],[0,0],[0,0]]
|
self.hdwcounts = [[0,0],[0,0],[0,0]]
|
||||||
num += 1
|
num += 1
|
||||||
@@ -257,6 +270,11 @@ class Host:
|
|||||||
except:
|
except:
|
||||||
self.cver = 0
|
self.cver = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
a=host.connections
|
||||||
|
except:
|
||||||
|
host.connections=[]
|
||||||
|
|
||||||
|
|
||||||
def getstate(self):
|
def getstate(self):
|
||||||
return self.state
|
return self.state
|
||||||
@@ -503,6 +521,11 @@ def readsock(sock):
|
|||||||
host = hosts[name]
|
host = hosts[name]
|
||||||
newh=False
|
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.doesack = msg.get('acks', -1)
|
||||||
host.setcver(msg.get('ver', 0))
|
host.setcver(msg.get('ver', 0))
|
||||||
host.lastbeat = now
|
host.lastbeat = now
|
||||||
|
|||||||
Reference in New Issue
Block a user