ui/go/characters/torstatuspoller.go

29 lines
615 B
Go
Raw Permalink Normal View History

2018-11-22 00:01:17 +00:00
package characters
import (
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
"time"
)
2018-11-22 00:01:17 +00:00
func TorStatusPoller(setTorStatus func(int, string), acn connectivity.ACN) {
for {
time.Sleep(time.Second)
2018-11-22 00:01:17 +00:00
percent, message := acn.GetBootstrapStatus()
var statuscode int
if percent == 0 {
statuscode = 0
message = "can't find tor. is it running? is the controlport configured?"
} else if percent == 100 {
statuscode = 3
message = "tor appears to be running just fine!"
} else if percent < 80 {
statuscode = 1
} else {
statuscode = 2
2018-11-28 22:14:02 +00:00
}
setTorStatus(statuscode, message)
}
2018-11-22 00:01:17 +00:00
}