Skip to content

bofrim/gorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gorch

Note: This module is still very early in development. It should be considered pre-pre-alpha.

Warning: By definition portions of this module will be used for remote code execution. Ensure you understand the security implications of this before using this module.

gorch mascot

About

Gorch (pronounced gork) is a tool that can be used to interface with and manage multiple remote nodes. Drop json files into your node's data directory and gorch will serve them for you.

Gorch is also able to run remote actions on your nodes. Specify a configuration file when starting your node and gorch will provide an interface for executing those actions.

Building

git clone https://github.com/bofrim/gorch
cd gorch
go build -o gorch gorch.go

Usage

Running an orchestrator

./gorch orchestrator \
  --cert-path /path/to/pem/certs \
  --log /some/path/to/gorch_log.txt # optional

Running a node

./gorch node --config /path/to/config.yaml --token "some_token"
# config.yaml
cert-path: "/path/to/pem/certs"
data: "/some/path/to/data_dir"
name: "cool_node_1"
orchestrator: "127.0.0.1:443"
port: 8776 # optional
arbitrary-actions: true # Optional; Danger: allows arbitrary code execution
log-level: "INFO" # options from slog.Level: DEBUG, INFO, WARN, ERROR

actions:
  "list":
    description: "List the contents of a directory"
    resources:
      "status": 1
    params: []
    commands:
      - "ls"

  "echo":
    description: "A command that will allow you to print a message"
    params: ["message", "other"]
    resources:
      "status": 1
    commands:
      - "echo {{.message}}"
      - "echo {{.other}}"

  "sleep":
    description: "A command that will sleep"
    params: ["time"]
    resources:
      "blocking": 1
    commands:
      - "date"
      - "sleep {{.time}}"
      - "date"

resource-groups:
  "blocking": 1
  "status": 100

Running user operations

Get info about the orchestrator

./gorch user info \
  --orchestrator "127.0.0.1:443"

Get all the data from a node

./gorch user data \
  --orchestrator "127.0.0.1:443" \
  --node cool_node_1 \
  --json \ # optional
  --header "X-Authorization: Bearer some_token"

Get a specific json file from a node

./gorch user data \
  --orchestrator "127.0.0.1:443" \
  --node cool_node_1 \
  --path asdf \
  --json \ # optional
  --header "X-Authorization: Bearer some_token"

Run an action on a node

./gorch user action \
  --orchestrator "127.0.0.1:443" \
  --node cool_node_1 \
  --action hello \
  --data message=hello \
  --data other=world \
  --header "X-Authorization: Bearer some_token"

Run an action on a node and stream output.

./gorch user action \
  --orchestrator "127.0.0.1:443" \
  --node cool_node_1 \
  --action sleep \
  --data time=5 \
  --stream-port 8323 \
  --header "X-Authorization: Bearer some_token"

Specify a data file to use as the body of the request

./gorch user action \
  --orchestrator "127.0.0.1:443" \
  --node cool_node_1 \
  --action sleep \
  --data-file params.json \
  --stream-port 8323 \
  --header "X-Authorization: Bearer some_token"

Run arbitrary commands on a node (Note: The node must be running with the --arbitrary-actions flag set)

.gorch user action \
  --node brad \
  --data-file adhoc.json \
  --data message="hello" \  # data can be specified in the data-file, or as a flag
  --stream-port 8323 \
  --header "X-Authorization: Bearer some_token"

Where adhoc.json is:

{
  "action": {
    "name": "adhoc-list",
    "description": "List the contents of a directory",
    "params": ["dir", "message"],
    "commands": ["ls {{.dir}}", "echo {{.message}}"]
  },
  "dir": "/path/to/list"
}

TODO

BUGS

  • sending a sleep action, then sending an echo will cause the echo to override the sleep and return on the sleep's stream if the steam port is the same

High Priority

  • Setup centralized logging for nodes so logs will be accessible through the orchestrator even if the node is offline
  • Generate TLS certs on the fly (simplify setup/dependencies)
  • Ability to list currently running actions (with info about them; params, age, etc)
  • Ability to kill a running action
  • a front end for the orchestrator and nodes

Nice to have

  • Add a way to run periodic actions on a node (should be an optional configuration option for a node) Figure out what to do with the output of the action.
  • Setup web hooks for data changes or events related to actions
  • Add a user command to stream logs from either the orchestrator or a specific node
  • Hook listeners should have IDs for actions that are tracked on the node side
  • webhook for action completion

About

Remote machine orchestration tool.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages