Spaces:
Paused
Paused
Update server.js
Browse files
server.js
CHANGED
|
@@ -7,49 +7,25 @@ const app = express();
|
|
| 7 |
app.use(express.urlencoded({ extended: true }));
|
| 8 |
app.use(cookieParser());
|
| 9 |
|
| 10 |
-
// Hugging Face Secret থেকে পাসওয়ার্ড নেওয়া হচ্ছে
|
| 11 |
const SECRET_PASSWORD = process.env.TERMINAL_PASSWORD || 'ayon123';
|
| 12 |
|
| 13 |
-
/
|
| 14 |
-
app.get('/login', (req, res) => {
|
| 15 |
-
res.sendFile(path.join(__dirname, 'login.html'));
|
| 16 |
-
});
|
| 17 |
-
|
| 18 |
-
// পাসওয়ার্ড ভেরিফিকেশন এবং লগ ট্র্যাকিং
|
| 19 |
app.post('/login', (req, res) => {
|
| 20 |
if (req.body.password === SECRET_PASSWORD) {
|
| 21 |
-
console.log('🔐 [AUTH] Desktop access granted. Welcome User!');
|
| 22 |
res.cookie('auth_token', 'secure_session_active', { httpOnly: true, maxAge: 24 * 60 * 60 * 1000 });
|
| 23 |
res.redirect('/');
|
| 24 |
-
} else
|
| 25 |
-
console.log('⚠️ [AUTH] Failed desktop login attempt! Invalid key.');
|
| 26 |
-
res.redirect('/login?error=1');
|
| 27 |
-
}
|
| 28 |
});
|
| 29 |
|
| 30 |
-
// সিকিউরিটি চেক মিডলওয়্যার
|
| 31 |
const checkAuth = (req, res, next) => {
|
| 32 |
-
if (req.cookies.auth_token === 'secure_session_active')
|
| 33 |
-
|
| 34 |
-
} else {
|
| 35 |
-
res.redirect('/login');
|
| 36 |
-
}
|
| 37 |
};
|
| 38 |
|
| 39 |
-
/
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
logLevel: 'silent'
|
| 45 |
-
});
|
| 46 |
|
| 47 |
-
|
| 48 |
-
app.use('/', checkAuth, desktopProxy);
|
| 49 |
-
|
| 50 |
-
// Hugging Face-এর মূল পোর্টে সার্ভার রান করা
|
| 51 |
-
app.listen(7860, () => {
|
| 52 |
-
console.log('\n===================================================');
|
| 53 |
-
console.log('🖥️ UBUNTU GUI & SECURE PROXY ENGINE RUNNING 🖥️');
|
| 54 |
-
console.log('===================================================\n');
|
| 55 |
-
});
|
|
|
|
| 7 |
app.use(express.urlencoded({ extended: true }));
|
| 8 |
app.use(cookieParser());
|
| 9 |
|
|
|
|
| 10 |
const SECRET_PASSWORD = process.env.TERMINAL_PASSWORD || 'ayon123';
|
| 11 |
|
| 12 |
+
app.get('/login', (req, res) => res.sendFile(path.join(__dirname, 'login.html')));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
app.post('/login', (req, res) => {
|
| 14 |
if (req.body.password === SECRET_PASSWORD) {
|
|
|
|
| 15 |
res.cookie('auth_token', 'secure_session_active', { httpOnly: true, maxAge: 24 * 60 * 60 * 1000 });
|
| 16 |
res.redirect('/');
|
| 17 |
+
} else res.redirect('/login?error=1');
|
|
|
|
|
|
|
|
|
|
| 18 |
});
|
| 19 |
|
|
|
|
| 20 |
const checkAuth = (req, res, next) => {
|
| 21 |
+
if (req.cookies.auth_token === 'secure_session_active') next();
|
| 22 |
+
else res.redirect('/login');
|
|
|
|
|
|
|
|
|
|
| 23 |
};
|
| 24 |
|
| 25 |
+
app.use('/', checkAuth, createProxyMiddleware({
|
| 26 |
+
target: 'http://127.0.0.1:8080',
|
| 27 |
+
ws: true,
|
| 28 |
+
logLevel: 'silent'
|
| 29 |
+
}));
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
app.listen(7860, () => console.log('🛡️ Gatekeeper active on port 7860'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|