Exemplo n.º 1
0
def _site_config_for_livestatus(site_id: SiteId, site: SiteConfiguration) -> SiteConfiguration:
    """Prepares a site config specification for the livestatus module

    In case the GUI connects to the local livestatus proxy there are several
    special things to do:
    a) Tell livestatus not to strip away the cache header
    b) Connect in plain text to the sites local proxy unix socket
    """
    copied_site: SiteConfiguration = site.copy()

    if copied_site["proxy"] is not None:
        copied_site["cache"] = site["proxy"].get("cache", True)

    else:
        if copied_site["socket"][0] in ["tcp", "tcp6"]:
            copied_site["tls"] = site["socket"][1]["tls"]

    copied_site["socket"] = encode_socket_for_livestatus(site_id, site)

    return copied_site
Exemplo n.º 2
0
def _site_config_for_livestatus(
        site_id: SiteId, site_spec: SiteConfiguration) -> SiteConfiguration:
    """Prepares a site config specification for the livestatus module

    In case the GUI connects to the local livestatus proxy there are several
    special things to do:
    a) Tell livestatus not to strip away the cache header
    b) Connect in plain text to the sites local proxy unix socket
    """
    copied_site: SiteConfiguration = SiteConfiguration(site_spec.copy())

    # Astroid 2.x bug prevents us from using NewType https://github.com/PyCQA/pylint/issues/2296
    # pylint: disable=unsupported-assignment-operation
    if copied_site["proxy"] is not None:
        copied_site["cache"] = site_spec["proxy"].get("cache", True)
    else:
        if copied_site["socket"][0] in ["tcp", "tcp6"]:
            copied_site["tls"] = site_spec["socket"][1]["tls"]
    copied_site["socket"] = encode_socket_for_livestatus(site_id, site_spec)

    return copied_site