forked from openprivacy/connectivity
Merge pull request 'NoTorrcErr typed error' (#10) from notorrcerr into master
Reviewed-on: openprivacy/connectivity#10
This commit is contained in:
commit
d290b705eb
|
@ -42,6 +42,13 @@ const (
|
||||||
networkUp = 0
|
networkUp = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NoTorrcError is a typed error thrown to indicate start could not complete due to lack of a torrc file
|
||||||
|
type NoTorrcError struct {
|
||||||
|
path string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *NoTorrcError) Error() string { return fmt.Sprintf("torrc file does not exist at %v", e.path) }
|
||||||
|
|
||||||
type onionListenService struct {
|
type onionListenService struct {
|
||||||
os *tor.OnionService
|
os *tor.OnionService
|
||||||
tp *torProvider
|
tp *torProvider
|
||||||
|
@ -286,8 +293,9 @@ func startTor(appDirectory string, bundledTorPath string, controlPort int, authe
|
||||||
|
|
||||||
// check if the torrc file is present where expected
|
// check if the torrc file is present where expected
|
||||||
if _, err := os.Stat(path.Join(dataDir, "torrc")); os.IsNotExist(err) {
|
if _, err := os.Stat(path.Join(dataDir, "torrc")); os.IsNotExist(err) {
|
||||||
log.Debugf("torrc file does not exist at %v", path.Join(dataDir, "torrc"))
|
err = &NoTorrcError{path.Join(dataDir, "torrc")}
|
||||||
return nil, fmt.Errorf("torrc file does not exist at %v", path.Join(dataDir, "torrc"))
|
log.Debugln(err.Error())
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// if not, try running system tor
|
// if not, try running system tor
|
||||||
|
|
Loading…
Reference in New Issue