diff --git a/src/l3_distributedattackdetector/service/l3_distributedattackdetector.py b/src/l3_distributedattackdetector/service/l3_distributedattackdetector.py index e8763695222538d2c4b4525d105c2797a95d29d9..1ed5182b96ead1af969ff2b7909fd6b0a9035979 100644 --- a/src/l3_distributedattackdetector/service/l3_distributedattackdetector.py +++ b/src/l3_distributedattackdetector/service/l3_distributedattackdetector.py @@ -177,6 +177,7 @@ class l3_distributedattackdetector: stub = ContextServiceStub(channel) context_id = ContextId() context_id.context_uuid.uuid = context_id_str + return stub.ListServiceIds(context_id) def get_services(self, context_id_str): @@ -184,26 +185,31 @@ class l3_distributedattackdetector: stub = ContextServiceStub(channel) context_id = ContextId() context_id.context_uuid.uuid = context_id_str + return stub.ListServices(context_id) def get_service_id(self, context_id): service_list = self.get_services(context_id) service_id = None + for s in service_list.services: if s.service_type == ServiceTypeEnum.SERVICETYPE_L3NM: service_id = s.service_id break else: pass + return service_id def get_endpoint_id(self, context_id): service_list = self.get_services(context_id) endpoint_id = None + for s in service_list.services: if s.service_type == ServiceTypeEnum.SERVICETYPE_L3NM: endpoint_id = s.service_endpoint_ids[0] break + return endpoint_id def get_features_ids(self): @@ -275,7 +281,7 @@ class l3_distributedattackdetector: LOGGER.error(f"Error sending batch: {e}") async def send_data(self, metrics_list_pb, send_data_times): - # Send to CAD + # Send data to CAD if SEND_DATA_IN_BATCHES: if len(metrics_list_pb) == BATCH_SIZE: send_data_time_start = time.time() @@ -319,24 +325,24 @@ class l3_distributedattackdetector: LOGGER.info("Waiting for new data...") time.sleep(1 / 100) line = next(loglines, None) + if index == 0 and IGNORE_FIRST_LINE_TSTAT: index = index + 1 continue + if STOP: break num_lines += 1 start = time.time() line_id = line.split(" ") + self.conn_id = (line_id[0], line_id[1], line_id[14], line_id[15]) self.new_connections[self.conn_id] = self.process_line(line) self.check_if_connection_is_attack() - self.insert_connection() - self.create_cad_features() - self.check_types() connection_metadata = ConnectionMetadata(**self.cad_features["connection_metadata"])