@@ -14,10 +14,17 @@ import dotenv from 'dotenv';
1414import fs from 'fs' ;
1515import auth from 'http-auth' ;
1616dotenv . config ( ) ;
17+ //getting environment vars
1718const numCPUs = process . env . CPUS || os . cpus ( ) . length ;
19+ let key = process . env . KEY || 'unlock' ;
20+ let url = process . env . URL || 'rubynetwork.tech' ;
21+ let user = process . env . USERNAME || 'ruby' ;
22+ let pass = process . env . PASSWORD || 'ruby' ;
23+ let disableKEY = process . env . KEYDISABLE || 'false' ;
1824let educationWebsite = fs . readFileSync ( join ( __dirname , 'education/index.html' ) ) ;
1925let loadingPage = fs . readFileSync ( join ( __dirname , 'education/load.html' ) ) ;
2026const blacklisted : string [ ] = [ ] ;
27+ const disableyt : string [ ] = [ ] ;
2128fs . readFile ( join ( __dirname , 'blocklists/ADS.txt' ) , ( err , data ) => {
2229 if ( err ) {
2330 console . error ( err ) ;
@@ -26,7 +33,6 @@ fs.readFile(join(__dirname, 'blocklists/ADS.txt'), (err, data) => {
2633 const lines = data . toString ( ) . split ( '\n' ) ;
2734 for ( let i in lines ) blacklisted . push ( lines [ i ] ) ;
2835} ) ;
29-
3036if ( numCPUs > 0 && cluster . isPrimary ) {
3137 console . log ( `Primary ${ process . pid } is running` ) ;
3238 for ( let i = 0 ; i < numCPUs ; i ++ ) {
@@ -52,12 +58,6 @@ if (numCPUs > 0 && cluster.isPrimary) {
5258 app . use ( express . urlencoded ( { extended : false } ) ) ;
5359 //uv config
5460 app . use ( '/uv/' , express . static ( uvPath ) ) ;
55- //env vars for the unlock feature
56- //analytics object
57- let key = process . env . KEY || '' ;
58- if ( ! key || key === undefined || key === null || key === '' ) {
59- key = 'unlock' ;
60- }
6161 const server = createServer ( ) ;
6262 server . on ( 'request' , ( req , res ) => {
6363 //@ts -ignore
@@ -82,11 +82,13 @@ if (numCPUs > 0 && cluster.isPrimary) {
8282 res . end ( ) ;
8383 return ;
8484 }
85- } else if ( req . headers . host === 'rubynetwork.tech' ) {
85+ //@ts -ignore
86+ } else if ( req . headers . host === url ) {
8687 app ( req , res ) ;
8788 } else if (
8889 url . search === `?${ key } ` &&
89- ! req . headers . cookie ?. includes ( key )
90+ ! req . headers . cookie ?. includes ( key ) &&
91+ disableKEY === 'false'
9092 ) {
9193 res . writeHead ( 302 , {
9294 Location : '/' ,
@@ -168,8 +170,6 @@ if (numCPUs > 0 && cluster.isPrimary) {
168170 } ) ;
169171 app . post ( '/login-form' , ( req , res ) => {
170172 let body = req . body ;
171- let user = process . env . USERNAME || 'ruby' ;
172- let pass = process . env . PASSWORD || 'ruby' ;
173173 body = JSON . stringify ( body ) ;
174174 body = JSON . parse ( body ) ;
175175 if ( body . username === user && body . password === pass ) {
0 commit comments