update
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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([{
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user