Update server.js
Browse files
server.js
CHANGED
|
@@ -38,7 +38,7 @@ async function connectDB() {
|
|
| 38 |
if (!adminExists) {
|
| 39 |
await db.collection('users').insertOne({
|
| 40 |
username: 'admin',
|
| 41 |
-
password: crypto.createHash('sha256').update('
|
| 42 |
isAdmin: true,
|
| 43 |
createdAt: new Date()
|
| 44 |
});
|
|
@@ -186,6 +186,29 @@ io.on('connection', (socket) => {
|
|
| 186 |
});
|
| 187 |
});
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
// Start server
|
| 190 |
const PORT = process.env.PORT || 7860;
|
| 191 |
connectDB().then(() => {
|
|
|
|
| 38 |
if (!adminExists) {
|
| 39 |
await db.collection('users').insertOne({
|
| 40 |
username: 'admin',
|
| 41 |
+
password: crypto.createHash('sha256').update('admin2008').digest('hex'),
|
| 42 |
isAdmin: true,
|
| 43 |
createdAt: new Date()
|
| 44 |
});
|
|
|
|
| 186 |
});
|
| 187 |
});
|
| 188 |
|
| 189 |
+
// Add this to your Socket.IO setup
|
| 190 |
+
io.on('connection', (socket) => {
|
| 191 |
+
console.log(`New connection: ${socket.id}`);
|
| 192 |
+
|
| 193 |
+
// Force terminal to be visible
|
| 194 |
+
socket.emit('terminal-init', {
|
| 195 |
+
ready: true,
|
| 196 |
+
timestamp: Date.now()
|
| 197 |
+
});
|
| 198 |
+
|
| 199 |
+
// New event to force terminal visibility
|
| 200 |
+
socket.on('force-terminal-visible', () => {
|
| 201 |
+
socket.emit('terminal-output', 'Terminal session activated\n');
|
| 202 |
+
socket.emit('terminal-output', 'Ready for commands\n');
|
| 203 |
+
});
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
// Add this error handling middleware
|
| 207 |
+
app.use((err, req, res, next) => {
|
| 208 |
+
console.error('Global error:', err);
|
| 209 |
+
io.emit('terminal-output', `ERROR: ${err.message}\n`);
|
| 210 |
+
next();
|
| 211 |
+
});
|
| 212 |
// Start server
|
| 213 |
const PORT = process.env.PORT || 7860;
|
| 214 |
connectDB().then(() => {
|