(job async.Job)
| 136 | } |
| 137 | |
| 138 | func cmdWorker(job async.Job) { |
| 139 | shell := job.(models.Shell) |
| 140 | start := time.Now() |
| 141 | |
| 142 | err, session := findSessionFor(shell) |
| 143 | if err != nil { |
| 144 | trackFailure(true) |
| 145 | if doTest { |
| 146 | onTestFail(shell, err) |
| 147 | } else { |
| 148 | log.Warning("error while creating session for shell %s: %s", shell.Name, err) |
| 149 | } |
| 150 | return |
| 151 | } |
| 152 | defer session.Close() |
| 153 | |
| 154 | out, err := session.Exec(command) |
| 155 | took := tui.Dim(time.Since(start).String()) |
| 156 | trackOutput(out) |
| 157 | |
| 158 | if doTest { |
| 159 | if err != nil { |
| 160 | trackFailure(false) |
| 161 | onTestFail(shell, err) |
| 162 | } else { |
| 163 | trackSuccess() |
| 164 | onTestSuccess(shell) |
| 165 | } |
| 166 | } else { |
| 167 | outs := processOutput(out, shell) |
| 168 | host := "" |
| 169 | if shell.Identity.Username != "" { |
| 170 | host = tui.Dim(fmt.Sprintf("%s@%s", shell.Identity.Username, shell.Host)) |
| 171 | } else { |
| 172 | host = tui.Dim(shell.Host) |
| 173 | } |
| 174 | |
| 175 | if !shell.Proxy.Empty() { |
| 176 | host = tui.Dim(fmt.Sprintf("%s:%d > %s", shell.Proxy.Address, shell.Proxy.Port, host)) |
| 177 | } |
| 178 | |
| 179 | if err != nil { |
| 180 | trackFailure(false) |
| 181 | log.Error("%s (%s %s %s) > %s (%s)%s", |
| 182 | tui.Bold(shell.Name), |
| 183 | tui.Green(shell.Type), |
| 184 | host, |
| 185 | took, |
| 186 | command, |
| 187 | tui.Red(err.Error()), |
| 188 | outs) |
| 189 | } else { |
| 190 | trackSuccess() |
| 191 | log.Info("%s (%s %s %s) > %s%s", |
| 192 | tui.Bold(shell.Name), |
| 193 | tui.Green(shell.Type), |
| 194 | host, |
| 195 | took, |
nothing calls this directly
no test coverage detected