■ ■ ■ ■ ■ ■
internal/server/commands/list.go
1 | 1 | | package commands |
2 | 2 | | |
3 | 3 | | import ( |
4 | | - | "encoding/json" |
5 | 4 | | "fmt" |
6 | 5 | | "io" |
7 | 6 | | "log" |
8 | 7 | | "sort" |
9 | 8 | | "strings" |
10 | 9 | | |
11 | | - | "github.com/NHAS/reverse_ssh/internal" |
12 | 10 | | "github.com/NHAS/reverse_ssh/internal/server/clients" |
13 | 11 | | "github.com/NHAS/reverse_ssh/internal/terminal" |
14 | 12 | | "github.com/NHAS/reverse_ssh/internal/terminal/autocomplete" |
| skipped 11 lines |
26 | 24 | | |
27 | 25 | | func fancyTable(tty io.ReadWriter, applicable []displayItem) { |
28 | 26 | | |
29 | | - | t, _ := table.NewTable("Targets", "IDs", "Version", "Arch") |
| 27 | + | t, _ := table.NewTable("Targets", "IDs", "Version") |
30 | 28 | | for _, a := range applicable { |
31 | | - | |
32 | | - | ok, result, err := a.sc.SendRequest("info", true, nil) |
33 | | - | if err != nil { |
34 | | - | continue |
35 | | - | } |
36 | | - | |
37 | | - | arch := "-" |
38 | | - | if ok { |
39 | | - | c := internal.ClientInfo{} |
40 | | - | err = json.Unmarshal(result, &c) |
41 | | - | if err == nil { |
42 | | - | arch = c.GoOS + "_" + c.GoArch |
43 | | - | } |
44 | | - | } |
45 | 29 | | |
46 | 30 | | keyId := a.sc.Permissions.Extensions["pubkey-fp"] |
47 | 31 | | if a.sc.Permissions.Extensions["comment"] != "" { |
48 | 32 | | keyId = a.sc.Permissions.Extensions["comment"] |
49 | 33 | | } |
50 | 34 | | |
51 | | - | if err := t.AddValues(fmt.Sprintf("%s\n%s\n%s\n%s\n", a.id, keyId, clients.NormaliseHostname(a.sc.User()), a.sc.RemoteAddr().String()), string(a.sc.ClientVersion()), arch); err != nil { |
| 35 | + | if err := t.AddValues(fmt.Sprintf("%s\n%s\n%s\n%s\n", a.id, keyId, clients.NormaliseHostname(a.sc.User()), a.sc.RemoteAddr().String()), string(a.sc.ClientVersion())); err != nil { |
52 | 36 | | log.Println("Error drawing pretty ls table (THIS IS A BUG): ", err) |
53 | 37 | | return |
54 | 38 | | } |
| skipped 54 lines |
109 | 93 | | |
110 | 94 | | for i, tr := range toReturn { |
111 | 95 | | |
112 | | - | ok, result, err := tr.sc.SendRequest("info", true, nil) |
113 | | - | if err != nil { |
114 | | - | continue |
115 | | - | } |
116 | | - | |
117 | | - | arch := "-" |
118 | | - | if ok { |
119 | | - | c := internal.ClientInfo{} |
120 | | - | err = json.Unmarshal(result, &c) |
121 | | - | if err == nil { |
122 | | - | arch = c.GoOS + "_" + c.GoArch |
123 | | - | } |
124 | | - | } |
125 | | - | |
126 | 96 | | keyId := tr.sc.Permissions.Extensions["pubkey-fp"] |
127 | 97 | | if tr.sc.Permissions.Extensions["comment"] != "" { |
128 | 98 | | keyId = tr.sc.Permissions.Extensions["comment"] |
129 | 99 | | } |
130 | 100 | | |
131 | | - | fmt.Fprintf(tty, "%s %s %s %s, version: %s arch: %s", tr.id, keyId, clients.NormaliseHostname(tr.sc.User()), tr.sc.RemoteAddr().String(), tr.sc.ClientVersion(), arch) |
| 101 | + | fmt.Fprintf(tty, "%s %s %s %s, version: %s", tr.id, keyId, clients.NormaliseHostname(tr.sc.User()), tr.sc.RemoteAddr().String(), tr.sc.ClientVersion()) |
132 | 102 | | |
133 | 103 | | if i != len(toReturn)-1 { |
134 | 104 | | fmt.Fprint(tty, sep) |
| skipped 28 lines |