|
|
|
@ -3,6 +3,7 @@ package tor
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"git.openprivacy.ca/openprivacy/connectivity"
|
|
|
|
|
"git.openprivacy.ca/openprivacy/log"
|
|
|
|
|
"github.com/cretz/bine/control"
|
|
|
|
@ -282,9 +283,16 @@ func startTor(appDirectory string, bundledTorPath string, controlPort int, authe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.Debugf("launching system tor\n")
|
|
|
|
|
|
|
|
|
|
// check if the torrc file is present where expected
|
|
|
|
|
if _, err := os.Stat(path.Join(dataDir, "torrc")); os.IsNotExist(err) {
|
|
|
|
|
log.Debugf("torrc file does not exist at %v", path.Join(dataDir, "torrc"))
|
|
|
|
|
return nil, fmt.Errorf("torrc file does not exist at %v", path.Join(dataDir, "torrc"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if not, try running system tor
|
|
|
|
|
if checkCmdlineTorVersion("tor") {
|
|
|
|
|
t, err := tor.Start(nil, &tor.StartConf{EnableNetwork: true, DataDir: dataDir, TorrcFile: "torrc", DebugWriter: nil, ProcessCreator: newHideCmd("tor")})
|
|
|
|
|
t, err := tor.Start(nil, &tor.StartConf{EnableNetwork: true, DataDir: dataDir, TorrcFile: path.Join(dataDir, "torrc"), DebugWriter: nil, ProcessCreator: newHideCmd("tor")})
|
|
|
|
|
if err == nil {
|
|
|
|
|
tp.t = t
|
|
|
|
|
return tp, nil
|
|
|
|
@ -296,7 +304,7 @@ func startTor(appDirectory string, bundledTorPath string, controlPort int, authe
|
|
|
|
|
// try running bundledTor
|
|
|
|
|
if bundledTorPath != "" && checkCmdlineTorVersion(bundledTorPath) {
|
|
|
|
|
log.Debugln("using bundled tor '" + bundledTorPath + "'")
|
|
|
|
|
t, err := tor.Start(nil, &tor.StartConf{EnableNetwork: true, DataDir: dataDir, TorrcFile: "torrc", ExePath: bundledTorPath, DebugWriter: nil, ProcessCreator: newHideCmd(bundledTorPath)})
|
|
|
|
|
t, err := tor.Start(nil, &tor.StartConf{EnableNetwork: true, DataDir: dataDir, TorrcFile: path.Join(dataDir, "torrc"), ExePath: bundledTorPath, DebugWriter: nil, ProcessCreator: newHideCmd(bundledTorPath)})
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Debugf("Error running bundled tor: %v\n", err)
|
|
|
|
|
}
|
|
|
|
|