Skip to content

RESTaurant is a powerful, secure, and easy-to-use server that transforms your command-line tools into RESTful APIs. Whether you're looking to remotely execute system commands, integrate shell scripts with web services, or build automation workflows, RESTaurant has you covered with a clean, intuitive interface.

Notifications You must be signed in to change notification settings

norcimo5/RESTaurant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTaurant 🍲

Serving up your shell commands fresh and hot, RESTfully!

License: MIT Rust

RESTaurant is a powerful, secure, and easy-to-use server that transforms your command-line tools into RESTful APIs. Whether you're looking to remotely execute system commands, integrate shell scripts with web services, or build automation workflows, RESTaurant has you covered with a clean, intuitive interface.

🍽️ Features

  • RESTful Command Execution: Turn any shell command into an API endpoint
  • Custom Commands: Define your own command menu in a simple JSON configuration file
  • Built-in Security: Protection against dangerous commands and rate limiting
  • Metrics & Monitoring: Track usage statistics for all your endpoints
  • Configurable Timeouts: Set global or per-request execution time limits
  • Cross-Origin Support: Built-in CORS handling for web applications
  • Graceful Shutdown: Clean termination with proper signal handling
  • Comprehensive Logging: Detailed insights into all operations

🥗 Quick Start

Installation

# Clone the repository
git clone https://github.com/yourusername/restaurant.git
cd restaurant

# Build the project
cargo build --release

# Run the server with default settings
./target/release/restaurant

Configuration

RESTaurant can be configured via command-line arguments, environment variables, or a config file:

# Run with custom settings
./target/release/restaurant --host 0.0.0.0 --port 8080 --config-file my-commands.json

Define Your Menu (Commands)

Create a config.json file with your custom commands:

{
    "commands": {
        "uptime": {
            "command": "uptime",
            "description": "System uptime information",
            "methods": ["GET"]
        },
        "runmyscript": {
            "command": "/usr/bin/myscript.sh -i ok.txt -o output.txt",
            "description": "My script that does something amazing",
            "methods": ["GET"]
        }
    }
}

🍳 Usage

Predefined Commands

Access your predefined commands via simple GET requests:

# Get system uptime
curl http://localhost:55555/uptime

# Run a custom script defined in config.json
curl http://localhost:55555/runmyscript

Custom Command Execution

Execute arbitrary commands (if they pass security checks):

curl -X POST http://localhost:55555/custom \
  -H "Content-Type: application/json" \
  -d '{"command": "ls -la", "timeout": 10}'

API Documentation

RESTaurant serves these special endpoints:

  • GET /health: Server health check
  • GET /api/endpoints: List all available command endpoints
  • GET /metrics: Request statistics and metrics
  • POST /custom: Execute custom commands

🔒 Security

RESTaurant takes security seriously:

  • Commands are checked against a list of dangerous patterns
  • Rate limiting prevents abuse
  • Custom commands are sanitized
  • Execution timeouts prevent resource exhaustion
  • Security headers are added to all responses

🔧 Configuration Options

Option Environment Variable Default Description
--host COMMAND_SERVER_HOST 127.0.0.1 Server host address
--port COMMAND_SERVER_PORT 55555 Server port
--timeout COMMAND_TIMEOUT 30 Command execution timeout in seconds
--rate-limit-requests RATE_LIMIT_REQUESTS 100 Rate limit: requests per window
--rate-limit-window RATE_LIMIT_WINDOW 60 Rate limit window in seconds
--config-file COMMAND_CONFIG_FILE config.json Path to command definitions file
--log-level LOG_LEVEL info Logging level (trace, debug, info, warn, error)
--debug COMMAND_SERVER_DEBUG false Enable debug mode

🍽️ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgements


RESTaurant: Where your commands are always served fresh and RESTfully!

About

RESTaurant is a powerful, secure, and easy-to-use server that transforms your command-line tools into RESTful APIs. Whether you're looking to remotely execute system commands, integrate shell scripts with web services, or build automation workflows, RESTaurant has you covered with a clean, intuitive interface.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages