update
This commit is contained in:
@@ -47,6 +47,6 @@ export const app = useContextKey('app', init);
|
||||
export const ai = useContextKey('ai', () => {
|
||||
return new BailianProvider({
|
||||
apiKey: process.env.BAILIAN_API_KEY || '',
|
||||
model: 'qwen-turbo',
|
||||
model: 'qwen-plus',
|
||||
});
|
||||
});
|
||||
@@ -16,6 +16,9 @@ export const bannedUserNames = [
|
||||
"backup", // 备份相关
|
||||
"backups", // 备份相关
|
||||
"tmp", // 临时相关
|
||||
"var", // 变量相关
|
||||
"www", // 网站相关
|
||||
"app", // 应用相关
|
||||
]
|
||||
|
||||
/**
|
||||
@@ -40,5 +43,20 @@ export const appIsBanned = (appname: string): boolean => {
|
||||
if (appname.endsWith('.')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export const userPathIsBanned = (appname: string): boolean => {
|
||||
if (appname.startsWith('.')) {
|
||||
return true;
|
||||
}
|
||||
if (appname.endsWith('.')) {
|
||||
return true;
|
||||
}
|
||||
const bans = ['.php', '.json', '.yml', '.db', '.env', '.backup', 'database.sql', 'db.sql', 'backup.zip',];
|
||||
if (bans.some(ban => appname.includes(ban))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -170,6 +170,17 @@ router.get('/api/container/file/:id', async (req, res) => {
|
||||
res.end(JSON.stringify(container));
|
||||
});
|
||||
|
||||
router.all('/api/nocodb-test/router', async (req, res) => {
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
|
||||
const param = await router.getSearch(req);
|
||||
const body = await router.getBody(req);
|
||||
|
||||
const contentType = req.headers['content-type'] || '';
|
||||
console.log('Content-Type:', contentType);
|
||||
console.log('NocoDB test router called.', req.method, param, JSON.stringify(body, null));
|
||||
res.end(JSON.stringify({ message: 'NocoDB test router is working' }));
|
||||
});
|
||||
const simpleAppsPrefixs = [
|
||||
"/api/app/",
|
||||
"/api/micro-app/",
|
||||
@@ -177,9 +188,11 @@ const simpleAppsPrefixs = [
|
||||
"/api/s1/",
|
||||
"/api/container/",
|
||||
"/api/resource/",
|
||||
"/api/wxmsg"
|
||||
"/api/wxmsg",
|
||||
"/api/nocodb-test/"
|
||||
];
|
||||
|
||||
|
||||
export const handleRequest = async (req: http.IncomingMessage, res: http.ServerResponse) => {
|
||||
if (req.url?.startsWith('/api/router')) {
|
||||
// router自己管理
|
||||
|
||||
@@ -13,7 +13,7 @@ import { getLoginUser } from '../modules/auth.ts';
|
||||
import { rediretHome } from '../modules/user-app/index.ts';
|
||||
import { logger } from '../modules/logger.ts';
|
||||
import { UserV1Proxy } from '../modules/ws-proxy/proxy.ts';
|
||||
import { hasBadUser, userIsBanned, appIsBanned } from '@/modules/off/index.ts';
|
||||
import { hasBadUser, userIsBanned, appIsBanned, userPathIsBanned } from '@/modules/off/index.ts';
|
||||
import { robotsTxt } from '@/modules/html/index.ts';
|
||||
const domain = config?.proxy?.domain;
|
||||
const allowedOrigins = config?.proxy?.allowedOrigin || [];
|
||||
@@ -205,7 +205,11 @@ export const handleRequest = async (req: http.IncomingMessage, res: http.ServerR
|
||||
res.end(robotsTxt);
|
||||
return;
|
||||
}
|
||||
console.log('urls error', urls, 'originUrl:', url);
|
||||
if(userPathIsBanned(_user)) {
|
||||
logger.warn(`Bad user access from IP: ${dns.ip}, Host: ${dns.hostName}, URL: ${req.url}`);
|
||||
} else {
|
||||
console.log('urls error', urls, 'originUrl:', url);
|
||||
}
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' });
|
||||
res.write('Invalid Proxy URL\n');
|
||||
if (hasBadUser(_user)) {
|
||||
|
||||
@@ -14,4 +14,4 @@ import './config/index.ts';
|
||||
|
||||
// import './mark/index.ts';
|
||||
|
||||
import './file-listener/index.ts';
|
||||
import './file-listener/index.ts';
|
||||
@@ -55,7 +55,7 @@ app
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const { id, updatedAt: _clear, title = 'life', createdAt: _clear2, token, ...rest } = ctx.query.data;
|
||||
const { id, updatedAt: _clear, title = 'life', createdAt: _clear2, token: _, ...rest } = ctx.query.data;
|
||||
let secret: UserSecret;
|
||||
let isNew = false;
|
||||
|
||||
@@ -75,8 +75,12 @@ app
|
||||
title,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
secret = await UserSecret.createSecret(tokenUser);
|
||||
}
|
||||
if (!secret) {
|
||||
secret = await UserSecret.createSecret({
|
||||
...tokenUser,
|
||||
title,
|
||||
});
|
||||
isNew = true;
|
||||
}
|
||||
if (secret) {
|
||||
|
||||
28
src/test/nocodb.ts
Normal file
28
src/test/nocodb.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { SimpleRouter, HttpChain } from "@kevisual/router/simple";
|
||||
import http from "http";
|
||||
const server = http.createServer();
|
||||
const router = new SimpleRouter();
|
||||
|
||||
router.all('/', async (req, res) => {
|
||||
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||
res.end('NocoDB Test Server is running');
|
||||
});
|
||||
router.all("/api/router", async (req, res) => {
|
||||
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||
const params = req.url ? new URL(req.url, 'http://localhost').searchParams : null;
|
||||
console.log('Router API called with params:', params?.toString());
|
||||
const body = await router.getBody(req);
|
||||
console.log('Request body:', body);
|
||||
res.end('Upload API is ready');
|
||||
});
|
||||
|
||||
const httpChain = new HttpChain({ simpleRouter: router });
|
||||
httpChain.setServer(server)
|
||||
httpChain.parse()
|
||||
|
||||
httpChain.listen({
|
||||
port: 4000,
|
||||
host: '0.0.0.0',
|
||||
}, () => {
|
||||
console.log('NocoDB test server is running on http://localhost:4000');
|
||||
});
|
||||
Reference in New Issue
Block a user