Example #1
0
def test_has_esni():
    check = ESNICheck("foobar.com")
    with patch("esnicheck.check.ESNICheck.has_dns") as mock_dns, \
            patch("esnicheck.check.ESNICheck.has_tls13") as mock_tls:
        mock_dns.return_value = (True, )
        mock_tls.return_value = (True, )
        assert (True) == check.has_esni()
Example #2
0
def has_esni(hostname):
    esni = ESNICheck(hostname)
    (tls13, tls13_output) = esni.has_tls13()
    (dns, error, dns_output) = esni.has_dns()
    (host_ip, is_host_cf) = esni.is_cloudflare()

    result = dict()

    result["tls13"] = {}
    result["tls13"]["enabled"] = True if tls13 else False
    result["tls13"]["output"] = tls13_output

    result["dns"] = {}
    result["dns"]["enabled"] = True if dns else False
    result["dns"]["output"] = dns_output
    result["dns"]["error"] = error

    result["hostname"] = hostname
    result["has_esni"] = esni.has_esni()
    result["host_ip"] = host_ip
    result["is_host_cf"] = is_host_cf
    return result