From 91409861b9ffeb13282ee1e13f8e4492756c8018 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Mon, 29 Dec 2025 01:34:06 +0800 Subject: [PATCH] update --- assistant/package.json | 4 +-- assistant/src/server.ts | 6 +++- .../src/services/proxy/proxy-page-index.ts | 14 ++++++++- pnpm-lock.yaml | 31 ++++++++++++------- src/module/login/login-by-web.ts | 2 +- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/assistant/package.json b/assistant/package.json index dff73b2..fa08258 100644 --- a/assistant/package.json +++ b/assistant/package.json @@ -48,7 +48,7 @@ "@kevisual/logger": "^0.0.4", "@kevisual/query": "0.0.33", "@kevisual/query-login": "0.0.7", - "@kevisual/router": "^0.0.49", + "@kevisual/router": "^0.0.51", "@kevisual/types": "^0.0.10", "@kevisual/use-config": "^1.0.21", "@types/bun": "^1.3.5", @@ -76,7 +76,7 @@ "access": "public" }, "dependencies": { - "@kevisual/ha-api": "^0.0.4", + "@kevisual/ha-api": "^0.0.5", "@kevisual/video-tools": "^0.0.12", "eventemitter3": "^5.0.1", "lowdb": "^7.0.1", diff --git a/assistant/src/server.ts b/assistant/src/server.ts index 8102c5c..3be585d 100644 --- a/assistant/src/server.ts +++ b/assistant/src/server.ts @@ -36,7 +36,11 @@ export const runServer = async (port: number = 51515, listenPath = '127.0.0.1') } else { app.listen(_port, listenPath, () => { const protocol = assistantConfig.getHttps().protocol; - console.log(`Server is running on ${protocol}://${listenPath}:${_port}`); + let showListenPath = listenPath; + if (listenPath === '::') { + showListenPath = 'localhost'; + } + console.log(`Server is running on ${protocol}://${showListenPath}:${_port}`); }); } app.server.on([{ diff --git a/assistant/src/services/proxy/proxy-page-index.ts b/assistant/src/services/proxy/proxy-page-index.ts index 81ed1b2..66b4e52 100644 --- a/assistant/src/services/proxy/proxy-page-index.ts +++ b/assistant/src/services/proxy/proxy-page-index.ts @@ -10,6 +10,15 @@ import WebSocket from 'ws'; const localProxy = new LocalProxy({}); localProxy.initFromAssistantConfig(assistantConfig); +const isOpenPath = (pathname: string): boolean => { + const openPaths = ['/root/home', '/root/cli']; + for (const openPath of openPaths) { + if (pathname.startsWith(openPath)) { + return true; + } + } + return false; +} /** * 过滤访问的资源,允许谁访问 * @param req @@ -108,6 +117,7 @@ export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResp target: apiBackendProxy.target, }); } + logger.debug('proxyRoute handle by router', { url: req.url }, noAdmin); const urls = pathname.split('/'); const [_, _user, _app] = urls; if (!_app) { @@ -115,7 +125,9 @@ export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResp res.end('Not Found Proxy'); return; } - if (noAdmin) { + const isOpen = isOpenPath(pathname) + log.debug('proxyRoute', { _user, _app, pathname, noAdmin, isOpen }); + if (noAdmin && !isOpen) { return toSetting(); } if (_app && urls.length === 3) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index efa9bdb..2771c85 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -112,8 +112,8 @@ importers: assistant: dependencies: '@kevisual/ha-api': - specifier: ^0.0.4 - version: 0.0.4 + specifier: ^0.0.5 + version: 0.0.5 '@kevisual/video-tools': specifier: ^0.0.12 version: 0.0.12(dotenv@17.2.3)(supports-color@10.2.2) @@ -152,8 +152,8 @@ importers: specifier: 0.0.7 version: 0.0.7(@kevisual/query@0.0.33) '@kevisual/router': - specifier: ^0.0.49 - version: 0.0.49(supports-color@10.2.2) + specifier: ^0.0.51 + version: 0.0.51(supports-color@10.2.2) '@kevisual/types': specifier: ^0.0.10 version: 0.0.10 @@ -1276,8 +1276,8 @@ packages: resolution: {integrity: sha512-4T/m2LqhtwWEW+lWmg7jLxKFW7VtIAftsWFDDZvh10bZunqFf8iXxChHcVSQWikghJb4cq1IkWzPkvc2l+Asdw==} hasBin: true - '@kevisual/ha-api@0.0.4': - resolution: {integrity: sha512-ZBtfE/zFieDU7ff9zo4pKR7LDhFEdkDQuYU/uH5ZJkFWke4gOxEIatZcM6CJmgKDjoMLMk2w+gpk8eJqJ42GBw==} + '@kevisual/ha-api@0.0.5': + resolution: {integrity: sha512-0A4Hmw797yqB9B92G2vPIn4sxIoNYWBm8D3+yWkUkH+XjEBOE65ScK2j4aJVBfwBNd470QqGlK4DcZ5NmQT5iw==} '@kevisual/hot-api@0.0.3': resolution: {integrity: sha512-qZ4CNK08StZP4+DR1vWwJhKVDoSXXC+PBFG4ZxtkXF5vO2rybE055zp1n3dg5jo8GwW5wxpqMIG3KBp3pYSTkg==} @@ -1329,8 +1329,8 @@ packages: '@kevisual/router@0.0.48': resolution: {integrity: sha512-WsSvT+NpfC/bZbaAzE3WSKD2DRZP0JuPQJGr4YucSdO/lOLB4cEpOZRbPlV3l7G064ow8QJRAN2DUW+bRjrp1A==} - '@kevisual/router@0.0.49': - resolution: {integrity: sha512-2HXuOnnWdRfkO0LyqolWU9cvWHGXi8FV3OqEvWgfO+f7wx8GT8T6Bb8dCzdldDaAxve1dgLBavtdmnHyCkp+1Q==} + '@kevisual/router@0.0.51': + resolution: {integrity: sha512-i9qYBeS/um78oC912oWJD3iElB+5NTKyTrz1Hzf4DckiUFnjLL81UPwjIh5I2l9+ul0IZ/Pxx+sFSF99fJkzKg==} '@kevisual/types@0.0.10': resolution: {integrity: sha512-Q73uzzjk9UidumnmCvOpgzqDDvQxsblz22bIFuoiioUFJWwaparx8bpd8ArRyFojicYL1YJoFDzDZ9j9NN8grA==} @@ -4575,6 +4575,10 @@ packages: resolution: {integrity: sha512-QKF6fsJgdKn5Cy1SekTuwUQ6LOLUdnO4gVne1+TGSAyL/CD1aznNCmBna+bQB9xyon7DiYbDtTR1cLaxDXuaVA==} engines: {node: '>=15.6.0'} + selfsigned@5.4.0: + resolution: {integrity: sha512-Yn8qZOOJv+NhcGY19iC+ngW6hlUCNpvWEkrKllXNhmkLgR9fcErm8EqZ/wev7/tiwjKC9qj17Fa/PtBNzb6q8g==} + engines: {node: '>=15.6.0'} + semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true @@ -6384,7 +6388,7 @@ snapshots: transitivePeerDependencies: - typescript - '@kevisual/ha-api@0.0.4': + '@kevisual/ha-api@0.0.5': dependencies: '@kevisual/cache': 0.0.4 fuse.js: 7.1.0 @@ -6518,10 +6522,10 @@ snapshots: transitivePeerDependencies: - supports-color - '@kevisual/router@0.0.49(supports-color@10.2.2)': + '@kevisual/router@0.0.51(supports-color@10.2.2)': dependencies: path-to-regexp: 8.3.0 - selfsigned: 5.2.0 + selfsigned: 5.4.0 send: 1.2.1(supports-color@10.2.2) transitivePeerDependencies: - supports-color @@ -10710,6 +10714,11 @@ snapshots: '@peculiar/x509': 1.14.2 pkijs: 3.3.3 + selfsigned@5.4.0: + dependencies: + '@peculiar/x509': 1.14.2 + pkijs: 3.3.3 + semver@5.7.2: {} semver@6.3.1: {} diff --git a/src/module/login/login-by-web.ts b/src/module/login/login-by-web.ts index 3458b5a..507bcc3 100644 --- a/src/module/login/login-by-web.ts +++ b/src/module/login/login-by-web.ts @@ -1,7 +1,7 @@ import MD5 from 'crypto-js/md5.js'; +import jsonwebtoken from 'jsonwebtoken'; import { getBaseURL, queryLogin } from '../query.ts'; import { chalk } from '../chalk.ts'; -import jsonwebtoken from 'jsonwebtoken'; import { BaseLoad } from '@kevisual/load'; type LoginWithWebOptions = {};