# 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
        next_protocol_ext = None
        for extension in server_hello.extensions:
            if isinstance(extension.payload, NextProtocolNegotiation):
                next_protocol_ext = extension.payload

        if next_protocol_ext is None:
            return None

        detected_protocols = []
        for protocol in next_protocol_ext.payload:
            detected_protocols.append(protocol.value)

        return detected_protocols

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

        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)

# 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

        next_protocol_ext = None
        for extension in server_hello.extensions:
            if isinstance(extension.payload, NextProtocolNegotiation):
                next_protocol_ext = extension.payload

        if next_protocol_ext is None:
            return None

        detected_protocols = []
        for protocol in next_protocol_ext.payload:
            detected_protocols.append(protocol.value)

        return detected_protocols

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

        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: