aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-02-02 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-02-02 20:20:20 +0100
commite9e2f686737d9ff395af502f9aeee17548dfcb2c (patch)
treeed60b6c8f16aa4debebb76f478a1bd7329a14fa5 /src
parentstack (diff)
downloadhardflip-e9e2f686737d9ff395af502f9aeee17548dfcb2c.tar.gz
hardflip-e9e2f686737d9ff395af502f9aeee17548dfcb2c.tar.bz2
hardflip-e9e2f686737d9ff395af502f9aeee17548dfcb2c.tar.xz
hardflip-e9e2f686737d9ff395af502f9aeee17548dfcb2c.tar.zst
hardflip-e9e2f686737d9ff395af502f9aeee17548dfcb2c.zip
func pointers yo
Diffstat (limited to '')
-rw-r--r--src/c_defs.go6
-rw-r--r--src/c_exec.go10
-rw-r--r--src/c_init.go2
-rw-r--r--src/c_lhosts.go2
-rw-r--r--src/c_parse.go2
-rw-r--r--src/i_info.go90
6 files changed, 80 insertions, 32 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index 2ec2346..68d2204 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_defs.go
- * Wed Jan 31 16:40:52 2024
+ * Fri Feb 02 10:07:55 2024
* Joe
*
* constants
@@ -91,6 +91,10 @@ const (
STYLE_BOT = 6
)
+const (
+ PROTOCOL_MAX = 3
+)
+
var (
HOST_ICONS = [4]string{" ", " ", " ", "󰞵 "}
DIRS_ICONS = [2]string{" ", " "}
diff --git a/src/c_exec.go b/src/c_exec.go
index 722dfbd..9d36cc8 100644
--- a/src/c_exec.go
+++ b/src/c_exec.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_exec.go
- * Fri Feb 02 09:41:42 2024
+ * Fri Feb 02 10:09:23 2024
* Joe
*
* exec the command at some point
@@ -177,6 +177,12 @@ func c_format_cmd(host *HostNode, opts HardOpts,
gpg, term := opts.GPG, opts.Term
if len(gpg) > 0 && gpg != "plain" && len(host.Pass) > 0 {
+ i_draw_msg(ui.s, 1, ui.style[STYLE_BOX], ui.dim, " GnuPG ")
+ text := "decryption using gpg..."
+ left, right := i_left_right(len(text), ui)
+ i_draw_text(ui.s, left, ui.dim[H] - 3, right, ui.dim[H] - 3,
+ ui.style[STYLE_DEF], text)
+ ui.s.Show()
var err error
pass, err = c_decrypt_str(host.Pass)
if err != nil {
@@ -196,7 +202,7 @@ func c_format_cmd(host *HostNode, opts HardOpts,
case 3:
cmd_fmt, cmd_env = c_format_openstack(host, pass)
default:
- c_die("you fucked up joe, users cant see this", nil)
+ return nil, nil
}
if len(term) > 0 {
// TODO: setsid
diff --git a/src/c_init.go b/src/c_init.go
index f90a4ad..a9da6c5 100644
--- a/src/c_init.go
+++ b/src/c_init.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/c_init.go
- * Wed Jan 31 14:10:00 2024
+ * Fri Feb 02 10:09:18 2024
* Joe
*
* init functions
diff --git a/src/c_lhosts.go b/src/c_lhosts.go
index 39800f6..d3e201e 100644
--- a/src/c_lhosts.go
+++ b/src/c_lhosts.go
@@ -161,7 +161,7 @@ func (host *HostNode) protocol_str() string {
case 0: return "SSH"
case 1: return "RDP"
case 2: return "Single command"
- case 3: return "OpenStack"
+ case 3: return "OpenStack CLI"
default: return ""
}
}
diff --git a/src/c_parse.go b/src/c_parse.go
index 4bb70dd..9ce5b31 100644
--- a/src/c_parse.go
+++ b/src/c_parse.go
@@ -115,7 +115,7 @@ func c_read_yaml_file(file string, ui *HardUI) (*HostNode, error) {
if host.Height == 0 {
host.Height = 1200
}
- } else if host.Protocol > 3 {
+ } else if host.Protocol > PROTOCOL_MAX {
return nil, errors.New(file + ": unknown protocol")
}
if host.Quality > 2 {
diff --git a/src/i_info.go b/src/i_info.go
index 019ea69..76dcdad 100644
--- a/src/i_info.go
+++ b/src/i_info.go
@@ -57,7 +57,9 @@ import (
"github.com/gdamore/tcell/v2"
)
-func i_info_panel_dirs(ui HardUI, dir *DirsNode) {
+type info_func func(HardUI, *HostNode, int) int
+
+func i_info_dirs(ui HardUI, dir *DirsNode) {
line := 2
if line > ui.dim[H] - 3 {
return
@@ -89,7 +91,7 @@ func i_info_panel_dirs(ui HardUI, dir *DirsNode) {
ui.style[STYLE_DEF], dir.path()[1:])
}
-func i_info_panel_name_type(ui HardUI, host *HostNode) int {
+func i_info_name_type(ui HardUI, host *HostNode) int {
line := 2
if line > ui.dim[H] - 3 {
return line
@@ -114,29 +116,17 @@ func i_info_panel_name_type(ui HardUI, host *HostNode) int {
return line + 2
}
-func i_info_panel_host(ui HardUI, host *HostNode, line int) int {
+func i_info_ssh(ui HardUI, host *HostNode, line int) int {
if line > ui.dim[H] - 3 {
return line
}
// host, port
- if host.Protocol == 2 {
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Command: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Host)
- if line += 1; line > ui.dim[H] - 3 {
- return line
- }
- } else {
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
- ui.style[STYLE_TITLE], "Host: ")
- i_draw_text(ui.s,
- (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
- ui.style[STYLE_DEF], host.Host)
- }
+ i_draw_text(ui.s,
+ (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
+ ui.style[STYLE_TITLE], "Host: ")
+ i_draw_text(ui.s,
+ (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
+ ui.style[STYLE_DEF], host.Host)
if line += 1; line > ui.dim[H] - 3 || host.Protocol == 2 {
return line
}
@@ -321,7 +311,46 @@ func i_info_panel_host(ui HardUI, host *HostNode, line int) int {
return line
}
-func i_info_panel_note(ui HardUI, host *HostNode, line int) {
+func i_info_rdp(ui HardUI, host *HostNode, line int) int {
+ i_draw_text(ui.s,
+ (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
+ ui.style[STYLE_TITLE], "Host: ")
+ i_draw_text(ui.s,
+ (ui.dim[W] / 3) + 9, line, ui.dim[W] - 2, line,
+ ui.style[STYLE_DEF], host.Host)
+ if line += 1; line > ui.dim[H] - 3 || host.Protocol == 2 {
+ return line
+ }
+ return line
+}
+
+func i_info_cmd(ui HardUI, host *HostNode, line int) int {
+ i_draw_text(ui.s,
+ (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
+ ui.style[STYLE_TITLE], "Command: ")
+ i_draw_text(ui.s,
+ (ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line,
+ ui.style[STYLE_DEF], host.Host)
+ if line += 1; line > ui.dim[H] - 3 {
+ return line
+ }
+ return line
+}
+
+func i_info_openstack(ui HardUI, host *HostNode, line int) int {
+ i_draw_text(ui.s,
+ (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line,
+ ui.style[STYLE_TITLE], "Endpoint: ")
+ i_draw_text(ui.s,
+ (ui.dim[W] / 3) + 13, line, ui.dim[W] - 2, line,
+ ui.style[STYLE_DEF], host.Host)
+ if line += 1; line > ui.dim[H] - 3 {
+ return line
+ }
+ return line
+}
+
+func i_info_note(ui HardUI, host *HostNode, line int) {
if line > ui.dim[H] - 3 {
return
}
@@ -375,10 +404,19 @@ func i_draw_info_panel(ui HardUI, percent bool, litems *ItemsList) {
if litems.head == nil {
return
} else if litems.curr.is_dir() == true {
- i_info_panel_dirs(ui, litems.curr.Dirs)
+ i_info_dirs(ui, litems.curr.Dirs)
} else {
- line := i_info_panel_name_type(ui, litems.curr.Host)
- line = i_info_panel_host(ui, litems.curr.Host, line)
- i_info_panel_note(ui, litems.curr.Host, line)
+ line := i_info_name_type(ui, litems.curr.Host)
+ if litems.curr.Host.Protocol > PROTOCOL_MAX {
+ return
+ }
+ fn := [PROTOCOL_MAX + 1]info_func{
+ i_info_ssh,
+ i_info_rdp,
+ i_info_cmd,
+ i_info_openstack,
+ }
+ line = fn[litems.curr.Host.Protocol](ui, litems.curr.Host, line)
+ i_info_note(ui, litems.curr.Host, line)
}
}