def is_local_destination(self, mapping_socket): destination_is_local = False if mapping_socket.destination_ip is not None and mapping_socket.family == "AF_INET": for nic in self.nics: if NetworkInterfaceCard.ip_is_in_subnet(mapping_socket.destination_ip, nic.ipv4_subnet_addr, nic.ipv4_subnet_mask): destination_is_local = True break elif mapping_socket.destination_ip is not None and mapping_socket.family == "AF_INET6": destination_ipv4 = MapSocket.ipv6_2_ipv4(mapping_socket.destination_ip) if destination_ipv4 != mapping_socket.destination_ip: for nic in self.nics: if NetworkInterfaceCard.ip_is_in_subnet(destination_ipv4, nic.ipv4_subnet_addr, nic.ipv4_subnet_mask): destination_is_local = True break else: #TODO: check is ipv6 in subnet ? for nic in self.nics: if nic.ipv6_address is not None and mapping_socket.destination_ip == nic.ipv6_address: destination_is_local = True break elif NetworkInterfaceCard.ip_is_in_subnet(mapping_socket.destination_ip, nic.ipv4_subnet_addr, nic.ipv4_subnet_mask): destination_is_local = True break elif mapping_socket.family == "AF_UNIX": destination_is_local = True return destination_is_local
def from_json(json_obj): #LOGGER.debug("DockerContainerProcess.from_json") map_sockets_json = json_obj['map_sockets'] if json_obj['map_sockets'] else [] map_sockets = [] for map_socket_json in map_sockets_json: map_sockets.append(MapSocket.from_json(map_socket_json)) last_map_sockets_json = json_obj['last_map_sockets'] if json_obj['last_map_sockets'] else [] last_map_sockets = [] for last_map_socket_json in last_map_sockets_json: last_map_sockets.append(MapSocket.from_json(last_map_socket_json)) return DockerContainerProcess( pid=json_obj['pid'] if json_obj['pid'] else None, mdpid=json_obj['mdpid'] if json_obj['mdpid'] else None, mospid=json_obj['mospid'] if json_obj['mospid'] else None, mcid=json_obj['mcid'] if json_obj['mcid'] else None, map_sockets=map_sockets, last_map_sockets=last_map_sockets )