This commit is contained in:
2025-12-29 01:34:06 +08:00
parent ff7e6aa152
commit 91409861b9
5 changed files with 41 additions and 16 deletions

View File

@@ -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",

View File

@@ -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([{

View File

@@ -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) {

31
pnpm-lock.yaml generated
View File

@@ -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: {}

View File

@@ -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 = {};