Skip to content

Commit

Permalink
fix #36
Browse files Browse the repository at this point in the history
  • Loading branch information
takayama-lily committed Feb 1, 2021
1 parent d3e89cd commit e185b95
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,8 @@ function createServer() {
wss.on("connection", (ws, req)=>{
ws.on("error", ()=>{});
if (config.access_token) {
if (!req.headers["authorization"])
return ws.close(1401);
if (!req.headers["authorization"].includes(config.access_token))
return ws.close(1403);
if (!req.headers["authorization"] || !req.headers["authorization"].includes(config.access_token))
return ws.close(1002);
}
onWSOpen(ws);
});
Expand Down Expand Up @@ -309,8 +307,8 @@ function createWSClient(url, headers) {
websockets.add(ws);
onWSOpen(ws);
});
ws.on("close", ()=>{
bot.logger.error(`反向ws连接(${url})被关闭,将在${config.ws_reverse_reconnect_interval}毫秒后尝试连接。`);
ws.on("close", (code)=>{
bot.logger.error(`反向ws连接(${url})被关闭,关闭码${code}将在${config.ws_reverse_reconnect_interval}毫秒后尝试连接。`);
websockets.delete(ws);
setTimeout(()=>{
createWSClient(url, headers);
Expand Down

0 comments on commit e185b95

Please sign in to comment.