Exemplo n.º 1
0
    def _load_control_data(self):
        """
        Sets the control data defined in the configuration file
        """
        self.logger.debug("Stating _load_control_data")

        try:
            self.use_ssl = ParseFormats.parse_bool(Config().get_config_param(
                'Control', 'UseSSL'))
            self.control_port = ParseFormats.parse_uint16(
                Config().get_config_param('Control', 'ControlPort'))
            self.log_on_connect = ParseFormats.parse_bool(
                Config().get_config_param('Control', 'LogOnConnect'))
            self.log_command = ParseFormats.parse_bool(
                Config().get_config_param('Control', 'LogCommand'))
            self.control_hosts = self.config['Control']['Access']['Host']
            self.control_user, self.control_passwd = \
                self.config['Control']['Access']['User'].split(':')

            self.logger.debug("Ending _load_control_data")

        except ValueError as verr:
            self.logger.error(
                "The value for control port{0} is not a valid number".format(
                    Config().get_config_param('Control', 'ControlPort')))

            raise ValueError(
                "The value for control port{0} is not a valid number".format(
                    Config().get_config_param('Control', 'ControlPort')))
Exemplo n.º 2
0
    def __init__(self):
        self.domain = Config().get_config_param('Main','Domain')
        use_ipv6 = Config().get_config_param('Main','UseIPv6')
        self.use_ipv6 = ParseFormats.parse_bool(use_ipv6)
        if self.use_ipv6:
            self.ip_address6 = ParseFormats.parse_ipaddress(Config().get_config_param('Main','LocalAddr-V6'))
        else:
            self.ip_address4 = ParseFormats.parse_ipaddress(Config().get_config_param('Main','LocalAddr-V4'))

        # Gets default ports (origin, destination)
        self.local_port = ParseFormats.parse_uint16(Config().get_config_param('Main','LocalPort'))
        self.protocol = ParseFormats.parse_uint8( Config().get_config_param('Main','DefaultProtocol'))
        self.life_time = ParseFormats.parse_uint8( Config().get_config_param('Main','LifeTime'))
        self.inmediate_start = ParseFormats.parse_bool( Config().get_config_param('Main','ImmediateStart'))
Exemplo n.º 3
0
    def _parse_global_options(self, item: Element) -> (dict, dict):
        """
        Parse global options within the xml
        :param item: Global Tag
        :return: dictionary of configuration items.
                list of actions.
        """
        global_misc = {}
        global_actions = {}

        for sub_item in item.iterchildren():
            if isinstance(sub_item.tag, str):
                if sub_item.tag.lower() == "pref":
                    config_param = ConfigParam()
                    config_param.parse_config_item(sub_item)
                    global_misc[config_param.name] = config_param

                if sub_item.tag.lower() == "action":
                    action = Action("", False, dict())
                    action.parse_action(sub_item)
                    default = sub_item.get("DEFAULT")
                    if not default:
                        raise ValueError(
                            "Auction Parser Error: missing name at line {0}".
                            format(str(sub_item.sourceline)))
                    else:
                        action.default_action = ParseFormats.parse_bool(
                            default)
                    global_actions[action.name] = action

        return global_misc, global_actions
Exemplo n.º 4
0
    def __init__(self, config_file_name: str):
        self._pending_tasks_by_auction = {}

        self.config = Config(config_file_name).get_config()

        # Start Listening the web server application
        loop = asyncio.get_event_loop()
        self.app = Application(loop=loop)

        # Gets the log file
        log_file_name = self.config['DefaultLogFile']
        self.logger = log(log_file_name).get_logger()

        self.domain = ParseFormats.parse_int(Config().get_config_param(
            'Main', 'Domain'))
        self.immediate_start = ParseFormats.parse_bool(
            Config().get_config_param('Main', 'ImmediateStart'))

        self._load_main_data()
        self._load_control_data()
Exemplo n.º 5
0
    def __init__(self):

        self.domain = Config().get_config_param('Main', 'Domain')
        use_ipv6 = Config().get_config_param('Main', 'UseIPv6')
        self.use_ipv6 = ParseFormats.parse_bool(use_ipv6)
        self.ip_address6 = ParseFormats.parse_ipaddress(
            Config().get_config_param('Main', 'LocalAddr-V6'))
        self.destination_address6 = ParseFormats.parse_ipaddress(
            Config().get_config_param('Main', 'DefaultDestinationAddr-V6'))
        self.ip_address4 = ParseFormats.parse_ipaddress(
            Config().get_config_param('Main', 'LocalAddr-V4'))
        self.destination_address4 = ParseFormats.parse_ipaddress(
            Config().get_config_param('Main', 'DefaultDestinationAddr-V4'))

        # Gets default ports (origin, destination)
        self.source_port = ParseFormats.parse_uint16(Config().get_config_param(
            'Main', 'DefaultSourcePort'))
        self.destination_port = ParseFormats.parse_uint16(
            Config().get_config_param('Main', 'DefaultDestinationPort'))
        self.protocol = ParseFormats.parse_uint8(Config().get_config_param(
            'Main', 'DefaultProtocol'))
        self.life_time = ParseFormats.parse_uint8(Config().get_config_param(
            'Main', 'LifeTime'))