- File-based configuration (
config.json) - ConfigManager class with full CRUD operations
- Environment variable support for all settings
- Validation and error handling
- Import/Export functionality
- Hot-reload capability
- All modules now read from centralized configuration
- Dynamic port configuration
- Configurable monitoring intervals
- Module-specific settings support
- Backward compatible with existing code
Base URL: http://localhost:3000/api
Authentication: Basic Auth (default: admin/admin123)
Endpoints:
GET /api/status- Server statusGET /api/config- Get configurationPUT /api/config- Update configurationGET /api/modules/:name/config- Get module configPUT /api/modules/:name/config- Update module configPOST /api/modules/:name/start- Start modulePOST /api/modules/:name/stop- Stop modulePOST /api/modules/:name/reload- Reload moduleGET /api/config/export- Export configPOST /api/config/import- Import configPOST /api/config/reload- Reload from filePOST /api/config/reset- Reset to defaults
- Real-time updates every 5 seconds
- Event broadcasting for config changes
- Module lifecycle events (start/stop/reload)
- Automatic reconnection on disconnect
Features:
- 🎨 Modern dark theme UI
- 📊 Real-time dashboard with statistics
- 🔧 Module management (start/stop/reload)
- ⚙️ Configuration editor with JSON syntax
- 📝 Live log viewer
- 🔄 Auto-refresh status updates
- 📱 Responsive design
- 🔐 Authentication protected
Tabs:
- Dashboard - Overview and quick actions
- Modules - Individual module controls
- Configuration - JSON editor with save/reload
- Logs - Real-time log viewer
OneStack/
├── main.js # Main server orchestrator
├── config-manager.js # Configuration management class
├── admin-api.js # REST API & WebSocket server
├── config.json # Server configuration (auto-generated)
├── package.json # Dependencies
├── .env.example # Environment variables template
├── README.md # Main documentation
├── SETUP.md # Quick setup guide
├── modules/
│ ├── base_module.js # Base module class
│ ├── http.js # HTTP server module
│ ├── https.js # HTTPS server module
│ ├── dns.js # DNS server module
│ ├── email.js # Email (SMTP/IMAP) module
│ └── ssh.js # SSH server module
└── admin-panel/
└── dist/
└── index.html # Admin panel SPA
npm starthttp://localhost:3000
Login: admin / admin123
Get Server Status:
curl http://localhost:3000/api/status -u admin:admin123Update HTTP Port:
curl -X PUT http://localhost:3000/api/config \
-u admin:admin123 \
-H "Content-Type: application/json" \
-d '{"modules":{"http":{"port":9090}}}'Stop DNS Module:
curl -X POST http://localhost:3000/api/modules/dns/stop \
-u admin:admin123Export Configuration:
curl http://localhost:3000/api/config/export \
-u admin:admin123 > backup.json# Set custom ports
ADMIN_PORT=8000 HTTP_PORT=9090 npm start
# Disable modules
DNS_ENABLED=false EMAIL_ENABLED=false npm start
# Custom credentials
ADMIN_USERNAME=myuser ADMIN_PASSWORD=mypass npm startAll configurable via:
- Admin Panel UI (easiest)
- config.json file (manual editing)
- Environment variables (deployment)
- REST API (programmatic)
Each module supports:
enabled- Enable/disable moduleport- Port numberhost- Bind addressmonitoring- Background monitoring settings- Module-specific options
Example:
{
"modules": {
"http": {
"enabled": true,
"port": 8080,
"host": "0.0.0.0",
"monitoring": {
"enabled": true,
"interval": 30000
}
}
}
}- ✅ Basic Authentication for admin panel
- ✅ CORS support for API
- ✅ Input validation
- ✅ Environment variable support for secrets
- ✅ Configurable user credentials
⚠️ Remember to change default passwords!
- Real-time uptime counter
- Memory usage monitoring
- Active modules count
- Total threads count
- Quick configuration actions
- Individual module cards
- Status badges (Running/Stopped)
- Port information
- Worker thread counts
- Start/Stop/Reload buttons
- Full JSON editor
- Syntax validation
- Save to file
- Reload from file
- Reset to defaults
- Export/Import
- Real-time log entries
- Timestamp for each entry
- Auto-scroll
- Clear logs button
Subscribe to real-time updates:
const ws = new WebSocket('ws://localhost:3000');
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
switch(message.type) {
case 'status':
console.log('Server status:', message.data);
break;
case 'configUpdated':
console.log('Config updated:', message.data);
break;
case 'moduleStarted':
console.log('Module started:', message.data.module);
break;
}
};- ✅ Run
npm install - ✅ Run
npm start - ✅ Open
http://localhost:3000 - ✅ Change default password
- ✅ Configure modules as needed
- Add HTTPS support for admin panel
- Implement JWT authentication
- Add role-based access control
- Create module templates
- Add module marketplace/plugins
- Implement log file persistence
- Add metrics and charts
- Create mobile app
- Add database integration
- Implement clustering support
See SETUP.md for detailed troubleshooting guide.
Common issues:
- Port in use: Change port in config.json
- Permission denied: Use non-privileged ports or run as admin
- Can't connect: Check firewall settings
- Module won't start: Check module logs in admin panel
- README.md - Full documentation with API reference
- SETUP.md - Quick setup guide and troubleshooting
- config.json - Live configuration file
- .env.example - Environment variables template
You now have a fully functional multi-protocol server with:
- ✅ Modular architecture
- ✅ Thread-based processing
- ✅ File-based configuration
- ✅ Modern admin panel
- ✅ REST API
- ✅ Real-time WebSocket updates
- ✅ Comprehensive documentation
Enjoy your OneStack server! 🚀