testing
This commit is contained in:
parent
49c508aae7
commit
5c7c748a69
@ -14,7 +14,7 @@ import (
|
||||
*/
|
||||
|
||||
type Client struct {
|
||||
cli *mcr.Client
|
||||
cli mcr.Client
|
||||
}
|
||||
|
||||
type IClient interface {
|
||||
@ -25,9 +25,9 @@ type IClient interface {
|
||||
// creates a new mcr client using saved credentials and decrypted password
|
||||
func New() (*Client, error) {
|
||||
//grab saved credentials
|
||||
server := viper.Get("server").(string)
|
||||
password := viper.Get("password").(string)
|
||||
port := viper.Get("port").(int)
|
||||
server := viper.GetString("server")
|
||||
password := viper.GetString("password")
|
||||
port := viper.GetInt("port")
|
||||
fmt.Printf("Logging into %s on port %d\n", server, port)
|
||||
|
||||
//decrypt password
|
||||
|
@ -24,7 +24,7 @@ var loginCmd = &cobra.Command{
|
||||
sending commands to server and printing the response.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
//grab saved credentials
|
||||
server := viper.Get("server").(string)
|
||||
server := viper.GetString("server")
|
||||
cli, err := client.New()
|
||||
cobra.CheckErr(err)
|
||||
defer cli.Close()
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
)
|
||||
|
||||
func EncryptPassword(b []byte) ([]byte, error) {
|
||||
nonce := viper.Get("nonce").(string)
|
||||
dev := viper.Get("device").(string)
|
||||
nonce := viper.GetString("nonce")
|
||||
dev := viper.GetString("device")
|
||||
|
||||
block, err := aes.NewCipher([]byte(dev))
|
||||
if err != nil {
|
||||
@ -29,9 +29,9 @@ func EncryptPassword(b []byte) ([]byte, error) {
|
||||
}
|
||||
|
||||
func DecryptPassword(b []byte) (string, error) {
|
||||
nonce := viper.Get("nonce").(string)
|
||||
password := viper.Get("password").(string)
|
||||
dev := viper.Get("device").(string)
|
||||
nonce := viper.GetString("nonce")
|
||||
password := viper.GetString("password")
|
||||
dev := viper.GetString("device")
|
||||
|
||||
block, err := aes.NewCipher([]byte(dev))
|
||||
if err != nil {
|
||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module code.jakeyoungdev.com/jake/mctl
|
||||
go 1.24.2
|
||||
|
||||
require (
|
||||
github.com/jake-young-dev/mcr v1.3.1
|
||||
github.com/jake-young-dev/mcr v1.3.3-0.20250531035550-4d1e822a867f
|
||||
github.com/spf13/cobra v1.9.1
|
||||
github.com/spf13/viper v1.20.1
|
||||
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/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.3-0.20250531035550-4d1e822a867f h1:G0G+K+dtO63jByfA7XDxvP8dCTET5C+CRbJjFCysXwM=
|
||||
github.com/jake-young-dev/mcr v1.3.3-0.20250531035550-4d1e822a867f/go.mod h1:74yZHGf9h3tLUDUpInA17grKLrNp9lVesWvisCFCXKY=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
|
Loading…
x
Reference in New Issue
Block a user