fix: ws url token parse

This commit is contained in:
linyuchen 2024-02-16 22:48:43 +08:00
parent 4f9682289c
commit d54111ce94
4 changed files with 5 additions and 5 deletions

View File

@ -4,7 +4,7 @@
"name": "LLOneBot",
"slug": "LLOneBot",
"description": "LiteLoaderQQNT的OneBotApi",
"version": "3.2.0",
"version": "3.2.1",
"thumbnail": "./icon.png",
"authors": [{
"name": "linyuchen",

View File

@ -88,5 +88,5 @@ export function getStrangerByUin(uin: string) {
}
}
export const version = "v3.2.0"
export const version = "v3.2.1"
export const heartInterval = 15000 // 毫秒

View File

@ -33,7 +33,7 @@ export function log(...msg: any[]) {
}
logMsg += msgItem + " ";
}
logMsg = `${currentDateTime} ${userInfo}: ${logMsg}\n`
logMsg = `${currentDateTime} ${userInfo}: ${logMsg}\n\n`
// sendLog(...msg);
// console.log(msg)
fs.appendFile(path.join(CONFIG_DIR , `llonebot-${currentDate}.log`), logMsg, (err: any) => {

View File

@ -103,7 +103,7 @@ export function startWSServer(port: number) {
}
wsServer = new websocket.Server({port})
wsServer.on("connection", (ws, req) => {
const url = req.url;
const url = req.url.split("?").shift();
log("received ws connect", url)
let token: string = ""
const authHeader = req.headers['authorization'];
@ -111,7 +111,7 @@ export function startWSServer(port: number) {
token = authHeader.split("Bearer ").pop()
log("receive ws header token", token);
} else {
const parsedUrl = urlParse.parse(url, true);
const parsedUrl = urlParse.parse(req.url, true);
const urlToken = parsedUrl.query.access_token;
if (urlToken) {
if (Array.isArray(urlToken)) {