aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-04-24 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-04-24 20:20:20 +0200
commit5359e616741930906047907555e3014200909362 (patch)
tree986e4d3403dcf719b9729cbf466099514b880298
parentroad (diff)
downloadhardflip-5359e616741930906047907555e3014200909362.tar.gz
hardflip-5359e616741930906047907555e3014200909362.tar.bz2
hardflip-5359e616741930906047907555e3014200909362.tar.xz
hardflip-5359e616741930906047907555e3014200909362.tar.zst
hardflip-5359e616741930906047907555e3014200909362.zip
menu
-rw-r--r--ROADMAP.md2
-rw-r--r--src/c_defs.go5
-rw-r--r--src/e_keys.go50
-rw-r--r--src/i_insert.go54
4 files changed, 95 insertions, 16 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index 666b861..cacebcd 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -32,7 +32,7 @@
- [x] reload keep position
- [x] add
- [x] clone
-- [ ] ssh jump for rdp - working but missing in add menu
+- [x] ssh jump for rdp - working but missing in add menu
- [ ] edit
- [ ] move
- [ ] rename
diff --git a/src/c_defs.go b/src/c_defs.go
index a1b5946..438ad26 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -137,6 +137,11 @@ const (
INS_RDP_DYNAMIC
INS_RDP_QUALITY
INS_RDP_DRIVE
+ INS_RDP_JUMP_HOST
+ INS_RDP_JUMP_PORT
+ INS_RDP_JUMP_USER
+ INS_RDP_JUMP_PASS
+ INS_RDP_JUMP_PRIV
INS_RDP_NOTE
INS_RDP_OK
INS_CMD_CMD
diff --git a/src/e_keys.go b/src/e_keys.go
index 1be652b..1dcba0d 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -330,6 +330,12 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
if data.insert.Protocol == PROTOCOL_RDP &&
ui.insert_sel == INS_PROTOCOL {
ui.insert_sel = INS_RDP_HOST
+
+ } else if data.insert.Protocol == PROTOCOL_RDP &&
+ ui.insert_sel == INS_RDP_JUMP_HOST +
+ len(data.insert.Drive) &&
+ len(data.insert.Jump.Host) == 0 {
+ ui.insert_sel = INS_RDP_NOTE + len(data.insert.Drive)
} else if data.insert.Protocol == PROTOCOL_CMD &&
ui.insert_sel == INS_PROTOCOL {
ui.insert_sel = INS_CMD_CMD
@@ -348,6 +354,11 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
if data.insert.Protocol == PROTOCOL_RDP &&
ui.insert_sel == INS_RDP_HOST {
ui.insert_sel = INS_PROTOCOL
+ } else if data.insert.Protocol == PROTOCOL_RDP &&
+ ui.insert_sel == INS_RDP_NOTE +
+ len(data.insert.Drive) &&
+ len(data.insert.Jump.Host) == 0 {
+ ui.insert_sel = INS_RDP_JUMP_HOST + len(data.insert.Drive)
} else if data.insert.Protocol == PROTOCOL_CMD &&
ui.insert_sel == INS_CMD_CMD {
ui.insert_sel = INS_PROTOCOL
@@ -403,15 +414,24 @@ 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_JUMP_HOST: ui.buff = data.insert.Jump.Host
- case INS_SSH_JUMP_PORT:
+ case INS_SSH_JUMP_HOST,
+ INS_RDP_JUMP_HOST + len(data.insert.Drive):
+ ui.buff = data.insert.Jump.Host
+ case INS_SSH_JUMP_PORT,
+ INS_SSH_JUMP_PORT + len(data.insert.Drive):
if data.insert.Jump.Port > 0 {
ui.buff = strconv.Itoa(int(
data.insert.Jump.Port))
}
- case INS_SSH_JUMP_USER: ui.buff = data.insert.Jump.User
- case INS_SSH_JUMP_PASS: return true
- case INS_SSH_JUMP_PRIV: ui.buff = data.insert.Jump.Priv
+ case INS_SSH_JUMP_USER,
+ INS_RDP_JUMP_USER + len(data.insert.Drive):
+ ui.buff = data.insert.Jump.User
+ case INS_SSH_JUMP_PASS,
+ INS_RDP_JUMP_PASS + len(data.insert.Drive):
+ return true
+ case INS_SSH_JUMP_PRIV,
+ INS_RDP_JUMP_PRIV + len(data.insert.Drive):
+ ui.buff = data.insert.Jump.Priv
case INS_RDP_DOMAIN: ui.buff = data.insert.Domain
case INS_RDP_FILE: ui.buff = data.insert.RDPFile
case INS_RDP_SCREENSIZE: return true
@@ -583,6 +603,11 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
INS_SSH_JUMP_USER,
INS_SSH_JUMP_PASS,
INS_SSH_JUMP_PRIV,
+ INS_RDP_JUMP_HOST + len(data.insert.Drive),
+ INS_RDP_JUMP_PORT + len(data.insert.Drive),
+ INS_RDP_JUMP_USER + len(data.insert.Drive),
+ INS_RDP_JUMP_PASS + len(data.insert.Drive),
+ INS_RDP_JUMP_PRIV + len(data.insert.Drive),
INS_SSH_NOTE,
INS_RDP_HOST,
INS_RDP_PORT,
@@ -627,22 +652,27 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
data.insert.Pass, _ = c_encrypt_str(ui.buff,
data.opts.GPG)
case INS_SSH_PRIV: data.insert.Priv = ui.buff
- case INS_SSH_JUMP_HOST:
+ case INS_SSH_JUMP_HOST,
+ INS_RDP_JUMP_HOST + len(data.insert.Drive):
data.insert.Jump.Host = ui.buff
if len(ui.buff) > 0 {
data.insert.Jump.Port = 22
} else {
data.insert.Jump.Port = 0
}
- case INS_SSH_JUMP_PORT:
+ case INS_SSH_JUMP_PORT,
+ INS_RDP_JUMP_PORT + len(data.insert.Drive):
tmp, _ := strconv.Atoi(ui.buff)
data.insert.Jump.Port = uint16(tmp)
- case INS_SSH_JUMP_USER:
+ case INS_SSH_JUMP_USER,
+ INS_RDP_JUMP_USER + len(data.insert.Drive):
data.insert.Jump.User = ui.buff
- case INS_SSH_JUMP_PASS:
+ case INS_SSH_JUMP_PASS,
+ INS_RDP_JUMP_PASS + len(data.insert.Drive):
data.insert.Jump.Pass, _ =
c_encrypt_str(ui.buff, data.opts.GPG)
- case INS_SSH_JUMP_PRIV:
+ case INS_SSH_JUMP_PRIV,
+ INS_RDP_JUMP_PRIV + len(data.insert.Drive):
data.insert.Jump.Priv = ui.buff
case INS_RDP_DOMAIN:
data.insert.Domain = ui.buff
diff --git a/src/i_insert.go b/src/i_insert.go
index ff71c06..75f2bf8 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_insert.go
- * Thu Apr 18 17:00:01 2024
+ * Wed Apr 24 17:40:10 2024
* Joe
*
* insert a new host
@@ -223,7 +223,7 @@ func i_insert_check_ok(data *HardData, in *HostNode) {
var file [2]string
switch in.Protocol {
case PROTOCOL_SSH: file[0], file[1] = in.Priv, in.Jump.Priv
- case PROTOCOL_RDP: file[0] = in.RDPFile
+ case PROTOCOL_RDP: file[0], file[1] = in.RDPFile, in.Jump.Priv
case PROTOCOL_CMD: file[0] = in.Shell[0]
default: return
}
@@ -341,24 +341,29 @@ func i_draw_insert_inputs(ui HardUI, in *HostNode, home_dir string) {
PROTOCOL_STR[:])
case INS_SSH_HOST,
INS_SSH_JUMP_HOST,
+ INS_RDP_JUMP_HOST + len(in.Drive),
INS_RDP_HOST:
i_prompt_generic(ui, "Host/IP: ", false, "")
case INS_SSH_PORT,
INS_SSH_JUMP_PORT,
+ INS_RDP_JUMP_PORT + len(in.Drive),
INS_RDP_PORT:
i_prompt_generic(ui, "Port: ", false, "")
case INS_SSH_USER,
INS_SSH_JUMP_USER,
+ INS_RDP_JUMP_USER + len(in.Drive),
INS_RDP_USER,
INS_OS_USER:
i_prompt_generic(ui, "User: ", false, "")
case INS_SSH_PASS,
INS_SSH_JUMP_PASS,
+ INS_RDP_JUMP_PASS + len(in.Drive),
INS_RDP_PASS,
INS_OS_PASS:
i_prompt_generic(ui, "Pass: ", true, "")
case INS_SSH_PRIV,
- INS_SSH_JUMP_PRIV:
+ INS_SSH_JUMP_PRIV,
+ INS_RDP_JUMP_PRIV + len(in.Drive):
i_prompt_generic(ui, "Private key: ",
false, home_dir)
case INS_SSH_NOTE,
@@ -389,9 +394,9 @@ func i_draw_insert_inputs(ui HardUI, in *HostNode, home_dir string) {
case INS_OS_HOST:
i_prompt_generic(ui, "Endpoint: ", false, "")
case INS_OS_USERDOMAINID:
- i_prompt_generic(ui, "UserDomainID: ", false, "")
+ i_prompt_generic(ui, "User Domain ID: ", false, "")
case INS_OS_PROJECTID:
- i_prompt_generic(ui, "ProjectID: ", false, "")
+ i_prompt_generic(ui, "Project ID: ", false, "")
case INS_OS_REGION:
i_prompt_generic(ui, "Region name: ", false, "")
case INS_OS_ENDTYPE:
@@ -628,6 +633,45 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad,
}
i_draw_text_box(ui, win.T + line, win, "Add share", "",
INS_RDP_DRIVE + len(in.Drive), false)
+ red = 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)
+ if line += 2; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Host/IP", in.Jump.Host,
+ INS_RDP_JUMP_HOST + len(in.Drive), false)
+ if len(in.Jump.Host) > 0 {
+ if line += 1; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Port",
+ strconv.Itoa(int(in.Jump.Port)),
+ INS_RDP_JUMP_PORT + len(in.Drive), false)
+ if line += 2; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "User", in.Jump.User,
+ INS_RDP_JUMP_USER + len(in.Drive), false)
+ if line += 1; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Pass", in.Jump.Pass,
+ INS_RDP_JUMP_PASS + len(in.Drive), false)
+ if line += 1; win.T + line >= win.B { return line}
+ if len(in.Jump.Priv) > 0 {
+ file := in.Jump.Priv
+ if file[0] == '~' {
+ file = home + file[1:]
+ }
+ if stat, err := os.Stat(file);
+ err != nil || stat.IsDir() == true {
+ red = true
+ }
+ }
+ i_draw_text_box(ui, win.T + line, win, "SSH private key", in.Jump.Priv,
+ INS_RDP_JUMP_PRIV + len(in.Drive), red)
+ if red == true {
+ if line += 1; win.T + line >= win.B { return line }
+ text := "file does not exist"
+ i_draw_text(ui.s, ui.dim[W] / 2, win.T + line,
+ win.R - 1, win.T + line, ui.style[ERR_STYLE], text)
+ }
+ }
if line += 2; win.T + line >= win.B { return line }
text = "---- Note ----"
i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line, win.R - 1,