Ejemplo n.º 1
0
    def __init__(self, args, listen_address, listen_port, received_mapping,
                 db_wrapper):
        self.__current_users = {}
        self.__listen_adress = listen_address
        self.__listen_port = listen_port
        self._send_queue = queue.Queue()

        self.__received = {}  # map with received IDs
        self.__receivedMutex = Lock()

        self.__requests = {}  # map with ID, event mapping
        self.__requestsMutex = Lock()

        self.__nextId = 0
        self.__idMutex = Lock()
        self.args = args
        self.db_wrapper = db_wrapper
        mapping_parser = MappingParser(self.db_wrapper)
        self.device_mappings = mapping_parser.get_devicemappings()
        self.routemanagers = mapping_parser.get_routemanagers()
        self.auths = mapping_parser.get_auths()
        self._received_mapping = received_mapping
Ejemplo n.º 2
0
def load_mappings(db_wrapper):
    mapping_parser = MappingParser(db_wrapper)
    device_mappings = mapping_parser.get_devicemappings()
    routemanagers = mapping_parser.get_routemanagers()
    auths = mapping_parser.get_auths()
    return (device_mappings, routemanagers, auths)
Ejemplo n.º 3
0
Archivo: start.py Proyecto: na-ji/MAD
                )
                sys.exit(1)

            log.fatal(
                "No mappings.json found - starting setup mode with madmin.")
            log.fatal("Open Madmin (ServerIP with Port " +
                      str(args.madmin_port) +
                      ") - 'Mapping Editor' and restart.")
            generate_mappingjson()
        else:

            try:
                mapping_parser = MappingParser(db_wrapper)
                device_mappings = mapping_parser.get_devicemappings()
                routemanagers = mapping_parser.get_routemanagers()
                auths = mapping_parser.get_auths()
            except KeyError as e:
                log.fatal(
                    "Could not parse mappings. Please check those. Description: %s"
                    % str(e))
                sys.exit(1)

            mitm_mapper = MitmMapper(device_mappings)
            ocr_enabled = False
            for routemanager in routemanagers.keys():
                area = routemanagers.get(routemanager, None)
                if area is None:
                    continue
                if "ocr" in area.get("mode", ""):
                    ocr_enabled = True
            if ocr_enabled: