|
@@ -60,6 +60,8 @@ class LogManagementView(View):
|
|
|
return self.getAlarmLog(request_dict, response)
|
|
|
elif operation == 'getDomainLog': # 获取域名日志
|
|
|
return self.getDomainLog(request_dict, response)
|
|
|
+ elif operation == 'getDomainScanLog': # 获取域名扫码日志
|
|
|
+ return self.getDomainScanLog(request_dict, response)
|
|
|
else:
|
|
|
return response.json(404)
|
|
|
|
|
@@ -474,3 +476,60 @@ class LogManagementView(View):
|
|
|
return response.json(0, {'list': device_domain_list, 'total': count})
|
|
|
except Exception as e:
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def getDomainScanLog(request_dict, response):
|
|
|
+ serial_number = request_dict.get('serialNumber', None)
|
|
|
+
|
|
|
+ if not all([serial_number]):
|
|
|
+ return response.json(444)
|
|
|
+
|
|
|
+ try:
|
|
|
+ scan_log_qs = AppScannedSerial.objects.filter(serial__contains=serial_number).values('ip', 'add_time',
|
|
|
+ 'update_time')
|
|
|
+ device_domain_qs = DeviceDomainRegionModel.objects.filter(~Q(country_code=''),
|
|
|
+ Q(serial_number__contains=serial_number)).values()
|
|
|
+ res = {}
|
|
|
+ if scan_log_qs.exists() and device_domain_qs.exists():
|
|
|
+ device_domain = device_domain_qs[0]
|
|
|
+ domain_ip = device_domain['ip']
|
|
|
+ region_id = device_domain['region_id']
|
|
|
+ country_code = device_domain['country_code']
|
|
|
+ ip_addr_qs = IPAddr.objects.filter(ip=domain_ip, is_geoip2=False).values('region')
|
|
|
+ if ip_addr_qs.exists():
|
|
|
+ region = ip_addr_qs[0]['region']
|
|
|
+ else:
|
|
|
+ ip_qs = IPQuery(domain_ip)
|
|
|
+ region = ip_qs.region
|
|
|
+
|
|
|
+ # 港澳台返回美洲域名
|
|
|
+ if country_code == 'CN' and region in ['香港', '澳门', '台湾']:
|
|
|
+ country_code = region
|
|
|
+
|
|
|
+ # 查询域名数据
|
|
|
+ region_qs = RegionModel.objects.filter(id=region_id).values('api', 'name')
|
|
|
+
|
|
|
+ api = 'https://www.dvema.com/'
|
|
|
+ region_name = '美洲'
|
|
|
+ if region_qs.exists():
|
|
|
+ api = region_qs[0]['api']
|
|
|
+ region_name = region_qs[0]['name']
|
|
|
+
|
|
|
+ api_region = region_name + '域名'
|
|
|
+
|
|
|
+ res = {
|
|
|
+ 'serial_number': device_domain['serial_number'],
|
|
|
+ 'domain_ip': domain_ip,
|
|
|
+ 'scan_ip': device_domain_qs[0]['ip'],
|
|
|
+ 'region_id': region_id,
|
|
|
+ 'country_code': country_code,
|
|
|
+ 'api': api,
|
|
|
+ 'api_region': api_region,
|
|
|
+ 'domain_add_time': device_domain['add_time'].strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
+ 'domain_update_time': device_domain['update_time'].strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
+ 'scan_add_time': device_domain_qs[0]['add_time'].strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
+ 'scan_update_time': device_domain_qs[0]['update_time'].strftime("%Y-%m-%d %H:%M:%S"),
|
|
|
+ }
|
|
|
+ return response.json(0, res)
|
|
|
+ except Exception as e:
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|