OneStack is a comprehensive, modular server platform built with Node.js that provides HTTP/HTTPS hosting, DNS services, email server, SSH access, and a powerful REST API with 50+ endpoints for extensions. It features a modern admin panel and dynamic module system for unlimited extensibility.
🎉 NEW: Complete REST API + Dynamic Module Loading + Extension System
- 🌐 HTTP/HTTPS Server - Virtual host management with statistics
- 🔍 DNS Server - Full DNS zone and record management
- 📧 Email Server - SMTP/IMAP with complete mailbox management
- 🔑 SSH Server - Secure shell access
- 📊 Admin Panel - Modern, dark-themed web UI
- 🔧 REST API - 50+ endpoints for complete programmatic control
- 🔌 Dynamic Modules - Auto-discovery and hot-loading of custom modules
- 📡 WebSocket API - Real-time updates and event streaming
- 🛠️ Module SDK - Complete framework for building extensions
- 📚 Comprehensive Docs - 6 detailed guides (3500+ lines total)
- API_DOCUMENTATION.md - Complete REST API reference
- MODULE_DEVELOPMENT.md - Module development guide
- EXTENSION_GUIDE.md - Extension system overview
- EMAIL_GUIDE.md - Email system documentation
- EMAIL_IMPLEMENTATION.md - Email architecture
- QUICKSTART.md - Testing guide
Each protocol is implemented as a separate module that extends the BaseModule class. Modules run independently and can create their own child threads for additional processing.
- Each module runs in the main process but can spawn:
- Worker Threads - For CPU-intensive operations
- Custom Threads - For background tasks like monitoring, cleanup, and processing
modules/
├── base_module.js - Base class with common functionality
├── http.js - HTTP server implementation
├── https.js - HTTPS server implementation
├── dns.js - DNS server implementation
├── email.js - Email (SMTP/IMAP) implementation
└── ssh.js - SSH server implementation
npm installnpm startOpen your browser and navigate to:
http://localhost:3000
Default Credentials:
- Username:
admin - Password:
admin123
config.json before deploying to production!
Configuration is stored in config.json. The file is automatically created with defaults on first run.
Example configuration structure:
{
"server": {
"name": "OneStack Server",
"version": "1.0.0",
"adminPanel": {
"enabled": true,
"port": 3000,
"username": "admin",
"password": "admin123"
}
},
"modules": {
"http": {
"enabled": true,
"port": 8080,
"host": "0.0.0.0",
"monitoring": {
"enabled": true,
"interval": 30000
}
},
"dns": {
"enabled": true,
"port": 5353,
"records": {
"localhost.local": {
"type": "A",
"ttl": 300,
"data": "127.0.0.1"
}
}
}
// ... more modules
}
}You can override configuration values using environment variables:
# Admin Panel
ADMIN_PORT=3000
ADMIN_USERNAME=admin
ADMIN_PASSWORD=secretpassword
# Module Ports
HTTP_PORT=8080
HTTPS_PORT=8443
DNS_PORT=5353
SMTP_PORT=2525
IMAP_PORT=1143
SSH_PORT=2222
# Enable/Disable Modules
HTTP_ENABLED=true
DNS_ENABLED=falseExample:
ADMIN_PORT=8000 HTTP_PORT=9090 npm start| Service | Default Port | Privileged Port | Notes |
|---|---|---|---|
| Admin Panel | 3000 | N/A | Web interface |
| HTTP | 8080 | 80 | Use non-privileged by default |
| HTTPS | 8443 | 443 | Use non-privileged by default |
| DNS | 5353 | 53 | Port 53 requires admin/root |
| SMTP | 2525 | 25 | Port 25 requires admin/root |
| IMAP | 1143 | 143 | Standard port is 143 |
| SSH | 2222 | 22 | Port 22 requires admin/root |
💡 Tip: Default configuration uses non-privileged ports (>1024) to avoid requiring administrator/root access.
# Using browser
http://localhost:8080
# Using curl
curl http://localhost:8080
curl http://localhost:8080/status
curl http://localhost:8080/health# Query DNS server (using dig on Linux/Mac or nslookup on Windows)
nslookup onestack.local 127.0.0.1Built-in DNS records:
localhost.local→ 127.0.0.1onestack.local→ 127.0.0.1www.onestack.local→ onestack.local (CNAME)
# Send test email using telnet
telnet localhost 25
HELO localhost
MAIL FROM:<sender@example.com>
RCPT TO:<recipient@example.com>
DATA
Subject: Test
This is a test email.
.
QUIT# Connect to SSH server
ssh admin@localhost -p 22
# Password: admin (demo only!)
# Available commands in SSH shell:
# - help
# - status
# - uptime
# - whoami
# - exit- Real-time server statistics
- Module status overview
- Quick actions for common tasks
- Live connection status
- Start/Stop/Reload individual modules
- View module configuration
- Monitor worker threads
- Real-time status updates via WebSocket
- Visual JSON editor
- Real-time validation
- Save/Reload/Reset options
- Export/Import configuration
- Syntax highlighting
- Real-time log viewer
- WebSocket-based updates
- Filterable log entries
The admin panel exposes a REST API for programmatic control:
All API endpoints require Basic Authentication:
const auth = 'Basic ' + btoa('admin:admin123');
fetch('/api/status', {
headers: { 'Authorization': auth }
});GET /api/statusReturns server uptime, memory usage, and module status.
GET /api/configReturns current configuration.
PUT /api/config
Content-Type: application/json
{
"modules": {
"http": {
"port": 8090
}
}
}POST /api/modules/:name/start
POST /api/modules/:name/stop
POST /api/modules/:name/reload
GET /api/modules/:name/status
GET /api/modules/:name/config
PUT /api/modules/:name/configGET /api/config/export # Download config as JSON
POST /api/config/import # Import configuration
POST /api/config/reload # Reload from file
POST /api/config/reset # Reset to defaultscurl -X PUT http://localhost:3000/api/config \
-u admin:admin123 \
-H "Content-Type: application/json" \
-d '{"modules":{"http":{"port":9090}}}'Real-time updates are available via WebSocket at ws://localhost:3000
// Connection established
{ "type": "connected", "data": { "timestamp": "..." } }
// Status update (every 5 seconds)
{ "type": "status", "data": { ...serverStatus } }
// Configuration updated
{ "type": "configUpdated", "data": { ...newConfig } }
// Module events
{ "type": "moduleStarted", "data": { "module": "http" } }
{ "type": "moduleStopped", "data": { "module": "dns" } }- Via Admin Panel: Navigate to the Configuration tab
- Via File: Edit
config.jsondirectly - Via API: Use PUT
/api/config
After editing config.json:
# Option 1: Via API
curl -X POST http://localhost:3000/api/config/reload -u admin:admin123
# Option 2: Via Admin Panel
# Click "Reload Config" button in Dashboard
# Option 3: Restart servercurl -X POST http://localhost:3000/api/config/reset -u admin:admin123curl http://localhost:3000/api/config/export -u admin:admin123 > backup.jsoncurl -X POST http://localhost:3000/api/config/import \
-u admin:admin123 \
-H "Content-Type: application/json" \
-d @backup.json- Create a new file in
modules/directory - Extend the
BaseModuleclass - Implement
start()andstop()methods - Add module to
main.js
Example:
const BaseModule = require('./base_module');
class MyProtocolModule extends BaseModule {
constructor(config) {
super('MyProtocol', config);
}
async start() {
await super.start();
// Initialize your server here
// Create a worker thread if needed
this.createCustomThread(this.backgroundTask, { interval: 10000 });
}
async backgroundTask(thread, data) {
while (thread.running) {
await new Promise(resolve => setTimeout(resolve, data.interval));
// Do background work
}
}
async stop() {
// Clean up resources
await super.stop();
}
}
module.exports = MyProtocolModule;createWorkerThread(workerFile, workerData)- Create a worker threadcreateCustomThread(threadFunction, data)- Create a custom async threadstopThread(threadId)- Stop a specific threadlog(message)- Emit a log messageerror(error)- Emit an errorgetStatus()- Get module status
{
"enabled": true,
"port": 8080,
"host": "0.0.0.0",
"monitoring": {
"enabled": true,
"interval": 30000
},
"routes": {
"enableDefaultRoutes": true
}
}{
"enabled": true,
"port": 5353,
"host": "0.0.0.0",
"records": {
"example.local": {
"type": "A",
"ttl": 300,
"data": "192.168.1.100"
}
},
"cacheCleanup": {
"enabled": true,
"interval": 60000
}
}{
"enabled": true,
"smtp": {
"enabled": true,
"port": 2525,
"host": "0.0.0.0"
},
"imap": {
"enabled": true,
"port": 1143,
"host": "0.0.0.0"
},
"processing": {
"enabled": true,
"interval": 5000
}
}{
"enabled": true,
"port": 2222,
"host": "0.0.0.0",
"authentication": {
"users": [
{
"username": "admin",
"password": "admin",
"allowPasswordAuth": true,
"allowPublicKeyAuth": true
}
]
},
"monitoring": {
"enabled": true,
"interval": 30000
}
}- Change default credentials in
config.json - Use HTTPS for the admin panel in production
- Implement rate limiting for API endpoints
- Use proper SSL certificates for HTTPS module
- Implement proper authentication for SSH (key-based recommended)
- Add input validation and sanitization
- Enable firewall rules to restrict access
- Use environment variables for sensitive credentials
- Regular security updates of all dependencies
- Change Admin Credentials:
{
"server": {
"adminPanel": {
"username": "your-secure-username",
"password": "your-very-secure-password"
}
}
}- Use Environment Variables:
export ADMIN_USERNAME=secure_user
export ADMIN_PASSWORD=complex_password_here
npm start- Restrict Access:
- Bind admin panel to localhost only
- Use reverse proxy (nginx/Apache) with HTTPS
- Implement IP whitelisting
- Use VPN for remote access
ssh2- SSH server implementationnodemailer- Email utilitiesdns-packet- DNS protocol implementation
MIT
Feel free to submit issues and enhancement requests!