# 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, ApplicationLayerProtocolNegotiation
from flextls.field import VectorUInt8Field
from sslscan import modules
from sslscan.exception import Timeout
from sslscan.module.scan import BaseScan
            detected_protocol = None
            for extension in server_hello.extensions:
                if isinstance(extension.payload, ApplicationLayerProtocolNegotiation):
                    if len(extension.payload.protocol_name_list) > 0:
                        detected_protocol = extension.payload.protocol_name_list[0].value

            if detected_protocol is None:
                return detected_protocols

            detected_protocols.append(detected_protocol)
            available_protocols.remove(detected_protocol)

        return detected_protocols

    def run(self):
        kb = self._scanner.get_knowledge_base()

        if kb.get("server.extension.alpn") 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_alpn_tls(protocol_version)

# Path: sslscan.py

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


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

            detected_protocol = None
            for extension in server_hello.extensions:
                if isinstance(extension.payload, ApplicationLayerProtocolNegotiation):
                    if len(extension.payload.protocol_name_list) > 0:
                        detected_protocol = extension.payload.protocol_name_list[0].value

            if detected_protocol is None:
                return detected_protocols

            detected_protocols.append(detected_protocol)
            available_protocols.remove(detected_protocol)

        return detected_protocols

    def run(self):
        kb = self._scanner.get_knowledge_base()

        if kb.get("server.extension.alpn") 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_alpn_tls(protocol_version)

            except Timeout: