add GetVersion to acn and torProvider #15
3
acn.go
3
acn.go
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue