diff --git a/.gitignore b/.gitignore index 1892fca..88278a7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules dist config.juml .vscode -test \ No newline at end of file +test +build \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8d91eba..49a17ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "auth-header": "^1.0.0", "commander": "^10.0.0", "cors": "^2.8.5", - "dblang": "https://jusax.de/git/attachments/c13552b7-c9f0-4f50-bcce-96a124c1c286", + "dblang": "https://jusax.de/git/attachments/f23f8128-4fde-4ec6-a8cd-cfc5068b2cfd", "express": "^4.18.2", "juml": "https://jusax.de/git/attachments/208913c5-2851-4b86-a53d-ca99fed168cc", "nman": "https://jusax.de/git/attachments/5333948b-fe6b-45d2-9230-ca388f6a89bc", @@ -1101,9 +1101,9 @@ } }, "node_modules/dblang": { - "version": "0.7.0", - "resolved": "https://jusax.de/git/attachments/c13552b7-c9f0-4f50-bcce-96a124c1c286", - "integrity": "sha512-NU4INAcpQKMWcBE59wGO+4BRsJqEYHA+IbsQhr6OYqNUPw5a+LSAEr4coAZ9UHqewZaX10+20oJ1dkIADzzeCQ==", + "version": "0.8.0", + "resolved": "https://jusax.de/git/attachments/f23f8128-4fde-4ec6-a8cd-cfc5068b2cfd", + "integrity": "sha512-hHfxa5iHD3fumMzH/LvVwB2kPUfs1TsxRdOS1veIppfgsJNUxqxPdEljd+EluWpHrPklfO3AJr2vWiZe4N0NBg==", "license": "UNLICENSED", "dependencies": { "gitea-release": "git+https://jusax.de/git/jusax23/gitea-release.git", diff --git a/package.json b/package.json index 026e7a9..a6ca4a6 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "scripts": { "main": "tsc && node . -c config.juml", "debug": "tsc && node . -c config.juml -d", - "setup": "tsc && node . -c config.juml -s" + "setup": "tsc && node . -c config.juml -s", + "bundleRelease": "mkdir build/bundle & esbuild src/main.ts --platform=node --bundle --minify --outfile=build/bundle/main.js", + "build-linux-x64": "npm run bundleRelease && mkdir build/bin & pkg -t node18-linux-x64 -o build/bin/outbag-linux-x64 build/bundle/main.js" }, "repository": { "type": "git", @@ -34,7 +36,7 @@ "auth-header": "^1.0.0", "commander": "^10.0.0", "cors": "^2.8.5", - "dblang": "https://jusax.de/git/attachments/c13552b7-c9f0-4f50-bcce-96a124c1c286", + "dblang": "https://jusax.de/git/attachments/f23f8128-4fde-4ec6-a8cd-cfc5068b2cfd", "express": "^4.18.2", "juml": "https://jusax.de/git/attachments/208913c5-2851-4b86-a53d-ca99fed168cc", "nman": "https://jusax.de/git/attachments/5333948b-fe6b-45d2-9230-ca388f6a89bc", diff --git a/src/api/helper.ts b/src/api/helper.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/api/user.ts b/src/api/user.ts index a27eb74..5c31735 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -103,9 +103,9 @@ export function checktype(data: any, type: string) { return true; } else if (type == "name" && typeof data == "string" && /^[a-zA-Z0-9\-_.]+$/.test(data)) { return true; - } else if (type.startsWith("name-") && typeof data == "string" && /^[a-zA-Z0-9\-_.]+$/.test(data)) { + } else if (typeof data == "string" && type.startsWith("name-") && /^[a-zA-Z0-9\-_.]+$/.test(data)) { return parseInt(type.split("-")[1]) >= data.length; - } else if (type.startsWith("string-") && typeof data == "string") { + } else if (typeof data == "string" && type.startsWith("string-")) { return parseInt(type.split("-")[1]) >= data.length; } else if (type == "any") { return true; diff --git a/src/setup/config.ts b/src/setup/config.ts index 980eef1..ea81b95 100644 --- a/src/setup/config.ts +++ b/src/setup/config.ts @@ -299,7 +299,7 @@ const setupFunc = async (func: () => Promise, name: string) => { export const partiellSetup = async () => { while (true) { - log("Setup", "Slection:"); + log("Setup", "Selection:"); const resp = await prompts({ type: 'select', name: 'value', diff --git a/src/sys/bruteforce.ts b/src/sys/bruteforce.ts index c2b62f8..e8aba52 100644 --- a/src/sys/bruteforce.ts +++ b/src/sys/bruteforce.ts @@ -19,11 +19,11 @@ export const addBruteforcePotantial = (ip: string) => { if (bruteforcedata[ip].n > maxSus) { log("Bruteforce Protection", "blocking ip: ", ip); } -} +}; export const bruteforcecheck = (ip: string) => { return (bruteforcedata[ip]?.n || 0) <= maxSus || uts() - (bruteforcedata[ip]?.t || uts()) > timeout; -} +}; var bruteforcedatacleaner = setInterval(async () => { var utst = uts(); @@ -40,7 +40,7 @@ addShutdownTask(() => clearInterval(bruteforcedatacleaner), 5000); export interface suspectRequest extends express.Request { suspect?: () => void -} +}; export default (req: suspectRequest, res: express.Response, next: express.NextFunction) => { if (!bruteforcecheck(req.ip)) return void res.status(400).send("bruteforce"); @@ -48,4 +48,4 @@ export default (req: suspectRequest, res: express.Response, next: express.NextFu addBruteforcePotantial(req.ip); }; next(); -} \ No newline at end of file +}; \ No newline at end of file