@@ -4,15 +4,10 @@ const fs = require('fs');
44const app = express ( ) ;
55const crypto = require ( 'crypto' ) ;
66const cookieParser = require ( 'cookie-parser' ) ;
7- const dotenv = require ( 'dotenv' ) ;
87require ( 'better-logging' ) ( console , {
98 format : ctx => `${ ctx . date } ${ ctx . time24 } ${ ctx . type } ${ ctx . msg } `
109} ) ;
11- const result = dotenv . config ( )
12-
13- if ( result . error ) {
14- throw result . error ;
15- }
10+ require ( 'dotenv' ) . config ( ) ;
1611
1712let timeoutObject = new Object ( ) ;
1813let failedCounter = new Object ( ) ;
@@ -50,21 +45,22 @@ function checkFileExist(path, exit) {
5045 return ( false ) ;
5146}
5247
48+ checkFileExist ( ".env" , true ) ;
5349checkFileExist ( "views/bot.pug" , true ) ;
5450
5551app . use ( cookieParser ( ) ) ;
5652app . set ( 'view engine' , 'pug' ) ;
5753
5854app . get ( "/" + endpointName , function ( userReq , userRes ) {
59- const IP = ( userReq . headers [ "x-real-ip" ] || userReq . connection . remoteAddress ) ;
55+ const IP = userReq . headers [ "x-real-ip" ] ;
6056 clearTimeout ( timeoutObject [ IP ] ) ;
6157 userRes . setHeader ( 'Content-Type' , 'text/css' ) ;
6258 userRes . setHeader ( 'Cache-Control' , 'no-store' ) ;
6359 userRes . end ( ) ;
6460} ) ;
6561
6662app . all ( "*" , function ( userReq , userRes , next ) {
67- const IP = ( userReq . headers [ "x-real-ip" ] || userReq . connection . remoteAddress ) ;
63+ const IP = userReq . headers [ "x-real-ip" ] ;
6864 const secretCookie = crypto . createHash ( 'md5' ) . update ( IP ) . digest ( 'hex' ) ;
6965 if ( userReq . headers [ 'user-agent' ] . toLowerCase ( ) . includes ( "bot" ) || checkFileExist ( jailPath + "/" + IP , false ) )
7066 userRes . render ( 'bot' , { website : process . env . WEBSITE_NAME } ) ;
@@ -90,7 +86,7 @@ app.all('*', proxy(targetToProxy, {
9086 return req . method == 'GET' ;
9187 } ,
9288 userResHeaderDecorator ( headers , userReq , userRes , proxyReq , proxyRes ) {
93- const IP = ( headers [ "x-real-ip" ] || userReq . connection . remoteAddress ) ;
89+ const IP = headers [ "x-real-ip" ] ;
9490 if ( headers [ 'content-type' ] && ! whitelist . includes ( IP ) && ( userReq . method == "GET" || userReq . method == "POST" ) ) {
9591 if ( headers [ 'content-type' ] . includes ( "text/html" ) && ( proxyRes . statusCode >= 200 && proxyRes . statusCode < 400 ) ) {
9692 if ( ! timeoutObject [ IP ] || timeoutObject [ IP ] . _called )
0 commit comments