tm status work
This commit is contained in:
parent
be290d021d
commit
9a62468915
|
@ -28,6 +28,16 @@ func NewTorManager(socksPort int, controlPort int, torPath string, torrc string)
|
||||||
torManager.socksPort = socksPort
|
torManager.socksPort = socksPort
|
||||||
torManager.controlPort = controlPort
|
torManager.controlPort = controlPort
|
||||||
|
|
||||||
|
fmt.Println("NewTorManager")
|
||||||
|
go func() {
|
||||||
|
fmt.Printf("Monitor\n")
|
||||||
|
for {
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
resp, err := torManager.GetStatus()
|
||||||
|
fmt.Println(resp, err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
err := torManager.TestConnection()
|
err := torManager.TestConnection()
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -141,3 +151,18 @@ func (tm *Manager) TestConnection() error {
|
||||||
}
|
}
|
||||||
return errors.New(proxyStatusMessage(proxyStatus))
|
return errors.New(proxyStatusMessage(proxyStatus))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tm *Manager) GetStatus() ([]string, error) {
|
||||||
|
controlAddress := fmt.Sprintf("127.0.0.1:%d", tm.controlPort)
|
||||||
|
c, err := bulb.Dial("tcp4", controlAddress)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, err
|
||||||
|
}
|
||||||
|
defer c.Close()
|
||||||
|
c.Request("AUTHENTICATE \"\"")
|
||||||
|
resp, err := c.Request("GETINFO status/bootstrap-phase")
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, err
|
||||||
|
}
|
||||||
|
return resp.RawLines, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue