Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix full ProxyCommand display missing #33

Merged
merged 3 commits into from
Jul 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions ui/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
)

type Host struct {
Aliases []string
Name string
User string
HostName string
Expand Down Expand Up @@ -117,7 +118,8 @@ func NewHostsTable(app *tview.Application, sshConfigPath string, filter string,
})

for _, host := range hosts {
name := strings.Join(host.Host, " ")
// Get first entry, considere it as the full hostname (not an alias)
name := host.Host[0]
if name == "" {
continue
}
Expand All @@ -135,13 +137,21 @@ func NewHostsTable(app *tview.Application, sshConfigPath string, filter string,
}

item := Host{
Aliases: []string{},
Name: name,
User: host.User,
HostName: host.HostName,
ProxyCommand: host.ProxyCommand,
Port: strconv.Itoa(host.Port),
}

// If there is other name than the main name (mean aliases)
if len(host.Host) > 1 {
for _, alias_name := range host.Host[1:] {
item.Aliases = append(item.Aliases, alias_name)
}
}

itemSha256 := asSha256(item)
duplicate := false

Expand Down Expand Up @@ -183,7 +193,11 @@ func (t *HostsTable) Filter(filter string) *HostsTable {
func (t *HostsTable) Generate() *HostsTable {
t.Clear()

headers := []string{"Hostname", "User", "Target", "Port"}
headers := []string{"Hostname", "Aliases", "User", "Target", "Port"}

if t.displayFullProxy {
headers = append(headers, "ProxyCommand")
}

for col, header := range headers {
cell := tview.NewTableCell(padding(header)).
Expand Down Expand Up @@ -218,11 +232,16 @@ func (t *HostsTable) Generate() *HostsTable {
}
}

if !strings.Contains(strings.ToLower(host.Name), t.filter) && !strings.Contains(strings.ToLower(target), t.filter) {
if !strings.Contains(strings.ToLower(host.Name), t.filter) && !strings.Contains(strings.Join(host.Aliases, " - "), t.filter) && !strings.Contains(strings.ToLower(target), t.filter) {
continue
}

values := []string{host.Name, host.User, target, host.Port}
values := []string{host.Name, strings.Join(host.Aliases, " - "), host.User, target, host.Port}

if t.displayFullProxy {
values = append(values, host.ProxyCommand)
}

row := t.GetRowCount()

isPreviouslySelected := true
Expand Down