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", "name": "LLOneBot",
"slug": "LLOneBot", "slug": "LLOneBot",
"description": "LiteLoaderQQNT的OneBotApi", "description": "LiteLoaderQQNT的OneBotApi",
"version": "3.2.0", "version": "3.2.1",
"thumbnail": "./icon.png", "thumbnail": "./icon.png",
"authors": [{ "authors": [{
"name": "linyuchen", "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 // 毫秒 export const heartInterval = 15000 // 毫秒

View File

@ -33,7 +33,7 @@ export function log(...msg: any[]) {
} }
logMsg += msgItem + " "; logMsg += msgItem + " ";
} }
logMsg = `${currentDateTime} ${userInfo}: ${logMsg}\n` logMsg = `${currentDateTime} ${userInfo}: ${logMsg}\n\n`
// sendLog(...msg); // sendLog(...msg);
// console.log(msg) // console.log(msg)
fs.appendFile(path.join(CONFIG_DIR , `llonebot-${currentDate}.log`), logMsg, (err: any) => { 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 = new websocket.Server({port})
wsServer.on("connection", (ws, req) => { wsServer.on("connection", (ws, req) => {
const url = req.url; const url = req.url.split("?").shift();
log("received ws connect", url) log("received ws connect", url)
let token: string = "" let token: string = ""
const authHeader = req.headers['authorization']; const authHeader = req.headers['authorization'];
@ -111,7 +111,7 @@ export function startWSServer(port: number) {
token = authHeader.split("Bearer ").pop() token = authHeader.split("Bearer ").pop()
log("receive ws header token", token); log("receive ws header token", token);
} else { } else {
const parsedUrl = urlParse.parse(url, true); const parsedUrl = urlParse.parse(req.url, true);
const urlToken = parsedUrl.query.access_token; const urlToken = parsedUrl.query.access_token;
if (urlToken) { if (urlToken) {
if (Array.isArray(urlToken)) { if (Array.isArray(urlToken)) {