update
This commit is contained in:
@@ -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