Spaces:
Paused
Paused
| const express = require('express'); | |
| const { createProxyMiddleware } = require('http-proxy-middleware'); | |
| const cookieParser = require('cookie-parser'); | |
| const path = require('path'); | |
| const app = express(); | |
| app.use(express.urlencoded({ extended: true })); | |
| app.use(cookieParser()); | |
| // Hugging Face Secret থেকে পাসওয়ার্ড নেওয়া হচ্ছে | |
| const SECRET_PASSWORD = process.env.TERMINAL_PASSWORD || 'ayon123'; | |
| // লগইন পেজ রেন্ডার করা | |
| app.get('/login', (req, res) => { | |
| res.sendFile(path.join(__dirname, 'login.html')); | |
| }); | |
| // পাসওয়ার্ড ভেরিফিকেশন এবং লগ ট্র্যাকিং | |
| app.post('/login', (req, res) => { | |
| if (req.body.password === SECRET_PASSWORD) { | |
| console.log('🔐 [AUTH] Desktop access granted. Welcome User!'); | |
| res.cookie('auth_token', 'secure_session_active', { httpOnly: true, maxAge: 24 * 60 * 60 * 1000 }); | |
| res.redirect('/'); | |
| } else { | |
| console.log('⚠️ [AUTH] Failed desktop login attempt! Invalid key.'); | |
| res.redirect('/login?error=1'); | |
| } | |
| }); | |
| // সিকিউরিটি চেক মিডলওয়্যার | |
| const checkAuth = (req, res, next) => { | |
| if (req.cookies.auth_token === 'secure_session_active') { | |
| next(); | |
| } else { | |
| res.redirect('/login'); | |
| } | |
| }; | |
| // NoVNC ডেস্কটপ স্ক্রিনের সাথে কানেকশন প্রক্সি করা | |
| const desktopProxy = createProxyMiddleware({ | |
| target: 'http://127.0.0.1:8080', | |
| ws: true, | |
| changeOrigin: true, | |
| logLevel: 'silent' | |
| }); | |
| // মূল রাউটে প্রক্সি যুক্ত করা | |
| app.use('/', checkAuth, desktopProxy); | |
| // Hugging Face-এর মূল পোর্টে সার্ভার রান করা | |
| app.listen(7860, () => { | |
| console.log('\n==================================================='); | |
| console.log('🖥️ UBUNTU GUI & SECURE PROXY ENGINE RUNNING 🖥️'); | |
| console.log('===================================================\n'); | |
| }); | |