Spaces:
Paused
Paused
Create server.js
Browse files
server.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const express = require('express');
|
| 2 |
+
const { createProxyMiddleware } = require('http-proxy-middleware');
|
| 3 |
+
const cookieParser = require('cookie-parser');
|
| 4 |
+
const path = require('path');
|
| 5 |
+
|
| 6 |
+
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 |
+
next();
|
| 34 |
+
} else {
|
| 35 |
+
res.redirect('/login');
|
| 36 |
+
}
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
// NoVNC ডেস্কটপ স্ক্রিনের সাথে কানেকশন প্রক্সি করা
|
| 40 |
+
const desktopProxy = createProxyMiddleware({
|
| 41 |
+
target: 'http://127.0.0.1:8080',
|
| 42 |
+
ws: true,
|
| 43 |
+
changeOrigin: true,
|
| 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 |
+
});
|