Merge pull request 'add GetVersion to acn and torProvider' (#15) from getVer into master
the build was successful Details

Reviewed-on: #15
This commit is contained in:
Sarah Jamie Lewis 2020-11-30 18:45:45 -08:00
commit fa03a91425
3 changed files with 29 additions and 3 deletions

3
acn.go
View File

@ -55,5 +55,8 @@ type ACN interface {
// Get PID
GetPID() (int, error)
// GetVersion returns a string of what the ACN returns when asked for a version
GetVersion() string
Close()
}

View File

@ -47,6 +47,10 @@ func (lp *localProvider) GetPID() (int, error) {
return 0, nil
}
func (lp *localProvider) GetVersion() string {
return "0.1"
}
// WaitTillBootstrapped Blocks until underlying network is bootstrapped
func (lp *localProvider) WaitTillBootstrapped() {
}

View File

@ -137,6 +137,22 @@ func (tp *torProvider) GetBootstrapStatus() (int, string) {
return progress, status
}
func (tp *torProvider) GetVersion() string {
tp.lock.Lock()
defer tp.lock.Unlock()
if tp.t == nil {
return "No Tor"
}
pinfo, err := tp.t.Control.ProtocolInfo()
if err == nil {
return pinfo.TorVersion
}
return "No Tor"
}
// WaitTillBootstrapped Blocks until underlying network is bootstrapped
func (tp *torProvider) WaitTillBootstrapped() {
for true {
@ -290,9 +306,12 @@ func (tp *torProvider) checkVersion() error {
if err == nil {
log.Debugln("connected to control port")
pinfo, err := controlport.ProtocolInfo()
if err == nil && minTorVersionReqs(pinfo.TorVersion) {
log.Debugln("OK version " + pinfo.TorVersion)
return nil
if err == nil {
if minTorVersionReqs(pinfo.TorVersion) {
log.Debugln("OK version " + pinfo.TorVersion)
return nil
}
return fmt.Errorf("Tor version not supported: %v", pinfo.TorVersion)
}
}
}