first commit

This commit is contained in:
YSASM 2024-12-18 19:56:17 +08:00
commit 7135ea4ce2
7 changed files with 4829 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/*
package-lock.json

14
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "调试当前文件",
"program": "${file}"
}
]
}

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM registry.cn-shanghai.aliyuncs.com/devcon/node:18
ADD . /app
WORKDIR /app
RUN mkdir /app/log
RUN cd /app && \
chmod +x start.sh && \
npm config set registry https://registry.npmmirror.com/ && \
npm install
EXPOSE 9000
CMD [ "/app/start.sh" ]

38
app.js Normal file
View File

@ -0,0 +1,38 @@
const express = require("express");
const request = require("request");
const fs = require("fs");
const app = express();
const port = 9000;
const { getDecryptionArray } = require("./decode");
const { Transform } = require("stream");
function xorTransform(decryptionArray) {
let processedBytes = 0;
return new Transform({
transform(chunk, encoding, callback) {
if (processedBytes < decryptionArray.length) {
let remaining = Math.min(
decryptionArray.length - processedBytes,
chunk.length
);
for (let i = 0; i < remaining; i++) {
chunk[i] = chunk[i] ^ decryptionArray[processedBytes + i];
}
processedBytes += remaining;
}
this.push(chunk);
callback();
},
});
}
app.get("/download", (req, res) => {
const { url, decodeKey } = req.query;
let xorStream = xorTransform(
getDecryptionArray(decodeURIComponent(decodeKey))
);
request(decodeURIComponent(url)).pipe(xorStream).pipe(res);
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});

4744
decode.js Normal file

File diff suppressed because one or more lines are too long

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "origin",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"express": "~4.16.1",
"stream": "^0.0.3",
"request": "^2.88.2"
}
}

4
start.sh Normal file
View File

@ -0,0 +1,4 @@
cd /app
while [ true ];do
nohup npm run start
done