diff --git a/packages/server/src/options.example.json b/packages/server/options.example.json similarity index 53% rename from packages/server/src/options.example.json rename to packages/server/options.example.json index 46be294..2f5730e 100644 --- a/packages/server/src/options.example.json +++ b/packages/server/options.example.json @@ -3,13 +3,13 @@ "dataDir": "/home/master/desktop", "serve": true, "httpHost": "localhost", - "httpPort": 9200, + "httpPort": 8094, "debugMode": false, - "baseUrl": "http://localhost:9200", + "baseUrl": "http://localhost:8094", "appCode": { - "mattuy-laptop": "iasdjfkwe3ds-qw3rjkwjfda8" + "debug": "debug" }, "appAuthHash": { - "mattuy-laptop": "b9c901e0ee98486361b2e5461442af3f3863961f" + "debug": "" } } diff --git a/packages/server/src/index.js b/packages/server/src/index.js index 80f1c23..70e952e 100644 --- a/packages/server/src/index.js +++ b/packages/server/src/index.js @@ -61,34 +61,3 @@ async function start() { } start(); - -// let sessionData = JSON.parse( -// fs.readFileSync("/home/master/desktop/session.json"), -// { -// encoding: "utf-8", -// } -// ); -// const W = require("wechat4u"); -// const bot = new W(sessionData); -// bot.on("uuid", (uuid) => { -// qrCode.generate("https://login.weixin.qq.com/l/" + uuid, { -// small: true, -// }); -// }); - -// bot.on("login", async () => { -// console.log("logged in"); -// fs.writeFileSync( -// "/home/master/desktop/session.json", -// JSON.stringify(bot.botData) -// ); -// const { mediaId } = await bot.uploadMedia( -// fs.createReadStream("/home/master/desktop/q.jpg"), -// undefined, -// "filehelper" -// ); -// bot.sendPic(mediaId, "filehelper").then((rse) => { -// console.log(rse); -// }); -// }); -// bot.restart(); diff --git a/packages/server/src/socket.js b/packages/server/src/socket.js index ab43f8c..30f3417 100644 --- a/packages/server/src/socket.js +++ b/packages/server/src/socket.js @@ -40,7 +40,10 @@ io.use((socket, next) => { if (!appCode || appCode !== auth.appCode) { return next(Error("认证失败")); } - if (textSHA1(auth.passphrase) !== config.appAuthHash[appName]) { + if ( + config.appAuthHash[appName] && + textSHA1(auth.passphrase) !== config.appAuthHash[appName] + ) { return next(Error("口令错误")); } if (activeSessions.has(socket.handshake.auth.sessionID)) { @@ -268,7 +271,7 @@ router.get("/session/:sessionID/media/:composedID/:filename", (ctx, next) => { /** 上传文件 */ router.post("/upload_file", async (ctx, next) => { - if (!activeSessions.has(ctx.request.headers.session_id)) { + if (!activeSessions.has(ctx.request.headers['sid'])) { ctx.throw(401); } const filename = dayjs().format("YYYYMMDD_") + String(Math.random()).slice(2);