-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
IPV6支持,astrbot run子命令完善 #4892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IPV6支持,astrbot run子命令完善 #4892
Changes from 1 commit
ecbbdc8
0003dec
84ef04e
24f9db2
40f9045
279a39c
a8cad50
84fad9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 3.10 | ||
| 3.10 |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -9,7 +9,6 @@ | |||
| from flask.json.provider import DefaultJSONProvider | ||||
| from hypercorn.asyncio import serve | ||||
| from hypercorn.config import Config as HyperConfig | ||||
| from psutil._common import addr as psutil_addr | ||||
| from quart import Quart, g, jsonify, request | ||||
| from quart.logging import default_handler | ||||
|
|
||||
|
|
@@ -168,7 +167,7 @@ def get_process_using_port(self, port: int) -> str: | |||
| """获取占用端口的进程详细信息""" | ||||
| try: | ||||
| for conn in psutil.net_connections(kind="inet"): | ||||
|
LIghtJUNction marked this conversation as resolved.
Outdated
|
||||
| if cast(psutil_addr, conn.laddr).port == port: | ||||
| if conn.laddr and conn.laddr.port == port: | ||||
| try: | ||||
| process = psutil.Process(conn.pid) | ||||
| # 获取详细信息 | ||||
|
|
@@ -197,29 +196,45 @@ def _init_jwt_secret(self): | |||
|
|
||||
| def run(self): | ||||
| ip_addr = [] | ||||
| if p := os.environ.get("DASHBOARD_PORT"): | ||||
| port = p | ||||
| else: | ||||
| port = self.core_lifecycle.astrbot_config["dashboard"].get("port", 6185) | ||||
| host = self.core_lifecycle.astrbot_config["dashboard"].get("host", "0.0.0.0") | ||||
| enable = self.core_lifecycle.astrbot_config["dashboard"].get("enable", True) | ||||
| conf = self.core_lifecycle.astrbot_config["dashboard"] | ||||
| port = os.environ.get("DASHBOARD_PORT") or conf.get("port", 6185) | ||||
| host = os.environ.get("DASHBOARD_HOST") or conf.get("host", "::") | ||||
| enable = os.environ.get("DASHBOARD_ENABLE") or conf.get("enable", True) | ||||
|
sourcery-ai[bot] marked this conversation as resolved.
Outdated
LIghtJUNction marked this conversation as resolved.
Outdated
|
||||
|
|
||||
| if not enable: | ||||
| logger.info("WebUI 已被禁用") | ||||
| return None | ||||
|
|
||||
| logger.info(f"正在启动 WebUI, 监听地址: http://{host}:{port}") | ||||
| display_host = f"[{host}]" if ":" in host and "[" not in host else host | ||||
| logger.info(f"正在启动 WebUI, 监听地址: http://{display_host}:{port}") | ||||
|
|
||||
| if host == "0.0.0.0": | ||||
| if host == "::" or host == "0.0.0.0": | ||||
| logger.info( | ||||
| "提示: WebUI 将监听所有网络接口,请注意安全。(可在 data/cmd_config.json 中配置 dashboard.host 以修改 host)", | ||||
| ) | ||||
|
|
||||
| if host not in ["localhost", "127.0.0.1"]: | ||||
| try: | ||||
| ip_addr = get_local_ip_addresses() | ||||
| except Exception as _: | ||||
| pass | ||||
| if host == "::" or host == "0.0.0.0": | ||||
| try: | ||||
| ip_addr = get_local_ip_addresses() | ||||
| # 尝试获取 IPv6 地址 | ||||
| import socket | ||||
|
||||
| import socket |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition any(":" in ip and not ip.startswith(("fe80", "::1")) for ip in ip_addr) on line 260 intends to detect public IPv6 addresses, but this logic is flawed. It will match any IPv6 address containing ":" that doesn't start with "fe80" or "::1", including private IPv6 addresses like those in the fd00::/8 range (Unique Local Addresses). This could result in displaying the "检测到公网 IPv6 地址" message for private IPv6 addresses, which is misleading.
Consider adding additional checks for other private IPv6 address ranges (e.g., fc00::/7 for ULA addresses) or improving the logic to more accurately identify public IPv6 addresses.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,48 @@ | ||
| import { fileURLToPath, URL } from 'url'; | ||
| import { defineConfig } from 'vite'; | ||
| import vue from '@vitejs/plugin-vue'; | ||
| import vuetify from 'vite-plugin-vuetify'; | ||
| import { fileURLToPath, URL } from "url"; | ||
| import { defineConfig } from "vite"; | ||
| import vue from "@vitejs/plugin-vue"; | ||
| import vuetify from "vite-plugin-vuetify"; | ||
|
|
||
| // https://vitejs.dev/config/ | ||
| export default defineConfig({ | ||
| plugins: [ | ||
| vue({ | ||
| template: { | ||
| compilerOptions: { | ||
| isCustomElement: (tag) => ['v-list-recognize-title'].includes(tag) | ||
| } | ||
| } | ||
| isCustomElement: (tag) => ["v-list-recognize-title"].includes(tag), | ||
| }, | ||
| }, | ||
| }), | ||
| vuetify({ | ||
| autoImport: true | ||
| }) | ||
| autoImport: true, | ||
| }), | ||
| ], | ||
| resolve: { | ||
| alias: { | ||
| mermaid: 'mermaid/dist/mermaid.js', | ||
| '@': fileURLToPath(new URL('./src', import.meta.url)) | ||
| } | ||
| mermaid: "mermaid/dist/mermaid.js", | ||
| "@": fileURLToPath(new URL("./src", import.meta.url)), | ||
| }, | ||
| }, | ||
| css: { | ||
| preprocessorOptions: { | ||
| scss: {} | ||
| } | ||
| scss: {}, | ||
| }, | ||
| }, | ||
| build: { | ||
| chunkSizeWarningLimit: 1024 * 1024 // Set the limit to 1 MB | ||
| chunkSizeWarningLimit: 1024 * 1024, // Set the limit to 1 MB | ||
| }, | ||
| optimizeDeps: { | ||
| exclude: ['vuetify'], | ||
| entries: ['./src/**/*.vue'] | ||
| exclude: ["vuetify"], | ||
| entries: ["./src/**/*.vue"], | ||
| }, | ||
| server: { | ||
| host: '0.0.0.0', | ||
| host: "::", | ||
| port: 3000, | ||
| proxy: { | ||
| '/api': { | ||
| target: 'http://127.0.0.1:6185/', | ||
| "/api": { | ||
| target: "http://127.0.0.1:6185/", | ||
| changeOrigin: true, | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| }, | ||
| }, | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.