Skip to content

CYW-Allen/Shell-Proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

Shell Proxy

An API server designed to accept HTTP requests for executing shell scripts.

Table of Contents
  1. About The Project
  2. Running The Demo
  3. Built With

About The Project

This server provides two main routes, shell and status, for script executing and status inquires.

  • Route shell:
    • Function: Allow user to execute specific shell script by sending HTTP request.
    • Method: GET
    • Query string:
      • name (required): Specify the name of the script to be executed.
      • opts (optional): Provide additional option parameters for script execution.
    • Response:
      • Type: JSON
      • Properties:
        • result: Describe the outcome of the script execution, indicating whether it's still running, completed, or failed. - String
        • logs: Contain the logs generated by the script execution. - Array of Strings
  • Route status:
    • Function: Allow user to query the status of specific script executions.
    • Method: GET
    • Query string:
      • name (required): Specify the name of the script execition to be checked.
    • Response: Same as route shell for consistency and ease of use.

Notice :

  • No script is allowed to execute multiple times at the same time.

  • When a script is progress, the other execution requests for that script are ignored until the current execution finishes and the cooldown period elapses.

  • Initiating a script execution during the cooldown period resets the cooldown timer.

  • For security reason, only the scripts under the directory of the server artifact are permitted to execute.

    name example:

    • script -> ✔
    • folder1/folder2/script -> ✔
    • ../folder/script -> ✘
    • folder/../../script -> ✘

    To streamline the logic implementation, all of string .. in name have been removed. Although the path folder/../folder/script is equivalent to folder/script, it will be treated as folder/folder/script

(back to top)

Running The Demo

  1. Create and start the docker container
    docker-compose up --build
  2. Make some requests for executing the example shell scripts.
    curl 'localhost:8080/shell?name=f1/test1&opts=p1&opts=p2'
    curl 'localhost:8080/shell?name=test2'
  3. Check the status of the execution
    curl 'localhost:8080/status?name=f1/test1'
    curl 'localhost:8080/status?name=test2'
  4. Exit the demo project.
    docker-compose down --rmi all

(back to top)

Additional

Customize the icon of the executable file on windows.

  1. Prepare one ico file (exe.ico).
  2. Create rc file with the following content.
    #include "winuser.h"
    #define IDR_MYICON 101
    IDR_MYICON ICON "./exe.ico"
    
  3. Build syso file.
    windres -o file fileinfo.syso fileinfo.rc
  4. Build artifact.
    go build

(back to top)

Built With

  • Golang
  • Gin

(back to top)

About

An API server accepts HTTP requests to execute shell scripts.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors