diff options
author | Joe <rbo@gmx.us> | 2024-05-02 20:20:20 +0200 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-05-02 20:20:20 +0200 |
commit | 2f20bfedc4394301af9613e44bfe305b701ee12f (patch) | |
tree | eab2bc5da8de0555173d99f097d469af2bda4984 | |
parent | quick weird bugfix (diff) | |
download | hardflip-2f20bfedc4394301af9613e44bfe305b701ee12f.tar.gz hardflip-2f20bfedc4394301af9613e44bfe305b701ee12f.tar.bz2 hardflip-2f20bfedc4394301af9613e44bfe305b701ee12f.tar.xz hardflip-2f20bfedc4394301af9613e44bfe305b701ee12f.tar.zst hardflip-2f20bfedc4394301af9613e44bfe305b701ee12f.zip |
sshcmd
-rw-r--r-- | ROADMAP.md | 1 | ||||
-rw-r--r-- | src/c_defs.go | 1 | ||||
-rw-r--r-- | src/c_exec.go | 34 | ||||
-rw-r--r-- | src/c_lhosts.go | 1 | ||||
-rw-r--r-- | src/e_keys.go | 5 | ||||
-rw-r--r-- | src/i_info.go | 9 | ||||
-rw-r--r-- | src/i_insert.go | 8 |
7 files changed, 42 insertions, 17 deletions
@@ -46,6 +46,7 @@ ## v0.8 - [ ] theming +- [ ] default ssh key ## v1.0 - wheelbite diff --git a/src/c_defs.go b/src/c_defs.go index 01cfee5..d071de9 100644 --- a/src/c_defs.go +++ b/src/c_defs.go @@ -120,6 +120,7 @@ const ( INS_SSH_USER INS_SSH_PASS INS_SSH_PRIV + INS_SSH_EXEC INS_SSH_JUMP_HOST INS_SSH_JUMP_PORT INS_SSH_JUMP_USER diff --git a/src/c_exec.go b/src/c_exec.go index a1547d4..6829d94 100644 --- a/src/c_exec.go +++ b/src/c_exec.go @@ -82,20 +82,20 @@ func c_exec_cmd(cmd_fmt, cmd_env []string, silent bool) (error, string) { } func c_format_ssh_jump(host *HostNode) string { - jump_fmt := "-oProxyCommand=ssh" - if len(host.Jump.Priv) > 0 { - jump_fmt += " -i " + host.Jump.Priv - } - if host.Jump.Port != 0 { - jump_fmt += " -p " + strconv.Itoa(int(host.Jump.Port)) - } - if len(host.Jump.User) == 0 { - jump_fmt += " root" - } else { - jump_fmt += " " + host.Jump.User - } - jump_fmt += "@" + host.Jump.Host + " -W %h:%p" - return jump_fmt + jump_fmt := "-oProxyCommand=ssh" + if len(host.Jump.Priv) > 0 { + jump_fmt += " -i " + host.Jump.Priv + } + if host.Jump.Port != 0 { + jump_fmt += " -p " + strconv.Itoa(int(host.Jump.Port)) + } + if len(host.Jump.User) == 0 { + jump_fmt += " root" + } else { + jump_fmt += " " + host.Jump.User + } + jump_fmt += "@" + host.Jump.Host + " -W %h:%p" + return jump_fmt } func c_format_ssh(host *HostNode, pass string) ([]string, []string) { @@ -114,7 +114,13 @@ func c_format_ssh(host *HostNode, pass string) ([]string, []string) { if host.Port != 0 { cmd_fmt = append(cmd_fmt, "-p", strconv.Itoa(int(host.Port))) } + if len(host.Exec) > 0 { + cmd_fmt = append(cmd_fmt, "-t") + } cmd_fmt = append(cmd_fmt, host.User + "@" + host.Host) + if len(host.Exec) > 0 { + cmd_fmt = append(cmd_fmt, "--", host.Exec) + } return cmd_fmt, nil } diff --git a/src/c_lhosts.go b/src/c_lhosts.go index 66d58e3..301a618 100644 --- a/src/c_lhosts.go +++ b/src/c_lhosts.go @@ -84,6 +84,7 @@ type HostNode struct { User string `yaml:"user,omitempty"` Pass string `yaml:"pass,omitempty"` Priv string `yaml:"priv,omitempty"` + Exec string `yaml:"exec,omitempty"` RDPFile string `yaml:"rdp_file,omitempty"` Jump JumpSettings `yaml:"jump,omitempty"` Quality uint8 `yaml:"quality,omitempty"` diff --git a/src/e_keys.go b/src/e_keys.go index 8f4c91b..fb07685 100644 --- a/src/e_keys.go +++ b/src/e_keys.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/e_keys.go - * Thu Apr 25 15:49:50 2024 + * Thu May 02 10:16:58 2024 * Joe * * events in the keys @@ -461,6 +461,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { INS_OS_PASS: return true case INS_SSH_PRIV: ui.buff = data.insert.Priv + case INS_SSH_EXEC: ui.buff = data.insert.Exec case INS_SSH_JUMP_HOST, INS_RDP_JUMP_HOST + len(data.insert.Drive): ui.buff = data.insert.Jump.Host @@ -647,6 +648,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { INS_SSH_USER, INS_SSH_PASS, INS_SSH_PRIV, + INS_SSH_EXEC, INS_SSH_JUMP_HOST, INS_SSH_JUMP_PORT, INS_SSH_JUMP_USER, @@ -706,6 +708,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { data.opts.GPG) } case INS_SSH_PRIV: data.insert.Priv = ui.buff + case INS_SSH_EXEC: data.insert.Exec = ui.buff case INS_SSH_JUMP_HOST, INS_RDP_JUMP_HOST + len(data.insert.Drive): data.insert.Jump.Host = ui.buff diff --git a/src/i_info.go b/src/i_info.go index a5860f3..442a828 100644 --- a/src/i_info.go +++ b/src/i_info.go @@ -149,6 +149,15 @@ func i_info_ssh(ui HardUI, host *HostNode, line int) int { if line += 1; line > ui.dim[H] - 3 { return line } } if line += 1; line > ui.dim[H] - 3 { return line } + if len(host.Exec) > 0 { + i_draw_text(ui.s, + (ui.dim[W] / 3) + 3, line, ui.dim[W] - 2, line, + ui.style[TITLE_STYLE], "Command: ") + i_draw_text(ui.s, + (ui.dim[W] / 3) + 12, line, ui.dim[W] - 2, line, + ui.style[DEF_STYLE], host.Exec) + if line += 2; line > ui.dim[H] - 3 { return line } + } // jump if len(host.Jump.Host) > 0 { i_draw_text(ui.s, diff --git a/src/i_insert.go b/src/i_insert.go index 5b769f4..68d674c 100644 --- a/src/i_insert.go +++ b/src/i_insert.go @@ -383,8 +383,9 @@ func i_draw_insert_inputs(ui HardUI, in *HostNode, home_dir string) { case INS_SSH_PRIV, INS_SSH_JUMP_PRIV, INS_RDP_JUMP_PRIV + len(in.Drive): - i_prompt_generic(ui, "Private key: ", - false, home_dir) + i_prompt_generic(ui, "Private key: ", false, home_dir) + case INS_SSH_EXEC: + i_prompt_generic(ui, "Command (optional): ", false, "") case INS_SSH_NOTE, INS_RDP_NOTE + len(in.Drive), INS_CMD_NOTE, @@ -514,6 +515,9 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, } red = false if line += 2; win.T + line >= win.B { return line } + i_draw_text_box(ui, win.T + line, win, "Custom command", in.Exec, + INS_SSH_EXEC, false, false) + if line += 2; win.T + line >= win.B { return line } text = "---- Jump settings ----" i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line, win.R - 1, win.T + line, ui.style[DEF_STYLE], text) |