Example #1
0
def test_has_dns():
    output_valid = {
        'ESNIKeys':
        '/wFAca5pACQAHQAg/wJCen8ikwzbG8WEPaXqBqD+PnYAF07MA/JEmRbCmVYAAhMBAQQAAAAAXqjDgAAAAABesKyAAAA=',
        'version': 'FF 01',
        'checksum': '40 71 AE 69',
        'keys [0]': 'x25519',
        'keys_value [0]':
        '00 20 FF 02 42 7A 7F 22 93 0C DB 1B C5 84 3D A5 EA 06 A0 FE 3E 76 00 17 4E CC 03 F2 44 99 16 C2',
        'cipher_suites': 'TLS_AES_128_GCM_SHA256',
        'padded_length': 260,
        'not_before': datetime.datetime(2020, 4, 29, 0, 0),
        'not_after': datetime.datetime(2020, 5, 5, 0, 0),
        'extensions': '00 00'
    }
    check = ESNICheck("example.com")
    with patch("esnicheck.check.ESNICheck.dns_lookup") as mock_dns:
        mock_dns.side_effect = [
            (False, "Error"),
            (True,
             b"/wFAca5pACQAHQAg/wJCen8ikwzbG8WEPaXqBqD+PnYAF07MA/JEmRbCmVYAAhMBAQQAAAAAXqjDgAAAAABesKyAAAA="
             )
        ]
        assert (False, "Error", {}) == check.has_dns()
        assert (True, None, output_valid) == check.has_dns()
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