|
|
|
@ -29,12 +29,12 @@ class DoorController: |
|
|
|
|
api_longpoll, |
|
|
|
|
api_swipe, |
|
|
|
|
api_key, |
|
|
|
|
uid_hash): |
|
|
|
|
uid_salt): |
|
|
|
|
self.door = door |
|
|
|
|
self.api_allowed = api_allowed |
|
|
|
|
self.api_longpoll = api_longpoll |
|
|
|
|
self.api_swipe = api_swipe |
|
|
|
|
self.uid_hash = uid_hash |
|
|
|
|
self.uid_salt = uid_salt |
|
|
|
|
|
|
|
|
|
self.uids = {} |
|
|
|
|
|
|
|
|
@ -67,20 +67,19 @@ class DoorController: |
|
|
|
|
uids.add(token["token"]["uid_hash"].strip()) |
|
|
|
|
self.uids = uids |
|
|
|
|
|
|
|
|
|
def wiegand_callback(self, bits, value): |
|
|
|
|
uid_h = hash_uid(value, self.uid_hash) |
|
|
|
|
logging.debug("hash %s", uid_h) |
|
|
|
|
if uid_h in self.uids: |
|
|
|
|
logging.info("Opening door for UID hash trail %s", uid_h[-10:]) |
|
|
|
|
def wiegand_callback(self, value): |
|
|
|
|
uid_hash = hash_uid(value, self.uid_salt) |
|
|
|
|
logging.debug(f"hash {uid_hash}") |
|
|
|
|
if uid_hash in self.uids: |
|
|
|
|
logging.info(f"Opening door for UID hash trail {uid_hash[-10:]}") |
|
|
|
|
self.wiegand.open_door() |
|
|
|
|
success = True |
|
|
|
|
else: |
|
|
|
|
logging.info("Access card not in allow list, hash trail %s", |
|
|
|
|
uid_h[-10:]) |
|
|
|
|
logging.info(f"Access card not in allow list, hash trail {uid_hash[-10:]}") |
|
|
|
|
success = False |
|
|
|
|
data = { |
|
|
|
|
"uid": value, |
|
|
|
|
"uid_hash": uid_h, |
|
|
|
|
"uid_hash": uid_hash, |
|
|
|
|
"door": self.door, |
|
|
|
|
"timestamp": time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) |
|
|
|
|
} |
|
|
|
@ -127,9 +126,10 @@ class DoorController: |
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
DoorController( |
|
|
|
|
os.environ["KDOORPI_DOOR"], |
|
|
|
|
os.environ["KDOORPI_API_ALLOWED"], |
|
|
|
|
os.environ["KDOORPI_API_LONGPOLL"], |
|
|
|
|
os.environ["KDOORPI_API_SWIPE"], |
|
|
|
|
os.environ["KDOORPI_API_KEY"], |
|
|
|
|
os.environ["KDOORPI_UID_SALT"]) |
|
|
|
|
door=os.environ["KDOORPI_DOOR"], |
|
|
|
|
api_allowed=os.environ["KDOORPI_API_ALLOWED"], |
|
|
|
|
api_longpoll=os.environ["KDOORPI_API_LONGPOLL"], |
|
|
|
|
api_swipe=os.environ["KDOORPI_API_SWIPE"], |
|
|
|
|
api_key=os.environ["KDOORPI_API_KEY"], |
|
|
|
|
uid_salt=os.environ["KDOORPI_UID_SALT"], |
|
|
|
|
) |
|
|
|
|