@@ -5,6 +5,7 @@ import { readFileSync } from 'node:fs';
55import { spawn } from 'node-pty' ;
66import { WebSocketServer } from 'ws' ;
77
8+ const sessionName = 'HESTIASID' ;
89const hostname = execSync ( 'hostname' , { silent : true } ) . toString ( ) . trim ( ) ;
910const systemIPs = JSON . parse (
1011 execSync ( `${ process . env . HESTIA } /bin/v-list-sys-ips json` , { silent : true } ) . toString ( ) ,
@@ -16,7 +17,7 @@ const { config } = JSON.parse(
1617const wss = new WebSocketServer ( {
1718 port : parseInt ( config . WEB_TERMINAL_PORT , 10 ) ,
1819 verifyClient : async ( info , cb ) => {
19- if ( ! info . req . headers . cookie . includes ( 'PHPSESSID' ) ) {
20+ if ( ! info . req . headers . cookie . includes ( sessionName ) ) {
2021 cb ( false , 401 , 'Unauthorized' ) ;
2122 return ;
2223 }
@@ -47,7 +48,7 @@ wss.on('connection', (ws, req) => {
4748 const remoteIP = req . headers [ 'x-real-ip' ] || req . socket . remoteAddress ;
4849
4950 // Check if session is valid
50- const sessionID = req . headers . cookie . split ( '=' ) [ 1 ] ;
51+ const sessionID = req . headers . cookie . split ( ` ${ sessionName } =` ) [ 1 ] . split ( ';' ) [ 0 ] ;
5152 console . log ( `New connection from ${ remoteIP } (${ sessionID } )` ) ;
5253
5354 const file = readFileSync ( `${ process . env . HESTIA } /data/sessions/sess_${ sessionID } ` ) ;
0 commit comments