1
1
require ( "dotenv" ) . config ( ) ;
2
- const VERSION = "1.4.2 " ;
2
+ const VERSION = "1.4.3 " ;
3
3
4
4
const express = require ( "express" ) ;
5
5
const schedule = require ( "node-schedule" ) ;
@@ -427,22 +427,31 @@ if (typeof hbwgConfig.external === "object") {
427
427
hbwgConfig . apiconfig . debug . url = "/debug" ;
428
428
else hbwgConfig . apiconfig . debug . url = String ( hbwgConfig . external . debug . url ) ;
429
429
430
- if ( hbwgConfig . external . debug . passwd ) {
431
- const hash = crypto . createHash ( "sha256" ) ;
432
- hash . update ( hbwgConfig . external . debug . passwd ) ;
433
- hbwgConfig . DebugPasswd = hash . digest ( "hex" ) ;
434
- }
435
-
436
430
if ( hbwgConfig . external . debug . method ) {
437
431
if ( hbwgConfig . external . debug . method === "POST" )
438
432
hbwgConfig . apiconfig . debug . method = "POST" ;
439
433
else if ( hbwgConfig . external . debug . method === "GET" )
440
434
hbwgConfig . apiconfig . debug . method = "GET" ;
441
- else if ( ! hbwgConfig . external . debug . method ) hbwgConfig . apiconfig . debug . method = "GET" ;
442
435
else {
443
436
logerr ( "Debug method is wrong! Can only be POST or GET." ) ;
444
437
process . exit ( 1 ) ;
445
438
}
439
+ } else hbwgConfig . apiconfig . debug . method = "GET" ;
440
+
441
+ if ( hbwgConfig . external . debug . passwd ) {
442
+ if ( hbwgConfig . apiconfig . debug . method === "GET" ) {
443
+ logerr (
444
+ "Passwords are not allowed in GET mode, please use POST instead."
445
+ ) ;
446
+ process . exit ( 1 ) ;
447
+ } else {
448
+ const hash = crypto . createHash ( "sha256" ) ;
449
+ hash . update ( hbwgConfig . external . debug . passwd ) ;
450
+ hash . update ( VERSION ) ;
451
+ hash . update ( String ( process . pid ) ) ;
452
+ hash . update ( __dirname ) ;
453
+ hbwgConfig . DebugPasswd = hash . digest ( "hex" ) ;
454
+ }
446
455
}
447
456
}
448
457
}
@@ -532,6 +541,9 @@ if (hbwgConfig.apiconfig.debug.url) {
532
541
const passwd = req . body . passwd ;
533
542
if ( typeof passwd === "undefined" ) hash . update ( "" ) ;
534
543
else hash . update ( passwd ) ;
544
+ hash . update ( VERSION ) ;
545
+ hash . update ( String ( process . pid ) ) ;
546
+ hash . update ( __dirname ) ;
535
547
if ( hash . digest ( "hex" ) == hbwgConfig . DebugPasswd ) {
536
548
postback ( ip , `${ hbwgConfig . apiconfig . debug . url } ?passwd=***` ) ;
537
549
ShowDebug ( ) ;
@@ -553,24 +565,8 @@ if (hbwgConfig.apiconfig.debug.url) {
553
565
res . setHeader ( "Content-Type" , "text/html" ) ;
554
566
res . send ( GetDebugInfo ( ) ) ;
555
567
} ;
556
- if ( hbwgConfig . DebugPasswd ) {
557
- const hash = crypto . createHash ( "sha256" ) ;
558
- const passwd = req . query . passwd ;
559
- if ( typeof passwd === "undefined" ) hash . update ( "" ) ;
560
- else hash . update ( passwd ) ;
561
- if ( hash . digest ( "hex" ) == hbwgConfig . DebugPasswd ) {
562
- getback ( ip , `${ hbwgConfig . apiconfig . debug . url } ?passwd=***` ) ;
563
- ShowDebug ( ) ;
564
- } else {
565
- getback ( ip , `${ hbwgConfig . apiconfig . debug . url } ?passwd=***` ) ;
566
- logwarn ( "Password is wrong!" ) ;
567
- res . setHeader ( "Content-Type" , "text/html" ) ;
568
- res . status ( 403 ) . send ( '<script>alert("Password is wrong!")</script>' ) ;
569
- }
570
- } else {
571
- getback ( ip , `${ hbwgConfig . apiconfig . debug . url } ` ) ;
572
- ShowDebug ( ) ;
573
- }
568
+ getback ( ip , `${ hbwgConfig . apiconfig . debug . url } ` ) ;
569
+ ShowDebug ( ) ;
574
570
} ) ;
575
571
}
576
572
}
0 commit comments