Skip to content

Commit

Permalink
fix findTorExecutableLocal()
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroleak committed Jan 1, 2020
1 parent a1bc326 commit 7a52230
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/samourai/tor/client/JavaTorClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ private TorConfig computeTorConfig(String dirName, Optional<File> torExecutable)
private Optional<File> findTorExecutableLocal() {
try {
// try uppercase
List<String> whichResult = CliUtils.exec("which Tor");
List<String> whichResult = CliUtils.execOrEmpty("which Tor");
if (whichResult.isEmpty()) {
// try lowercase
whichResult = CliUtils.exec("which tor");
whichResult = CliUtils.execOrEmpty("which tor");
}
if (whichResult.size() > 0) {
if (log.isDebugEnabled()) {
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/samourai/whirlpool/cli/utils/CliUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ protected static HttpClient computeHttpClient(Optional<CliProxy> cliProxyOptiona
return jettyHttpClient;
}

public static List<String> execOrEmpty(String cmd) throws Exception {
try {
return exec(cmd);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug(
"execOrNull error: "
+ e.getClass().getName()
+ ": "
+ (e.getMessage() != null ? e.getMessage() : ""));
}
}
return new ArrayList<>();
}

public static List<String> exec(String cmd) throws Exception {
List<String> lines = new ArrayList<>();
Process proc = null;
Expand Down

0 comments on commit 7a52230

Please sign in to comment.