|
|
@@ -147,6 +147,9 @@ class SearchDomainGUI:
|
|
|
self.search_button = ttk.Button(button_frame, text="开始搜索", command=self.start_search)
|
|
|
self.search_button.pack(side=tk.LEFT, padx=5)
|
|
|
|
|
|
+ self.cancel_search_button = ttk.Button(button_frame, text="终止", command=self.cancel_search, state=tk.DISABLED)
|
|
|
+ self.cancel_search_button.pack(side=tk.LEFT, padx=5)
|
|
|
+
|
|
|
ttk.Button(button_frame, text="清空日志", command=self.clear_log).pack(side=tk.LEFT, padx=5)
|
|
|
|
|
|
def browse_input_file(self):
|
|
|
@@ -315,11 +318,19 @@ class SearchDomainGUI:
|
|
|
# 在后台线程中运行
|
|
|
self.is_running = True
|
|
|
self.search_button.config(state=tk.DISABLED)
|
|
|
+ self.cancel_search_button.config(state=tk.NORMAL)
|
|
|
self.status_var.set("正在搜索域名...")
|
|
|
|
|
|
thread = threading.Thread(target=self._search_thread, args=(params, export_all))
|
|
|
thread.daemon = True
|
|
|
thread.start()
|
|
|
+
|
|
|
+ def cancel_search(self):
|
|
|
+ """取消搜索任务"""
|
|
|
+ if self.search_domain_instance and self.is_running:
|
|
|
+ self.search_domain_instance.cancel()
|
|
|
+ self.log("正在终止搜索任务...")
|
|
|
+ self.status_var.set("正在终止...")
|
|
|
|
|
|
def _search_thread(self, params, export_all):
|
|
|
"""搜索域名的后台线程"""
|
|
|
@@ -331,32 +342,39 @@ class SearchDomainGUI:
|
|
|
self.log(f"导出所有: {export_all}")
|
|
|
|
|
|
# 传入日志回调函数,将搜索进度显示在运行日志中
|
|
|
- searchdomain = SearchDomain(params=params, debug=True, export_all=export_all, log_callback=self.log)
|
|
|
- searchdomain.run()
|
|
|
-
|
|
|
- self.log("域名搜索完成!")
|
|
|
- output_path = os.path.join(params["app_path"], params["output"])
|
|
|
- self.log(f"结果已保存到: {output_path}")
|
|
|
+ self.search_domain_instance = SearchDomain(params=params, debug=True, export_all=export_all, log_callback=self.log)
|
|
|
+ self.search_domain_instance.run()
|
|
|
|
|
|
- # 验证文件是否真的存在
|
|
|
- if os.path.exists(output_path):
|
|
|
- file_size = os.path.getsize(output_path)
|
|
|
- self.log(f"文件大小: {file_size} 字节")
|
|
|
- messagebox.showinfo("成功", f"域名搜索完成!\n结果已保存到: {output_path}\n文件大小: {file_size} 字节")
|
|
|
+ # 检查是否被取消
|
|
|
+ if self.search_domain_instance._cancelled:
|
|
|
+ self.log("搜索任务已取消")
|
|
|
+ self.root.after(0, lambda: messagebox.showinfo("提示", "搜索任务已取消"))
|
|
|
else:
|
|
|
- error_msg = f"警告:输出文件不存在: {output_path}"
|
|
|
- self.log(error_msg)
|
|
|
- messagebox.showwarning("警告", error_msg)
|
|
|
+ self.log("域名搜索完成!")
|
|
|
+ output_path = os.path.join(params["app_path"], params["output"])
|
|
|
+ self.log(f"结果已保存到: {output_path}")
|
|
|
+
|
|
|
+ # 验证文件是否真的存在
|
|
|
+ if os.path.exists(output_path):
|
|
|
+ file_size = os.path.getsize(output_path)
|
|
|
+ self.log(f"文件大小: {file_size} 字节")
|
|
|
+ self.root.after(0, lambda: messagebox.showinfo("成功", f"域名搜索完成!\n结果已保存到: {output_path}\n文件大小: {file_size} 字节"))
|
|
|
+ else:
|
|
|
+ error_msg = f"警告:输出文件不存在: {output_path}"
|
|
|
+ self.log(error_msg)
|
|
|
+ self.root.after(0, lambda: messagebox.showwarning("警告", error_msg))
|
|
|
|
|
|
except Exception as e:
|
|
|
error_msg = f"搜索域名时出错: {str(e)}"
|
|
|
self.log(error_msg)
|
|
|
import traceback
|
|
|
self.log(traceback.format_exc())
|
|
|
- messagebox.showerror("错误", error_msg)
|
|
|
+ self.root.after(0, lambda: messagebox.showerror("错误", error_msg))
|
|
|
finally:
|
|
|
self.is_running = False
|
|
|
+ self.search_domain_instance = None
|
|
|
self.root.after(0, lambda: self.search_button.config(state=tk.NORMAL))
|
|
|
+ self.root.after(0, lambda: self.cancel_search_button.config(state=tk.DISABLED))
|
|
|
self.root.after(0, lambda: self.status_var.set("就绪"))
|
|
|
|
|
|
|