# Path: sslscan.py

# 
# Path: sslscan/exception.py
# class Timeout(Exception):
#     pass


import flextls
from flextls.protocol.handshake import Handshake, ServerHello
from flextls.protocol.handshake.extension import Extension, NextProtocolNegotiation
from flextls.field import VectorUInt8Field
from sslscan import modules
from sslscan.exception import Timeout
from sslscan.module.scan import BaseScan

        if kb.get("server.extension.next_protocol_negotiation") is not None:
            return

        protocol_versions = self._scanner.get_enabled_versions()
        protocol_versions.reverse()

        detected_protocols = None
        for protocol_version in protocol_versions:
            if protocol_version == flextls.registry.version.SSLv2:
                continue

            try:
                detected_protocols = self._scan_next_protocol_tls(protocol_version)
            except Timeout:
                continue

            if detected_protocols is not None:
                break

        if detected_protocols is None or len(detected_protocols) == 0:
            kb.set("server.extension.next_protocol_negotiation", False)
        else:
            tmp_proto = []
            for protocol in detected_protocols:
                tmp_proto.append(flextls.registry.tls.alpn_protocols.get(protocol))

            kb.set("server.extension.next_protocol_negotiation", tmp_proto)



# Path: sslscan.py

# 
# Path: sslscan/exception.py
# class Timeout(Exception):
#     pass


# Path: sslscan/module/scan/server_next_protocol.py
import flextls
from flextls.protocol.handshake import Handshake, ServerHello
from flextls.protocol.handshake.extension import Extension, NextProtocolNegotiation
from flextls.field import VectorUInt8Field
from sslscan import modules
from sslscan.exception import Timeout
from sslscan.module.scan import BaseScan


        if kb.get("server.extension.next_protocol_negotiation") is not None:
            return

        protocol_versions = self._scanner.get_enabled_versions()
        protocol_versions.reverse()

        detected_protocols = None
        for protocol_version in protocol_versions:
            if protocol_version == flextls.registry.version.SSLv2:
                continue

            try:
                detected_protocols = self._scan_next_protocol_tls(protocol_version)
            except Timeout:
                continue

            if detected_protocols is not None:
                break

        if detected_protocols is None or len(detected_protocols) == 0:
            kb.set("server.extension.next_protocol_negotiation", False)
        else:
            tmp_proto = []
            for protocol in detected_protocols:
                tmp_proto.append(flextls.registry.tls.alpn_protocols.get(protocol))

            kb.set("server.extension.next_protocol_negotiation", tmp_proto)



modules.register(ServerNextProtocolNegotiation)