Fix crashes with ProxyCommand

This commit is contained in:
SimonGaufreteau 2025-10-15 12:58:10 +02:00
parent dcf3199464
commit 8278a3752b
2 changed files with 13 additions and 12 deletions

View File

@ -49,7 +49,7 @@ func NewAddForm(hostname string, styles Styles, width, height int, configFile st
} }
} }
inputs := make([]textinput.Model, 10) // Increased from 9 to 10 for RequestTTY inputs := make([]textinput.Model, 11)
// Name input // Name input
inputs[nameInput] = textinput.New() inputs[nameInput] = textinput.New()
@ -93,7 +93,7 @@ func NewAddForm(hostname string, styles Styles, width, height int, configFile st
// ProxyCommand input // ProxyCommand input
inputs[proxyCommandInput] = textinput.New() inputs[proxyCommandInput] = textinput.New()
inputs[proxyCommandInput].Placeholder = "/usr/local/bin/wssh proxy %h" inputs[proxyCommandInput].Placeholder = "ssh -W %h:%p Jumphost"
inputs[proxyCommandInput].CharLimit = 200 inputs[proxyCommandInput].CharLimit = 200
inputs[proxyCommandInput].Width = 50 inputs[proxyCommandInput].Width = 50
@ -408,7 +408,7 @@ func (m *addFormModel) renderGeneralTab() string {
{portInput, "Port"}, {portInput, "Port"},
{identityInput, "Identity File"}, {identityInput, "Identity File"},
{proxyJumpInput, "ProxyJump"}, {proxyJumpInput, "ProxyJump"},
{proxyCommandInput, "ProxyCommand"} {proxyCommandInput, "ProxyCommand"},
{tagsInput, "Tags (comma-separated)"}, {tagsInput, "Tags (comma-separated)"},
} }

View File

@ -91,7 +91,7 @@ func NewEditForm(hostName string, styles Styles, width, height int, configFile s
} }
} }
inputs := make([]textinput.Model, 9) // Increased from 8 to 9 for RequestTTY inputs := make([]textinput.Model, 10)
// Hostname input // Hostname input
inputs[0] = textinput.New() inputs[0] = textinput.New()
@ -130,7 +130,7 @@ func NewEditForm(hostName string, styles Styles, width, height int, configFile s
// ProxyCommand input // ProxyCommand input
inputs[5] = textinput.New() inputs[5] = textinput.New()
inputs[5].Placeholder = "/bin/wssh proxy" inputs[5].Placeholder = "ssh -W %h:%p Jumphost"
inputs[5].CharLimit = 200 inputs[5].CharLimit = 200
inputs[5].Width = 50 inputs[5].Width = 50
inputs[5].SetValue(host.ProxyCommand) inputs[5].SetValue(host.ProxyCommand)
@ -260,19 +260,19 @@ func (m *editFormModel) updateFocus() tea.Cmd {
func (m *editFormModel) getPropertiesForCurrentTab() []int { func (m *editFormModel) getPropertiesForCurrentTab() []int {
switch m.currentTab { switch m.currentTab {
case 0: // General case 0: // General
return []int{0, 1, 2, 3, 4, 5, 6} // hostname, user, port, identity, proxyjump, proxycommand, tags return []int{0, 1, 2, 3, 4, 5, 7} // hostname, user, port, identity, proxyjump, proxycommand, tags
case 1: // Advanced case 1: // Advanced
return []int{5, 7, 8} // options, remotecommand, requesttty return []int{6, 8, 9} // options, remotecommand, requesttty
default: default:
return []int{0, 1, 2, 3, 4, 6} return []int{0, 1, 2, 3, 4, 5, 7}
} }
} }
// getFirstPropertyForTab returns the first property index for a given tab // getFirstPropertyForTab returns the first property index for a given tab
func (m *editFormModel) getFirstPropertyForTab(tab int) int { func (m *editFormModel) getFirstPropertyForTab(tab int) int {
properties := []int{0, 1, 2, 3, 4, 6} // General tab properties := []int{0, 1, 2, 3, 4, 5, 7} // General tab
if tab == 1 { if tab == 1 {
properties = []int{5, 7, 8} // Advanced tab properties = []int{6, 8, 9} // Advanced tab
} }
if len(properties) > 0 { if len(properties) > 0 {
return properties[0] return properties[0]
@ -587,7 +587,8 @@ func (m *editFormModel) renderEditGeneralTab() string {
{2, "Port"}, {2, "Port"},
{3, "Identity File"}, {3, "Identity File"},
{4, "Proxy Jump"}, {4, "Proxy Jump"},
{6, "Tags (comma-separated)"}, {5, "Proxy Command"},
{7, "Tags (comma-separated)"},
} }
for _, field := range fields { for _, field := range fields {
@ -690,7 +691,7 @@ func (m *editFormModel) submitEditForm() tea.Cmd {
port := strings.TrimSpace(m.inputs[2].Value()) // portInput port := strings.TrimSpace(m.inputs[2].Value()) // portInput
identity := strings.TrimSpace(m.inputs[3].Value()) // identityInput identity := strings.TrimSpace(m.inputs[3].Value()) // identityInput
proxyJump := strings.TrimSpace(m.inputs[4].Value()) // proxyJumpInput proxyJump := strings.TrimSpace(m.inputs[4].Value()) // proxyJumpInput
proxyCommand := strings.TrimSpace(m.inputs[5].Value()) // proxyCommandInput proxyCommand := strings.TrimSpace(m.inputs[5].Value()) // proxyCommandInput
options := strings.TrimSpace(m.inputs[6].Value()) // optionsInput options := strings.TrimSpace(m.inputs[6].Value()) // optionsInput
remoteCommand := strings.TrimSpace(m.inputs[8].Value()) // remoteCommandInput remoteCommand := strings.TrimSpace(m.inputs[8].Value()) // remoteCommandInput
requestTTY := strings.TrimSpace(m.inputs[9].Value()) // requestTTYInput requestTTY := strings.TrimSpace(m.inputs[9].Value()) // requestTTYInput