# Path: toolbox/config/common.py
# BUTTON_CONFIG_KEYS = {'text', 'hidden'}
# 
# CRP_TYPES = {'docker', 'gce', 'static'}
# 
# CURRENT_MAX_VERSION = 'v3.2'
# 
# CURRENT_MIN_VERSION = 'v3.1'
# 
# PROTOCOLS = {'udp', 'tcp', 'ssh', 'http', 'ws', CONTROLLER_PROTOCOL}
# 
# Path: toolbox/utils/utils.py
# def counted_error(*args, **kwargs) -> None:
#     """
#     Wrapper for logging.error that will increase the error_counter
#     """
#     global _error_counter  # pylint: disable=global-statement
#     _error_counter += 1
#     logging.error(*args, **kwargs)
# 
# def fatal_error(*args, **kwargs) -> None:
#     """
#     Abort execution with a fatal error
#     """
#     counted_error(*args, **kwargs)
#     counted_error_at_exit()


import os
import re
import yaml
    from packaging.version import parse as parse_version
    from pkg_resources import parse_version
from toolbox.config.common import BUTTON_CONFIG_KEYS, CRP_TYPES, CURRENT_MAX_VERSION, CURRENT_MIN_VERSION, PROTOCOLS
from .utils import counted_error, fatal_error

    if config.get('flag'):
        try:
            if config['flag'][0:6] == 'regex:':
                re.compile(config['flag'][6:])
        except TypeError:
            counted_error('Invalid flag value. It must be string.')
        except Exception:
            counted_error('Failed to compile regex flag.')

        if not parse_bool(config.get('enable_flag_input')):
            counted_error('enable_flag_input must be true for static flags.')

    elif flag_required:
        counted_error('A static (or regex) flag must be set.')


def validate_ports(ports: list, buttons: dict = None):  # pylint: disable=too-many-branches
    unique_ports = set()
    ssh_ports_count = 0
    for port in ports:
        try:
            port, protocol = port.split('/', 1)
            unique_ports.add(port)
            try:
                if not 0 < int(port) < 65536:
                    raise ValueError
            except Exception:
                counted_error('Invalid port number: %s. Ports must be numbers between 1 and 65535.', port)


# Path: toolbox/config/common.py
# BUTTON_CONFIG_KEYS = {'text', 'hidden'}
# 
# CRP_TYPES = {'docker', 'gce', 'static'}
# 
# CURRENT_MAX_VERSION = 'v3.2'
# 
# CURRENT_MIN_VERSION = 'v3.1'
# 
# PROTOCOLS = {'udp', 'tcp', 'ssh', 'http', 'ws', CONTROLLER_PROTOCOL}
# 
# Path: toolbox/utils/utils.py
# def counted_error(*args, **kwargs) -> None:
#     """
#     Wrapper for logging.error that will increase the error_counter
#     """
#     global _error_counter  # pylint: disable=global-statement
#     _error_counter += 1
#     logging.error(*args, **kwargs)
# 
# def fatal_error(*args, **kwargs) -> None:
#     """
#     Abort execution with a fatal error
#     """
#     counted_error(*args, **kwargs)
#     counted_error_at_exit()


# Path: toolbox/utils/config.py
import os
import re
import yaml
    from packaging.version import parse as parse_version
    from pkg_resources import parse_version
from toolbox.config.common import BUTTON_CONFIG_KEYS, CRP_TYPES, CURRENT_MAX_VERSION, CURRENT_MIN_VERSION, PROTOCOLS
from .utils import counted_error, fatal_error


    if config.get('flag'):
        try:
            if config['flag'][0:6] == 'regex:':
                re.compile(config['flag'][6:])
        except TypeError:
            counted_error('Invalid flag value. It must be string.')
        except Exception:
            counted_error('Failed to compile regex flag.')

        if not parse_bool(config.get('enable_flag_input')):
            counted_error('enable_flag_input must be true for static flags.')

    elif flag_required:
        counted_error('A static (or regex) flag must be set.')


def validate_ports(ports: list, buttons: dict = None):  # pylint: disable=too-many-branches
    unique_ports = set()
    ssh_ports_count = 0
    for port in ports:
        try:
            port, protocol = port.split('/', 1)
            unique_ports.add(port)
            try:
                if not 0 < int(port) < 65536:
                    raise ValueError
            except Exception:
                counted_error('Invalid port number: %s. Ports must be numbers between 1 and 65535.', port)


            if protocol not in PROTOCOLS: