def matchReturnDomain(match, val, reverse=False): if dmdomain.match(match, val): if restype=='int': if reverse: return 0 return 1 else: if reverse: return False return True if restype=='int': if reverse: return 1 return 0 else: if reverse: return True return False
def networkEventMatch(self, er, data): ret=False try: # ['IOSTATUS.NOW', 'CAMERETTATER15 ', '65534', '5', '3', '\x02\x02\x01\x00\x06@\x07\xe0\x01\xef\xe5\xf0\x02\x07i\xabP\x00\x00\x00\x00\x00\x00\x00J', '192.168.4.215'] # ['RELAYSTATUS.CHANGE', 'E0D015 ', '65534', '5', '3', 'RELAY', ' 9 CHANGED TO', 'OFF', '192.168.3.203'] dst=data[0].replace(" ","") src=data[1].replace(" ","") ctx=data[2] msgtype=data[3] act=data[4] arg=data[5:len(data)-1] host=data[len(data)-1] if "arg" in er.keys(): try: ret=True a=er["arg"].split("|") for ar in a: aidx=int(ar.split(",")[0]) amatch=ar.split(",")[1] if aidx <= len(arg)-1: if arg[aidx] != amatch: return False else: return False except: pass if "dmdomain" in er.keys(): ret=True if not dmdomain.match(er["dmdomain"], dst): return False if "revdmdomain" in er.keys(): ret=True if not dmdomain.match(dst, er["dmdomain"]): return False if "exactdomain" in er.keys(): ret=True if er["exactdomain"] != dst: return False if "src" in er.keys(): ret=True if src != er["src"]: return False if "exactsrc" in er.keys(): ret=True if src != er["exactsrc"]: return False if "srcdomain" in er.keys(): ret=True if not dmdomain.match(er["srcdomain"], src): return False if "ctx" in er.keys(): ret=True if int(er["ctx"]) != int(ctx): return False if "msgtype" in er.keys(): ret=True if int(er["msgtype"]) != int(msgtype): return False if "act" in er.keys(): ret=True if int(er["act"]) != int(act): return False if "host" in er.keys(): ret=True if not host.startswith(er["host"]): return False if "parsearg" in er.keys(): # XXX TODO Qui bisogna inventarsi un parser per gli argomenti return False return ret except: return False