fix: import errors and port detection issue
This commit is contained in:
@@ -419,7 +419,7 @@ class AiocqhttpAdapter(Platform):
|
||||
def run(self) -> Awaitable[Any]:
|
||||
if not self.host or not self.port:
|
||||
logger.warning(
|
||||
"aiocqhttp: 未配置 ws_reverse_host 或 ws_reverse_port,将使用默认值:http://[::]:6199",
|
||||
"aiocqhttp: 未配置 ws_reverse_host 或 ws_reverse_port,将使用默认值:http://0.0.0.0:6199",
|
||||
)
|
||||
self.host = "0.0.0.0"
|
||||
self.port = 6199
|
||||
|
||||
@@ -21,7 +21,7 @@ class QQOfficialWebhook:
|
||||
self.secret = config["secret"]
|
||||
self.port = config.get("port", 6196)
|
||||
self.is_sandbox = config.get("is_sandbox", False)
|
||||
self.callback_server_host = config.get("callback_server_host", "::")
|
||||
self.callback_server_host = config.get("callback_server_host", "0.0.0.0")
|
||||
|
||||
if isinstance(self.port, str):
|
||||
self.port = int(self.port)
|
||||
|
||||
@@ -43,7 +43,7 @@ class WecomServer:
|
||||
def __init__(self, event_queue: asyncio.Queue, config: dict) -> None:
|
||||
self.server = quart.Quart(__name__)
|
||||
self.port = int(cast(str, config.get("port")))
|
||||
self.callback_server_host = config.get("callback_server_host", "::")
|
||||
self.callback_server_host = config.get("callback_server_host", "0.0.0.0")
|
||||
self.server.add_url_rule(
|
||||
"/callback/command",
|
||||
view_func=self.verify,
|
||||
|
||||
@@ -333,10 +333,18 @@ class AstrBotDashboard:
|
||||
def get_process_using_port(self, port: int) -> str:
|
||||
"""获取占用端口的进程信息"""
|
||||
try:
|
||||
for proc in psutil.process_iter(["pid", "name", "connections"]):
|
||||
for conn in proc.info["connections"] or []: # type: ignore
|
||||
if conn.laddr.port == port:
|
||||
return f"PID: {proc.info['pid']}, Name: {proc.info['name']}" # type: ignore
|
||||
for proc in psutil.process_iter(["pid", "name"]):
|
||||
try:
|
||||
connections = proc.net_connections()
|
||||
for conn in connections:
|
||||
if conn.laddr.port == port:
|
||||
return f"PID: {proc.info['pid']}, Name: {proc.info['name']}" # type: ignore
|
||||
except (
|
||||
psutil.NoSuchProcess,
|
||||
psutil.AccessDenied,
|
||||
psutil.ZombieProcess,
|
||||
):
|
||||
pass
|
||||
except Exception as e:
|
||||
return f"获取进程信息失败: {e!s}"
|
||||
return "未知进程"
|
||||
|
||||
Reference in New Issue
Block a user