summaryrefslogtreecommitdiff
path: root/server/apps/target.py
diff options
context:
space:
mode:
author韩丁康 <[email protected]>2024-05-11 20:03:24 +0800
committer韩丁康 <[email protected]>2024-05-11 20:03:24 +0800
commit840d64c187899afd7dab123f461dd0ac275c1a9c (patch)
tree2e9761b6a772af10e81e7a9daebee68a8cc6594e /server/apps/target.py
parent6208efa535f5ba7aba079cb50a8b9b871edacb48 (diff)
已实现接口同步
Diffstat (limited to 'server/apps/target.py')
-rw-r--r--server/apps/target.py43
1 files changed, 17 insertions, 26 deletions
diff --git a/server/apps/target.py b/server/apps/target.py
index 5a1875e..b80e130 100644
--- a/server/apps/target.py
+++ b/server/apps/target.py
@@ -1,6 +1,7 @@
# 目标状态感知
# 时延测试接口
import threading
+import json
import pandas as pd
import requests
@@ -95,34 +96,20 @@ def get_pernode_delay(query_data, type):
threadLock = threading.Lock()
-def task(ans, addr, row, type):
+def task(ans, addr, agent, type):
+ res = 0
if type == "icmp":
- res = icmp_delay_query(addr, row['ip'])
- threadLock.acquire()
- ans.append({
- 'Id': row['id'],
- 'CurrDelay': res,
- 'Type': type})
- threadLock.release()
- return
+ res = icmp_delay_query(addr, agent['ip'])
if type == "tcp":
- res = tcp_delay_query(addr, row['ip'])
- threadLock.acquire()
- ans.append({
- 'Id': row['id'],
- 'CurrDelay': res,
- 'Type': type})
- threadLock.release()
- return
+ res = tcp_delay_query(addr, agent['ip'])
if type == "dns":
- res = dns_delay_query(addr, row['ip'])
- threadLock.acquire()
- ans.append({
- 'Id': row['id'],
- 'CurrDelay': res,
- 'Type': type})
- threadLock.release()
-
+ res = dns_delay_query(addr, agent['ip'])
+ threadLock.acquire()
+ ans.append({
+ 'Id': agent['id'],
+ 'CurrDelay': res,
+ 'Type': type})
+ threadLock.release()
def icmp_delay_query(target, addr):
try:
@@ -180,7 +167,10 @@ from dns import resolver
@bp.get("/check")
[email protected]("通过指定的解析器获取指定域名的A/AAAA记录", hide=True)
[email protected]("通过指定的解析器获取指定域名的A/AAAA记录", description="参数说明:</br>" +
+ "rev:解析器的IP地址</br>"
+ + "domain:查询的目标域名</br>"
+ + "qtype:查询的记录类型")
@bp.input({
'rev': String(required=True),
'domain': String(required=True),
@@ -225,6 +215,7 @@ def record(query_data):
return {"code": 200, 'ans': ans}
+
@bp.get("/")
@bp.doc("(表格)目标信息获取接口", "返回目标信息")
@bp.input({