Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
58ece42142 | |||
49c508aae7 | |||
dcfad2dfee | |||
5b6ddc71cf | |||
f8282c3676 | |||
386a766185 |
@@ -1,25 +1,17 @@
|
|||||||
name: "code scans"
|
name: "code scans"
|
||||||
on: [push, pull_request] #runs on pushes to any branch
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
scans:
|
scans:
|
||||||
runs-on: smoke-test
|
runs-on: fire
|
||||||
steps:
|
steps:
|
||||||
- name: "clone code"
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: "install go"
|
|
||||||
uses: https://code.jakeyoungdev.com/actions/install-go@v0.1.3
|
|
||||||
with:
|
|
||||||
commands: |
|
|
||||||
golang.org/x/vuln/cmd/govulncheck@latest
|
|
||||||
|
|
||||||
- name: "dependency and stdlib scan"
|
- name: "dependency scan and static code analysis"
|
||||||
uses: https://code.jakeyoungdev.com/actions/report-vulns@master
|
uses: https://code.jakeyoungdev.com/actions/donotpassgo@v1.1.0
|
||||||
with:
|
|
||||||
manager: go
|
|
||||||
|
|
||||||
- name: "static code analysis"
|
|
||||||
uses: securego/gosec@master
|
|
||||||
with:
|
|
||||||
args: ./...
|
|
43
README.md
43
README.md
@@ -1,14 +1,24 @@
|
|||||||
# mctl
|
# mctl
|
||||||
mctl is a terminal-friendly remote console client
|
mctl is a terminal-friendly remote console client
|
||||||
|
|
||||||
## Installation
|
# Index
|
||||||
|
1. [Installation](#installation)
|
||||||
|
2. [Setup](#setup)
|
||||||
|
3. [Documentation](#documentation)
|
||||||
|
4. [Security](#security)
|
||||||
|
5. [Development](#development)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
# Installation
|
||||||
Install mctl using golang
|
Install mctl using golang
|
||||||
```bash
|
```bash
|
||||||
go install code.jakeyoungdev.com/jake/mctl@main #it is recommended to use a tagged version
|
go install code.jakeyoungdev.com/jake/mctl@main #it is recommended to use a tagged version
|
||||||
```
|
```
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
## Setup
|
# Setup
|
||||||
### Configuring mctl
|
### Configuring mctl
|
||||||
mctl requires a one-time setup via the 'config' command before interacting with any servers, password is entered securely from the terminal and encrypted
|
mctl requires a one-time setup via the 'config' command before interacting with any servers, password is entered securely from the terminal and encrypted
|
||||||
```bash
|
```bash
|
||||||
@@ -75,7 +85,16 @@ Commands can be deleted with:
|
|||||||
mctl delete <name>
|
mctl delete <name>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
### Clear configuration file
|
||||||
|
To clear all fields from the configuration file use:
|
||||||
|
```bash
|
||||||
|
#CAUTION: If the config file is cleared all data previously saved will be lost forever
|
||||||
|
mctl clear
|
||||||
|
```
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
# Documentation
|
||||||
### Commands
|
### Commands
|
||||||
|Command|Description|
|
|Command|Description|
|
||||||
|---|---|
|
|---|---|
|
||||||
@@ -85,21 +104,19 @@ mctl delete <name>
|
|||||||
|view \<name>|displays saved command|
|
|view \<name>|displays saved command|
|
||||||
|delete \<name>|deletes saved command|
|
|delete \<name>|deletes saved command|
|
||||||
|run \<name> args...|runs saved command filling placeholders with supplied args|
|
|run \<name> args...|runs saved command filling placeholders with supplied args|
|
||||||
|
|clear|clears config file|
|
||||||
### Flags
|
|
||||||
#### config
|
|
||||||
|Flag|Shorthand|Required|Description|
|
|
||||||
|---|---|---|---|
|
|
||||||
|port|p|yes|RCon port|
|
|
||||||
|server|s|yes|RCon address|
|
|
||||||
|
|
||||||
### Configuration file
|
### Configuration file
|
||||||
All configuration data will be kept in the home directory and any sensitive data is encrypted for added security
|
All configuration data will be kept in the home directory and any sensitive data is encrypted for added security
|
||||||
|
|
||||||
## Security
|
<br />
|
||||||
|
|
||||||
|
# Security
|
||||||
RCon is an inherently insecure protocol, passwords are sent in plaintext and, if possible, the port should not be exposed to the internet. It is best to keep these connections local or over a VPN.
|
RCon is an inherently insecure protocol, passwords are sent in plaintext and, if possible, the port should not be exposed to the internet. It is best to keep these connections local or over a VPN.
|
||||||
|
|
||||||
mctl utilizes [govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck) and [gosec](https://github.com/securego/gosec) in workflows to ensure quality, secure code is being pushed. These workflow steps must pass before a PR will be accepted
|
mctl utilizes [govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck) and [gosec](https://github.com/securego/gosec) in workflows to ensure quality, secure code is being pushed. These workflow steps must pass before a PR will be accepted
|
||||||
|
|
||||||
## Development
|
<br />
|
||||||
this repo is currently in heavy development and may encounter breaking changes, use a tag to prevent any surprises
|
|
||||||
|
# Development
|
||||||
|
this repo is currently in development and may encounter breaking changes, use a tag to prevent any surprises
|
@@ -14,7 +14,7 @@ import (
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
cli *mcr.Client
|
cli mcr.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
type IClient interface {
|
type IClient interface {
|
||||||
|
43
cmd/clear.go
Normal file
43
cmd/clear.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
Copyright © 2025 Jake jake.young.dev@gmail.com
|
||||||
|
*/
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"code.jakeyoungdev.com/jake/mctl/models"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
// clearCmd represents the clear command
|
||||||
|
var clearCmd = &cobra.Command{
|
||||||
|
Use: "clear",
|
||||||
|
Short: "Clear config file",
|
||||||
|
Long: `Clears all configuration values for mctl, all server configuration will be lost`,
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
home, err := os.UserHomeDir()
|
||||||
|
cobra.CheckErr(err)
|
||||||
|
|
||||||
|
viper.AddConfigPath(home)
|
||||||
|
viper.SetConfigType("yaml")
|
||||||
|
viper.SetConfigName(".mctl")
|
||||||
|
|
||||||
|
err = viper.ReadInConfig()
|
||||||
|
if err == nil {
|
||||||
|
//clear values if file exists
|
||||||
|
for _, v := range models.ConfigFields {
|
||||||
|
viper.Set(v, "")
|
||||||
|
}
|
||||||
|
err := viper.WriteConfig()
|
||||||
|
cobra.CheckErr(err)
|
||||||
|
fmt.Println("Config file cleared, use 'config' command to re-populate it")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(clearCmd)
|
||||||
|
}
|
@@ -76,9 +76,8 @@ func initConfig() {
|
|||||||
viper.SetConfigName(".mctl")
|
viper.SetConfigName(".mctl")
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
err = viper.ReadInConfig()
|
err = viper.ReadInConfig()
|
||||||
cobra.CheckErr(err)
|
|
||||||
|
|
||||||
if err := viper.ReadInConfig(); err != nil {
|
if err != nil {
|
||||||
//file does not exist, create it
|
//file does not exist, create it
|
||||||
viper.Set("server", cfgserver)
|
viper.Set("server", cfgserver)
|
||||||
viper.Set("password", "")
|
viper.Set("password", "")
|
||||||
|
@@ -28,5 +28,7 @@ func Execute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
rootCmd.CompletionOptions = cobra.CompletionOptions{
|
||||||
|
DisableDefaultCmd: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
2
go.mod
2
go.mod
@@ -3,7 +3,7 @@ module code.jakeyoungdev.com/jake/mctl
|
|||||||
go 1.24.2
|
go 1.24.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/jake-young-dev/mcr v1.3.1
|
github.com/jake-young-dev/mcr v1.4.0
|
||||||
github.com/spf13/cobra v1.9.1
|
github.com/spf13/cobra v1.9.1
|
||||||
github.com/spf13/viper v1.20.1
|
github.com/spf13/viper v1.20.1
|
||||||
golang.org/x/term v0.31.0
|
golang.org/x/term v0.31.0
|
||||||
|
2
go.sum
2
go.sum
@@ -14,6 +14,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
|
|||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
github.com/jake-young-dev/mcr v1.3.1 h1:ELJsrJHwQsMiM09o+q8auUaiGXXX3DWIgh/TfZQc0B0=
|
github.com/jake-young-dev/mcr v1.3.1 h1:ELJsrJHwQsMiM09o+q8auUaiGXXX3DWIgh/TfZQc0B0=
|
||||||
github.com/jake-young-dev/mcr v1.3.1/go.mod h1:74yZHGf9h3tLUDUpInA17grKLrNp9lVesWvisCFCXKY=
|
github.com/jake-young-dev/mcr v1.3.1/go.mod h1:74yZHGf9h3tLUDUpInA17grKLrNp9lVesWvisCFCXKY=
|
||||||
|
github.com/jake-young-dev/mcr v1.4.0 h1:cXZImkfI8aNIiVPrONE6qP+nfblTGsD2iXpPKTcA25U=
|
||||||
|
github.com/jake-young-dev/mcr v1.4.0/go.mod h1:74yZHGf9h3tLUDUpInA17grKLrNp9lVesWvisCFCXKY=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
4
models/data.go
Normal file
4
models/data.go
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
//list of all fields kept in config file
|
||||||
|
var ConfigFields = [6]string{"customcmd", "device", "nonce", "port", "server", "password"}
|
Reference in New Issue
Block a user