Skip to content

Commit

Permalink
更新 test_doh.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sinspired authored Dec 7, 2024
1 parent 9273938 commit 075aad8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test_doh.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
}
}


# 通过 UDP 查询 DNS
def perform_udp_query(domain: str, server: str, port: int = 53) -> dict:
try:
Expand All @@ -57,6 +58,7 @@ def perform_udp_query(domain: str, server: str, port: int = 53) -> dict:
except Exception as e:
return {'server': server, 'error': str(e)}


# 通过 DoH 查询 DNS
async def perform_doh_query(domain: str, server: str) -> dict:
try:
Expand All @@ -72,6 +74,7 @@ async def perform_doh_query(domain: str, server: str) -> dict:
except Exception as e:
return {'server': server, 'error': str(e)}


# 通过 DoT 查询 DNS
async def perform_dot_query(domain: str, server: str) -> dict:
try:
Expand All @@ -92,6 +95,7 @@ async def perform_dot_query(domain: str, server: str) -> dict:
except Exception as e:
return {'server': server, 'error': str(e)}


# 执行查询并对比结果
async def compare_dns_results(domain: str, servers: List[str]):
results = []
Expand All @@ -110,6 +114,7 @@ async def compare_dns_results(domain: str, servers: List[str]):
results.append(result)
return results


# 调用函数并输出结果
async def main():
domain = "translate.google.com"
Expand All @@ -119,6 +124,7 @@ async def main():
for result in results:
print(result)


# 运行主函数
if __name__ == "__main__":
asyncio.run(main())

0 comments on commit 075aad8

Please sign in to comment.