How to use the nfstream.classifier.NFStreamClassifier.on_flow_terminate function in nfstream

To help you get started, we’ve selected a few nfstream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aouinizied / nfstream / nfstream / classifier.py View on Github external
def on_flow_terminate(self, flow):
        NFStreamClassifier.on_flow_terminate(self, flow)
        if flow.classifiers[self.name]['detected_protocol'].app_protocol == 0 and \
                flow.classifiers[self.name]['guessed'] == 0:  # didn't reach max and still unknown, so give up!
            flow.classifiers[self.name]['detected_protocol'] = ndpi.ndpi_detection_giveup(
                self.mod,
                byref(flow.classifiers[self.name]['ndpi_flow']),
                1,
                cast(addressof(c_uint8(0)), POINTER(c_uint8))
            )
            flow.classifiers[self.name]['guessed'] = 1

        master_name = self.str(
            ndpi.ndpi_get_proto_name(self.mod, flow.classifiers[self.name]['detected_protocol'].master_protocol)
        )
        app_name = self.str(
            ndpi.ndpi_get_proto_name(self.mod, flow.classifiers[self.name]['detected_protocol'].app_protocol)
        )