Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
)
category_name = self.str(
ndpi.ndpi_category_get_name(self.mod, flow.classifiers[self.name]['detected_protocol'].category)
)
flow.classifiers[self.name]['application_name'] = master_name + '.' + app_name
flow.classifiers[self.name]['category_name'] = category_name
flow.classifiers[self.name]['app_id'] = flow.classifiers[self.name]['detected_protocol'].app_protocol
flow.classifiers[self.name]['master_id'] = flow.classifiers[self.name]['detected_protocol'].master_protocol
# Now we do move some values to flow.metrics just to print purpose. If you are implementing your magic
# classifier, just do flow.classifiers['name_of_your_classifier]['name_of_your_feature']
# if we move it before, it will trigger metrics callback.
flow.metrics['application_name'] = flow.classifiers[self.name]['application_name']
flow.metrics['category_name'] = flow.classifiers[self.name]['category_name']
flow.metrics['http_dns_server_name'] = self.str(
flow.classifiers[self.name]['ndpi_flow'].host_server_name
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)
)
category_name = self.str(
ndpi.ndpi_category_get_name(self.mod, flow.classifiers[self.name]['detected_protocol'].category)
)
flow.classifiers[self.name]['application_name'] = master_name + '.' + app_name
flow.classifiers[self.name]['category_name'] = category_name
flow.classifiers[self.name]['app_id'] = flow.classifiers[self.name]['detected_protocol'].app_protocol
flow.classifiers[self.name]['master_id'] = flow.classifiers[self.name]['detected_protocol'].master_protocol
# Now we do move some values to flow.metrics just to print purpose. If you are implementing your magic
# classifier, just do flow.classifiers['name_of_your_classifier]['name_of_your_feature']
# if we move it before, it will trigger metrics callback.
flow.metrics['application_name'] = flow.classifiers[self.name]['application_name']